/* Agent Office — one stylesheet. Light + dark themes from the same custom properties (docs/design/SYSTEM.md).
   Theme: <html data-theme="light|dark"> forces one; without it, prefers-color-scheme decides. */

:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --border: #e7e7ec;
  --border-strong: #d6d6de;
  --border-hover: #c5c5cf;
  --text: #16171d;
  --text-2: #4a4c57;
  --muted: #696b7e;
  --faint: #a3a5b5;

  --accent: #4f46e5;          /* text, icons, focus — on surfaces */
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-ring: rgba(79, 70, 229, 0.22);
  --accent-solid: #4f46e5;    /* fills behind --on-accent text (primary button, badge, my bubble) */
  --accent-solid-hover: #4338ca;
  --on-accent: #ffffff;

  --green: #15803d;   --green-bg: #ecfdf3;  --green-bd: #c6f0d6;  --green-fill: #22c55e;  --green-ink: #14532d;
  --amber: #b45309;   --amber-bg: #fff8eb;  --amber-bd: #fbe2b5;  --amber-fill: #f59e0b;  --amber-ink: #78350f;
  --red: #c0262d;     --red-bg: #fef2f2;    --red-bd: #fbd0d0;    --red-fill: #ef4444;    --red-ink: #7f1d1d;
  --blue: #1d5fd6;    --blue-bg: #eff5ff;   --blue-bd: #cfe0fd;   --blue-ink: #1e3a8a;  --blue-fill: #3b82f6;
  --red-solid: #d92d20;  /* count badges behind white text (4.9:1) */
  --violet: #6d3fd6;  --violet-bg: #f5f0ff; --violet-bd: #e2d6fd;
  --gray: #545667;    --gray-bg: #f2f2f5;   --gray-bd: #e2e2e8;
  /* Categorical chart series (fixed order, validated for colour-vision deficiency as adjacent stack pairs). */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300; --series-other: #a3a5b5;

  --topbar-bg: rgba(247, 247, 249, 0.85);
  --scrim: rgba(20, 20, 40, 0.25);
  --highlight: #fffbe8;
  --auth-glow: #e9ebff;
  --pulse-ring: rgba(29, 95, 214, 0.45);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23696b7e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, 0.05);
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.04), 0 4px 14px rgba(20, 20, 40, 0.05);
  --shadow-lg: 0 10px 30px rgba(20, 20, 40, 0.12);
  --sidebar: 236px;

  /* type scale (px; 14 is body) and spacing scale (4px grid) — see docs/design/SYSTEM.md */
  --fs-micro: 11.5px;  --fs-small: 12.5px;  --fs-ui: 13.5px;  --fs-body: 14px;  --fs-title: 15px;  --fs-h2: 18px;  --fs-h1: 24px;
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;  --space-4: 16px;  --space-5: 20px;  --space-6: 24px;  --space-8: 32px;  --space-12: 48px;

  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 120ms;   /* hover, press, colour changes */
  --dur: 180ms;        /* menus, popovers, small layout moves */
  --dur-slow: 260ms;   /* drawers (mobile nav) */
}

