/* ============================================================
   STATUS — k9.ms attendance dashboard
   Design tokens, three aesthetics × two themes × two densities
   ============================================================ */

:root {
  /* Type stacks */
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;

  /* Type scale */
  --t-12: 12px;
  --t-13: 13px;
  --t-14: 14px;
  --t-16: 16px;
  --t-18: 18px;
  --t-22: 22px;
  --t-28: 28px;
  --t-40: 40px;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 22px;

  /* Brand — refined blue */
  --blue-50:  #eef4ff;
  --blue-100: #dbe6ff;
  --blue-200: #b8ccff;
  --blue-300: #8aaaff;
  --blue-400: #5b85ff;
  --blue-500: #3b66f5;
  --blue-600: #2c4fdb;
  --blue-700: #233fae;
  --blue-800: #1d3286;
  --blue-900: #16265f;

  /* Signal palette — used identically across aesthetics */
  --ok:    #16a34a;
  --warn:  #d97706;
  --err:   #dc2626;
  --info:  var(--blue-500);
  --muted: #94a3b8;

  /* Density (default = balanced) */
  --pad-page: 28px;
  --pad-card: 20px;
  --pad-row:  14px;
  --gap:      14px;
}

html[data-density="roomy"] {
  --pad-page: 36px;
  --pad-card: 26px;
  --pad-row:  18px;
  --gap:      18px;
}

/* balanced = default vars above; explicit rule keeps localStorage restore working */
html[data-density="balanced"] {
  --pad-page: 28px;
  --pad-card: 20px;
  --pad-row:  14px;
  --gap:      14px;
}

html[data-density="compact"] {
  --pad-page: 16px;
  --pad-card: 12px;
  --pad-row:  8px;
  --gap:      8px;
  --t-13:     12px;
  --t-14:     12.5px;
}

/* ============================================================
   AESTHETIC: EDITORIAL — Cool Modern. The ONLY direction.
   ----------------------------------------------------------
   Replaced the earlier warm cream/petrol attempt (user
   rejection: "don't make it a warm color"). Direction now:
   Linear's clarity × a magazine spread.

   • Cool off-white / cool near-black canvas — NEVER warm.
   • Purple brand (#7c3aed light / #a78bfa dark) appears
     ONLY on hover, active nav, and focus rings — never at
     rest on a button.
   • Cyan accent (#06b6d4 / #67e8f9) is reserved for the
     italic <em> moment inside titles + the caret. Precious
     by scarcity.
   • Primary CTAs at rest are MONOCHROME ink-on-paper
     (light) / cream-on-ink (dark). Hover reveals purple —
     accent only at the moment of intent.
   • Fraunces italic display + Manrope body + JetBrains
     Mono labels/numerals.
   • Component rules + hairline dividers live in
     styles-editorial.css.
   • 9 other aesthetics (pro/terminal/soft/ivory/paper/coal/
     gold/emerald/copper/violet) were removed.
   ============================================================ */
