/* ==========================================================================
   Tryvon back office — admin overview, growth report, salaries, expenses.
   Charts follow the data-viz rules (validated palette: teal + orange, both modes).
   ========================================================================== */
:root {
  --viz-1: #0b93a3;   /* teal  — slot 1 (validated light, surface #fff) */
  --viz-2: #eb6834;   /* orange — slot 2 */
  --viz-neg: #d03b3b; /* critical — losses only */
  --viz-grid: #e6e8e6;
  --viz-base: #c3c2b7;
  --viz-ink: #52514e;
}
:root[data-theme="dark"] {
  --viz-1: #20a5b1;   /* validated dark, surface #0f2a33 */
  --viz-2: #d95926;
  --viz-grid: rgba(255,255,255,.07);
  --viz-base: rgba(255,255,255,.22);
  --viz-ink: #c3c2b7;
}

.section-h { margin: 28px 0 12px; font-size: 1.15rem; }
.office-head p { max-width: 70ch; }

/* KPI board: number, delta vs last month, sparkline */
.kpi-board { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 6px 0 18px; }
.kpi2 { position: relative; display: grid; gap: 4px; padding: 16px 18px 14px; border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); color: inherit; text-decoration: none; overflow: hidden; transition: transform .25s var(--ease), box-shadow .25s; }
a.kpi2:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi2::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--viz-1), transparent); opacity: .8; }
.kpi2 .l { color: var(--muted); font-size: .82rem; font-weight: 650; }
.kpi2 .n { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.kpi2 .delta { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; font-weight: 700; color: var(--muted); flex-wrap: wrap; }
.kpi2 .delta small { font-weight: 500; }
.kpi2 .delta.up { color: var(--ok); } .kpi2 .delta.down { color: var(--err); }
.kpi2 .delta .i { width: 15px; height: 15px; } .i.flip { transform: scaleY(-1); }
.kpi2 .spark { position: absolute; right: 14px; top: 40px; width: 64px; height: 26px; opacity: .85; }
.kpi2 .l { padding-right: 4px; }
.spark polyline { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* overview layout */
.overview-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) { .overview-grid { grid-template-columns: minmax(300px, .8fr) minmax(0, 1.6fr); } }
.overview-grid h2 { display: flex; gap: 8px; align-items: center; }
.action-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.action-list a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; border-radius: 14px; background: var(--soft); color: inherit; text-decoration: none; font-weight: 600; transition: background .2s; }
.action-list a:hover { background: color-mix(in oklab, var(--brand) 10%, var(--soft)); }
.action-list a > span:nth-child(2) { flex: 1; }
.action-list .count { min-width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--card); border: 1px solid var(--line); }
.action-list .count.urgent { background: var(--err-bg); color: var(--err); border-color: transparent; }
.tool-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tool { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 2px; align-items: start; padding: 16px; border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--line); color: inherit; text-decoration: none; transition: transform .25s var(--ease), border-color .2s; }
.tool:hover { transform: translateY(-2px); border-color: color-mix(in oklab, var(--brand) 40%, var(--line)); }
.tool .i { grid-row: span 2; width: 38px; height: 38px; padding: 9px; border-radius: 12px; background: color-mix(in oklab, var(--brand) 12%, transparent); color: var(--brand); }
.tool b { font-size: .95rem; } .tool span { color: var(--muted); font-size: .82rem; }

/* tables */
[data-testid="team-table"] td:first-child { min-width: 150px; }
[data-testid="team-table"] td:first-child .small { display: block; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-table tfoot th { border-top: 2px solid var(--line); }
.neg-text { color: var(--err); }
.edit-row td { background: var(--soft); }
.slip-edit label { display: flex; flex-direction: column; gap: 2px; font-size: .75rem; color: var(--muted); }
.slip-edit input { width: 130px; min-height: 38px; }
.slip-edit .grow { flex: 1; } .slip-edit .grow input { width: 100%; }

/* segmented period switch */
.seg-tabs { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); }
.seg-tabs a { padding: 8px 14px; min-height: 36px; display: inline-flex; align-items: center; border-radius: 999px; font-weight: 700; font-size: .85rem; color: var(--muted); text-decoration: none; }
.seg-tabs a[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

/* charts */
.viz-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.viz { margin: 0; padding: 16px 16px 8px; border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); position: relative; }
.viz-title { font-weight: 750; font-size: .95rem; margin-bottom: 6px; }
.viz-legend { list-style: none; display: flex; gap: 14px; margin: 0 0 4px; padding: 0; font-size: .8rem; color: var(--viz-ink); }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1 { background: var(--viz-1); } .sw.s2 { background: var(--viz-2); }
.viz svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz .grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz .base { stroke: var(--viz-base); stroke-width: 1; }
.viz .tick { fill: var(--viz-ink); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.viz .bar.s1 { fill: var(--viz-1); } .viz .bar.s2 { fill: var(--viz-2); } .viz .bar.neg { fill: var(--viz-neg); }
.viz .bar { transition: opacity .15s; }
.viz .hit { fill: transparent; cursor: crosshair; }
.viz .hit:hover { fill: color-mix(in oklab, var(--viz-1) 8%, transparent); }
.viz-table { margin-top: 4px; font-size: .82rem; }
.viz-table summary { cursor: pointer; color: var(--muted); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.viz-table table { font-size: .82rem; }
.viz-tip { position: fixed; z-index: 90; pointer-events: none; padding: 8px 10px; border-radius: 10px; background: var(--ink); color: var(--bg, #fff); font-size: .8rem; line-height: 1.45; box-shadow: var(--shadow-lg); max-width: 240px; }
:root[data-theme="dark"] .viz-tip { background: #f0efec; color: #0b0b0b; }
.viz-tip b { display: block; margin-bottom: 2px; }

/* horizontal bars (areas, sources, expense categories) */
.hbar { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: .88rem; }
.hbar .hl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 10px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.hbar .fill { display: block; height: 100%; border-radius: 999px; background: var(--viz-1); }
.hbar .hv { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* salaries */
.pay-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.pay-card { display: grid; gap: 10px; }
.pay-card-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.pay-card .field { margin: 0; }
.pay-card .field label { font-size: .8rem; }
.empty-state { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 28px; color: var(--muted); }
.empty-state .i { width: 32px; height: 32px; color: var(--brand); }
.big-number { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; margin: 2px 0 10px; }
.month-nav strong { min-width: 9ch; text-align: center; }

@media print {
  .viz, .kpi2, .panel { box-shadow: none !important; }
  .viz-table { display: none; }
}
