/* =====================================================================
   Kalis OS — design system (v5)
   One grotesk (Geist) with tabular numerals. Near-black charcoal surfaces layered by tone rather than borders,
   a faint atmospheric glow on the workspace, emerald as the only accent, and one strong gradient (the money card).
   Status colors carry one meaning everywhere: green healthy, amber attention, red underperforming / urgent,
   neutral grey for insufficient, missing or stale data.
   Motion: 140–300 ms on opacity and transform only, one easing family, all of it off for reduced motion.
   ===================================================================== */

/* ---------- tokens: light ---------- */
:root {
  --bg: #E9E8E4; --canvas: #F4F3F0; --panel: #FFFFFF; --panel-2: #F7F6F3; --panel-3: #EDECE8; --field: #FFFFFF;
  --line: #E2E0DB; --line-2: #ECEAE6; --card-line: rgba(20, 20, 26, .055); --tint: rgba(255, 255, 255, 0);
  --surface: linear-gradient(180deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, 0) 140px);
  --hl: inset 0 1px 0 rgba(255, 255, 255, .9);
  --nav-active: #FFFFFF; --nav-hover: rgba(20, 20, 26, .045); --nav-shadow: 0 1px 2px rgba(20, 20, 26, .06), 0 0 0 1px rgba(20, 20, 26, .045);
  --ink: #121214; --ink-2: #45464C; --muted: #72737B; --faint: #A3A4AB;
  --accent: #12925B; --accent-2: #5CC592; --accent-ink: #0B7A4A; --accent-soft: #E1F2E8; --accent-fg: #FFFFFF;
  --lav: #6E5BE0; --lav-soft: #EEEBFC; --info: var(--lav); --info-soft: var(--lav-soft);
  --good: #12925B; --good-soft: #E1F2E8; --warn: #A66D05; --warn-soft: #F9EFD8;
  --bad: #C9372E; --bad-soft: #FAE6E3; --hot: #B5573A; --hot-soft: #F7E7DF;
  --neutral: #8A8B92; --neutral-soft: #EEEDEA;
  --primary-bg: var(--accent); --primary-fg: var(--accent-fg);
  --inv-bg: #141416; --inv-fg: #FFFFFF;
  --shadow-1: 0 1px 2px rgba(20, 20, 26, .03), 0 8px 24px -16px rgba(20, 20, 26, .12);
  --shadow-2: 0 16px 36px -18px rgba(20, 20, 26, .22);
  --shadow-pop: 0 28px 70px -22px rgba(20, 20, 26, .3), 0 2px 8px rgba(20, 20, 26, .05), 0 0 0 1px rgba(20, 20, 26, .05);
  --scrim: rgba(24, 24, 28, .26);
  --atmos: radial-gradient(760px 420px at 78% -120px, rgba(238, 196, 168, .32), transparent 70%), radial-gradient(620px 460px at 108% 22%, rgba(196, 218, 168, .28), transparent 70%), radial-gradient(520px 380px at -6% -60px, rgba(214, 226, 236, .5), transparent 70%);
  --rail-glow: radial-gradient(260px 220px at 0% 0%, rgba(255, 255, 255, .55), transparent 70%);
  --feature: radial-gradient(120% 90% at 90% 105%, rgba(214, 232, 140, .55), transparent 58%), linear-gradient(150deg, #34481F 0%, #587428 52%, #8FA748 100%);
  --hero: radial-gradient(90% 140% at 0% 0%, rgba(240, 200, 172, .30), transparent 60%), radial-gradient(70% 120% at 100% 100%, rgba(200, 222, 172, .32), transparent 60%);
  --focus: 0 0 0 2px var(--canvas), 0 0 0 4px color-mix(in srgb, var(--accent) 55%, transparent);
  --r: 20px; --r-sm: 14px; --r-xs: 10px;
  --f-ui: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-num: var(--f-ui);
  --f-brand: var(--f-ui);
  /* type scale */
  --fs-display: 28px; --fs-h1: 24px; --fs-h2: 15px; --fs-body: 14px; --fs-sm: 12.5px; --fs-xs: 11.5px;
  --fs-num-xl: 40px; --fs-num-l: 30px; --fs-num-m: 21px;
  /* motion */
  --ease: cubic-bezier(.2, .7, .2, 1); --ease-out: cubic-bezier(.16, 1, .3, 1); --ease-slide: cubic-bezier(.32, .72, 0, 1);
  --t-fast: .14s; --t: .22s; --t-page: .26s;
  color-scheme: light;
}
/* ---------- tokens: dark (OS preference, or the user's choice) ---------- */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #060607; --canvas: #0B0B0D; --panel: #131316; --panel-2: #18181C; --panel-3: #222227; --field: #161619;
  --line: rgba(255, 255, 255, .075); --line-2: rgba(255, 255, 255, .048); --card-line: rgba(255, 255, 255, .042); --tint: rgba(255, 255, 255, .018);
  --surface: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .006) 160px);
  --hl: inset 0 1px 0 rgba(255, 255, 255, .045);
  --nav-active: rgba(255, 255, 255, .065); --nav-hover: rgba(255, 255, 255, .04); --nav-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 1px rgba(255, 255, 255, .045);
  --ink: #EDEDEF; --ink-2: #ADADB5; --muted: #7F7F89; --faint: #56565F;
  --accent: #3ECF8E; --accent-2: #8BE4B9; --accent-ink: #62DBA3; --accent-soft: rgba(62, 207, 142, .12); --accent-fg: #03140B;
  --lav: #A99BFF; --lav-soft: rgba(169, 155, 255, .13);
  --good: #3ECF8E; --good-soft: rgba(62, 207, 142, .11); --warn: #E6B04F; --warn-soft: rgba(230, 176, 79, .11);
  --bad: #F07572; --bad-soft: rgba(240, 117, 114, .11); --hot: #E59570; --hot-soft: rgba(229, 149, 112, .12);
  --neutral: #8A8A94; --neutral-soft: rgba(255, 255, 255, .06);
  --inv-bg: #EDEDEF; --inv-fg: #0B0B0C;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .02) inset, 0 18px 40px -30px rgba(0, 0, 0, .9);
  --shadow-2: 0 18px 44px -22px rgba(0, 0, 0, .9);
  --shadow-pop: 0 30px 80px -20px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .07);
  --scrim: rgba(2, 2, 4, .6);
  --atmos: radial-gradient(820px 380px at 72% -160px, rgba(62, 207, 142, .05), transparent 70%), radial-gradient(640px 420px at -8% -120px, rgba(140, 150, 255, .045), transparent 70%);
  --rail-glow: radial-gradient(280px 240px at 0% 0%, rgba(255, 255, 255, .035), transparent 70%);
  --feature: radial-gradient(120% 90% at 92% 108%, rgba(178, 214, 104, .30), transparent 58%), linear-gradient(150deg, #142219 0%, #1F3A25 50%, #3F6430 100%);
  --hero: radial-gradient(90% 150% at 0% 0%, rgba(62, 207, 142, .07), transparent 60%);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #060607; --canvas: #0B0B0D; --panel: #131316; --panel-2: #18181C; --panel-3: #222227; --field: #161619;
  --line: rgba(255, 255, 255, .075); --line-2: rgba(255, 255, 255, .048); --card-line: rgba(255, 255, 255, .042); --tint: rgba(255, 255, 255, .018);
  --surface: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .006) 160px);
  --hl: inset 0 1px 0 rgba(255, 255, 255, .045);
  --nav-active: rgba(255, 255, 255, .065); --nav-hover: rgba(255, 255, 255, .04); --nav-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 1px rgba(255, 255, 255, .045);
  --ink: #EDEDEF; --ink-2: #ADADB5; --muted: #7F7F89; --faint: #56565F;
  --accent: #3ECF8E; --accent-2: #8BE4B9; --accent-ink: #62DBA3; --accent-soft: rgba(62, 207, 142, .12); --accent-fg: #03140B;
  --lav: #A99BFF; --lav-soft: rgba(169, 155, 255, .13);
  --good: #3ECF8E; --good-soft: rgba(62, 207, 142, .11); --warn: #E6B04F; --warn-soft: rgba(230, 176, 79, .11);
  --bad: #F07572; --bad-soft: rgba(240, 117, 114, .11); --hot: #E59570; --hot-soft: rgba(229, 149, 112, .12);
  --neutral: #8A8A94; --neutral-soft: rgba(255, 255, 255, .06);
  --inv-bg: #EDEDEF; --inv-fg: #0B0B0C;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .02) inset, 0 18px 40px -30px rgba(0, 0, 0, .9);
  --shadow-2: 0 18px 44px -22px rgba(0, 0, 0, .9);
  --shadow-pop: 0 30px 80px -20px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .07);
  --scrim: rgba(2, 2, 4, .6);
  --atmos: radial-gradient(820px 380px at 72% -160px, rgba(62, 207, 142, .05), transparent 70%), radial-gradient(640px 420px at -8% -120px, rgba(140, 150, 255, .045), transparent 70%);
  --rail-glow: radial-gradient(280px 240px at 0% 0%, rgba(255, 255, 255, .035), transparent 70%);
  --feature: radial-gradient(120% 90% at 92% 108%, rgba(178, 214, 104, .30), transparent 58%), linear-gradient(150deg, #142219 0%, #1F3A25 50%, #3F6430 100%);
  --hero: radial-gradient(90% 150% at 0% 0%, rgba(62, 207, 142, .07), transparent 60%);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { scrollbar-gutter: stable; }
body { margin: 0; color: var(--ink); background: var(--bg); font: var(--fs-body)/1.5 var(--f-ui); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; }
h1, h2, h3, .kpi .v, .brand-name, .auth-card h1 { letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.num, .mono { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; letter-spacing: -.005em; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: var(--fs-sm); } .tiny { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.hide { display: none !important; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- boot / sign-in ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); background: var(--atmos), var(--canvas); }
.boot-mark, .brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font: 700 15px var(--f-brand); letter-spacing: -.02em;
  background: var(--inv-bg); color: var(--inv-fg); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); position: relative; flex: none; }