html[data-aesthetic="editorial"][data-theme="light"] {
  /* Creamy off-white palette — warm paper tone instead of pure white.
   * Easier on the eye than #ffffff and pairs with the warm splash
   * screen + Fraunces italic display. Cards are a touch warmer than
   * the page so panels lift cleanly. */
  --bg:        #f7f2e8;         /* page — creamy paper */
  --bg-elev-1: #fdf8ed;         /* card — slightly warmer than page */
  --bg-elev-2: #efe8d6;         /* secondary panel / hover */
  --bg-hover:  #ebe3cc;
  --bg-active: #e3d9bf;
  --line:      #e3d8bf;         /* default border — warm tan hairline */
  --line-hi:   #d8caa6;         /* hairline divider */
  --text:      #0a0a0c;         /* deep cool ink */
  --text-2:    #52525b;
  --text-3:    #a1a1aa;
  --brand:     #7c3aed;         /* purple — hover + active + focus only */
  --brand-2:   #6d28d9;
  --brand-soft: color-mix(in oklab, #7c3aed 10%, transparent);
  --shadow:    none;            /* hairlines carry the depth */
  --grid-line: rgba(10,10,12,0.04);
  --pop-bg:    rgba(255,255,255,0.96);
}

html[data-aesthetic="editorial"][data-theme="dark"] {
  --bg:        #0a0a0d;         /* cool near-black, NOT warm */
  --bg-elev-1: #14141a;         /* card */
  --bg-elev-2: #1c1c24;         /* secondary panel / hover */
  --bg-hover:  #1a1a22;
  --bg-active: #20202a;
  --line:      #24242b;
  --line-hi:   #1e1e26;
  --text:      #f3f3f5;         /* near-white, cool */
  --text-2:    #a1a1aa;
  --text-3:    #71717a;
  --brand:     #a78bfa;         /* softer purple for dark */
  --brand-2:   #c4b5fd;
  --brand-soft: color-mix(in oklab, #a78bfa 16%, transparent);
  --shadow:    none;
  --grid-line: rgba(243,243,245,0.04);
  --pop-bg:    rgba(20,20,26,0.96);
}

html[data-aesthetic="editorial"] {
  --font-sans:  'Manrope', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: 'Fraunces', 'Iowan Old Style', 'Charter', Georgia, serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  /* Editorial leans on generous spacing */
  --pad-page: 36px;
  --pad-card: 22px;
  --r-md: 12px;
  --r-lg: 18px;
}

/* Editorial form-field rhythm — used by the new Rooms create modal but
   safe anywhere. Same tokens, just typographic restraint. */
.ed-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-2);
  margin-bottom: 7px;
  text-transform: uppercase;
}
.ed-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color 120ms, box-shadow 120ms;
}
.ed-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.editorial-modal h2 { font-feature-settings: "ss01", "liga", "calt"; }

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: var(--t-14);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
/* Fix #16: <select> inherits the dark-theme light text color, but the native
   dropdown popup renders options on a light/white background -> light-on-light
   = invisible titles. Pin option text+bg to readable dark-theme values so the
   dropdown entries are legible in every browser. */
select option,
.sel option,
.inp option { color: var(--text-1, #e8eaed); background: var(--bg-elev-2, #1a1d23); }
/* Bug #9: standup task text (Yesterday/Today/blockers) is stored multi-line,
   but .standup-row .txt collapsed newlines into one run-on line. pre-line keeps
   each task on its own line so multi-task standups aren't shown as a single line. */
.standup-row .txt { white-space: pre-line; }
[hidden] { display: none !important; }

::selection { background: var(--brand-soft); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line-hi); }

/* Utility */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-serif); letter-spacing: -0.01em; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
}

/* ============================================================
   PRIMITIVES
   ============================================================ */
.surface {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.surface-flat {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.divider { height: 1px; background: var(--line); }
.divider-v { width: 1px; align-self: stretch; background: var(--line); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: var(--r-sm);
  font-size: var(--t-13);
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--line);
  transition: background 120ms, color 120ms, border-color 120ms;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--line-hi); }