/* Dark tokens, twice: forced (data-theme="dark") and system (no data-theme + dark preference). Keep in sync. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e12;
  --surface: #16171c;
  --surface-2: #1b1c22;
  --border: #26272f;
  --border-strong: #363742;
  --border-hover: #474856;
  --text: #ededf2;
  --text-2: #c0c2cf;
  --muted: #9092a3;
  --faint: #626475;
  --accent: #a5a7ff;
  --accent-hover: #c0c1ff;
  --accent-soft: #1f2040;
  --accent-ring: rgba(129, 131, 255, 0.38);
  --accent-solid: #5856e0;
  --accent-solid-hover: #6866ea;
  --on-accent: #ffffff;
  --green: #5fd294;   --green-bg: #102419;  --green-bd: #1d3b2a;  --green-fill: #22c55e;  --green-ink: #a3ebc3;
  --amber: #f2b357;   --amber-bg: #291d0b;  --amber-bd: #4a3413;  --amber-fill: #f59e0b;  --amber-ink: #fbd59c;
  --red: #ff8f8f;     --red-bg: #2c1316;    --red-bd: #4e2328;    --red-fill: #ef4444;    --red-ink: #ffc2c2;
  --blue: #7fb3ff;    --blue-bg: #0f1c33;   --blue-bd: #1f3557;   --blue-ink: #bcd6ff;  --blue-fill: #3b82f6;
  --red-solid: #d92d20;
  --violet: #bda8ff;  --violet-bg: #1e1736; --violet-bd: #352a5c;
  --gray: #a9abba;    --gray-bg: #1f2027;   --gray-bd: #2f303a;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-other: #626475;
  --topbar-bg: rgba(13, 14, 18, 0.8);
  --scrim: rgba(0, 0, 0, 0.55);
  --highlight: #2a2612;
  --auth-glow: #1c1c3d;
  --pulse-ring: rgba(127, 179, 255, 0.45);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239092a3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0d0e12;
    --surface: #16171c;
    --surface-2: #1b1c22;
    --border: #26272f;
    --border-strong: #363742;
    --border-hover: #474856;
    --text: #ededf2;
    --text-2: #c0c2cf;
    --muted: #9092a3;
    --faint: #626475;
    --accent: #a5a7ff;
    --accent-hover: #c0c1ff;
    --accent-soft: #1f2040;
    --accent-ring: rgba(129, 131, 255, 0.38);
    --accent-solid: #5856e0;
    --accent-solid-hover: #6866ea;
    --on-accent: #ffffff;
    --green: #5fd294;   --green-bg: #102419;  --green-bd: #1d3b2a;  --green-fill: #22c55e;  --green-ink: #a3ebc3;
    --amber: #f2b357;   --amber-bg: #291d0b;  --amber-bd: #4a3413;  --amber-fill: #f59e0b;  --amber-ink: #fbd59c;
    --red: #ff8f8f;     --red-bg: #2c1316;    --red-bd: #4e2328;    --red-fill: #ef4444;    --red-ink: #ffc2c2;
    --blue: #7fb3ff;    --blue-bg: #0f1c33;   --blue-bd: #1f3557;   --blue-ink: #bcd6ff;  --blue-fill: #3b82f6;
    --red-solid: #d92d20;
    --violet: #bda8ff;  --violet-bg: #1e1736; --violet-bd: #352a5c;
    --gray: #a9abba;    --gray-bg: #1f2027;   --gray-bd: #2f303a;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-other: #626475;
    --topbar-bg: rgba(13, 14, 18, 0.8);
    --scrim: rgba(0, 0, 0, 0.55);
    --highlight: #2a2612;
    --auth-glow: #1c1c3d;
    --pulse-ring: rgba(127, 179, 255, 0.45);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239092a3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.55);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
a { color: inherit; text-decoration: none; }
code, pre, kbd { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--gray-bg); border: 1px solid var(--gray-bd); border-radius: 5px; padding: 0.05em 0.35em; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25em 0; }
::selection { background: var(--accent-ring); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* Theme flips must not animate every colour at once (app.js adds this class for one frame). */
.theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--accent-solid); color: var(--on-accent); font-weight: 600; box-shadow: var(--shadow-lg); }
.skip-link:focus { top: 10px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-red { color: var(--red); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52ch; }
.link { color: var(--accent); font-weight: 500; }
.link:hover { color: var(--accent-hover); text-decoration: underline; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 13px; height: 13px; }
.link-external { display: inline-flex; align-items: center; gap: 4px; }
.num, .tabular, time { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
[id] { scroll-margin-top: 72px; }

/* ---------- app shell ---------- */

.app { display: flex; min-height: 100vh; background: linear-gradient(90deg, var(--surface) 0 calc(var(--sidebar) - 1px), var(--border) calc(var(--sidebar) - 1px) var(--sidebar), var(--bg) var(--sidebar)); }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  width: var(--sidebar); flex: none;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  z-index: 30;
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.office-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15), 0 1px 2px rgba(67,56,202,0.3);
}
.office-name { font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px; border-radius: 7px;
  color: var(--text-2); font: inherit; font-weight: 500;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-item .icon { color: var(--faint); }
.nav-item:hover { background: var(--gray-bg); color: var(--text); }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active .icon { color: var(--accent); }
.nav-item .nav-external { margin-left: auto; width: 13px; height: 13px; color: var(--faint); }
.nav-progress { margin-left: auto; font-size: var(--fs-micro); color: var(--muted); font-variant-numeric: tabular-nums; }
.badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--accent-solid); color: var(--on-accent);
  font-size: 11.5px; font-weight: 650; display: grid; place-items: center;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.nav-form { margin: 0; }