.brand-mark::after, .boot-mark::after { content: ''; position: absolute; right: 5px; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.boot-mark { animation: breathe 1.6s var(--ease) infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .7; } }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--atmos), var(--canvas); }
.auth-card { width: min(400px, 100%); background: var(--surface), var(--panel); border: 1px solid var(--card-line); border-radius: 24px; padding: 30px; display: grid; gap: 18px;
  box-shadow: var(--shadow-pop); animation: rise .3s var(--ease-out) both; }
.auth-card h1 { font: 650 20px var(--f-brand); margin: 0; }
.auth-card p { margin: 0; }
.auth-head { display: flex; align-items: center; gap: 12px; }

/* ---------- shell: quiet sidebar + inset workspace ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--t-page) var(--ease-slide); }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 12px 12px; gap: 1px; overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
  background: var(--rail-glow); }
.rail::-webkit-scrollbar { display: none; }
/* nothing in the rail shrinks: on a short screen the rail scrolls instead of squashing the header (which hid the toggle) */
.rail > * { flex: none; }
.rail > .rail-spacer { flex: 1 0 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 2px 14px 6px; min-height: 48px; }
.brand-mark { cursor: default; }
.brand-name { font: 650 15px/1.1 var(--f-brand); white-space: nowrap; }
.brand-name small { display: block; font: 500 11px var(--f-ui); color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.brand .icon-btn { margin-left: auto; }
#rail-toggle { border: 1px solid var(--line-2); background: var(--panel); box-shadow: var(--nav-shadow); }
#rail-toggle:hover { color: var(--ink); border-color: var(--line); }
#rail-toggle svg { transition: transform var(--t-page) var(--ease-slide); }
.rail-search { display: flex; align-items: center; gap: 9px; width: 100%; border: 1px solid var(--line-2); background: var(--panel); color: var(--muted); border-radius: 12px;
  padding: 8px 10px; margin: 0 0 8px; cursor: pointer; font-size: 13.5px; text-align: left; box-shadow: var(--nav-shadow); }
.rail-search:hover { color: var(--ink-2); border-color: var(--line); }
.rail-search svg { width: 16px; height: 16px; flex: none; }
.rail-search .kbd { margin-left: auto; }
.nav-sec { font-size: 12px; font-weight: 500; color: var(--faint); padding: 14px 10px 5px; white-space: nowrap; }
.nav-link { position: relative; display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 11px; color: var(--ink-2); font-weight: 500; font-size: 13.5px; text-decoration: none; white-space: nowrap; }
.nav-link:hover { background: var(--nav-hover); color: var(--ink); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--nav-active); color: var(--ink); font-weight: 600; box-shadow: var(--nav-shadow); }
.nav-link svg { width: 17px; height: 17px; flex: none; opacity: .78; }
.nav-link[aria-current="page"] svg { opacity: 1; color: var(--accent-ink); }
.nav-link .count { margin-left: auto; font: 600 11px var(--f-num); background: var(--bad); color: #fff; border-radius: 999px; padding: 1px 7px; }
.rail-spacer { min-height: 12px; }
.dev-flag { display: flex; align-items: center; gap: 7px; margin: 0 4px 8px; padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft); white-space: nowrap; }
.dev-flag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.me { display: flex; align-items: center; gap: 8px; padding: 9px 6px 9px 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--nav-shadow); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 650; font-size: 12px; flex: none; }
.me-name { font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 11.5px; color: var(--muted); }
.me > div:nth-child(2) { min-width: 0; flex: 1; }
.me .icon-btn { width: 30px; height: 30px; }

/* collapsed sidebar (desktop only): icons only; labels stay available to screen readers and as tooltips */
@media (min-width: 861px) {
  .shell.rail-collapsed { grid-template-columns: 72px minmax(0, 1fr); }
  .rail-collapsed .rail { padding-inline: 12px; }
  .rail-collapsed .brand { flex-direction: column; gap: 10px; padding: 2px 0 12px; min-height: 0; }
  .rail-collapsed .brand-mark { cursor: pointer; }
  .rail-collapsed .brand .icon-btn { margin: 0; }
  .rail-collapsed #rail-toggle svg { transform: scaleX(-1); }
  .rail-collapsed .brand-name, .rail-collapsed .rail-search span, .rail-collapsed .rail-search .kbd { display: none; }
  .rail-collapsed .rail-search { justify-content: center; padding: 9px 0; }
  .rail-collapsed .nav-sec { font-size: 0; padding: 10px 0 6px; }
  .rail-collapsed .nav-sec::after { content: ''; display: block; height: 1px; background: var(--line-2); margin: 0 10px; }
  .rail-collapsed .nav-link { justify-content: center; padding: 10px 0; }
  .rail-collapsed .nav-link > span:not(.count) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rail-collapsed .nav-link .count { position: absolute; top: 3px; right: 6px; padding: 0 5px; font-size: 10px; }
  .rail-collapsed .dev-flag { font-size: 0; justify-content: center; padding: 8px 0; margin-inline: 0; gap: 0; }
  .rail-collapsed .me { flex-direction: column; padding: 8px 0; gap: 6px; }
  .rail-collapsed .me > div:nth-child(2) { display: none; }
}

.main { min-width: 0; display: flex; flex-direction: column; margin: 8px 8px 8px 0; background: var(--atmos), var(--canvas); background-repeat: no-repeat;
  border: 1px solid var(--card-line); border-radius: 22px; min-height: calc(100vh - 16px); box-shadow: var(--hl); }
.topbar { position: sticky; top: 0; z-index: 20; padding: 24px 32px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-radius: 22px 22px 0 0; transition: background-color var(--t) ease, box-shadow var(--t) ease, padding var(--t) var(--ease); }
.topbar.stuck { background: color-mix(in srgb, var(--canvas) 80%, transparent); backdrop-filter: saturate(150%) blur(18px); -webkit-backdrop-filter: saturate(150%) blur(18px);
  box-shadow: 0 1px 0 var(--line-2); padding-top: 12px; padding-bottom: 12px; border-radius: 0; }