.btn:active { background: var(--bg-active); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .kbd { font-size: 10.5px; color: var(--text-3); padding: 1px 5px; border: 1px solid var(--line); border-radius: 3px; font-family: var(--font-mono); }

.btn-pri {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-pri:hover { background: var(--brand-2); border-color: var(--brand-2); color: white; }

.btn-ghost {
  border-color: transparent;
}
.btn-ghost:hover { border-color: var(--line); }

.btn-icon { padding: 6px; min-width: 28px; justify-content: center; }

/* Inputs */
.inp {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: var(--t-13);
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
html[data-aesthetic="soft"] .inp { background: var(--bg-elev-1); }
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.inp::placeholder { color: var(--text-3); }
select.inp { cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.badge-ok    { color: var(--ok);   background: color-mix(in oklab, var(--ok) 12%, transparent);   border-color: color-mix(in oklab, var(--ok) 30%, transparent); }
.badge-warn  { color: var(--warn); background: color-mix(in oklab, var(--warn) 14%, transparent); border-color: color-mix(in oklab, var(--warn) 32%, transparent); }
.badge-err   { color: var(--err);  background: color-mix(in oklab, var(--err) 12%, transparent);  border-color: color-mix(in oklab, var(--err) 30%, transparent); }
.badge-info  { color: var(--brand);background: var(--brand-soft);                                border-color: color-mix(in oklab, var(--brand) 32%, transparent); }
.badge-mute  { color: var(--text-3); }

/* Pulse dot */
.pulse {
  position: relative;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 70%, transparent);
  animation: pulse 1.8s cubic-bezier(0,0,.2,1) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 60%, transparent); }
  70%  { box-shadow: 0 0 0 8px color-mix(in oklab, var(--ok) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 0%, transparent); }
}

/* Skeletons */
.sk { background: linear-gradient(90deg, var(--bg-hover) 0%, var(--bg-active) 50%, var(--bg-hover) 100%); background-size: 200% 100%; animation: sk 1.4s linear infinite; border-radius: var(--r-xs); }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Page transitions */
.fade-in { animation: fadeIn 240ms cubic-bezier(.2,.7,.2,1) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; max-width: 360px; }
.toast {
  pointer-events: auto;
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: toastIn 220ms ease-out;
  min-width: 260px;
}
.toast.ok   { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.err  { border-left-color: var(--err); }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ============================================================
   SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
  background: var(--bg);
}

/* Sidebar */
.side {
  width: 232px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  flex-shrink: 0;
  transition: width 220ms cubic-bezier(.2,.7,.2,1);
}
.side.collapsed { width: 60px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 14px;
  height: 56px;
  border-bottom: 1px solid var(--line);
}
.brand-glyph {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  /* The brand logo is now a full self-contained icon (Pulse mascot badge),
     so the glyph wrapper is transparent and blends with the header instead
     of sitting in a white/inverted box. */
  background: transparent;
  color: var(--bg);
  border-radius: 7px;
  position: relative;
  overflow: hidden;
}
html[data-aesthetic="soft"] .brand-glyph { background: var(--brand); color: white; border-radius: 9px; }
html[data-aesthetic="terminal"] .brand-glyph { border-radius: 2px; background: var(--brand); color: var(--bg); }

.brand-mark { display: flex; flex-direction: column; line-height: 1; gap: 2px; overflow: hidden; }
.brand-mark .name {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
html[data-aesthetic="terminal"] .brand-mark .name { font-family: var(--font-mono); letter-spacing: 0; }
.brand-mark .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.nav { flex: 1; padding: 8px; overflow-y: auto; overflow-x: hidden; }
.nav-section + .nav-section { margin-top: 14px; }
.nav-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: 1px;
  position: relative;
  transition: background 100ms, color 100ms;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--text); }
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 2px;
  background: var(--brand); border-radius: 2px;
}
.nav-item .ic { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .ic { opacity: 1; color: var(--brand); }
.nav-item .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  padding: 0 5px;
  border-radius: 4px;
  min-width: 20px; text-align: center;
}
.nav-item.has-pill .count { color: var(--brand); border-color: color-mix(in oklab, var(--brand) 30%, transparent); background: var(--brand-soft); }

.side.collapsed .nav-item { justify-content: center; padding: 8px; }
.side.collapsed .nav-item .label,
.side.collapsed .nav-item .count,
.side.collapsed .brand-mark,
.side.collapsed .nav-section-label,
.side.collapsed .me-block .meta { display: none; }

