/* Office app polish layer: one calm look for numbers, tiles, tables, charts and motion across every office screen
   (Vincent, 2026-11-17: "sleeker, more organized, cleaner animations, data easy to read"). The kit only (ADR-0012):
   no new colour, font or radius. Loaded after motion.css; every rule starts with #main so it wins over the per-screen
   files that load later (channels.css, funnel.css, ads.css…). Changes no number, label meaning or calculation.

   Pattern in one line: one number per tile first, then the words under it; recessed wells instead of boxes inside
   boxes; tables right-align their figures and keep a sticky header; motion is 150-250ms, ease-out, once. */

:root { --p-fast: 150ms; --p-mid: 220ms; --p-ease: cubic-bezier(0.22, 1, 0.36, 1); }

/* ---------- Fewer boxes: a card inside a card is flat; section titles breathe ---------- */
#main .card .card { box-shadow: none; background: var(--surface-2); border: 0; }
#main .card > h2 { margin: 0 0 4px; font-size: 1.05rem; }
#main .card > h2 + .muted, #main .card > h2 + p.small { margin-top: 0; }
#main .card > p.muted.small { max-width: 72ch; line-height: 1.5; }

/* ---------- KPI tiles: value first, then label, then a one-line hint ----------
   Same tile on every screen: the old .kpi (Sales, Finance…) and Channels' .ch-kpi. A recessed well, no border or
   edge bar, a big mono figure, a sentence-case label and a faint hint. */
#main .ch-kpis, #main .kpis { gap: 8px; }
#main .ch-kpis { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-top: 8px; }
#main .ch-kpi, #main .kpi {
  background: var(--surface-2); border: 0; box-shadow: none; border-radius: var(--radius-md);
  padding: 12px 14px 12px; display: grid; align-content: start; gap: 2px; min-width: 0;
}
#main .kpi::before { display: none; }
/* order inside a tile: figure, label, hint */
#main .ch-kpi b, #main .kpi b {
  order: 0; font-family: var(--font-mono); font-weight: 500; font-size: 1.5rem; line-height: 1.15;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); overflow-wrap: anywhere;
}
#main .ch-kpi span, #main .kpi span {
  order: 1; font: 500 .8rem/1.3 var(--font-sans); letter-spacing: 0; text-transform: none; color: var(--ink-muted); margin: 0;
}
#main .ch-kpi small, #main .kpi small { order: 2; font-size: .72rem; line-height: 1.35; color: var(--ink-faint); margin: 0; }
/* the one number that matters on a card leads: first tile is larger, supporting tiles quieter */
#main .ch-kpis > .ch-kpi:first-child b { font-size: 1.75rem; }
#main .ch-kpi-sub b { font-size: 1.15rem; color: var(--ink-muted); }
#main .kpi.good b, #main .kpi.info b { color: var(--accent); }
#main .kpi.bad b { color: var(--danger); }
@media (max-width: 560px) {
  #main .ch-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #main .ch-kpi b, #main .kpi b { font-size: 1.3rem; }
  #main .ch-kpis > .ch-kpi:first-child b { font-size: 1.5rem; }
}

/* "What is this" hint on money terms: a dotted underline marks the word, the sentence shows on hover/focus/tap */
#main :is(.ch-kpi, .sa-card) span[title], #main th[title], #main abbr[title] {
  text-decoration: underline dotted var(--ink-faint); text-underline-offset: 3px; cursor: help;
}

/* ---------- Status pills: one shape, a word always ---------- */
#main :is(.ch-status, .mo-st, .fn-count, .sa-mark, .ah-v, .ads-chip) { font-size: .76rem; font-weight: 600; letter-spacing: 0; }

/* ---------- Tables ----------
   Sticky header on the scroll box, right-aligned mono figures (every column after the name column on Marketing
   tables), calm hover, no zebra noise; hairlines only between rows. */
#main :is(.tbl, .ah-table, .ads-table, .lq-table) { font-variant-numeric: tabular-nums; }
#main .scroll, #main .ah-scroll, #main .ads-scroll { max-height: min(70vh, 640px); overflow: auto; border-radius: var(--radius-md); }
#main .tbl th, #main .ah-table thead th, #main .ads-table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); box-shadow: inset 0 -1px 0 var(--hairline);
  border-bottom: 0; font: 500 11px/16px var(--font-sans); letter-spacing: .02em; text-transform: none; color: var(--ink-muted); white-space: nowrap;
}
#main .tbl td, #main :is(.ah-table, .ads-table) td { border-bottom: 1px solid var(--hairline); padding: 12px 10px; vertical-align: middle; }
#main .tbl tr:last-child td { border-bottom: 0; }
#main .tbl tbody tr:nth-child(even) td:not([class*="st-"]) { background: color-mix(in srgb, var(--surface-2) 38%, transparent); }
@media (hover: hover) and (pointer: fine) {
  #main .tbl tr.click { transition: background-color var(--p-fast) ease; }
  #main .tbl tr.click:hover td { background: var(--surface-2); }
}
#main .tbl td b { font-weight: 600; }
/* numbers line up on the right on the Marketing tables; the first column (the name) and the plain-words columns stay left */
#main :is(.ch-body, .ads-body, .ah-body, .fn-body, .mo-grid) .tbl :is(th, td):not(:first-child):not(.small):not(.wide):not(.acts) { text-align: right; }
#main :is(.ch-body, .ads-body, .ah-body, .fn-body, .mo-grid) .tbl td:not(:first-child) { font-family: var(--font-mono); font-weight: 500; }
#main :is(.ch-body, .ads-body, .ah-body, .fn-body, .mo-grid) .tbl td.muted { color: var(--ink-muted); }
#main :is(.ch-body, .ads-body, .ah-body, .fn-body, .mo-grid) .tbl td.small { font-family: var(--font-sans); text-align: left; }
#main :is(.ch-body, .ads-body, .ah-body, .fn-body, .mo-grid) .tbl td .ch-share { margin-left: auto; }
#main .ah-table :is(th, td):first-child, #main .ads-table :is(th, td):first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
#main .ah-table td, #main .ads-table td { font-family: var(--font-mono); font-weight: 500; }
#main .ah-table td:first-child, #main .ads-table td:first-child { font-family: var(--font-sans); font-weight: 600; }
#main .ah-table, #main .ads-table { font-size: .84rem; border-collapse: separate; border-spacing: 0; }