.topbar h1 { font: 640 var(--fs-h1)/1.18 var(--f-ui); letter-spacing: -.03em; margin: 0; transition: font-size var(--t) var(--ease); }
.topbar.stuck h1 { font-size: 18px; }
.topbar h1.hello { font-size: var(--fs-display); }
.topbar.stuck h1.hello { font-size: 18px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.topbar.stuck .sub { display: none; }
.topbar .grow { flex: 1; min-width: 12px; }
.topbar #search-btn { display: none; }
.content { padding: 6px 32px 72px; display: grid; gap: 22px; min-width: 0; width: 100%; max-width: 1440px; margin: 0 auto; }
.view-root { display: grid; gap: 22px; min-width: 0; align-content: start; }
.banner { padding: 11px 14px; border-radius: var(--r-sm); background: var(--warn-soft); color: color-mix(in srgb, var(--warn) 78%, var(--ink)); font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--warn) 14%, transparent); }
.banner.bad { background: var(--bad-soft); color: color-mix(in srgb, var(--bad) 80%, var(--ink)); border-color: color-mix(in srgb, var(--bad) 16%, transparent); }
.banner.neutral { background: var(--neutral-soft); color: var(--ink-2); border-color: var(--line-2); }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--muted); }
.note::before { content: 'i'; flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font: 600 10px/1 var(--f-ui); color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 11px; padding: 7px 13px; min-height: 36px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-1), var(--hl); }
.btn:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--line) 60%, var(--faint)); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary-bg); border-color: transparent; color: var(--primary-fg); box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 8px 20px -12px color-mix(in srgb, var(--accent) 85%, transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary-bg) 90%, var(--ink)); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 28%, var(--line)); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--nav-hover); color: var(--ink); }
.btn.sm { padding: 5px 11px; min-height: 30px; font-size: 12.5px; border-radius: 10px; }
.btn svg { width: 15px; height: 15px; flex: none; }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--nav-hover); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.spinning svg, .btn.spinning svg { animation: spin .8s linear infinite; }
.icon-btn:disabled { opacity: .45; cursor: progress; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--field); border-radius: 11px; padding: 8px 11px; font-size: 13.5px; }
.input::placeholder { color: var(--faint); }
textarea.input { min-height: 80px; resize: vertical; line-height: 1.5; }
.input:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--faint)); }
.input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 65%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad); }
input[type="date"].input { font-variant-numeric: tabular-nums; }
input[type="date"].input::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
:root[data-theme="dark"] input[type="date"].input::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input[type="date"].input::-webkit-calendar-picker-indicator { filter: invert(1); } }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--field); border-radius: 999px; padding: 7px 14px; color: var(--muted); min-width: 220px; cursor: text; }
.search:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--ink); }
.search svg { width: 15px; height: 15px; flex: none; }
button.search { font: inherit; text-align: left; }
.kbd { font: 500 11px var(--f-num); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; color: var(--muted); background: var(--panel-2); }
#period-btn { border-radius: 999px; padding-inline: 14px; }
#period-btn .pd { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
#period-btn .pd::before { content: '·'; margin: 0 6px 0 2px; color: var(--faint); }

/* ---------- pills: page tabs, segmented choices, menus ---------- */
/* page tabs and segmented choices share one sliding indicator (lib/ui.js installSegs) */
.tabs { position: relative; display: flex; gap: 4px; flex-wrap: nowrap; isolation: isolate; }
.tabs a { position: relative; z-index: 1; padding: 7px 15px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--ink); background: var(--nav-hover); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--inv-bg); color: var(--inv-fg); }
.seg { position: relative; display: inline-flex; border-radius: 999px; background: var(--panel-3); padding: 3px; gap: 2px; isolation: isolate; }
.seg button { position: relative; z-index: 1; border: 0; background: transparent; padding: 5px 13px; border-radius: 999px; font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--line-2); }
.seg button .n { font-variant-numeric: tabular-nums; color: var(--faint); font-weight: 600; margin-left: 5px; }
.seg button[aria-pressed="true"] .n { color: var(--muted); }
.seg-ind { position: absolute; z-index: 0; left: 0; top: 0; border-radius: 999px; pointer-events: none; opacity: 0;
  transition: transform .3s var(--ease-slide), width .3s var(--ease-slide), height .3s var(--ease-slide), opacity .15s ease; }
.seg-ind.on { opacity: 1; }
.seg-ind.instant { transition: none; }
.seg > .seg-ind { background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--line-2); }
.tabs > .seg-ind { background: var(--inv-bg); }
.feature-seg > .seg-ind { background: rgba(255, 255, 255, .92); }
.has-ind > button[aria-pressed="true"], .has-ind > a[aria-current="page"] { background: transparent !important; box-shadow: none !important; }
.tabs.has-ind > a[aria-current="page"] { color: var(--inv-fg); }
.has-ind > button, .has-ind > a { transition: color .2s ease, background-color var(--t-fast) ease; }
/* underline tabs inside cards (quieter than pills) */
.utabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line-2); }
.utabs button { border: 0; background: none; padding: 8px 0 10px; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; box-shadow: inset 0 -2px 0 transparent; }
.utabs button[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow-pop);
  padding: 6px; z-index: 40; min-width: 220px; display: grid; gap: 1px; }
.menu button, .menu a { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; text-align: left;
  padding: 8px 10px; border-radius: 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: var(--nav-hover); color: var(--ink); text-decoration: none; box-shadow: none; }