/* Sidebar bottom */
.side-bottom { padding: 8px; border-top: 1px solid var(--line); }
.me-block {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.me-block:hover { background: var(--bg-hover); }
.me-avatar {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
html[data-aesthetic="terminal"] .me-avatar { border-radius: 3px; }
.me-block .meta { overflow: hidden; }
.me-block .meta .n { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-block .meta .r { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }

/* Topbar */
.top {
  display: flex; align-items: center; gap: 14px;
  height: 56px; padding: 0 var(--pad-page);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.top h1 {
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.top h1 .crumb { color: var(--text-3); font-weight: 400; }
.top h1 .crumb-sep { color: var(--text-3); }

.top .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.cmd-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 5px 8px 5px 10px;
  font-size: 12.5px;
  color: var(--text-3);
  cursor: pointer;
  min-width: 240px;
  transition: border-color 120ms;
}
.cmd-pill:hover { border-color: var(--line-hi); color: var(--text-2); }
.cmd-pill .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; padding: 1px 5px; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; }

/* Live ticker */
.live-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--ok) 30%, transparent);
  background: color-mix(in oklab, var(--ok) 10%, transparent);
  font-size: 11.5px; font-weight: 500;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}
.live-pill .pulse { width: 6px; height: 6px; }

.clock {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2;
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}
.clock .t { font-size: 13px; font-weight: 500; color: var(--text); font-family: var(--font-mono); }
.clock .d { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }

/* Main content */
.main { min-width: 0; }
.page {
  padding: var(--pad-page);
  max-width: 1300px;
  margin: 0 auto;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  margin-bottom: 22px;
}
.kpi {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--pad-card);
  position: relative;
  overflow: hidden;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-label { font-size: 11.5px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--font-mono); }
.kpi-icon { font-size: 16px; opacity: 0.85; }
.kpi-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}
html[data-aesthetic="soft"] .kpi-value { font-size: 36px; font-weight: 500; }
html[data-aesthetic="terminal"] .kpi-value { font-family: var(--font-mono); font-weight: 500; }
.kpi-value .denom { color: var(--text-3); font-size: 14px; font-weight: 400; margin-left: 4px; }
.kpi-trend { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-2); }
.kpi-trend .delta { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kpi-trend .delta.up { color: var(--ok); }
.kpi-trend .delta.down { color: var(--err); }
.kpi-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--bg-active); }
.kpi-bar-fill { height: 100%; transition: width 600ms cubic-bezier(.2,.7,.2,1); }

/* Spark */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 22px; margin-top: 6px; }
.spark-bar { width: 4px; background: var(--brand); border-radius: 1px; opacity: 0.9; min-height: 1px; }

/* ============================================================
   TABLES
   ============================================================ */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.tbl th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 500;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 10px 14px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  position: sticky; top: 0;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text-2); }
.tbl th .sort-ic { display: inline-block; margin-left: 4px; opacity: 0.5; }
.tbl th.sorted { color: var(--text); }
.tbl th.sorted .sort-ic { opacity: 1; color: var(--brand); }
.tbl td {
  padding: var(--pad-row) 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
.tbl tbody tr { transition: background 80ms; }
.tbl tbody tr:hover td { background: var(--bg-hover); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.dim { color: var(--text-3); }
.tbl td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Person cell */
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .ava {
  width: 28px; height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 600; color: white;
  position: relative;
}
html[data-aesthetic="terminal"] .person .ava { border-radius: 3px; }
.person .ava .stat-pip {
  position: absolute; right: -2px; bottom: -2px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--bg-elev-1);
}
.person .meta { min-width: 0; }
.person .n { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .h { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Time bar (today) */
.timebar {
  position: relative;
  height: 22px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  overflow: hidden;
}
.timebar-fill {
  position: absolute;
  top: 0; bottom: 0;
  background: linear-gradient(90deg, color-mix(in oklab, var(--brand) 50%, transparent), var(--brand));
}
.timebar-late {
  background: linear-gradient(90deg, color-mix(in oklab, var(--warn) 50%, transparent), var(--warn));
}
.timebar-marker {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--brand);
  box-shadow: 0 0 0 1px var(--bg);
}
.timebar-marker::after {
  content: ''; position: absolute; top: -3px; left: -3px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand);
}
.timebar-axis {
  display: flex; justify-content: space-between;
  font-size: 9.5px; font-family: var(--font-mono);
  color: var(--text-3); margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.timebar-axis span { text-align: center; }

/* AI roll-up card */
.rollup {
  position: relative;
  background: linear-gradient(180deg, var(--brand-soft) 0%, transparent 80%), var(--bg-elev-1);
  border: 1px solid color-mix(in oklab, var(--brand) 25%, var(--line));
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 22px;
  overflow: hidden;
}
.rollup .grid-bg {
  position: absolute; inset: 0;
  background-image: linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
                    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  mask-image: linear-gradient(180deg, black 0%, transparent 70%);
}
.rollup-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  position: relative;
}
.rollup-head .label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.rollup-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  position: relative;
}
.rollup-body p + p { margin-top: 8px; }
.rollup-body strong { font-weight: 600; color: var(--text); }
.rollup-body em { font-style: normal; background: var(--brand-soft); padding: 0 4px; border-radius: 3px; color: var(--brand); }

