:root {
  --ink: #222222;
  --ink-2: #3f3f3f;
  --muted: #6a6a6a;
  --line: #ebebeb;
  --line-2: #dddddd;
  --soft: #f7f7f7;
  --soft-2: #f0f0f0;
  --surface: #ffffff;
  --accent: #2a78d6;      /* chart: paid / this year */
  --accent-soft: #9ec5f4; /* chart: upcoming */
  --compare: #eb6834;     /* chart: last year */
  --good: #0a7a3d;
  --warn: #9a6400;
  --bad: #c13515;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--surface); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.boot { padding: 80px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); height: 76px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 40px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--ink); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 17px; }
.brand-lg { font-size: 18px; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.lang-toggle { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.lang-toggle button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.lang-toggle button.on { background: var(--ink); color: #fff; }
.avatar-btn { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 6px 5px 14px;
  background: #fff; cursor: pointer; }
.avatar-btn:hover { box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink-2); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.menu { position: absolute; right: 40px; top: 70px; background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.16);
  min-width: 220px; padding: 8px 0; z-index: 40; }
.menu .menu-head { padding: 10px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 16px; cursor: pointer; }
.menu button:hover { background: var(--soft); }

.viewas-bar { background: #fff8e6; border-bottom: 1px solid #f1dfb3; padding: 10px 40px; display: flex; gap: 14px; align-items: center; font-size: 14px; }
.viewas-bar button { border: 1px solid var(--ink); background: #fff; border-radius: 8px; padding: 5px 12px; cursor: pointer; font-weight: 600; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 340px 1fr; max-width: 1440px; margin: 0 auto; min-height: calc(100vh - 76px); }
.side { border-right: 1px solid var(--line); padding: 40px 32px 40px 40px; }
.side h2 { font-size: 30px; margin: 0 0 30px; font-weight: 600; letter-spacing: -0.02em; }
.nav a { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: 12px; text-decoration: none; font-size: 17px; margin-bottom: 4px; }
.nav a:hover { background: var(--soft); }
.nav a.on { background: var(--soft-2); font-weight: 500; }
.nav svg { width: 24px; height: 24px; flex: none; }
.nav-sep { height: 1px; background: var(--line); margin: 20px 16px; }
.nav-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 16px 8px; }
.main { padding: 40px 56px 80px; min-width: 0; }
.page { max-width: 980px; }
.page h1 { font-size: 30px; font-weight: 600; margin: 0 0 28px; letter-spacing: -0.02em; }
.page h2 { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.updated { font-size: 13px; color: var(--muted); margin-top: -18px; margin-bottom: 22px; }

/* ---------- pills & filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; align-items: center; }
.pill { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 9px 16px; cursor: pointer; font-size: 14px;
  display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.pill:hover { border-color: var(--ink); }
.pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill.set { border-color: var(--ink); background: var(--soft); }
.pill svg { width: 12px; height: 12px; }
.ghost-select { border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px; }

.pop { position: absolute; z-index: 50; background: #fff; border-radius: 16px; box-shadow: 0 8px 28px rgba(0,0,0,.2); width: 380px; max-width: calc(100vw - 24px); }
.pop-head { padding: 18px 22px 8px; }
.pop-title { font-weight: 600; text-align: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.pop-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 999px; padding: 10px 14px; }
.pop-search input { border: 0; outline: 0; flex: 1; font-size: 15px; }
.pop-meta { display: flex; justify-content: space-between; align-items: center; padding: 12px 22px; font-weight: 500; }
.pop-meta button, .btn-soft { border: 0; background: var(--soft-2); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 500; }
.pop-list { max-height: 360px; overflow: auto; padding: 0 22px 8px; }
.opt { display: flex; align-items: center; gap: 14px; padding: 10px 0; cursor: pointer; }
.opt .thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--soft-2); flex: none; }
.opt .label { flex: 1; }
.opt .sub { font-size: 12px; color: var(--muted); }
.check { width: 22px; height: 22px; border: 1.5px solid #b0b0b0; border-radius: 5px; display: grid; place-items: center; flex: none; background: #fff; }
.opt.on .check { background: var(--ink); border-color: var(--ink); }
.opt.on .check::after { content: ''; width: 10px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.radio { width: 22px; height: 22px; border: 1.5px solid #b0b0b0; border-radius: 50%; flex: none; display: grid; place-items: center; }
.opt.on .radio { border: 7px solid var(--ink); }
.pop-foot { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); }
.link-btn { border: 0; background: none; text-decoration: underline; font-weight: 600; cursor: pointer; padding: 8px 0; }
.link-btn:disabled { color: #c4c4c4; cursor: default; }
.btn { border: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 12px 22px; font-weight: 600; cursor: pointer; font-size: 15px; }
.btn:hover { background: #000; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--ink); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.custom-dates { display: flex; gap: 10px; padding: 4px 0 12px 36px; }
.custom-dates label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.custom-dates input { border: 1px solid var(--line-2); border-radius: 8px; padding: 8px; }

/* ---------- chart ---------- */
.summary-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.chart-wrap { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 12px; }
.chart .month-label { fill: var(--ink-2); font-size: 14px; cursor: pointer; }
.chart .month-label.on { fill: #fff; font-weight: 600; }
.chart .month-pill { fill: var(--ink); }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.legend { display: flex; gap: 18px; font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: #fff; border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,.18);
  padding: 10px 12px; font-size: 13px; min-width: 170px; z-index: 5; }
.tip .tip-title { font-weight: 600; margin-bottom: 6px; }
.tip .tip-row { display: flex; justify-content: space-between; gap: 16px; }
.tip i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); margin-top: 28px; }
.card-body { padding: 28px 32px; }
.month-title { font-weight: 600; font-size: 18px; margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.kpi-val { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.kpi-lab { color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.paid { background: var(--accent); }
.dot.up { background: #fff; border: 1.5px solid var(--accent); }
.expander { border-top: 1px solid var(--line); }
.expander > button { width: 100%; text-align: left; border: 0; background: none; padding: 22px 32px; font-weight: 600; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; }
.expander > button svg { width: 14px; height: 14px; transition: transform .15s; }
.expander.open > button svg { transform: rotate(180deg); }
.expander .exp-body { padding: 0 32px 24px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
.stat-grid .kpi-val { font-size: 20px; }

/* ---------- tables ---------- */
.table-wrap { border-top: 1px solid var(--line); max-height: 640px; overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-weight: 600; font-size: 14px; padding: 16px 12px; position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); z-index: 1; }
table.data td { padding: 18px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 15px; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #fafafa; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
table.data .chev { width: 28px; color: var(--muted); }
table.compact td, table.compact th { padding: 10px 8px; font-size: 14px; }
.exp-body table.compact th:first-child { width: 36%; }
.neg { color: var(--ink); }
.tag { display: inline-block; font-size: 12px; border-radius: 6px; padding: 2px 7px; background: var(--soft-2); color: var(--ink-2); }
.tag.final { background: #e6f4ea; color: var(--good); }
.tag.est { background: #fff4e0; color: var(--warn); }
.tag.off { background: #fde8e4; color: var(--bad); }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 20px 4px; }
.table-foot .total { font-size: 20px; font-weight: 600; }
.empty { padding: 50px 10px; text-align: center; color: var(--muted); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100vw; background: #fff; z-index: 61; overflow: auto;
  box-shadow: -8px 0 30px rgba(0,0,0,.15); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.icon-btn { border: 0; background: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--soft); }
.drawer-body { padding: 24px 26px 40px; }
.kv { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv.total { font-weight: 600; font-size: 17px; border-top: 1px solid var(--ink); border-bottom: 0; margin-top: 6px; }
.note { background: var(--soft); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--ink-2); margin-top: 18px; }

/* ---------- statements ---------- */
.year-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.feature { border: 1px solid var(--line); border-radius: 16px; padding: 48px 40px; display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.feature .badge { display: inline-block; background: #d70466; color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-bottom: 10px; }
.feature .f-month { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.feature .f-amt { font-size: 17px; margin: 6px 0 18px; }
.feature .f-left { text-align: center; }
.stack { position: relative; height: 170px; }
.stack img, .stack .ph { position: absolute; border-radius: 10px; object-fit: cover; box-shadow: 0 4px 14px rgba(0,0,0,.18); background: var(--soft-2); border: 3px solid #fff; }
.stack .s1 { width: 110px; height: 140px; left: 10%; top: 18px; }
.stack .s2 { width: 150px; height: 160px; left: 30%; top: 0; z-index: 2; }
.stack .s3 { width: 110px; height: 140px; left: 58%; top: 18px; }
.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 18px; }
.month-card { border: 1px solid var(--line); border-radius: 16px; padding: 44px 20px; text-align: center; cursor: pointer; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.month-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.month-card .mc-month { font-size: 20px; font-weight: 600; line-height: 1.3; }
.month-card .mc-amt { margin-top: 54px; font-size: 16px; }
.st-entity { border: 1px solid var(--line); border-radius: 16px; margin-top: 24px; }
.st-entity-head { display: flex; align-items: center; gap: 12px; padding: 20px 26px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.st-entity-head h3 { margin: 0; font-size: 19px; }
.st-entity-body { padding: 10px 26px 24px; }
.st-lines .kv { font-size: 15px; }
.st-section { margin-top: 22px; font-weight: 600; }

/* ---------- admin ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; background: var(--soft-2); border-radius: 999px; padding: 3px 9px; }
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(0,0,0,.4); padding: 20px; }
.modal-card { background: #fff; border-radius: 16px; width: 720px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; }
.modal-body { padding: 22px 26px; overflow: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field input, .field select, .field textarea, .inline-input, select.inline { border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; font-size: 15px; background: #fff; }
.field.wide { grid-column: 1 / -1; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.access-box { border: 1px solid var(--line); border-radius: 12px; padding: 6px 16px; max-height: 260px; overflow: auto; }
.access-box .opt { padding: 8px 0; }
.group-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 0 2px; }
.err-msg { color: var(--bad); font-size: 14px; margin-top: 10px; }
.status-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 26px; }
.status-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.status-card .sc-label { color: var(--muted); font-size: 13px; }
.status-card .sc-val { font-size: 17px; font-weight: 600; margin-top: 6px; }
.thumb-sm { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--soft-2); display: block; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 90; font-size: 14px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--soft); }
.login-card { background: #fff; border-radius: 20px; padding: 44px 40px; width: 420px; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.login-card h1 { font-size: 26px; margin: 28px 0 8px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 26px; border: 1px solid var(--line-2); border-radius: 10px;
  padding: 13px; text-decoration: none; font-weight: 600; }
.btn-google:hover { background: var(--soft); }
.login-error { color: var(--bad); margin-top: 18px; font-size: 14px; }

/* ---------- mobile ---------- */
.tabbar, .mlist { display: none; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.st-files { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.st-files a { text-decoration: none; }
body.noscroll { overflow: hidden; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 24px 20px 110px; }
  .topbar { padding: 0 16px; height: 64px; }
  .menu { right: 16px; top: 60px; }
  .viewas-bar { padding: 10px 16px; flex-wrap: wrap; }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px; padding: 4px 2px; }
  .tabbar a.on { color: var(--ink); font-weight: 600; }
  .tabbar svg { width: 24px; height: 24px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  html, body { font-size: 15px; }
  .brand span:last-child { display: none; }
  .page h1 { font-size: 26px; margin-bottom: 18px; }
  .page h2 { font-size: 20px; }
  .updated { margin-top: -10px; }
  .summary-head { flex-wrap: wrap; gap: 8px 12px; }
  .summary-head .spacer { display: none; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -20px 14px; padding: 0 20px 4px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .pill { padding: 8px 14px; }
  .card-body { padding: 20px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 16px; }
  .kpis > div:last-child { grid-column: 1 / -1; }
  .kpi-val { font-size: 22px; }
  .expander > button { padding: 18px 20px; }
  .expander .exp-body { padding: 0 16px 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  table.data .hide-sm { display: none; }
  /* Upcoming / Paid: cards instead of the table */
  .table-wrap:has(+ .mlist) { display: none; }
  .mlist { display: block; border-top: 1px solid var(--line); }
  .mrow { display: flex; width: 100%; gap: 12px; align-items: center; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
    padding: 14px 0; cursor: pointer; }
  .mrow-main { flex: 1; min-width: 0; }
  .mrow-main b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mrow .sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
  .mrow-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .table-foot { position: sticky; bottom: 70px; background: #fff; padding: 14px 0; border-top: 1px solid var(--line); }
  .table-foot .total { font-size: 18px; }
  .table-foot .btn { padding: 10px 16px; font-size: 14px; }
  /* filters open as a bottom sheet */
  .pop.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto !important; width: 100%; max-width: 100%; border-radius: 18px 18px 0 0;
    max-height: 85vh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
  .pop.sheet .pop-list { max-height: none; flex: 1; }
  .pop.sheet::before { content: ''; width: 40px; height: 4px; border-radius: 4px; background: #d0d0d0; margin: 10px auto 0; }
  .drawer { width: 100vw; }
  /* statements */
  .feature { grid-template-columns: 1fr; padding: 28px 18px; }
  .feature .f-month { font-size: 28px; }
  .stack { height: 140px; }
  .stack .s1, .stack .s3 { width: 90px; height: 115px; }
  .stack .s2 { width: 120px; height: 135px; left: 32%; }
  .stack .s1 { left: 6%; } .stack .s3 { left: 64%; }
  .month-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .month-card { padding: 26px 12px; }
  .month-card .mc-month { font-size: 17px; }
  .month-card .mc-amt { margin-top: 22px; }
  .st-entity-head { padding: 16px; }
  .st-entity-body { padding: 6px 16px 18px; }
  .st-files { width: 100%; }
  .st-files a { flex: 1; text-align: center; }
  /* admin */
  .modal { padding: 0; align-items: end; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal-body { padding: 18px; }
  .status-cards { grid-template-columns: 1fr 1fr; }
}
