@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Hanken+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* =========================================================================
   THEME TOKENS
   Dark is the default. Light is applied via <html data-theme="light">.
   ========================================================================= */
:root,
:root[data-theme="dark"] {
    --bg: #131419; --surface: #1A1C22; --surface-2: #21242C; --surface-3: #272B34;
    --line: #2C303A; --line-strong: #3A3F4B;
    --text: #E9E7E1; --soft: #9DA2AE; --faint: #6B7079;
    --accent: #34D399; --accent-dim: #1F6E4E; --accent-soft: rgba(52,211,153,.13); --cur-col: rgba(96,140,220,.20);
    --clay: #E8965B; --clay-soft: rgba(232,150,91,.14);
    --listed: #79A9E6; --listed-soft: rgba(121,169,230,.15);
    --sold-row: rgba(52,211,153,.10); --sold-row-hover: rgba(52,211,153,.16);
    --c1: #34D399; --c2: #79A9E6; --c3: #E8C15B; --c4: #B79CF0; --c5: #EA8AA6; --c6: #5BD0C8;
    --shadow: 0 1px 0 rgba(0,0,0,.2);
    color-scheme: dark;
}
:root[data-theme="light"] {
    --bg: #F6F3EC; --surface: #FFFFFF; --surface-2: #F0EDE4; --surface-3: #EAE6DA;
    --line: #E2DDD0; --line-strong: #D2CCBC;
    --text: #211F1A; --soft: #6E6B61; --faint: #9B9789;
    --accent: #1F6E4E; --accent-dim: #1F6E4E; --accent-soft: rgba(31,110,78,.10); --cur-col: rgba(70,110,190,.14);
    --clay: #A8501E; --clay-soft: rgba(168,80,30,.10);
    --listed: #2C557F; --listed-soft: rgba(44,85,127,.10);
    --sold-row: rgba(31,110,78,.085); --sold-row-hover: rgba(31,110,78,.14);
    --c1: #1F6E4E; --c2: #2C557F; --c3: #B98900; --c4: #6A4FB0; --c5: #B23A63; --c6: #2A8E86;
    --shadow: 0 1px 2px rgba(0,0,0,.04);
    color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
    font-family: 'Hanken Grotesk', ui-sans-serif, system-ui, sans-serif;
    color: var(--text); background: var(--bg); min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.serif { font-family: 'Fraunces', Georgia, serif; }
.pos { color: var(--accent); }
.neg { color: var(--clay); }
.muted { color: var(--soft); }

/* ---- Top bar ---- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 13px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; object-fit: contain; display: block; }
.brand-word { height: 35px; width: auto; display: block; }
.brand-word-l { display: none; }
:root[data-theme="light"] .brand-word-d { display: none; }
:root[data-theme="light"] .brand-word-l { display: block; }
.tabs { display: flex; gap: 2px; }
.tab { display: flex; align-items: center; gap: 7px; padding: 7px 13px; color: var(--soft); font-size: 14px; border-radius: 8px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); font-weight: 500; }
.spacer { margin-left: auto; }
.iconbtn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; background: none; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--soft); font-size: 13px; cursor: pointer; font-family: inherit; }
.iconbtn:hover { color: var(--text); border-color: var(--soft); }
.theme-toggle { width: 34px; height: 34px; padding: 0; justify-content: center; font-size: 15px; }

/* ---- Layout ---- */
.wrap { max-width: none; margin: 0; padding: 24px 30px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-family: 'Fraunces', serif; font-size: 28px; font-weight: 600; letter-spacing: -.015em; }
.page-sub { color: var(--soft); font-size: 14px; margin-top: 3px; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; background: var(--accent); color: #06281b; border: none; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn:hover { filter: brightness(1.07); }
:root[data-theme="light"] .btn { color: #fff; }

/* ---- KPI summary blocks ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 15px 16px; box-shadow: var(--shadow); }
.kpi-label { color: var(--soft); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 25px; font-weight: 500; margin-top: 9px; letter-spacing: -.02em; }
.kpi-foot { font-size: 12px; color: var(--faint); margin-top: 5px; }
.inv-head { display: flex; align-items: stretch; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.inv-head-left { display: flex; flex-direction: column; justify-content: space-between; gap: 16px; flex: 1 1 auto; min-width: 0; }
.inv-head-left .searchbar { margin-bottom: 0; }
.inv-head-right { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 14px; }
.inv-stats { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 16px; }
.inv-stats .kpi { flex: 0 0 auto; min-width: 160px; padding: 10px 14px; }
.inv-stats .kpi-value { font-size: 20px; margin-top: 4px; }
.inv-stats .kpi-foot { margin-top: 3px; }
.modal-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--soft); margin: 14px 0 2px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.section-title { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 26px 0 11px; }
.section-title:first-of-type { margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---- Chart panels ---- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-title { font-size: 14.5px; font-weight: 600; }
.panel-meta { font-size: 12.5px; color: var(--faint); }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
.dash-top { display: grid; grid-template-columns: minmax(360px, 0.82fr) 1.85fr; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.dash-right { display: flex; flex-direction: column; gap: 12px; }
.dash-statrow { display: grid; grid-template-columns: 2.4fr 1fr; gap: 16px; align-items: stretch; }
.dash-statrow .kpis { margin: 0; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 12px; }
.dash-cats { display: flex; flex-direction: column; overflow: hidden; }
.dash-annual { display: flex; flex-direction: column; }
.abar-chart { display: flex; flex-direction: column; gap: 6px; }
.abar-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.abar-vals span { text-align: center; font-size: 10.5px; font-family: 'JetBrains Mono', monospace; color: var(--soft); white-space: nowrap; }
.abar-bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; align-items: end; height: 168px; margin-top: 2px; }
.abar-track { height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.abar-fill { width: 74%; min-height: 3px; border-radius: 5px 5px 0 0; background: var(--c2); }
.abar-fill.abar-cur { background: var(--c1); }
.abar-years span { text-align: center; font-size: 11px; color: var(--faint); }
.abar-cnts span { text-align: center; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.abar-cap { font-size: 11px; color: var(--faint); margin-top: 10px; text-align: center; }
.abar-curkey { color: var(--c1); font-weight: 600; }
.cat-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.cat-table th { text-align: left; font-weight: 600; color: var(--soft); font-size: 10.5px; text-transform: uppercase; letter-spacing: .02em; padding: 5px 6px; border-bottom: 1px solid var(--line-strong); }
.cat-table th, .cat-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-table th.right, .cat-table td.right { text-align: right; }
.cat-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.cat-table th:nth-child(2), .cat-table td:nth-child(2) { width: 46px; }
.cat-table th:nth-child(3), .cat-table td:nth-child(3) { width: 54px; }
.cat-table th:nth-child(4), .cat-table td:nth-child(4) { width: 70px; }
.cat-table th:nth-child(5), .cat-table td:nth-child(5) { width: 60px; }
.cat-table .cat-name { color: var(--ink); }
.cat-table .cat-total td { border-top: 2px solid var(--line-strong); border-bottom: none; font-weight: 600; padding-top: 8px; color: var(--ink); }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--faint); font-size: 13.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; font-size: 12.5px; color: var(--soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Recent list ---- */
.recent { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.recent:first-of-type { border-top: none; }
.alert { display: flex; align-items: center; gap: 10px; background: var(--clay-soft); border: 1px solid var(--clay); border-radius: 9px; padding: 11px 13px; color: var(--clay); font-size: 13px; margin-top: 16px; }

/* ---- Spreadsheet tables ---- */
.sheet-wrap { border: 1px solid var(--line); border-radius: 11px; overflow: auto; max-height: 88vh; background: var(--surface); }
.sheet { width: 100%; border-collapse: collapse; font-size: 13px; }
.sheet th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--soft); text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 9px 12px; border: 1px solid var(--line); white-space: nowrap; }
.sheet td { padding: 8px 12px; border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.sheet tbody tr:nth-child(even) td { background: rgba(127,127,127,.035); }
.sheet tbody tr:hover td { background: var(--surface-2); }
/* Sold items: soft green wash across the row (merged lot cells stay neutral). */
.sheet tbody tr.row-sold td { background: var(--sold-row); }
.sheet tbody tr.row-sold:hover td { background: var(--sold-row-hover); }
.sheet tbody tr.row-sold td.lotcell { background: var(--surface); }
/* Inventory comment column: keep notes from blowing out the row width. */
.sheet td.comment-cell { white-space: nowrap; }
.sheet td.comment-cell .comment-text { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; color: var(--soft); }
.sheet .tr-name { font-weight: 500; }
.sheet .tr-meta { color: var(--soft); font-size: 11.5px; margin-top: 1px; white-space: normal; }
.right { text-align: right; }
.rownum { width: 38px; text-align: right; color: var(--faint); background: var(--surface-2) !important; position: sticky; left: 0; z-index: 1; font-family: 'JetBrains Mono', monospace; }
.sheet th.rownum { z-index: 3; }

/* ---- Frozen left columns (inventory only): ID + Vendor + Purchased + Item stay put; everything right of Item scrolls. ---- */
.sheet-frozen .fz-vendor, .sheet-frozen .fz-date, .sheet-frozen .fz-item { position: sticky; z-index: 1; }
.sheet-frozen .fz-vendor { left: 38px;  width: 200px; min-width: 200px; max-width: 200px; white-space: normal; }
.sheet-frozen .fz-date   { left: 238px; width: 100px; min-width: 100px; max-width: 100px; }
.sheet-frozen .fz-item   { left: 338px; max-width: 300px; white-space: nowrap; box-shadow: 2px 0 0 var(--line); }
.sheet .cell-clip { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
/* Opaque backgrounds (must beat the translucent zebra/sold overlays so nothing shows through while scrolling). */
.sheet-frozen td.fz-vendor, .sheet-frozen td.fz-date, .sheet-frozen td.fz-item { background: var(--surface) !important; }
.sheet-frozen thead th.fz-vendor, .sheet-frozen thead th.fz-date, .sheet-frozen thead th.fz-item { z-index: 4; background: var(--surface-2) !important; }
.sheet-frozen tbody tr.row-sold td.fz-item { background: linear-gradient(var(--sold-row), var(--sold-row)), var(--surface) !important; }
.sheet-frozen tbody tr:hover td.fz-item { background: var(--surface-2) !important; }
.sheet-frozen tbody tr.row-sold:hover td.fz-item { background: linear-gradient(var(--sold-row-hover), var(--sold-row-hover)), var(--surface-2) !important; }

/* ---- Shade by month group instead of per row (listings). A row carries .month-alt for every other month block. ---- */
.sheet-bymonth tbody tr:nth-child(even) td { background: none; }
.sheet-bymonth tbody tr.month-alt td { background: rgba(127,127,127,.05); }
.sheet-bymonth tbody tr.row-sold td { background: var(--sold-row); }
.sheet-bymonth tbody tr:hover td { background: var(--surface-2); }
.sheet-bymonth tbody tr.row-sold:hover td { background: var(--sold-row-hover); }

/* ---- Pills ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.p-stock { background: var(--surface-3); color: var(--soft); }
.p-listed { background: var(--listed-soft); color: var(--listed); }
.p-sold { background: var(--accent-soft); color: var(--accent); }
.p-age { background: var(--clay-soft); color: var(--clay); }

/* ---- Row actions ---- */
.row-acts { display: flex; gap: 6px; justify-content: flex-end; }
.mini { padding: 4px 9px; font-size: 12px; background: none; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--soft); cursor: pointer; font-family: inherit; }
.mini:hover { border-color: var(--soft); color: var(--text); }
.mini.danger:hover { border-color: var(--clay); color: var(--clay); }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 60px 20px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 12px; }
.empty p { color: var(--soft); font-size: 14px; margin-bottom: 16px; }

/* ---- Dialog ---- */
dialog { border: 1px solid var(--line-strong); border-radius: 15px; padding: 0; margin: auto; max-width: 460px; width: calc(100% - 32px); color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(0,0,0,.55); }
.modal-inner { padding: 22px 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; }
.modal-close { border: none; background: none; color: var(--faint); cursor: pointer; font-size: 22px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--soft); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 14px; font-family: inherit; background: var(--bg); color: var(--text); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot { display: flex; gap: 10px; margin-top: 20px; }
.modal-foot .btn { flex: 1; justify-content: center; }
.id-link { background: none; border: none; padding: 0; font: inherit; color: var(--listed); cursor: pointer; }
.id-link:hover { text-decoration: underline; }
#saleCard { max-width: 720px; max-height: 90vh; overflow-y: auto; }
.card-head { justify-content: flex-end; margin-bottom: 6px; }
.card-top { display: grid; grid-template-columns: 25% 1fr; gap: 18px; align-items: start; margin-bottom: 10px; }
.card-photo { width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: center; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-nophoto { font-size: 11px; color: var(--faint); }
.card-title { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; line-height: 1.2; }
.card-subline { margin-top: 6px; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.card-catline, .card-sizeline { font-size: 12px; margin-top: 3px; }
.card-numbers { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-grossval { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 600; color: var(--text); margin-top: 2px; }
.card-headline { text-align: right; }
.card-profit { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 600; color: var(--accent); margin-top: 2px; }
.card-profit.neg { color: var(--clay); }
.card-margins { font-size: 12px; margin-top: 4px; }
.card-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; margin: 8px 0 4px; }
.card-stat .cs-label { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--soft); }
.card-stat .cs-val { font-size: 13.5px; margin-top: 2px; color: var(--text); word-break: break-word; }
@media (max-width: 560px) {
    .card-top { grid-template-columns: 96px 1fr; }
    .card-row { grid-template-columns: repeat(2, 1fr); }
}
.ghost { padding: 9px 15px; background: none; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--soft); font-size: 14px; cursor: pointer; font-family: inherit; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 34px 32px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 10px; font-family: 'Fraunces', serif; font-size: 24px; font-weight: 600; margin-bottom: 6px; }
.login-sub { color: var(--soft); font-size: 14px; margin-bottom: 24px; }
.login-note { font-size: 12px; color: var(--faint); text-align: center; margin-top: 18px; line-height: 1.55; }
.err { background: var(--clay-soft); color: var(--clay); font-size: 13px; padding: 10px 12px; border-radius: 9px; margin-bottom: 16px; }

@media (max-width: 860px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .charts { grid-template-columns: 1fr; }
    .dash-top { grid-template-columns: 1fr; }
    .dash-statrow { grid-template-columns: 1fr; }
    .dash-statrow .kpis { grid-template-columns: repeat(2, 1fr); }
    .wrap { padding: 20px 14px 50px; }
    .topbar { padding: 11px 14px; gap: 10px; flex-wrap: wrap; }
    .tab span { display: none; }
    .page-head { flex-wrap: wrap; }
    .inv-head { flex-direction: column; align-items: stretch; }
    .inv-head-right { flex-direction: row; align-items: center; justify-content: space-between; }
    .inv-stats { flex: 1; }
    .inv-stats .kpi { flex: 1 1 0; min-width: 0; }
}

/* Search bar (inventory / listings / sales) */
.searchbar { display:flex; gap:10px; margin-bottom:18px; max-width:560px; }
.searchbar input { flex:1; background:var(--card); border:1px solid var(--line-strong); border-radius:8px; padding:9px 12px; color:inherit; font:inherit; }
.searchbar input::placeholder { color:var(--muted); }

/* KPI period grids: fixed layout + shared colgroup so month columns align across
   the metric table and the roll-forward table. Scoped to .sheet-kpi only. */
.sheet-kpi { table-layout: fixed; width: auto; min-width: 100%; }
.sheet-kpi th, .sheet-kpi td { overflow: hidden; text-overflow: ellipsis; }
.sheet-kpi col.spacer { width: 18px; }
.sheet-kpi th.spc, .sheet-kpi td.spc { padding: 0 !important; border: none !important; background: transparent !important; }
.sheet-kpi tbody tr:nth-child(even) td.spc,
.sheet-kpi tbody tr:hover td.spc { background: transparent !important; }

/* Inventory: Status pinned as a frozen column between Purchased and Item.
   fz-date ends at 338px; Status occupies 338–438; Item shifts to 438. */
.sheet-frozen .fz-status { position: sticky; z-index: 1; left: 338px; width: 100px; min-width: 100px; max-width: 100px; }
.sheet-frozen .fz-item { left: 438px; }
.sheet-frozen td.fz-status { background: var(--surface) !important; }
.sheet-frozen thead th.fz-status { z-index: 4; background: var(--surface-2) !important; }
.sheet-frozen tbody tr.row-sold td.fz-status { background: linear-gradient(var(--sold-row), var(--sold-row)), var(--surface) !important; }
.sheet-frozen tbody tr:hover td.fz-status { background: var(--surface-2) !important; }
.sheet-frozen tbody tr.row-sold:hover td.fz-status { background: linear-gradient(var(--sold-row-hover), var(--sold-row-hover)), var(--surface-2) !important; }

/* KPI tables: clean column channels — drop the vertical lines between columns
   (TOTAL→annual and between monthly columns); keep horizontal row separators. */
.sheet-kpi th, .sheet-kpi td { border-left: none !important; border-right: none !important; }

/* =========================================================================
   KPI cockpit (v49): hero tiles + paneled sections with colored keylines.
   All colors keyed to theme tokens so the look follows the light/dark toggle.
   ========================================================================= */
.kpi-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.ktile { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; overflow: hidden; box-shadow: var(--shadow); }
.ktile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ekey, var(--accent)); }
.ktile .kt-label { display: flex; align-items: center; gap: 7px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--soft); }
.ktile .kt-label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ekey, var(--accent)); }
.ktile .kt-value { font-family: 'JetBrains Mono', monospace; font-size: 29px; font-weight: 500; letter-spacing: -.025em; margin-top: 10px; }
.ktile .kt-foot { font-size: 12px; color: var(--faint); margin-top: 5px; }
.ktile.k-rev  { --ekey: var(--listed); } .ktile.k-rev .kt-value  { color: var(--listed); }
.ktile.k-prof { --ekey: var(--accent); } .ktile.k-prof .kt-value { color: var(--accent); }
.ktile.k-prof .kt-value.neg { color: var(--clay); }
.ktile.k-sold { --ekey: var(--c3); }
.ktile.k-act  { --ekey: var(--c6); }