.product-mark { padding: 12px 10px 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); opacity: 0.8; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; }
.topbar-office { color: var(--muted); font-weight: 500; white-space: nowrap; }
.topbar-sep { color: var(--faint); }
.topbar-crumb { color: var(--muted); font-weight: 500; white-space: nowrap; }
.topbar-crumb:hover { color: var(--text); }
.topbar-page { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-search { position: relative; display: flex; align-items: center; margin-left: auto; }
.topbar-search + .topbar-actions { margin-left: 6px; }
.topbar-search .icon { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.topbar-search input { width: 220px; height: 32px; padding: 0 10px 0 30px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
mark, .hit { background: var(--highlight); color: inherit; font-weight: 600; border-radius: 2px; padding: 0 1px; }
.topbar-user { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 10px; border-radius: 22px; }
.topbar-user:hover { background: var(--gray-bg); }
.topbar-user-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.topbar-user-name { font-weight: 600; font-size: 13px; }
.topbar-user-role { font-size: 11.5px; color: var(--muted); }
.nav-burger, .nav-scrim { display: none; }

.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 28px 64px; }
/* Every page shares one column width so the left edge never jumps between pages; `wide` is kept for API compat. */
.content-wide { max-width: 1240px; }

/* ---------- page header ---------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; font-weight: 680; letter-spacing: -0.02em; }
.subtitle { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.breadcrumbs { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs span:last-child { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons & forms ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 550; font-size: 13.5px; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast) var(--ease-out);
  user-select: none; list-style: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }
.btn::-webkit-details-marker { display: none; }
.btn-primary { background: var(--accent-solid); color: var(--on-accent); box-shadow: 0 1px 2px rgba(67,56,202,0.25), inset 0 1px 0 rgba(255,255,255,0.12); }
.btn-primary:hover { background: var(--accent-solid-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-hover); }
.btn-danger { background: var(--surface); color: var(--red); border-color: var(--red-bd); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-bg); color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 22px; padding: 0 6px; font-size: 11.5px; }
.btn-danger-ghost { background: transparent; color: var(--muted); }
.btn-danger-ghost:hover { background: var(--red-bg); color: var(--red); }

/* icon button + dropdown menu (a <details>; works without JS) */
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); cursor: pointer; list-style: none; transition: background var(--dur-fast), color var(--dur-fast); }
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover, .menu[open] > .icon-btn { background: var(--gray-bg); color: var(--text); }
.when-light, .when-dark { display: none; }
[data-theme-pref="light"] .when-system, [data-theme-pref="dark"] .when-system { display: none; }
[data-theme-pref="light"] .when-light, [data-theme-pref="dark"] .when-dark { display: block; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 168px; margin: 0;
  padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  transform-origin: top right; animation: menu-in var(--dur) var(--ease-out);
}
.menu-label { padding: 6px 8px 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text-2); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--gray-bg); color: var(--text); outline: none; }
.menu-item .menu-check { margin-left: auto; color: var(--accent); visibility: hidden; }
.menu-item[aria-pressed="true"] { color: var(--text); font-weight: 550; }
.menu-item[aria-pressed="true"] .menu-check { visibility: visible; }
@keyframes menu-in { from { opacity: 0; transform: scale(0.97) translateY(-2px); } to { opacity: 1; transform: none; } }