.menu button[aria-checked="true"] { color: var(--ink); font-weight: 600; }
.menu button[aria-checked="true"]::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.menu button .md { margin-left: auto; color: var(--faint); font-size: 11.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.menu button[aria-checked="true"] .md { color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 2px; }
.menu .menu-h { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 8px 10px 4px; }
.menu .custom { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; }
.menu .menu-q { border: 0; border-bottom: 1px solid var(--line-2); background: transparent; outline: 0; padding: 7px 10px 9px; margin-bottom: 4px; font-size: 13px; color: var(--ink); }
.menu.period-menu { min-width: 300px; max-height: min(560px, calc(100vh - 120px)); overflow-y: auto; }

/* ---------- surfaces ---------- */
.card { position: relative; background: var(--surface), var(--panel); border: 1px solid var(--card-line); border-radius: var(--r); min-width: 0; box-shadow: var(--shadow-1), var(--hl); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin: 0; font-size: var(--fs-h2); font-weight: 600; letter-spacing: -.012em; }
.card-h .grow { flex: 1; }
.card-h .count-pill { font: 600 11.5px var(--f-num); color: var(--muted); background: var(--panel-3); border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.card-b { padding: 14px 20px 20px; min-width: 0; }
.card-f { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
/* the one soft highlight on a page (VA "Start here", latest AI read) */
.card.hero { background: var(--hero), var(--surface), var(--panel); border-color: color-mix(in srgb, var(--accent) 14%, var(--card-line)); }
/* the featured money card: the only strong gradient in the app */
.feature { position: relative; overflow: hidden; border-radius: 24px; padding: 22px; color: #F7F8F2; background: var(--feature); display: flex; flex-direction: column; gap: 6px; min-width: 0;
  box-shadow: 0 24px 48px -28px rgba(40, 60, 20, .6), inset 0 1px 0 rgba(255, 255, 255, .14); }
.feature::before { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; background: radial-gradient(60% 50% at 0% 0%, rgba(255, 255, 255, .15), transparent 70%); }
.feature::after { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; opacity: .35; mix-blend-mode: overlay;
  background-image: radial-gradient(rgba(255, 255, 255, .5) 1px, transparent 1.2px); background-size: 14px 14px; mask-image: linear-gradient(200deg, #000 0%, transparent 55%); -webkit-mask-image: linear-gradient(200deg, #000 0%, transparent 55%); }
.feature > * { position: relative; z-index: 1; }
.feature .l { font-size: 13px; color: rgba(247, 248, 242, .82); font-weight: 500; display: flex; align-items: center; gap: 10px; }
.feature .v { font: 560 var(--fs-num-xl)/1.05 var(--f-num); letter-spacing: -.04em; font-variant-numeric: tabular-nums; margin-top: 12px; }
.feature .v .cur { font-size: .55em; vertical-align: .55em; margin-right: 2px; opacity: .75; letter-spacing: 0; }
.feature .s { font-size: 12.5px; color: rgba(247, 248, 242, .76); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 20px; }
.feature hr { border: 0; border-top: 1px solid rgba(255, 255, 255, .16); margin: auto 0 4px; width: 100%; padding-top: 14px; }
.feature .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 13px; color: rgba(247, 248, 242, .8); padding: 3px 0; }
.feature .row b { font: 600 15px var(--f-num); color: #fff; font-variant-numeric: tabular-nums; }
.feature .row .k-tag { font-size: 10.5px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .78); margin-left: 6px; }
.feature .delta { background: rgba(255, 255, 255, .16); color: #fff; }
.feature .delta b { background: #fff; color: #2B3B18; }
.feature .icon-ring { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .32); background: rgba(255, 255, 255, .08); display: grid; place-items: center; flex: none; }
.feature .icon-ring svg { width: 17px; height: 17px; }
.feature-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.feature-top .grow { flex: 1; }
.feature-kicker { font-size: 13px; font-weight: 600; color: rgba(247, 248, 242, .88); letter-spacing: -.005em; }
.feature-link { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .22); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); transition: background-color var(--t-fast) ease, transform var(--t-fast) var(--ease-out); }
.feature-link:hover { background: rgba(0, 0, 0, .34); text-decoration: none; transform: translate(1px, -1px); }
.feature-link svg { width: 15px; height: 15px; }
.feature-seg.full { display: flex; width: 100%; margin-bottom: 10px; }
.feature-seg.full button { flex: 1 1 auto; padding-inline: 8px; }
.feature-seg { position: relative; display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, .2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); max-width: 100%; overflow-x: auto; scrollbar-width: none; isolation: isolate; }
.feature-seg::-webkit-scrollbar { display: none; }
.feature-seg button { position: relative; z-index: 1; border: 0; background: transparent; color: rgba(247, 248, 242, .78); font: 600 12px var(--f-ui); padding: 5px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap; transition: background-color var(--t-fast) ease, color .2s ease; }
.feature-seg button:hover { color: #fff; }
.feature-seg button[aria-pressed="true"] { background: rgba(255, 255, 255, .92); color: #22301A; }
.feature-seg.has-ind button[aria-pressed="true"] { color: #22301A; }
.feature-body { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.feature-body.swap > * { animation: rise .26s var(--ease-out) both; }
.feature-tag { display: inline-block; margin-top: 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .9); }
.feature-tag.sim { background: rgba(255, 214, 120, .2); color: #FFE2A6; box-shadow: inset 0 0 0 1px rgba(255, 214, 120, .3); }
.feature-note { font-size: 11.5px; color: rgba(247, 248, 242, .68); margin-top: 6px; line-height: 1.45; }
.feature-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: auto; padding-top: 14px; }
.feature-inputs label { display: grid; gap: 4px; font-size: 11.5px; color: rgba(247, 248, 242, .78); }
.feature-inputs input { width: 100%; border: 1px solid rgba(255, 255, 255, .22); background: rgba(0, 0, 0, .18); color: #fff; border-radius: 10px; padding: 6px 8px; font: 600 13px var(--f-num); }
.feature-inputs input:focus { outline: none; border-color: rgba(255, 255, 255, .6); box-shadow: 0 0 0 3px rgba(255, 255, 255, .18); }
.rev-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-top: 12px; border-radius: 14px; background: rgba(0, 0, 0, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); overflow: hidden; }
.rev-strip > div { padding: 9px 11px; display: grid; gap: 1px; min-width: 0; box-shadow: -1px 0 0 rgba(255, 255, 255, .08); }
.rev-strip .rl { font-size: 10.5px; color: rgba(247, 248, 242, .62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rev-strip .rv { font: 600 14px var(--f-num); color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rev-strip .rt { font-size: 10px; color: rgba(247, 248, 242, .5); white-space: nowrap; }
.pulse .card-b { padding-top: 12px; }
.pulse-person { display: grid; gap: 8px; }
.pulse-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pulse-name .avatar { width: 26px; height: 26px; font-size: 11px; }
.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.hist-row + .hist-row { box-shadow: 0 -1px 0 var(--line-2); }
.hist-row .num { font-size: 15px; display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.hist-row svg { flex: none; }
.st-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 8px; vertical-align: middle; cursor: help; }
.st-healthy { background: var(--good); } .st-attention { background: var(--warn); } .st-critical { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); } .st-low_sample { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.grid { display: grid; gap: 14px; align-content: start; }

/* KPI tiles: label + change on one line, the value large, context underneath */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 14px; }
.kpi { position: relative; background: var(--surface), var(--panel); border: 1px solid var(--card-line); border-radius: var(--r); padding: 17px 18px 16px; display: grid; gap: 6px; min-width: 0; box-shadow: var(--shadow-1), var(--hl); }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: flex-start; gap: 7px; min-width: 0; line-height: 1.35; }
.kpi .l .delta { margin-left: auto; margin-top: -1px; }
.kpi .v { font: 580 var(--fs-num-l)/1.1 var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: -.035em; color: var(--ink); }
.kpi .v .small, .kpi .v .muted { letter-spacing: 0; font-weight: 500; }
.kpi .s { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi .bar { display: none; }
/* a narrow tile (phone, or many tiles in a row) moves the change badge under its label */
.kpi { container-type: inline-size; }
@container (max-width: 250px) {
  .kpi .l { display: block; }
  .kpi.l-healthy .l::before, .kpi.l-attention .l::before, .kpi.l-critical .l::before, .kpi.l-low_sample .l::before { display: inline-block; vertical-align: middle; margin: -2px 6px 0 0; }
  .kpi .l .delta { margin: 5px 0 0; display: flex; width: fit-content; }
}
/* status against target: a small dot before the label */
.kpi.l-healthy .l::before, .kpi.l-attention .l::before, .kpi.l-critical .l::before, .kpi.l-low_sample .l::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex: none; margin-top: 6px; }
.kpi.l-healthy .l::before { background: var(--good); }
.kpi.l-attention .l::before { background: var(--warn); }
.kpi.l-critical .l::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.kpi.l-low_sample .l::before { box-shadow: inset 0 0 0 1.5px var(--faint); }
/* compact strip: secondary numbers share one surface, separated by hairlines */
.kpis.strip { gap: 0; background: var(--surface), var(--panel); border: 1px solid var(--card-line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1), var(--hl); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpis.strip > .kpi { background: transparent; border: 0; border-radius: 0; box-shadow: -1px 0 0 var(--line-2), 0 -1px 0 var(--line-2); padding: 15px 18px; }
.kpis.strip > .kpi .v { font-size: var(--fs-num-m); }
.card .kpis.strip { border: 0; box-shadow: none; border-radius: 0; background: transparent; }
@supports (grid-template-rows: subgrid) {
  /* tiles in a row share label / value / note rows, so numbers line up even when one label wraps */
  .kpis:not(:has(> :not(.kpi), > .kpi > .s:not(:last-child))) > .kpi { grid-row: span 3; grid-template-rows: subgrid; row-gap: 6px; }
}
/* change vs the previous period: a filled arrow badge and the size of the change */
.delta { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 3px; border-radius: 999px; font: 600 12px var(--f-num); background: var(--panel-3); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta b { width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; line-height: 1; background: var(--muted); color: var(--panel); }
.delta.good { background: var(--good-soft); color: var(--good); } .delta.good b { background: var(--good); }
.delta.bad { background: var(--bad-soft); color: var(--bad); } .delta.bad b { background: var(--bad); }
.delta.flat b { background: var(--faint); }
.two { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr); gap: 18px; align-items: stretch; }
@media (max-width: 1100px) { .two, .three, .split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- chips & status ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--panel-3); color: var(--ink-2); line-height: 1.6; border: 1px solid transparent; }
.chip.good, .chip.warn, .chip.bad, .chip.hot { padding-left: 8px; }
.chip.good::before, .chip.warn::before, .chip.bad::before, .chip.hot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--lav-soft); color: var(--lav); }
.chip.hot { background: var(--hot-soft); color: var(--hot); }
.chip.outline { background: transparent; border-color: var(--line); }
.chip.neutral { background: var(--neutral-soft); color: var(--muted); }
button.chip { cursor: pointer; font-family: inherit; }
button.chip:hover { border-color: var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.dot.p1 { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); } .dot.p2 { background: var(--warn); } .dot.p3, .dot.p4 { background: var(--faint); }
/* status: a dot and a word, no pill (compact rows) */
.stat { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--muted); cursor: default; }
.stat[title] { cursor: help; }
.stat::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.stat.s-healthy { color: var(--good); } .stat.s-healthy::before { background: var(--good); }
.stat.s-attention { color: var(--warn); } .stat.s-attention::before { background: var(--warn); }
.stat.s-critical { color: var(--bad); } .stat.s-critical::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.stat.s-low_sample::before, .stat.s-no_target::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.stat.s-no_data::before { width: 8px; height: 2px; border-radius: 2px; }
.stat.s-stale::before { width: 9px; height: 9px; background: none; box-shadow: inset 0 0 0 1.5px var(--muted); border-radius: 50%;
  -webkit-mask: conic-gradient(#000 0 75%, transparent 75%); mask: conic-gradient(#000 0 75%, transparent 75%); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--card-line); border-radius: var(--r); background: var(--surface), var(--panel); box-shadow: var(--shadow-1), var(--hl); }
.card .table-wrap { box-shadow: none; border: 0; border-radius: 0; background: transparent; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; font-size: 12px; text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--ink); }
table.t td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; transition: background-color var(--t-fast) ease; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--panel-2); }
table.t .r { text-align: right; } table.t .c { text-align: center; }
table.t td.wrap { white-space: normal; min-width: 220px; }
table.t td.num, table.t .num { font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; color: var(--ink); } .cell-sub { font-size: 12px; color: var(--muted); }

/* ---------- in-app dropdowns (lib/dropdown.js) ---------- */
.dd-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; overflow: hidden; }
.input.dd { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; min-height: 36px; }
.input.dd .dd-v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.input.dd svg { width: 14px; height: 14px; flex: none; color: var(--muted); transition: transform var(--t) var(--ease-out); }
.input.dd[aria-expanded="true"] { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input.dd[aria-expanded="true"] svg { transform: rotate(180deg); }
.input.dd:disabled { opacity: .55; cursor: not-allowed; }
.menu.dd-menu { position: fixed; right: auto; z-index: 90; max-height: 340px; max-width: min(420px, calc(100vw - 16px)); overflow: hidden; display: flex; flex-direction: column; padding: 6px; }
.dd-menu .dd-list { overflow-y: auto; display: grid; gap: 1px; scrollbar-width: thin; }
.dd-menu .dd-q { border: 0; border-bottom: 1px solid var(--line-2); background: transparent; outline: 0; padding: 7px 10px 9px; margin-bottom: 4px; font-size: 13px; color: var(--ink); }
.dd-menu [role="option"] { justify-content: flex-start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-menu [role="option"]:focus-visible { background: var(--nav-hover); box-shadow: none; color: var(--ink); }
.dd-menu [role="option"][aria-selected="true"] { color: var(--ink); font-weight: 600; }
.dd-menu [role="option"][aria-selected="true"]::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: auto; flex: none; }
.dd-menu [role="option"]:disabled { opacity: .45; cursor: not-allowed; }
.dd-menu .dd-group { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 8px 10px 4px; }
.dd-menu .dd-empty, .menu .dd-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.filters .input.dd { width: auto; border-radius: 999px; padding: 6px 12px 6px 14px; min-height: 32px; font-size: 12.5px; font-weight: 500; }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 2px 0; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager-r { display: inline-flex; align-items: center; gap: 6px; }
.pager-size { display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; }
.pager-size .input.dd { width: auto; min-height: 30px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; }
.pager .icon-btn { width: 30px; height: 30px; border: 1px solid var(--line-2); }
.pager .icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.range-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.range-note svg { width: 13px; height: 13px; opacity: .7; }

/* ---------- lead quality ---------- */
.qbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--panel-3); gap: 2px; min-width: 90px; }
.qbar span { display: block; height: 100%; border-radius: 999px; }
.qfilters { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 18px; padding: 16px 18px; background: var(--surface), var(--panel); border: 1px solid var(--card-line); border-radius: var(--r); animation: drop .2s var(--ease-out); }
.qf-group { display: grid; gap: 8px; align-content: start; }
.qf-group .filters .input.dd { flex: 1 1 auto; max-width: 100%; }