/* Phones: a row becomes a card, label above its figure, figures left-aligned and easy to tap (app.css does the grid) */
@media (max-width: 760px) {
  #main .scroll, #main .ah-scroll, #main .ads-scroll { max-height: none; }
  #main .tbl.cards tbody tr { background: var(--surface-2); border-radius: var(--radius-md); border: 0; padding: 12px; margin-bottom: 8px; }
  #main .tbl.cards tbody tr:nth-child(even) td { background: none; }
  #main .tbl.cards td { padding: 3px 0; text-align: left !important; font-family: var(--font-mono); }
  #main .tbl.cards td:first-child { grid-column: 1 / -1; font-family: var(--font-sans); font-size: 1rem; padding-bottom: 6px; }
  #main .tbl.cards td.small { font-family: var(--font-sans); }
  #main .tbl.cards td[data-l]::before { font: 500 .7rem/1.2 var(--font-sans); letter-spacing: .02em; text-transform: none; margin-bottom: 1px; }
  #main .tbl.cards td[data-l="Channel"]::before { display: none; }
}

/* ---------- Charts: quiet grid, calm lines, readable ticks ---------- */
#main .viz-title { font-size: .9rem; font-weight: 600; }
#main .viz-grid { stroke-opacity: .7; stroke-dasharray: 2 3; }
#main .viz-tick { font-family: var(--font-mono); font-size: 10.5px; }
#main .viz-line { stroke-width: 1.75; }
#main .viz-area { opacity: .08; }
#main .viz-legend { font-size: .78rem; gap: 4px 14px; }
#main .viz-tip { border-radius: var(--radius-md); }

/* ---------- Lists with their own hairlines: lighter dividers, roomier rows ---------- */
#main :is(.fn-checks, .mo-needs, .ch-forms) li { border-color: var(--hairline); }
#main .mo-nums div { background: var(--surface-2); }
#main .mo-grid { gap: 12px; }
#main .sa-card, #main .sa-feed, #main .sa-switch { border-color: transparent; background: var(--surface-2); }
#main .sa-card .ch-share, #main .sa-card .sa-rows { border-color: var(--hairline); }
#main .ch-leads, #main .sa-answer, #main .ah-find { border-top-color: var(--hairline); }

/* ---------- Motion: fast, ease-out, once. Transform and opacity only; no layout shift ---------- */
@keyframes p-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#main.m-in > * { animation-duration: var(--p-mid); }
#main .ch-body.fx > * { animation-duration: var(--p-mid); animation-timing-function: var(--p-ease); }
#main .ch-body.fx > :nth-child(n) { animation-delay: 0ms; }
#main .ch-body.fx > :nth-child(2) { animation-delay: 30ms; } #main .ch-body.fx > :nth-child(3) { animation-delay: 60ms; }
#main .ch-body.fx > :nth-child(n+4) { animation-delay: 90ms; }
#main .ch-body.fx :is(.ch-kpi, .sa-card, .sa-feed) { animation: p-rise var(--p-mid) var(--p-ease) both; animation-delay: 0ms; }
#main .ch-body.fx :is(.ch-kpi, .sa-card, .sa-feed):nth-child(n+2) { animation-delay: 20ms; }
#main .ch-body.fx :is(.ch-kpi, .sa-card, .sa-feed):nth-child(n+4) { animation-delay: 40ms; }
#main .ch-body.fx .viz-bar { animation-duration: 320ms; animation-delay: 60ms; }
#main .ch-body.fx :is(.viz-line, .viz-area, .viz-dot, .ch-spark) { animation-duration: 300ms; animation-delay: 60ms; }
#main .ch-body.fx .ch-share i { animation-duration: 360ms; animation-delay: 60ms; }
/* the whole page dims while it refreshes instead of jumping */
#main .ch-body, #main .fn-body, #main .ads-body { transition: opacity var(--p-mid) ease; }
/* hover lift off: tiles don't move, they only deepen */
@media (hover: hover) {
  #main :is(.ch-kpi, .sa-card):hover { transform: none; box-shadow: none; }
  #main .sa-card { transition: background-color var(--p-fast) ease; }
  #main .sa-card:hover { background: var(--hairline); }
}
#main :is(.btn, .fchip, .subtab, .linkbtn) { transition-timing-function: ease-out; }
@media (prefers-reduced-motion: reduce) {
  #main *, #main *::before, #main *::after { animation: none !important; transition: none !important; }
}

/* Long explainers fold away: one line up front, the full words one tap below */
#main .ch-how { margin: 6px 0 0; }
#main .ch-how > summary { cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; color: var(--accent); font-weight: 500; }
#main .ch-how > p { margin: 6px 0 0; max-width: 72ch; line-height: 1.5; }

/* Channel chips: one scrolling row, never a wall of buttons; the date row sits level with its label */
#main .ch-chips { flex-wrap: nowrap; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; margin-inline: -2px; padding: 2px; }
#main .ch-chips .fchip { flex: none; }
#main .ch-head .ch-filters { align-items: center; margin-top: 8px; }
#main .ch-head .ch-filters > .small { align-self: center; }
