:root {
  --bg: #ffffff; --fg: #2f3437; --muted: #8a8f94; --line: #ededec;
  --accent: #2e7d52; --accent-bg: #eef6f0; --hover: #f7f7f5; --pill: #e8f0fe;
}
* { box-sizing: border-box; }
/* Always reserve the scrollbar gutter so short months (no scroll) and long
   months (with scroll) don't shift the centered layout left/right. */
html { overflow-y: scroll; scrollbar-gutter: stable; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: inherit; }
main { max-width: 1100px; margin: 0 auto; padding: 22px 26px 80px; }
h1 { font-size: 30px; margin: 14px 0 18px; }
h2 { font-size: 18px; margin: 26px 0 10px; }
.muted { color: var(--muted); }

/* nav */
.nav { display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.nav .brand { font-weight: 600; text-decoration: none; }
.nav nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav nav a { text-decoration: none; color: var(--fg); padding: 4px 8px; border-radius: 6px; }
.nav nav a:hover { background: var(--hover); }
.nav .user { margin-left: auto; color: var(--muted); font-size: 13px; }

/* login */
.login-box { max-width: 320px; margin: 12vh auto; text-align: center; }
.login-box form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.login-box input, .upload input, .editform input, .editform textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

/* selects (year / month dropdowns) */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 7px 32px 7px 12px; font: inherit; color: var(--fg);
  background-color: #fff; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; line-height: 1.3;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8f94' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
  transition: border-color .12s, box-shadow .12s;
}
select:hover { border-color: #cfd4d0; }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.yearpick label, .reportpick { display: flex; align-items: center; gap: 8px; }
.yearpick label { color: var(--muted); font-size: 14px; }
.login-box button, .sendform button, .upload button, .editform button, .carryover button {
  padding: 9px 14px; border: 0; border-radius: 8px; background: var(--accent); color: #fff;
  font: inherit; cursor: pointer; }
button:disabled { background: #c8ccc9; cursor: not-allowed; }
.error { background: #fdecec; color: #b3261e; padding: 8px 12px; border-radius: 8px; }
.ok { background: var(--accent-bg); color: var(--accent); padding: 8px 12px; border-radius: 8px; }

/* months + toolbar */
.toolbar { margin-bottom: 8px; }
.months { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.months .month { text-decoration: none; padding: 4px 10px; border-radius: 16px; color: var(--muted); font-size: 13px; }
.months .month:hover { background: var(--hover); }
.months .month.active { background: var(--accent); color: #fff; }

/* tables */
.tablewrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; table-layout: fixed; }
table.grid.narrow { max-width: 520px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; overflow-wrap: anywhere; word-break: break-word; }
table.grid th { color: var(--muted); font-weight: 500; font-size: 13px; }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.grid td.center { text-align: center; }
table.grid tbody tr:hover { background: var(--hover); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.pill { background: var(--pill); border-radius: 12px; padding: 1px 9px; font-size: 12px; }
tr.kind-topup td.num { color: var(--accent); }
tr.kind-carryover { color: var(--muted); }
tfoot td { padding-top: 10px; }

/* inline inputs in tables */
table.grid input[type=text], table.grid input:not([type]) { width: 100%; border: 1px solid transparent; background: transparent;
  padding: 5px 6px; border-radius: 6px; font: inherit; }
table.grid input:focus { border-color: var(--line); background: #fff; outline: none; }
table.grid input.num { text-align: right; }
.addrow input { border: 1px solid var(--line) !important; background: #fff !important; }
.actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.actions a { text-decoration: none; }
button.link { background: none; border: 0; cursor: pointer; padding: 0; font-size: 14px; }
button.add { background: var(--accent); color: #fff; border: 0; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; }

/* edit forms */
.editform { display: flex; flex-direction: column; gap: 12px; max-width: 460px; }
.editform label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.editform label.check { flex-direction: row; align-items: center; color: var(--fg); }
.formbtns { display: flex; gap: 14px; align-items: center; margin-top: 6px; }
.carryover { margin-top: 16px; }

/* report */
.cards2 { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 6px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; min-width: 220px; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .big { font-size: 26px; font-weight: 600; margin: 4px 0; }
.stat .sub { color: var(--muted); font-size: 12px; }
.tgpreview { background: var(--hover); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  white-space: pre-wrap; font-size: 13px; line-height: 1.5; }
.sendform { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.reportpick { display: flex; gap: 8px; margin-bottom: 12px; }

/* documents */
.upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0 20px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.card a { display: block; }
.card img { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--hover); }
.card .file { height: 130px; display: flex; align-items: center; justify-content: center; background: var(--hover); }
.card .cap { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px 10px; font-size: 13px; }
.card .cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