details.rec.play > summary { display: grid; gap: 2px; cursor: pointer; list-style: none; }
details.rec.play > summary::-webkit-details-marker { display: none; }
details.rec.play > summary .strong::after { content: ' +'; color: var(--faint); font-weight: 500; }
details.rec.play[open] > summary .strong::after { content: ' −'; }

/* sentence case for supporting text that is built from data or written lowercase in code */
.card-h > span.muted, .card-h > span.faint { display: inline-block; }
.card-h > span.muted::first-letter, .card-h > span.faint::first-letter, .kpi .s > span:not(.delta):not(.chip)::first-letter,
.cell-sub::first-letter, .field .hint::first-letter, .feature .s > span::first-letter, .pager > span:first-child::first-letter { text-transform: uppercase; }

/* ---------- toolbar & filters ---------- */
.result-line { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; font-size: 13px; margin-top: -8px; }
.result-line .chip { cursor: pointer; }
.btn.is-on { background: var(--inv-bg); color: var(--inv-fg); border-color: transparent; }
.btn.is-on:hover { background: color-mix(in srgb, var(--inv-bg) 88%, var(--accent)); }
.btn svg + svg, .btn > svg:last-child:not(:first-child) { width: 13px; height: 13px; opacity: .7; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters select.input { width: auto; padding: 6px 30px 6px 13px; font-size: 12.5px; font-weight: 500; border-radius: 999px; min-height: 32px; }

/* ---------- task list ---------- */
.tasks { display: grid; padding: 0 8px 8px; }
.task { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 13px 12px; border-radius: 14px; cursor: pointer; }
.task + .task::before { content: ''; position: absolute; left: 32px; right: 12px; top: 0; height: 1px; background: var(--line-2); }
.task:hover, .task:focus-visible { background: var(--panel-2); }
.task:hover + .task::before, .task:hover::before, .task:focus-visible::before { opacity: 0; }
.task .dot { margin-top: 7px; }
.task-title { font-weight: 600; line-height: 1.4; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.task-side { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; display: grid; gap: 3px; justify-items: end; padding-top: 1px; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.overdue { background: linear-gradient(90deg, color-mix(in srgb, var(--bad) 8%, transparent), transparent 55%); }
.task.overdue:hover { background: linear-gradient(90deg, color-mix(in srgb, var(--bad) 11%, transparent), var(--panel-2) 55%); }
.due-pill { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 11.5px; border-radius: 999px; padding: 1px 8px; background: var(--panel-3); color: var(--ink-2); }
.due-pill.overdue { background: var(--bad-soft); color: var(--bad); }
.due-pill.overdue svg { width: 12px; height: 12px; }
.due-pill.today { background: var(--warn-soft); color: var(--warn); }
.group-h { display: flex; align-items: center; gap: 8px; padding: 14px 12px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.group-h .n { font-variant-numeric: tabular-nums; color: var(--faint); font-weight: 600; }
.group-h + .task::before { display: none; }

/* ---------- callouts & lists ---------- */
/* attention panel (Today): the bottleneck and data warnings in one integrated surface, no accent bars */
.attn { position: relative; overflow: hidden; border-radius: var(--r); border: 1px solid var(--card-line); box-shadow: var(--shadow-1), var(--hl);
  background: radial-gradient(520px 220px at 0% 0%, var(--attn-glow, transparent), transparent 70%), var(--surface), var(--panel); }
.attn.lvl-critical { --attn-glow: color-mix(in srgb, var(--bad) 13%, transparent); --attn-c: var(--bad); --attn-soft: var(--bad-soft); }
.attn.lvl-attention { --attn-glow: color-mix(in srgb, var(--warn) 12%, transparent); --attn-c: var(--warn); --attn-soft: var(--warn-soft); }
.attn.lvl-ok { --attn-glow: color-mix(in srgb, var(--good) 9%, transparent); --attn-c: var(--good); --attn-soft: var(--good-soft); }
.attn.lvl-neutral { --attn-glow: transparent; --attn-c: var(--muted); --attn-soft: var(--neutral-soft); }
.attn-main { display: flex; align-items: center; gap: 16px; padding: 18px 20px; flex-wrap: wrap; }
.attn-ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--attn-soft); color: var(--attn-c); }
.attn-ico svg { width: 19px; height: 19px; }
.attn-copy { flex: 1 1 0; min-width: 200px; display: grid; gap: 3px; }
.attn-title { font-size: 17px; font-weight: 620; letter-spacing: -.015em; line-height: 1.3; }
.attn-title .num { color: var(--attn-c); }
.attn-sub { font-size: 12.5px; color: var(--muted); }
.attn-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.attn-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.attn-row .attn-row-t { flex: 1 1 200px; min-width: 0; }
.attn-row .attn-row-t b { color: var(--ink); font-weight: 600; }
.attn-row .stat { padding-top: 1px; }
.attn-row details > summary { cursor: pointer; color: var(--muted); list-style: none; display: inline; }
.attn-row details > summary::-webkit-details-marker { display: none; }
.attn-row details > summary:hover { color: var(--ink-2); }
.attn-row details[open] > summary { color: var(--ink-2); }
.attn-row details > div { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; animation: drop .18s var(--ease-out); }
.bottleneck { position: relative; overflow: hidden; border: 1px solid var(--card-line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 6px; background: var(--surface), var(--panel); align-content: start; }
.bottleneck .eyebrow { font-size: 12px; font-weight: 500; color: var(--muted); }
.bottleneck .big { font-size: 17px; font-weight: 650; }
.list-plain { margin: 0; padding: 0; list-style: none; display: grid; }
.list-plain li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.list-plain li:first-child { padding-top: 2px; }
.list-plain li:last-child { border-bottom: 0; padding-bottom: 2px; }
/* health check rows */
.hc { margin: 0; padding: 0; list-style: none; display: grid; }
.hc li { display: grid; grid-template-columns: minmax(0, 1fr) auto 128px; align-items: center; gap: 12px; padding: 9px 10px; margin: 0 -10px; border-radius: 11px; }
.hc li:hover { background: var(--panel-2); }
.hc li + li { box-shadow: 0 -1px 0 var(--line-2); }
.hc li:hover, .hc li:hover + li { box-shadow: none; }
.hc .hc-l { min-width: 0; font-size: 13px; color: var(--ink-2); }
.hc .hc-t { font-size: 11.5px; color: var(--faint); display: block; margin-top: 1px; }
.hc .hc-v { font: 580 14px var(--f-num); font-variant-numeric: tabular-nums; text-align: right; }
.hc .hc-v.none { color: var(--faint); font-weight: 500; }
.hc .stat { justify-self: start; }
.hc-sum { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 10px; }
.hc-sum .stat { font-weight: 500; }
.hc-sum .stat b { font-variant-numeric: tabular-nums; font-weight: 650; }
/* appointments (Today) */
.appts { display: grid; gap: 4px; margin: 0 -10px; }
.appt { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px; border-radius: 13px; }
.appt:hover { background: var(--panel-2); }
.appt-time { display: grid; gap: 1px; }
.appt-time b { font: 600 14px var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.appt-time span { font-size: 11px; color: var(--muted); font-weight: 500; }
.appt-who { min-width: 0; }
.appt-who .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty-inline { display: flex; align-items: center; gap: 14px; padding: 6px 0 2px; }
.empty-inline .empty-ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); flex: none; box-shadow: inset 0 0 0 1px var(--line-2); }
.empty-inline .empty-ico svg { width: 18px; height: 18px; }
.empty-inline strong { display: block; font-weight: 600; font-size: 13.5px; }
.empty-inline .small { color: var(--muted); }
.fresh { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); }
details.fresh { display: block; flex: none; max-width: 100%; }
details.fresh > summary > * { white-space: nowrap; }
details.fresh > summary { display: flex; width: fit-content; gap: 6px 8px; flex-wrap: wrap; align-items: center; cursor: pointer; list-style: none; max-width: 100%; border-radius: 999px; padding: 4px 12px 4px 10px; margin-left: -10px; }
details.fresh > summary::-webkit-details-marker { display: none; }
details.fresh > summary:hover { background: var(--nav-hover); color: var(--ink-2); }
details.fresh > summary::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint); transform: translateY(-2px) rotate(45deg); transition: transform var(--t-fast) ease; }
details.fresh[open] > summary::after { transform: translateY(1px) rotate(225deg); }
details.fresh > div { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0 2px; animation: drop .18s var(--ease-out); }
.section-t { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 10px; letter-spacing: -.005em; }
.eyebrow { font-size: 12px; font-weight: 500; color: var(--muted); }