/* segmented control */
.segmented { display: flex; gap: 2px; padding: 3px; margin: 0; background: var(--gray-bg); border: 1px solid var(--gray-bd); border-radius: 9px; }
.segmented-item {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.segmented-item .icon { width: 14px; height: 14px; }
.segmented-item:hover { color: var(--text); }
.segmented-item[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.card-foot-note { margin: 10px 0 0; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline > span { white-space: nowrap; }
.field-short { max-width: 240px; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 10px; min-height: 34px; width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 10px center; background-size: 12px; cursor: pointer; }
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: var(--border-hover); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent-solid); }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* Name field with suggested names: "‹" and "Another name" sit beside the input (shown by app.js). */
.field > .field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.name-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.name-pick input { flex: 1 1 160px; min-width: 0; }
.name-steps { display: flex; flex: none; gap: 4px; }
.name-pick .name-step { height: 34px; }
.name-pick .name-step[data-name-step="-1"] { width: 30px; padding: 0; font-size: 17px; }
.name-pick input.is-new { animation: name-in 0.32s var(--ease-out); }
@keyframes name-in { 0% { background: var(--accent-soft); transform: translateY(2px); } 100% { transform: none; } }
.form-actions { display: flex; gap: 8px; align-items: center; }
.form-actions-center { justify-content: center; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.fieldset legend { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 0 4px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 150px; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-narrow { max-width: 720px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 14.5px; font-weight: 650; }
.card-head-pad { padding: 16px 20px 0; }
.card-empty { color: var(--muted); margin: 4px 0; }
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; font-weight: 650; }
.count { background: var(--gray-bg); border: 1px solid var(--gray-bd); color: var(--text-2); border-radius: 10px; font-size: 12px; font-weight: 600; padding: 0 8px; }

/* ---------- pills, tags, avatars ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-live .dot { animation: pulse 1.6s ease-in-out infinite; }
.pill-green { color: var(--green); background: var(--green-bg); border-color: var(--green-bd); }
.pill-amber { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-bd); }
.pill-red { color: var(--red); background: var(--red-bg); border-color: var(--red-bd); }
.pill-blue { color: var(--blue); background: var(--blue-bg); border-color: var(--blue-bd); }
.pill-violet { color: var(--violet); background: var(--violet-bg); border-color: var(--violet-bd); }
.pill-gray { color: var(--gray); background: var(--gray-bg); border-color: var(--gray-bd); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 550; color: var(--text-2); background: var(--gray-bg); margin-right: 4px; }
.tag-blue { color: var(--blue); background: var(--blue-bg); }
.tag-violet { color: var(--violet); background: var(--violet-bg); }
.tag-red { color: var(--red); background: var(--red-bg); }
.tag-accent { color: var(--accent); background: var(--accent-soft); }
a.tag:hover { filter: brightness(0.97); text-decoration: underline; text-underline-offset: 2px; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  border-radius: 9px; font-weight: 650; letter-spacing: 0.01em;
  color: #fff; user-select: none;
}
.avatar-human { border-radius: 50%; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; border-radius: 7px; }
.avatar-human.avatar-sm { border-radius: 50%; }
.avatar-md { width: 34px; height: 34px; font-size: 12.5px; }
.avatar-lg { width: 42px; height: 42px; font-size: 15px; border-radius: 11px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; border-radius: 16px; }
.avatar-human.avatar-lg, .avatar-human.avatar-xl { border-radius: 50%; }
.av-0 { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.av-1 { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.av-2 { background: linear-gradient(135deg, #10b981, #047857); }
.av-3 { background: linear-gradient(135deg, #f59e0b, #c2410c); }
.av-4 { background: linear-gradient(135deg, #ec4899, #be185d); }
.av-5 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.av-6 { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.av-7 { background: linear-gradient(135deg, #64748b, #334155); }
.chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 550; vertical-align: middle; }
a.chip:hover { color: var(--accent); }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stats-5 { grid-template-columns: 1.4fr repeat(4, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); min-width: 0; }
.stat-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 680; letter-spacing: -0.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 15px; font-weight: 600; letter-spacing: 0; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-of { font-size: 15px; color: var(--muted); font-weight: 600; }
.stat-hint { font-size: 12px; color: var(--muted); }

/* ---------- floor ---------- */

.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }
.agent-card {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.agent-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.agent-card.is-muted { background: var(--surface-2); }
.agent-card.is-muted .avatar { filter: grayscale(0.7); opacity: 0.75; }
.agent-card-head { display: flex; align-items: center; gap: 12px; }
.agent-card-title { flex: 1; min-width: 0; }
.agent-name { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-role { color: var(--muted); font-size: 13px; }
.agent-card-body { min-height: 22px; }
.activity { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.activity-live { color: var(--blue); font-weight: 550; }
.activity-paused { color: var(--amber); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 0 var(--pulse-ring); animation: ring 1.6s ease-out infinite; }
.agent-card-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); margin-top: auto; }
.agent-card-meta { display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; }
.agent-card-flag, .agent-card .activity-live { position: relative; z-index: 1; }
.activity-live:hover { text-decoration: underline; text-underline-offset: 3px; }
.activity-since { font-weight: 450; color: var(--muted); }
.agent-card.is-working { border-color: color-mix(in srgb, var(--blue-fill) 30%, var(--border)); }

/* Presence: the floor's status language on an avatar (List, desk), matching the 2D/3D seats.
   Working = blue ring that breathes, suspended = dashed amber ring, idle = no ring; red count = waiting on you,
   accent badge = new mail. */
.presence { position: relative; display: inline-flex; flex: none; }
.presence::before { content: ""; position: absolute; inset: -4px; border-radius: 14px; border: 2px solid transparent; pointer-events: none; }
.presence-xl::before { inset: -5px; border-radius: 20px; }
.presence.is-working::before { border-color: var(--blue-fill); animation: presence 2.4s var(--ease-out) infinite; }
.presence.is-suspended::before { border: 2px dashed var(--amber-fill); }
.presence.is-proposed::before { border: 2px dashed var(--border-strong); }
.presence.is-suspended .avatar, .presence.is-proposed .avatar { filter: grayscale(0.7); opacity: 0.75; }
.presence-badge {
  position: absolute; right: -8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  font-size: 10.5px; font-weight: 750; line-height: 1; color: var(--on-accent);
  box-shadow: 0 0 0 2px var(--surface); font-variant-numeric: tabular-nums;
}
.presence-needs { top: -8px; background: var(--red-solid); }
.presence-mail { bottom: -8px; background: var(--accent-solid); }
.presence-mail svg { width: 10px; height: 10px; }
.presence-xl .presence-badge { right: -9px; min-width: 22px; height: 22px; border-radius: 11px; font-size: 12px; }
.presence-xl .presence-needs { top: -9px; }
.presence-xl .presence-mail { bottom: -9px; }
@keyframes presence { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue-fill) 35%, transparent); } 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue-fill) 0%, transparent); } }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 var(--pulse-ring); } 80%, 100% { box-shadow: 0 0 0 7px transparent; } }

.activity-list { list-style: none; margin: 0 -8px; padding: 0; }
.activity-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.activity-row:hover { background: var(--surface-2); }
.activity-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-time { width: 82px; text-align: right; color: var(--muted); font-size: 12.5px; flex: none; }

/* ---------- budget bar ---------- */

.budget { display: flex; flex-direction: column; gap: 6px; }
.budget-label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 550; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--gray-bg); overflow: hidden; }
.budget:not(.budget-compact) .bar { height: 8px; border-radius: 4px; }
.fill { display: block; height: 100%; border-radius: inherit; min-width: 0; transition: width 0.3s; }
.fill-green { background: var(--green-fill); }
.fill-amber { background: var(--amber-fill); }
.fill-red { background: var(--red-fill); }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

/* ---------- desk ---------- */