/* Section panels — each with a colored top keyline + dot in the header. */
.ksec { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--ekey, var(--accent)); border-radius: 13px; overflow: hidden; margin-bottom: 20px; }
.ksec.k-plat { --ekey: var(--c6); }
.ksec.k-fin  { --ekey: var(--accent); }
.ksec.k-roll { --ekey: var(--listed); }
.ksec.k-cat  { --ekey: var(--c3); }
.ksec-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 12px; }
.ksec-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ekey, var(--accent)); flex: none; }
.ksec-head h2 { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.ksec-head .ksec-desc { margin-left: auto; max-width: 54ch; text-align: right; font-size: 12px; color: var(--faint); line-height: 1.4; white-space: normal; }
.ksec .sheet-wrap { border: none; border-radius: 0; background: transparent; margin: 0 !important; max-height: 80vh; }
.ksec-empty { padding: 2px 18px 18px; color: var(--soft); font-size: 14px; }

/* Boxed TOTAL column (subtle side rules) so it reads as the anchor. */
.sheet-kpi th:nth-child(2), .sheet-kpi td:nth-child(2) { box-shadow: inset 1px 0 0 var(--line-strong), inset -1px 0 0 var(--line-strong); }

/* Blue accent rows (gross-sales / grand totals): color the numeric cells only. */
.sheet-kpi tr.kpi-blue td.num { color: var(--listed); }

@media (max-width: 980px) { .kpi-tiles { grid-template-columns: repeat(2, 1fr); } }

/* =========================================================================
   Listings — Accounts column monogram dots (v50). Color = platform,
   distinct shade per account; corner dot = status; full counts on hover/tap.
   ========================================================================= */
.acct-dots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.acct-dot { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 600; cursor: default; outline: none; }
.acct-sd { position: absolute; bottom: -1px; right: -1px; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--surface); }
.acct-tip { position: absolute; top: calc(100% + 7px); left: 0; z-index: 30; display: none; white-space: nowrap; background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; font-size: 12px; color: var(--text); box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.acct-dot:hover, .acct-dot:focus-visible { z-index: 40; }
.acct-dot:hover .acct-tip, .acct-dot:focus-visible .acct-tip { display: block; }

/* =========================================================================
   Sales — platform column: local logo tile + spelled-out name (v52).
   Account handle shown on hover/tap (reuses the .acct-tip popover).
   ========================================================================= */
.plat-tag { position: relative; display: inline-flex; align-items: center; gap: 7px; cursor: default; outline: none; }
.plat-ico { width: 18px; height: 18px; border-radius: 5px; flex: none; display: block; }
.plat-name { font-size: 13px; color: var(--text); white-space: nowrap; }
.plat-tag:hover, .plat-tag:focus-visible { z-index: 40; }
.plat-tag:hover .acct-tip, .plat-tag:focus-visible .acct-tip { display: block; }

/* =========================================================================
   Dashboard — Workspace layout (v55): sticky KPI sidebar + scrolling main.
   Reuses existing panel, cat-table, abar, recent, alert and chart-box styles. Theme-aware.
   ========================================================================= */
.dash-layout { display: grid; grid-template-columns: 300px 1fr; align-items: start; }
.dash-side { position: sticky; top: 0; align-self: start; height: 100vh; overflow: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 18px; }
.dash-side-head { margin-bottom: 6px; }
.dash-side-title { font-size: 22px; }
.dash-side .page-sub { margin: 2px 0 14px; }
.dash-side-cta { margin-bottom: 16px; width: 100%; justify-content: center; }
.dash-krows { display: flex; flex-direction: column; }
.dash-krow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.dash-krow:last-child { border-bottom: none; }
.dash-klabel { font-size: 12.5px; color: var(--soft); }
.dash-kval { font-size: 18px; font-weight: 500; letter-spacing: -.01em; color: var(--ink); }
.dash-krow.green .dash-kval { color: var(--accent); }
.dash-krow.blue .dash-kval { color: var(--listed); }
.dash-krow.neg .dash-kval { color: var(--clay); }

.dash-main { padding: 22px 26px 60px; min-width: 0; }
.dash-mb { margin-bottom: 16px; }
.dash-row-top { display: grid; grid-template-columns: 1.9fr 1fr; gap: 16px; align-items: stretch; }
.dash-g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.dash-g2 { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; }

/* colored top keyline per panel (scoped to dashboard main so other pages are untouched) */
.dash-main .panel { border-top: 3px solid var(--dash-key, var(--accent)); }
.dash-main .dk-rev { --dash-key: var(--c2); }
.dash-main .dk-ann { --dash-key: var(--c6); }
.dash-main .dk-m1 { --dash-key: var(--c1); }
.dash-main .dk-m2 { --dash-key: var(--listed); }
.dash-main .dk-m3 { --dash-key: var(--c3); }
.dash-main .dk-m4 { --dash-key: var(--c5); }
.dash-main .dk-cat { --dash-key: var(--c4); }
.dash-main .dk-rec { --dash-key: var(--accent); }
/* annual panel fills its (stretched) height; bars grow so both top-row panels line up */
.dash-main .dk-ann { display: flex; flex-direction: column; }
.dash-main .dk-ann .abar-chart { flex: 1; }
.dash-main .dk-ann .abar-bars { flex: 1; height: auto; min-height: 150px; }
.dash-main .dk-m1 .panel-title, .dash-main .dk-m2 .panel-title,
.dash-main .dk-m3 .panel-title, .dash-main .dk-m4 .panel-title { font-size: 14px; }

@media (max-width: 1080px) {
    .dash-layout { grid-template-columns: 1fr; }
    .dash-side { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
    .dash-krows { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 18px; }
    .dash-krow { border-bottom: 1px solid var(--line); }
    .dash-row-top, .dash-g4, .dash-g2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
    .dash-krows, .dash-row-top, .dash-g4, .dash-g2 { grid-template-columns: 1fr; }
}

/* ---- Split bundles: container + children + pieces reconcile ---- */
.pill.p-split { background: var(--listed-soft); color: var(--listed); }
.cont-badge { display: inline-block; margin-left: 7px; padding: 1px 7px; border-radius: 20px; font-size: 10.5px; font-weight: 500; background: var(--listed-soft); color: var(--listed); vertical-align: middle; }
tr.row-container td { background: var(--surface-2); }
tr.row-child td.rownum { color: var(--soft); padding-left: 18px; }
.child-tick { color: var(--faint); margin-right: 4px; }
tr.row-child td.fz-item { padding-left: 6px; }
tr.row-pieces td { background: var(--surface-2); border-top: none; }
.pieces-cell { font-size: 12px; color: var(--soft); padding-left: 18px; }
.pieces-cell .pieces-label { text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; color: var(--faint); margin-right: 8px; }
.pieces-cell .pieces-sum { color: var(--text); font-weight: 500; }
.pieces-cell .muted { margin: 0 8px 0 4px; }
.pieces-cell .pieces-ok { color: var(--accent); margin-right: 12px; }
.pieces-cell .pieces-warn { color: #d9a441; margin-right: 12px; }
.pieces-cell .pieces-over { color: #e06b6b; margin-right: 12px; }
.pieces-cell .mini { margin-right: 6px; }
.pieces-cell form { display: inline; }