/* ---------- Today layout: two columns on desktop; one ordered column below 1100px ---------- */
.today-cols { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.today-cols > .col { display: grid; gap: 18px; align-content: start; min-width: 0; }
@media (max-width: 1100px) {
  .today-cols { grid-template-columns: minmax(0, 1fr); }
  .today-cols > .col { display: contents; }
  .today-cols [data-o="appts"] { order: 1; } .today-cols [data-o="duties"] { order: 2; } .today-cols [data-o="prio"] { order: 3; }
  .today-cols [data-o="fb"] { order: 4; } .today-cols [data-o="decide"] { order: 5; } .today-cols [data-o="health"] { order: 6; } .today-cols [data-o="yday"] { order: 7; }
}

/* ---------- calendar (Appointments → Calendar) ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-head h2 { margin: 0 6px 0 0; font-size: 18px; font-weight: 620; letter-spacing: -.02em; min-width: 150px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 0 8px 4px; }
.cal-day { position: relative; min-height: 104px; border-radius: 14px; padding: 8px; background: var(--panel-2); border: 1px solid transparent; display: grid; align-content: start; gap: 4px; cursor: pointer; text-align: left; color: inherit; font: inherit; min-width: 0; }
.cal-day:hover { border-color: var(--line); }
.cal-day.out { background: transparent; color: var(--faint); }
.cal-day.today .cal-n { background: var(--accent); color: var(--accent-fg); }
.cal-day[aria-pressed="true"] { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.cal-n { font: 600 12px var(--f-num); font-variant-numeric: tabular-nums; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; justify-self: start; }
.cal-ev { display: block; font-size: 11.5px; line-height: 1.35; padding: 2px 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cal-ev.s-cancelled { background: var(--neutral-soft); color: var(--faint); text-decoration: line-through; }
.cal-ev.s-no_show { background: var(--bad-soft); color: var(--bad); }
.cal-ev.s-completed { background: var(--panel-3); color: var(--ink-2); }
.cal-ev.s-confirmed { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 6px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
@media (max-width: 760px) {
  .cal { gap: 4px; }
  .cal-day { min-height: 52px; padding: 6px 4px; justify-items: center; }
  .cal-n { justify-self: center; }
  .cal-ev, .cal-more { display: none; }
  .cal-dots { display: flex; justify-content: center; }
  .cal-dow { padding: 0; text-align: center; }
}

/* ---------- drawer & modal ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(2px); z-index: 60; animation: fade .2s ease-out; }
.drawer { position: fixed; top: 8px; right: 8px; bottom: 8px; width: min(580px, calc(100vw - 16px)); background: var(--panel); border: 1px solid var(--line-2); z-index: 61;
  border-radius: 22px; display: flex; flex-direction: column; box-shadow: var(--shadow-pop); animation: slide .28s var(--ease-out); overflow: hidden; }
.drawer.wide { width: min(780px, calc(100vw - 16px)); }
.drawer-h { padding: 20px 22px 14px; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; align-items: flex-start; }
.drawer-h h2 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.drawer-h .grow { flex: 1; min-width: 0; }
.drawer-b { padding: 18px 22px 30px; overflow-y: auto; flex: 1; display: grid; gap: 16px; align-content: start; background: var(--canvas); }
.drawer-b > .card { box-shadow: none; }
.drawer-f { padding: 12px 22px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: var(--panel); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.modal { position: fixed; z-index: 62; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 22px; box-shadow: var(--shadow-pop); padding: 22px; display: grid; gap: 14px; animation: pop .2s var(--ease-out); }
.modal h3 { margin: 0; font-size: 16px; font-weight: 650; }
@keyframes slide { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- forms ---------- */
.form { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field .err { font-size: 11.5px; color: var(--bad); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; gap: 7px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 500; cursor: pointer; background: var(--field); }
.checks label:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); color: var(--accent-ink); }
.checks input { accent-color: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- score bar & charts ---------- */
.scorebar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--panel-3); gap: 2px; }
.scorebar span:first-child { background: var(--accent); border-radius: 999px; } .scorebar span:nth-child(2) { background: var(--lav); border-radius: 999px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 11.5px var(--f-ui); font-variant-numeric: tabular-nums; }
.chart .axis { stroke: var(--line-2); }
.chart .xp rect { fill: var(--inv-bg); } .chart .xp text { fill: var(--inv-fg); font-weight: 600; }
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 64px; gap: 12px; align-items: center; font-size: 13px; }
.funnel-bar { height: 10px; border-radius: 999px; background: var(--panel-3); position: relative; overflow: hidden; }
.funnel-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 40%, var(--panel-3)), var(--accent)); transform-origin: left; animation: grow .8s var(--ease-out) both; }
@keyframes grow { from { transform: scaleX(0); } to { transform: none; } }
.funnel-step { font-size: 11.5px; color: var(--faint); padding-left: 142px; margin: -5px 0 -3px; }
.area-wrap { position: relative; touch-action: pan-y; cursor: crosshair; border-radius: var(--r-xs); }
.area-wrap:focus-visible { box-shadow: var(--focus); }
.area-wrap .xh, .area-wrap .xd, .area-wrap .xp { transition: opacity var(--t-fast) ease; pointer-events: none; }
.area-wrap .chart { width: 100%; height: auto; }
.chart.spark { width: auto; height: auto; max-width: 100%; flex: none; }
.area-tip { position: absolute; top: 0; pointer-events: none; min-width: 172px; display: grid; gap: 3px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 12px; font-size: 12px; box-shadow: var(--shadow-2); white-space: nowrap; opacity: 0; transition: opacity var(--t-fast) ease; z-index: 2; }
.area-tip.on { opacity: 1; }
.area-tip b { font: 600 12.5px var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.big-num { font: 580 var(--fs-num-l)/1.1 var(--f-num); letter-spacing: -.035em; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 10px; }
.stat-pair { display: flex; gap: 32px; flex-wrap: wrap; align-items: flex-end; }

/* ---------- empty, error, skeleton, toast ---------- */
.empty { padding: 32px 18px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty strong { color: var(--ink); font-size: 14px; font-weight: 600; }
.empty .empty-ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--muted); margin-bottom: 4px; }
.empty .empty-ico svg { width: 18px; height: 18px; }
.empty.error .empty-ico { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.skel { border-radius: var(--r); background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%); background-size: 220% 100%;
  border: 1px solid var(--card-line); animation: sk 1.5s ease-in-out infinite; }