.desk-head { display: flex; align-items: center; gap: 20px; margin-bottom: 22px; }
.desk-head-text { flex: 1; min-width: 0; }
.desk-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.desk-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.desk-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.desk-stats { margin-bottom: 16px; }
.desk-stats .stat-value { font-size: 22px; }
.bar-stat { margin: 8px 0 6px; }
.desk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 10px; font-size: 13px; }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.desk-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.desk-main, .desk-side { min-width: 0; }
.caps { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.caps li { position: relative; padding-left: 24px; font-size: 13.5px; }
.caps li::before {
  content: "✓"; position: absolute; left: 0; top: 1px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--green-bg); color: var(--green); font-size: 10px; font-weight: 800;
  display: grid; place-items: center;
}
.caps-small li { font-size: 12.5px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-compact { font-size: 12.5px; gap: 4px 12px; margin: 8px 0; }
.kv-compact dt::first-letter { text-transform: uppercase; }

.popover { position: relative; }
.popover > summary { list-style: none; }
.popover-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
  width: 320px; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.disclosure { margin-top: 12px; }
.card > .disclosure:first-child { margin-top: 0; }
.kv + p, .kv + .btn { margin-top: 12px; }
p + .btn { margin-top: 4px; }
.disclosure > summary { cursor: pointer; color: var(--accent); font-weight: 550; font-size: 13px; padding: 4px 0; }
.disclosure[open] > summary { margin-bottom: 10px; }

/* chat styles live in chat.css (linked on chat pages only) */

/* ---------- prose (charters, mail) ---------- */

.prose { font-size: 14px; line-height: 1.65; color: var(--text-2); }
.prose h3, .prose h4, .prose h5, .prose h6 { color: var(--text); font-size: 14px; font-weight: 650; margin: 1.3em 0 0.4em; }
.prose h3:first-child, .prose h4:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 0.9em; }
.prose li { margin: 0.25em 0; }
.prose strong { color: var(--text); font-weight: 620; }
.prose a { color: var(--accent); text-decoration: underline; }
.prose blockquote { margin: 0 0 1em; padding: 2px 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.prose pre, .pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; line-height: 1.55; margin: 0; }
.prose pre code { background: none; border: 0; padding: 0; }
.pre-code { white-space: pre; }
.lead { font-size: 15px; color: var(--text); }
.subtitle .chip { color: var(--text-2); }
.desk-main > :last-child, .desk-side > :last-child { margin-bottom: 0; }

/* ---------- tables & lists ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.card:not(.card-flush) .table th:first-child, .card:not(.card-flush) .table td:first-child { padding-left: 0; }
.card:not(.card-flush) .table th:last-child, .card:not(.card-flush) .table td:last-child { padding-right: 0; }
.card:not(.card-flush) .table th { background: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.stack-label { display: none; }
.row-link:hover td { background: var(--surface-2); }
.row-link td > a:not(.cell-agent) { display: block; }
.cell-agent { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.table-ledger td { font-size: 13px; vertical-align: top; }
.table-ledger tr:target td { background: var(--highlight); }
.action { background: none; border: 0; padding: 0; color: var(--text); font-weight: 550; }
.action-red { color: var(--red); }
.data summary { cursor: pointer; list-style: none; }
.data summary::-webkit-details-marker { display: none; }
.data summary code { background: none; border: 0; padding: 0; color: var(--muted); }
.data[open] .pre { margin: 8px 0 6px; max-width: 480px; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.list li:last-child .list-row { border-bottom: 0; }
.card:not(.card-flush) .list-row { padding-left: 0; padding-right: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main > code { align-self: flex-start; max-width: 100%; }
.list-line { font-size: 13px; }
.list-subject { color: var(--text-2); }
.list-subject.is-unread { color: var(--text); font-weight: 620; }
.list-time { width: 80px; text-align: right; font-size: 12.5px; color: var(--muted); flex: none; }

.pager { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- empty states & flashes ---------- */

.empty { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; }
.empty-page { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 24px; }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent); }
.empty-icon .icon { width: 22px; height: 22px; }
.empty-icon-green { background: var(--green-bg); color: var(--green); box-shadow: inset 0 0 0 1px var(--green-bd); }
.empty-icon-red { background: var(--red-bg); color: var(--red); box-shadow: inset 0 0 0 1px var(--red-bd); }
.empty-icon-gray { background: var(--gray-bg); color: var(--gray); box-shadow: inset 0 0 0 1px var(--gray-bd); }
.empty h3 { font-size: 16px; font-weight: 650; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 52ch; margin: 0 auto 18px; }
.agent-grid + .empty, .stats + .empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 12px; }