/* Section header */
.sh {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev-1);
}
.sh-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.sh-sub { font-size: 12px; color: var(--text-3); }
.sh .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Page header */
.ph {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 22px;
}
.ph h2 {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--text);
}
html[data-aesthetic="soft"] .ph h2 { font-family: var(--font-serif); font-weight: 400; font-size: 30px; letter-spacing: -0.01em; }
.ph .ph-meta { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); }
.ph .ph-meta .sep { color: var(--line-hi); }
.ph .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Empty / loader */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty .ic { font-size: 28px; margin-bottom: 10px; opacity: 0.6; }
.empty .t { font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.empty .s { font-size: 12.5px; }

/* ============================================================
   SEGMENTED CONTROL
   ============================================================ */
.seg {
  display: inline-flex;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 0;
}
.seg button {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  border-radius: 4px;
  white-space: nowrap;
}
.seg button:hover { color: var(--text-2); }
.seg button.on {
  background: var(--bg-elev-1);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-card {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
}
.chart-grid line { stroke: var(--line); stroke-dasharray: 2 4; }
.chart-axis { fill: var(--text-3); font-size: 10px; font-family: var(--font-mono); }
.chart-bar { fill: var(--brand); transition: fill 120ms; cursor: pointer; }
.chart-bar:hover { fill: var(--brand-2); }
.chart-bar.muted { fill: var(--bg-active); }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--brand); opacity: 0.12; }
.chart-dot { fill: var(--bg-elev-1); stroke: var(--brand); stroke-width: 2; }

/* ============================================================
   COMMAND PALETTE
   ============================================================ */
.cmd-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: color-mix(in oklab, black 50%, transparent);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 14vh;
  animation: fadeIn 140ms ease-out;
}
.cmd-box {
  width: 100%; max-width: 540px;
  background: var(--bg-elev-1);
  border: 1px solid var(--line-hi);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 60px -20px #000000a0;
  overflow: hidden;
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.cmd-input-wrap input { background: none; border: 0; outline: none; flex: 1; font-size: 15px; color: var(--text); }
.cmd-input-wrap input::placeholder { color: var(--text-3); }
.cmd-list { max-height: 360px; overflow-y: auto; padding: 6px; }
.cmd-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 10px 10px 6px;
}
.cmd-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
}
.cmd-row.on, .cmd-row:hover { background: var(--bg-hover); }
.cmd-row .ic { width: 16px; height: 16px; color: var(--text-3); }
.cmd-row .label { color: var(--text); }
.cmd-row .hint { margin-left: auto; font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }

/* ============================================================
   CHAT (Ask AI)
   ============================================================ */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 56px - var(--pad-page) * 2); }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 14px; }