@keyframes sk { from { background-position: 120% 0; } to { background-position: -120% 0; } }
#toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 10px; background: var(--inv-bg); color: var(--inv-fg); padding: 10px 16px 10px 13px; border-radius: 14px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-pop); pointer-events: auto; max-width: min(560px, calc(100vw - 32px)); animation: toast-in .24s var(--ease-out); transition: opacity .18s ease, transform .18s ease; }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: color-mix(in srgb, var(--inv-fg) 45%, transparent); flex: none; }
.toast.good::before { background: var(--accent); }
.toast.bad::before { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- command palette ---------- */
.palette { position: fixed; z-index: 70; top: 12vh; left: 50%; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 20px; box-shadow: var(--shadow-pop); overflow: hidden; animation: drop .18s var(--ease-out); }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line-2); padding: 16px 20px; font-size: 15px; background: transparent; outline: 0; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 11px; cursor: pointer; }
.palette-item[aria-selected="true"], .palette-item:hover { background: var(--nav-hover); }
.palette-item .k { margin-left: auto; font-size: 11.5px; color: var(--muted); }

/* ---------- report blocks, planner, misc ---------- */
.report-block { display: grid; gap: 8px; }
.report-block h3 { margin: 0; font-size: 14px; font-weight: 650; }
.rec { border: 1px solid var(--line-2); border-radius: 14px; padding: 12px 14px; display: grid; gap: 5px; background: var(--panel-2); }
.rec .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.prose { white-space: pre-wrap; line-height: 1.6; }
.planner input.input { padding: 6px 8px; text-align: right; min-width: 84px; }
.planner td, .planner th { white-space: nowrap; }
.kpi.click-tile { cursor: pointer; }
.kpi.click-tile:focus-visible { box-shadow: var(--focus); }
.fresh-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.fresh-item { display: grid; gap: 3px; padding: 12px 14px; border-radius: 14px; background: var(--panel-2); min-width: 0; }
.fresh-item .fl { font-size: 12px; color: var(--muted); }
.fresh-item .fv { font-weight: 600; font-size: 13.5px; }
.fresh-item .stat { font-weight: 500; }

/* =====================================================================
   Motion
   - page change: the new page fades and rises 6px (260 ms); sub-tab changes keep the page and dim it while loading
   - sections fade and rise as they scroll in, and recede slightly as they leave the top (scroll-driven, no JS)
   - the selected pill slides between options; menus open and close; buttons respond to hover, focus and press
   ===================================================================== */
.btn, .icon-btn, .nav-link, .seg button, .tabs a, .input, .search, .rail-search, .chip, .menu button, .menu a, .palette-item, .checks label, .task, .appt, .cal-day {
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, transform var(--t-fast) var(--ease-out); }
.btn:active:not(:disabled), .icon-btn:active, .seg button:active, .tabs a:active, .feature-seg button:active, .cal-day:active { transform: scale(.97); }
@media (hover: hover) {
  .kpi { transition: border-color var(--t) ease, box-shadow var(--t) ease, transform var(--t) var(--ease-out); }
  .kpi.click-tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); box-shadow: var(--shadow-2), var(--hl); }
  .btn:not(.ghost):not(:disabled):hover { transform: translateY(-.5px); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes drop-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-3px) scale(.985); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
#view.entering > .view-root { animation: page-in var(--t-page) var(--ease-out) both; }
#view.loading > .view-root { opacity: .55; transition: opacity .18s ease; pointer-events: none; }
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .45s var(--ease-out), transform .45s var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }
.view-root[aria-busy="true"] { animation: fade .2s ease-out; }
.menu { animation: drop .16s var(--ease-out); transform-origin: top right; }
.menu.dd-menu { transform-origin: top left; }
.menu.closing { animation: drop-out .12s ease forwards; pointer-events: none; }
#drawer-root .leaving { pointer-events: none; transition: opacity .16s ease, transform .16s ease; opacity: 0; }
#drawer-root .drawer.leaving { transform: translateX(24px); }
.chart .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s var(--ease-out) .1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .fade-in { animation: fade .7s ease-out .25s both; }
.chart.static .draw, .chart.static .fade-in { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
.btn[aria-busy="true"], .btn:disabled { cursor: progress; }
.tabs, .seg { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
/* scroll-driven: rise in on entry, recede gently over the last stretch of leaving the top. Opacity never drops so far that a control
   is unreadable, and nothing animates for reduced motion. Browsers without view timelines use the JS fade-in (lib/ui.js reveal). */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    #view .view-root :is(.card, .kpi, .feature, .attn, .table-wrap, .kpis.strip, .qfilters):not(:is(.card, .kpis.strip, .feature, .attn, .table-wrap) *) {
      animation: sd-in linear both, sd-out linear both;
      animation-timeline: view(), view();
      animation-range: entry 0% entry 140px, exit calc(100% - 120px) exit 100%;
    }
  }
}
@keyframes sd-in { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: none; } }
@keyframes sd-out { from { scale: 1; filter: none; } to { scale: .975; filter: opacity(.45); } }