.flash { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.flash a { font-weight: 600; text-decoration: underline; }
.flash-ok { background: var(--green-bg); border-color: var(--green-bd); color: var(--green-ink); }
.flash-error { background: var(--red-bg); border-color: var(--red-bd); color: var(--red-ink); }
.flash-info { background: var(--blue-bg); border-color: var(--blue-bd); color: var(--blue-ink); }

/* ---------- runs ---------- */

.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.tl-item { position: relative; display: flex; gap: 14px; padding: 7px 0; }
.tl-dot { position: relative; z-index: 1; width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex: none; background: var(--surface); border: 2px solid var(--faint); }
.tl-blue .tl-dot { border-color: var(--blue); }
.tl-green .tl-dot { border-color: var(--green); background: var(--green-fill); }
.tl-amber .tl-dot { border-color: var(--amber); }
.tl-red .tl-dot { border-color: var(--red); background: var(--red-fill); }
.tl-body { flex: 1; min-width: 0; }
.tl-denied .tl-body { background: var(--red-bg); border: 1px solid var(--red-bd); border-radius: var(--radius-sm); padding: 8px 12px; margin: -2px 0; }
.tl-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.tl-type { font-weight: 600; }
.tl-denied .tl-type { color: var(--red); }
.tl-tool { font-size: 12px; }
.tl-time { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.tl-summary { font-size: 13px; color: var(--text-2); margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-denied .tl-summary { color: var(--red-ink); }
.tl-shot { display: block; margin-top: 6px; max-width: 320px; height: auto; border: 1px solid var(--border, #e5e5e5); border-radius: 6px; }
.tl-hidden { color: var(--faint); font-style: italic; }

/* ---------- needs you ---------- */

.requests { display: flex; flex-direction: column; gap: 12px; }
.request { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.request-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; font-size: 13px; }
.request-head .pill { margin-left: auto; }
.request-head .pill + .pill { margin-left: 0; }
.request-removes { border-color: var(--red-bd); box-shadow: 0 0 0 1px var(--red-bd), var(--shadow-sm); }
.removal-warning { margin: 8px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--red-bg); color: var(--red-ink); font-size: 13.5px; font-weight: 600; }
.request-title { font-size: 15px; font-weight: 640; margin: 10px 0 6px; }
.request-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.request-actions input { flex: 1; }
.request-actions .small { flex: 1; }
.diff { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.diff li { padding: 5px 10px 5px 28px; border-radius: 6px; position: relative; }
.diff li::before { position: absolute; left: 10px; font-weight: 700; font-family: var(--mono); }
.diff-plus { background: var(--green-bg); color: var(--green-ink); }
.diff-plus::before { content: "+"; color: var(--green); }
.diff-minus { background: var(--red-bg); color: var(--red-ink); }
.diff-minus::before { content: "−"; color: var(--red); }

/* ---------- hire ---------- */

.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.steps li { display: flex; align-items: center; gap: 8px; padding-right: 18px; position: relative; }
.steps li:not(:last-child)::after { content: ""; width: 24px; height: 1px; background: var(--border-strong); margin-left: 6px; }
.steps span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 650; background: var(--gray-bg); border: 1px solid var(--gray-bd); }
.steps .is-active { color: var(--text); font-weight: 600; }
.steps .is-active span { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent); }
.steps .is-done span { background: var(--green-bg); border-color: var(--green-bd); color: var(--green); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.role-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px;
  box-shadow: var(--shadow-sm); transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.role-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); transform: translateY(-1px); }
.role-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px; letter-spacing: 0.02em; }
.role-title { font-weight: 650; font-size: 15px; }
.role-desc { color: var(--muted); font-size: 13px; flex: 1; }
.role-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.role-foot > .link { white-space: nowrap; flex-shrink: 0; }
.next-steps { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text-2); }
.success { text-align: center; padding: 36px 28px; max-width: 680px; margin: 0 auto; }
.success h1 { font-size: 22px; margin-bottom: 8px; }
.success .diff { text-align: left; margin: 16px 0 20px; }
.success-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--green-bg); color: var(--green); font-size: 24px; font-weight: 800; border: 1px solid var(--green-bd); }

/* ---------- people & account ---------- */

.grants { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.grants > li { display: flex; align-items: center; gap: 6px; }
.grant summary { cursor: pointer; font-weight: 550; font-size: 13px; }
.grant ul { margin: 6px 0 4px; padding-left: 1.1em; }
.grant-block + .grant-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.copyable { min-width: 0; max-width: 100%; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 8px 8px 12px; margin: 10px 0 14px; }
.copyable code { flex: 1; min-width: 0; background: none; border: 0; padding: 0; font-size: 12.5px; overflow-x: auto; white-space: nowrap; }
.copyable-multi code { white-space: pre-wrap; overflow-wrap: anywhere; }
.token-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.token-form .field { flex: 1; min-width: 260px; }
.note { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------- audit & settings ---------- */

.chain { display: flex; align-items: center; gap: 14px; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; border: 1px solid; }
.chain-ok { background: var(--green-bg); border-color: var(--green-bd); }
.chain-bad { background: var(--red-bg); border-color: var(--red-bd); }
.chain-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.chain-ok .chain-icon { background: var(--surface); color: var(--green); box-shadow: inset 0 0 0 1px var(--green-bd); }
.chain-bad .chain-icon { background: var(--surface); color: var(--red); box-shadow: inset 0 0 0 1px var(--red-bd); }
.chain-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-2); }
.chain-text strong { color: var(--text); font-size: 14px; }
.chain-anchor { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; text-align: right; }

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; gap: 12px; align-items: flex-start; }
.check-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; color: #fff; margin-top: 1px; }
.check-ok { background: var(--green-bg); color: var(--green); box-shadow: inset 0 0 0 1px var(--green-bd); }
.check-bad { background: var(--red-bg); color: var(--red); box-shadow: inset 0 0 0 1px var(--red-bd); }
.check-warn { background: var(--amber-bg); color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber-bd); }
.check-label { font-weight: 600; }
.check .pill { vertical-align: middle; }
.problems { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }

/* ---------- mail thread ---------- */

.thread { padding: 0; }
.thread-msg { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.thread-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.thread-reply { padding: 16px 20px; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- auth pages ---------- */

.auth-body { background: radial-gradient(1200px 600px at 30% -10%, var(--auth-glow) 0%, var(--bg) 60%); }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: 48px; max-width: 1120px; margin: 0 auto; padding: 40px 32px; }
.auth-main { display: flex; flex-direction: column; align-items: center; }
.auth-hero { max-width: 460px; justify-self: end; }
.auth-product { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.product-logo { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-solid); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.product-logo svg { width: 18px; height: 18px; }
.auth-pitch { font-size: 32px; line-height: 1.15; font-weight: 720; letter-spacing: -0.025em; margin: 22px 0 12px; color: var(--text); text-wrap: balance; }
.auth-lede { color: var(--text-2); font-size: 15px; line-height: 1.6; margin: 0 0 28px; max-width: 46ch; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 30px 30px 26px; }
.auth-card h1 { font-size: 21px; font-weight: 680; margin-bottom: 4px; }
.auth-card > p.muted { margin-bottom: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 26px; }
.auth-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }
.auth-hint a { color: var(--accent); }
.auth-foot { margin-top: 22px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.auth:has(.auth-hero) .auth-foot { display: none; }

/* The hero illustration: an office drawn with theme tokens (the floor's status language). */
.hero-art { display: block; width: 100%; height: auto; filter: drop-shadow(0 12px 28px color-mix(in srgb, var(--text) 8%, transparent)); }
.ha-floor { fill: var(--surface); stroke: var(--border); }
.ha-zone { fill: color-mix(in srgb, var(--accent) 6%, var(--surface)); stroke: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.ha-zone-2 { fill: color-mix(in srgb, var(--green-fill) 6%, var(--surface)); stroke: color-mix(in srgb, var(--green-fill) 24%, var(--surface)); }
.ha-zone-label { font: 700 9.5px var(--font); letter-spacing: 0.1em; fill: var(--accent); }
.ha-zone-label-2 { fill: var(--green); }
.ha-desk { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.2; }
.ha-screen { fill: color-mix(in srgb, var(--text) 40%, var(--surface)); }
.is-working .ha-screen { fill: var(--accent-solid); }
.ha-ring { fill: none; stroke: var(--border-strong); stroke-width: 1.6; }
.is-working .ha-ring { stroke: var(--blue-fill); stroke-width: 2.4; animation: ha-breathe 2.4s var(--ease-out) infinite; transform-box: fill-box; transform-origin: center; }
.ha-initials { font: 700 10.5px var(--font); fill: #fff; }
.av-fill-0 { fill: #4f46e5; } .av-fill-2 { fill: #059669; } .av-fill-3 { fill: #ea580c; } .av-fill-5 { fill: #7c3aed; }
.ha-trail { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 4 5; opacity: 0.45; }
.ha-mail rect { fill: var(--surface); stroke: var(--accent); stroke-width: 1.6; }
.ha-mail path { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linejoin: round; }
.ha-mail { animation: ha-float 3.2s ease-in-out infinite; }
.ha-badge circle { fill: var(--red-solid); stroke: var(--surface); stroke-width: 2; }
.ha-badge text { font: 800 10px var(--font); fill: #fff; }
@keyframes ha-breathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: 0.6; } }
@keyframes ha-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; gap: 24px; padding: 28px 16px; align-content: start; }
  .auth-hero { justify-self: center; text-align: left; width: 100%; max-width: 400px; }
  .auth-pitch { font-size: 24px; margin: 16px 0 8px; }
  .auth-lede { font-size: 14px; margin-bottom: 0; }
  .hero-art { display: none; }
  .auth-card { padding: 24px 20px 22px; }
}

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .desk-grid { grid-template-columns: 1fr; }
  .stats-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .app { background: var(--bg); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease-out); box-shadow: var(--shadow-lg); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 25; }
  .nav-burger { display: flex; flex-direction: column; gap: 4px; padding: 8px; margin-left: -8px; cursor: pointer; }
  .nav-burger span { width: 18px; height: 2px; background: var(--text-2); border-radius: 1px; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .form-row { grid-template-columns: 1fr; }
  .topbar-user-text { display: none; }
  .topbar-search input { width: 130px; }
  .table th:nth-child(n+5), .table td:nth-child(n+5) { display: none; }
  /* .table-stack: on phones each row becomes a small block (first cell + .stack-end on one line,
     .stack-full cells on their own line, .stack-meta muted, .stack-push pushed right). */
  .table.table-stack { min-width: 0 !important; }
  .table-stack thead { display: none; }
  .table-stack tbody { display: block; }
  .table-stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table.table-stack td:nth-child(n) { display: block; padding: 0; border: 0; min-width: 0; }
  .table.table-stack td:empty { display: none; }
  .table-stack td:first-child { order: -2; }
  .table-stack td.stack-end { order: -1; margin-left: auto; }
  .table-stack td.stack-full { flex-basis: 100%; max-width: 100%; }
  .table-stack .copyable { margin: 4px 0; }
  .table-stack td:first-child.stack-full { flex-basis: calc(100% - 120px); flex-grow: 1; }
  .table-stack td.stack-meta { font-size: 12.5px; color: var(--muted); }
  .table-stack td.stack-full.num { text-align: left; }
  .table-stack td.stack-push { margin-left: auto; }
  .table.table-stack td.stack-hide, .table.table-stack td:nth-child(n+5):not(.stack-push):not(.stack-end) { display: none; }
  .table-stack .stack-label { display: inline; }
  .table-stack tr.row-link:hover { background: var(--surface-2); }
  .table-stack tr.row-link:hover td { background: none; }
  .request-actions { flex-wrap: wrap; }
  .request-actions .small { flex-basis: 100%; }
  .request-actions .small + .btn, .request-actions .small + form { margin-left: auto; }
  /* list rows with a pill and a time: the pill drops under the time so the subject gets the width */
  .list-row:has(> .list-time) { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 4px; }
  .list-row:has(> .list-time) > :first-child { grid-row: 1 / span 2; align-self: center; }
  .list-row:has(> .list-time) > .list-main { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .list-row:has(> .list-time) > .list-time { grid-column: 3; grid-row: 1; width: auto; }
  .list-row:has(> .list-time) > .pill { grid-column: 3; grid-row: 2; justify-self: end; }
  .list-mail .list-subject { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  /* Other tables never get clipped: their card scrolls sideways instead. */
  .card-flush, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-flush > .table, .table-scroll > .table { min-width: 520px; }
  .truncate { max-width: 26ch; }
  .topbar-office, .topbar-office + .topbar-sep { display: none; }
  .nav-item { padding: 10px 12px; }
  .nav-toggle:focus-visible ~ .main .nav-burger { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
  .filters { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .filters .field-inline { display: grid; grid-template-columns: 64px 1fr; }
  .filters select, .filters input { width: 100%; min-width: 0; }
  .filters > .btn { justify-self: start; }
  .token-form .field { min-width: 0; }
  .token-form { flex-direction: column; align-items: stretch; }
  .token-form .field-inline { flex-direction: column; align-items: stretch; }
  .desk-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 16px; align-items: start; }
  .desk-head .page-actions { grid-column: 1 / -1; }
  .desk-head .page-actions > .btn-primary { flex: 1; justify-content: center; }
  .desk-head h1 { font-size: 22px; }
  .desk-meta { gap: 6px 12px; }
  .chain { flex-wrap: wrap; }
  .chain-anchor { align-items: flex-start; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.card-pad-x { padding: 0 20px 12px; margin: 0; }

/* ---------- floor card links + chat entry points (chat lane) ---------- */
.agent-card { position: relative; }
.agent-card-link { color: inherit; display: block; }
.agent-card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.agent-card-link:focus-visible { outline: none; }
.agent-card:has(.agent-card-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.agent-card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-card-chat { position: relative; z-index: 1; gap: 5px; }
.icon-sm { width: 15px; height: 15px; flex: none; }
.btn .icon-sm { margin-left: -2px; }
.desk-chats .card-head { align-items: center; }
.desk-chats .btn { gap: 6px; }
.desk-chats-foot { padding-top: 10px; }
.page-actions .btn { gap: 6px; }
.content-fill { max-width: none; padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-fill .main { height: 100vh; height: 100dvh; min-height: 0; }
body.page-fill { height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
.page-fill .app { height: 100vh; height: 100dvh; min-height: 0; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0 6px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.release-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--border); border-left: 3px solid var(--accent-solid); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; }
.release-banner form { margin-left: auto; }
.mini-head { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
.auto-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.auto-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.auto-list code { overflow-wrap: anywhere; }
.feedback-rating { margin-bottom: 4px; }
.feedback-rating input { margin-right: 4px; }
.feedback-notes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }

/* Evals (desk card, eval run page, policy PR card) */
.eval-pr + .eval-pr { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.eval-pr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.eval-scores td, .eval-scores th { padding: 6px 8px; }
.eval-delta { margin: 8px 0; }
.eval-pr-case { margin: 10px 0; }
.eval-checks { gap: 8px; margin: 8px 0; }
.eval-case { margin: 8px 0; }
.eval-case > summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Graduated autonomy (routes/autonomy.ts) */
.text-amber { color: var(--amber); }
textarea.mono { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 12px; }
.autonomy-list .list-main code { margin-left: 2px; }
.autonomy-list .list-row { align-items: flex-start; }