.chat-row { display: flex; gap: 10px; max-width: 82%; }
.chat-row.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.chat-row.user .chat-bubble {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.chat-avatar {
  width: 28px; height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  font-size: 13px;
}
html[data-aesthetic="terminal"] .chat-avatar { border-radius: 3px; }
.chat-row.user .chat-avatar { background: var(--brand); border-color: var(--brand); color: white; }

.chat-input-wrap {
  display: flex; gap: 8px;
  padding: 12px;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.chat-input { flex: 1; background: none; border: 0; outline: none; font-size: 13.5px; resize: none; max-height: 140px; min-height: 22px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 120ms, color 120ms, background 120ms;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  background: var(--bg);
}
.login-wrap .panel-left {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-wrap .panel-right {
  background:
    radial-gradient(800px 500px at 70% 30%, color-mix(in oklab, var(--brand) 18%, transparent), transparent 60%),
    radial-gradient(600px 400px at 30% 80%, color-mix(in oklab, var(--brand) 10%, transparent), transparent 60%),
    var(--bg-elev-1);
  border-left: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
}
.login-wrap .panel-right::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}
.login-card { width: 100%; max-width: 380px; }
.login-form > * + * { margin-top: 16px; }
.login-label {
  display: block; font-size: 11px; font-weight: 500;
  color: var(--text-3); margin-bottom: 6px;
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em;
}
.login-otp .inp { font-size: 24px; letter-spacing: 12px; text-align: center; padding: 14px; font-family: var(--font-mono); font-weight: 600; }

/* Status mosaic in login */
.demo-mosaic {
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  position: relative;
}
.demo-tile {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
}
.demo-tile.ok   { background: color-mix(in oklab, var(--ok) 35%, var(--bg-elev-2)); border-color: color-mix(in oklab, var(--ok) 50%, var(--line)); }
.demo-tile.warn { background: color-mix(in oklab, var(--warn) 35%, var(--bg-elev-2)); border-color: color-mix(in oklab, var(--warn) 50%, var(--line)); }
.demo-tile.err  { background: color-mix(in oklab, var(--err) 30%, var(--bg-elev-2)); border-color: color-mix(in oklab, var(--err) 50%, var(--line)); }

/* ============================================================
   TWEAKS PANEL OVERRIDES (use design tokens)
   ============================================================ */
.tweaks-panel { font-family: var(--font-sans); }

/* ============================================================
   HELPERS
   ============================================================ */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.between { display: flex; align-items: center; justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.no-scroll { overflow: hidden; }
.h-scroll { overflow-x: auto; }

/* Detail drawer */
.drawer {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in oklab, black 40%, transparent);
  backdrop-filter: blur(4px);
  animation: fadeIn 160ms ease;
}
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(560px, 96vw);
  background: var(--bg-elev-1);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px -20px #00000080;
  animation: drawerIn 240ms cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column;
}
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }

/* Heatmap */
.heat {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 6px 8px;
}
.heat-row { display: contents; }
.heat-label { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); align-self: center; white-space: nowrap; }
.heat-cells { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat-cell {
  height: 18px; border-radius: 3px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 100ms;
}
.heat-cell:hover { transform: scale(1.18); border-color: var(--brand); z-index: 2; }
.heat-cell.l1 { background: color-mix(in oklab, var(--brand) 18%, var(--bg-elev-2)); }
.heat-cell.l2 { background: color-mix(in oklab, var(--brand) 35%, var(--bg-elev-2)); }
.heat-cell.l3 { background: color-mix(in oklab, var(--brand) 55%, var(--bg-elev-2)); }
.heat-cell.l4 { background: color-mix(in oklab, var(--brand) 78%, var(--bg-elev-2)); }
.heat-cell.late { background: color-mix(in oklab, var(--warn) 50%, var(--bg-elev-2)); border-color: color-mix(in oklab, var(--warn) 60%, var(--line)); }
.heat-cell.absent { background: color-mix(in oklab, var(--err) 25%, var(--bg-elev-2)); border-color: color-mix(in oklab, var(--err) 40%, var(--line)); }
.heat-cell.weekend { background: transparent; border-style: dashed; opacity: 0.5; }

/* ============================================================
   MEDIA
   ============================================================ */
@media (max-width: 880px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-wrap .panel-right { display: none; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .side { width: 60px; }
  .side .nav-item .label, .side .brand-mark, .side .nav-section-label, .side .me-block .meta { display: none; }
}