/* feedback: a just-completed row glows once; buttons show a spinner while saving */
@keyframes done-glow { 0% { background: var(--good-soft); } 100% { background: transparent; } }
@keyframes done-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.08); } 100% { transform: none; } }
.just-done { animation: done-glow 1.2s ease-out; border-radius: 8px; }
.just-done .chip.good { animation: done-pop .32s var(--ease-out); }
.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { border-right-color: currentColor; opacity: .5; } .chart .draw { stroke-dasharray: none; stroke-dashoffset: 0; } }
/* grid/flex children may shrink below their content, so a long filter row scrolls instead of widening the page */
.view-root > *, .grid > *, .card-b > * { min-width: 0; }
.toolbar > .seg { min-width: 0; flex: 0 1 auto; }

/* =====================================================================
   Responsive: the workspace fills the screen, the sidebar becomes a sheet, a floating tab bar appears
   ===================================================================== */
.mobile-bar { display: none; }
.tabbar, .rail-scrim { display: none; }
@media (max-width: 1240px) and (min-width: 861px) {
  .topbar { padding-inline: 24px; } .content { padding-inline: 24px; }
}
@media (max-width: 860px) {
  #rail-toggle { display: none; }
  .shell, .shell.rail-collapsed { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; z-index: 50; left: 8px; top: 8px; bottom: 8px; height: auto; width: min(290px, 84vw); transform: translateX(calc(-100% - 16px)); transition: transform .28s var(--ease-slide);
    background: var(--rail-glow), var(--bg); border: 1px solid var(--line-2); border-radius: 20px; box-shadow: var(--shadow-pop); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .rail.open { transform: none; }
  .rail-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .rail-scrim.open { opacity: 1; pointer-events: auto; }
  .rail-search { display: none; }
  .mobile-bar { display: inline-grid; }
  .main { margin: 0; border: 0; border-radius: 0; min-height: 100vh; box-shadow: none; }
  .topbar, .topbar.stuck { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); border-radius: 0; }
  .topbar h1, .topbar.stuck h1, .topbar h1.hello { font-size: 20px; }
  .topbar #search-btn { display: flex; }
  .content { padding: 8px 16px calc(100px + env(safe-area-inset-bottom)); gap: 18px; }
  .view-root { gap: 18px; }
  .search { min-width: 0; flex: 1; }
  .search .kbd { display: none; }
  #period-btn .pd { display: none; }
  .funnel-row { grid-template-columns: 96px minmax(0, 1fr) 54px; }
  .funnel-step { padding-left: 108px; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
    background: color-mix(in srgb, var(--panel) 86%, transparent); backdrop-filter: saturate(150%) blur(18px); -webkit-backdrop-filter: saturate(150%) blur(18px); border: 1px solid var(--line-2); border-radius: 22px; padding: 5px; box-shadow: var(--shadow-pop); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; min-height: 50px; border: 0; background: transparent; border-radius: 17px;
    color: var(--muted); font: 600 10.5px var(--f-ui); text-decoration: none; cursor: pointer; transition: color var(--t-fast) ease, background-color var(--t-fast) ease; }
  .tabbar svg { width: 21px; height: 21px; }
  .tabbar a[aria-current="page"] { color: var(--inv-fg); background: var(--inv-bg); }
  #toast-root { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .hc li { grid-template-columns: minmax(0, 1fr) auto; }
  .hc .stat { grid-column: 1 / -1; margin-top: -4px; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar { flex-wrap: nowrap; gap: 8px; }
  .topbar .sub { display: none; }
  .topbar h1, .topbar.stuck h1, .topbar h1.hello { font-size: 18px; }
  .topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .topbar > div:nth-child(2) { min-width: 0; }
  .topbar #search-btn { flex: 0 0 auto; min-width: 0; padding: 7px 9px; }
  .topbar #search-btn span { display: none; }
  .topbar #period-btn { padding-inline: 10px; font-size: 12px; }
  .topbar #new-btn { padding-inline: 10px; }
  .topbar #new-btn span { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis.strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 13px 13px 12px; }
  .kpi .v { font-size: 22px; }
  .kpis.strip > .kpi .v { font-size: 19px; }
  .feature { padding: 18px; } .feature .v { font-size: 32px; }
  .feature-top .icon-ring { width: 30px; height: 30px; }
  .feature-seg button { padding: 5px 9px; font-size: 11.5px; }
  .feature-inputs { grid-template-columns: 1fr 1fr; }
  .rev-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rev-strip > div:nth-child(n+3) { box-shadow: -1px 0 0 rgba(255, 255, 255, .08), 0 -1px 0 rgba(255, 255, 255, .08); }
  .toolbar > .search { flex: 1 1 100%; }
  .stat-pair { gap: 20px; }
  .attn-main { padding: 16px; gap: 12px; align-items: flex-start; } .attn-row { padding: 12px 16px; gap: 6px 10px; }
  .attn-ico { width: 34px; height: 34px; border-radius: 11px; } .attn-ico svg { width: 17px; height: 17px; }
  .attn-side { width: 100%; }
  .hide-sm { display: none !important; }
  .attn-title { font-size: 15.5px; }
  .appt { grid-template-columns: 56px minmax(0, 1fr); }
  .appt-act { grid-column: 1 / -1; justify-content: flex-start; padding-left: 68px; }
}
@media (pointer: coarse) {
  .btn { min-height: 40px; padding: 8px 14px; }
  .btn.sm { min-height: 34px; padding: 6px 12px; }
  .icon-btn { width: 40px; height: 40px; }
  .seg button { padding: 8px 13px; }
  .tabs a { padding: 9px 15px; }
  .nav-link { padding: 11px 10px; }
  .input, select.input, textarea.input, .search input, .palette input { font-size: 16px; }
  .checks label { padding: 7px 13px; }
  .menu button, .menu a { padding: 11px 12px; }
}
@media (max-width: 640px) {
  .table-wrap:has(> table.stack) { border: 0; background: transparent; overflow: visible; box-shadow: none; }
  table.t.stack, table.t.stack tbody { display: block; }
  table.t.stack thead { display: none; }
  table.t.stack tr { display: grid; gap: 4px; background: var(--surface), var(--panel); border: 1px solid var(--card-line); border-radius: 16px; padding: 12px 14px; margin-bottom: 8px; }
  table.t.stack td { display: flex; justify-content: flex-end; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding: 2px 0; border: 0; text-align: right; min-width: 0; }
  table.t.stack td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 500; text-align: left; flex: none; max-width: 45%; margin-right: auto; }
  table.t.stack td[data-label=""]::before { content: none; }
  table.t.stack td[data-label=""] { justify-content: flex-end; }
  table.t.stack td.lead { display: block; text-align: left; padding-bottom: 6px; margin-bottom: 2px; border-bottom: 1px solid var(--line-2); }
  table.t.stack td.lead::before { content: none; }
  table.t.stack td.wrap { min-width: 0; }
  table.t.stack td > .cell-sub, table.t.stack td .cell-sub { white-space: normal; }
  table.t.stack tbody tr.click:hover td { background: transparent; }
  table.t.stack tbody tr.click:active { background: var(--panel-2); }
  .drawer, .drawer.wide { inset: env(safe-area-inset-top) 0 0 0; width: 100vw; border-radius: 22px 22px 0 0; border-bottom: 0; animation-name: sheet-up; }
  .drawer-h { padding: 16px 18px 12px; }
  .drawer-b { padding: 16px 16px 28px; }
  .drawer-f { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .drawer-f .btn { flex: 1 1 auto; justify-content: center; }
  .drawer-f .grow { display: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; } .kv dd { margin-bottom: 8px; }
  .toolbar > .btn { flex: 1 1 auto; justify-content: center; }
  .toolbar > .seg, .toolbar > select.input, .toolbar > .input.dd { flex: 1 1 100%; }
  .filters select.input, .filters .input.dd { flex: 1 1 calc(50% - 6px); }
  .pager-size span { display: none; }
  .card-h { padding: 15px 16px 0; } .card-b { padding: 12px 16px 16px; }
  .list-plain li { flex-wrap: wrap; }
  .funnel-row { grid-template-columns: 84px minmax(0, 1fr) 48px; font-size: 12px; }
  .funnel-step { padding-left: 96px; }
  .modal { width: calc(100vw - 24px); }
  #duties .list-plain li { flex-wrap: wrap; } #duties .duty-actions { flex-basis: 100%; justify-content: flex-start !important; }
}
