/* Droop console mock — the AFCA / TREAD console language (inset sidebar,
   raised nav pill, signature cards, dotted canvas, glossy tints, studio rail,
   library tables) recoloured with the Droop palette. Light by default; dark
   is a choice in the user menu. Client identity comes from client.js, so a
   future client swaps the palette and name without touching layouts. */

/* ── Tokens: light ───────────────────────────────────────────── */
:root {
  --radius: 0.65rem;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --radius-2xl: calc(var(--radius) * 1.8);
  --nav-width: 256px;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;

  /* Droop: canvas black, paper white, pink and teal. */
  --brand-ink: #070506;
  --brand-paper: #f8f8f4;
  --brand-pink: #ff83b4;
  --brand-teal: #00c5ac;

  --background: #f6f5f2;
  --foreground: #141012;
  --card: #ffffff;
  --popover: #ffffff;
  /* Monotone and muted: ink is the action colour. Brand pink and teal stay
     in the logo only. */
  --primary: #1b1718;
  --primary-foreground: #f8f8f4;
  --primary-strong: #1b1718;
  --secondary: #efede9;
  --muted: #efede9;
  --muted-foreground: #74696c;
  --accent: #eae7e2;
  --accent-foreground: #3a3234;
  --teal-strong: #3a3234;

  --destructive: #b42318;
  --success: #0f8a5f;
  --warning: #b86e00;
  --info: #1f4b99;

  --border: #e3e0db;
  --input: #d8d4ce;
  --ring: #6b6163;

  --sidebar: #eeece8;

  --motion-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --motion-emphasized: cubic-bezier(0.22, 1, 0.36, 1);
  --elevation-1: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 1px rgb(0 0 0 / 0.03);
  --elevation-2: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 16px -4px rgb(0 0 0 / 0.08);
  --elevation-3: 0 2px 4px rgb(0 0 0 / 0.05), 0 14px 32px -8px rgb(0 0 0 / 0.14), 0 2px 6px -2px rgb(0 0 0 / 0.06);
  --ring-hairline: inset 0 0 0 1px color-mix(in oklch, var(--border) 75%, transparent);
  --inset-top: inset 0 1px 0 rgb(255 255 255 / 0.6);
  color-scheme: light;
}

/* ── Tokens: dark ────────────────────────────────────────────── */
.dark {
  --background: #0b090a;
  --foreground: #f6f2ec;
  --card: #151213;
  --popover: #191617;
  --primary: #f1ece6;
  --primary-foreground: #121011;
  --primary-strong: #f1ece6;
  --ring: #a99fa1;
  --secondary: #1f1b1c;
  --muted: #1f1b1c;
  --muted-foreground: #a99fa1;
  --accent: #262122;
  --accent-foreground: #ddd5d6;
  --teal-strong: #ddd5d6;
  --destructive: #f97066;
  --success: #32b77c;
  --warning: #f0a73a;
  --info: #6f9be8;
  --border: #2e2829;
  --input: #3a3334;
  --sidebar: #0f0d0e;
  --elevation-1: 0 1px 2px rgb(0 0 0 / 0.35);
  --elevation-2: 0 2px 10px -2px rgb(0 0 0 / 0.45);
  --elevation-3: 0 16px 40px -10px rgb(0 0 0 / 0.6);
  --ring-hairline: inset 0 0 0 1px color-mix(in oklch, white 8%, transparent);
  --inset-top: inset 0 1px 0 rgb(255 255 255 / 0.06);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 var(--font);
  background: var(--sidebar);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: 0; }
h3 { font-size: 0.9rem; font-weight: 600; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted-foreground); }
.small { font-size: 0.8125rem; }
.tiny { font-size: .8125rem; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.04em; }
.link { color: var(--primary-strong); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ph { font-size: 1.05rem; line-height: 1; vertical-align: -0.15em; }

/* ── Shell ───────────────────────────────────────────────────── */
.app { display: flex; min-height: 100svh; }

.sidebar {
  position: sticky; top: 0; height: 100svh;
  width: var(--nav-width); flex: none;
  display: flex; flex-direction: column;
  padding: 8px;
  background: var(--sidebar);
  transition: width 0.25s var(--motion-emphasized);
}
.sb-head { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-md); }
.sb-logo {
  width: 36px; height: 36px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: var(--brand-ink); color: var(--brand-paper);
  font-weight: 600; font-size: 15px; letter-spacing: 0.02em;
  box-shadow: var(--inset-top), var(--elevation-1);
}
.dark .sb-logo { background: var(--brand-paper); color: var(--brand-ink); }
.sb-logo b { font-weight: inherit; color: inherit; }
.sb-name { display: grid; line-height: 1.2; min-width: 0; }
.sb-name strong { font-size: 0.875rem; font-weight: 600; white-space: nowrap; max-width: 100%; }
.sb-name span { font-size: .8125rem; color: var(--muted-foreground); white-space: nowrap; }

.sb-scroll { flex: 1; overflow-y: auto; scrollbar-width: none; padding-top: 6px; }
.sb-scroll::-webkit-scrollbar { display: none; }
.sb-group { padding: 8px; }
.sb-label { height: 32px; display: flex; align-items: center; padding: 0 8px; font-size: .8125rem; font-weight: 500; color: var(--muted-foreground); }
.sb-menu { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sb-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  border-radius: var(--radius-md); color: var(--foreground);
  font-weight: 500; cursor: pointer; white-space: nowrap; border: 1px solid transparent;
  transition: background 0.15s var(--motion-standard), color 0.15s;
}
.sb-item .ph { font-size: 1.1rem; flex: none; }
.sb-item:hover { background: color-mix(in oklch, var(--foreground) 5%, transparent); color: var(--foreground); }
.sb-item .badge-count { margin-left: auto; }
.sb-item.locked { opacity: 0.4; cursor: not-allowed; }
.sb-item.locked::after { content: ''; }
.nav-active { background: var(--card) !important; color: var(--foreground) !important; box-shadow: var(--ring-hairline), var(--elevation-1), var(--inset-top); }
.dark .nav-active { background: color-mix(in oklch, white 5%, var(--card)) !important; border-color: color-mix(in oklch, white 9%, transparent); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 1px 2px rgb(0 0 0 / 0.4); }
.sb-sub { list-style: none; margin: 2px 0 4px 21px; padding: 0 0 0 12px; border-left: 1px solid var(--border); display: grid; gap: 2px; animation: fade-down 0.2s var(--motion-emphasized); }
.sb-sub a { display: flex; align-items: center; height: 28px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--muted-foreground); font-size: 0.8125rem; font-weight: 500; }
.sb-sub a:hover { color: var(--foreground); background: color-mix(in oklch, var(--foreground) 5%, transparent); }
.sb-sub a.active { color: var(--foreground); background: color-mix(in oklch, var(--foreground) 7%, transparent); }
.sb-section-open > .sb-item { color: var(--foreground); font-weight: 600; }

.sb-foot { padding: 6px; border-top: 1px solid var(--border); margin-top: 6px; position: relative; }
.nav-user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: none; border-radius: var(--radius-md); cursor: pointer; text-align: left; }
.nav-user:hover { background: color-mix(in oklch, var(--foreground) 5%, transparent); }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 600; font-size: .8125rem; background: var(--accent); color: var(--accent-foreground); box-shadow: var(--inset-top); }
.avatar.lg { width: 44px; height: 44px; border-radius: 14px; font-size: 0.95rem; }
.avatar.teal { background: var(--secondary); color: var(--foreground); }
.nav-user .who { display: grid; line-height: 1.25; min-width: 0; flex: 1; }
.nav-user .who strong { font-size: 0.8125rem; font-weight: 600; }
.nav-user .who span { font-size: .8125rem; color: var(--muted-foreground); white-space: nowrap; max-width: 100%; }

/* Collapsed to icons */
.app.collapsed .sidebar { width: 64px; }
.app.collapsed .sb-name, .app.collapsed .sb-label, .app.collapsed .sb-item span, .app.collapsed .sb-sub,
.app.collapsed .nav-user .who, .app.collapsed .nav-user .ph-caret-up-down, .app.collapsed .badge-count { display: none; }
.app.collapsed .sb-group { padding: 4px 0; }
.app.collapsed .sb-item { justify-content: center; padding: 0; }
.app.collapsed .sb-head { justify-content: center; padding: 8px 0; }

/* Inset main surface */
.inset {
  flex: 1; min-width: 0; margin: 8px 8px 8px 0;
  border-radius: var(--radius-xl); background: var(--background);
  box-shadow: var(--elevation-1), var(--ring-hairline);
  display: flex; flex-direction: column; height: calc(100svh - 16px); overflow: hidden;
}
.hdr {
  position: sticky; top: 0; z-index: 30; height: 64px; flex: none;
  display: flex; align-items: center; gap: 8px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--background) 82%, transparent);
  backdrop-filter: blur(12px);
}
.hdr .sep { width: 1px; height: 16px; background: var(--border); margin: 0 6px 0 2px; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; font-size: 0.875rem; }
.crumbs .ws { color: var(--muted-foreground); white-space: nowrap; }
.crumbs .ph-caret-right { color: var(--muted-foreground); font-size: 0.8rem; }
.crumbs .here { font-weight: 500; white-space: nowrap; max-width: 100%; }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

.search {
  position: relative; width: clamp(180px, 26vw, 340px);
}
.search .ph { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); }
.search input {
  width: 100%; height: 36px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); padding: 0 14px 0 36px; color: var(--foreground); font: inherit; font-size: 0.875rem;
  box-shadow: var(--inset-top); outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.search input:focus { border-color: color-mix(in oklch, var(--primary) 60%, var(--input)); box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 22%, transparent); }
.search-results {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(460px, 90vw); z-index: 60;
  background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--elevation-3); padding: 8px; display: none; animation: fade-down 0.18s var(--motion-emphasized);
}
.search.open .search-results { display: block; }
.sr-group { padding: 6px 8px 2px; font-size: .8125rem; font-weight: 600; color: var(--muted-foreground);  }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-md); cursor: pointer; }
.sr-item:hover, .sr-item.on { background: color-mix(in oklch, var(--foreground) 5%, transparent); }
.sr-item .meta { margin-left: auto; color: var(--muted-foreground); font-size: 0.8rem; }

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  font-size: 0.875rem; font-weight: 500; cursor: pointer; white-space: nowrap; box-shadow: var(--inset-top);
  transition: background 0.15s;
}
.pill-btn:hover { background: var(--muted); }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 999px; border: 1px solid var(--border); background: var(--card); cursor: pointer; position: relative; box-shadow: var(--inset-top); }
.icon-btn:hover { background: var(--muted); }
.icon-btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.icon-btn.ghost:hover { background: color-mix(in oklch, var(--foreground) 6%, transparent); }
.dot-badge { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 99px; background: var(--foreground); box-shadow: 0 0 0 2px var(--card); }

.main { flex: 1; overflow-y: auto; }
.admin-canvas {
  background-color: var(--background);
}
.content { max-width: 1360px; margin: 0 auto; padding: 28px 32px 80px; animation: page-in 0.45s var(--motion-emphasized); }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ── Popover menus ───────────────────────────────────────────── */
.menu {
  position: absolute; z-index: 70; min-width: 240px; padding: 6px;
  background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--elevation-3); animation: fade-down 0.18s var(--motion-emphasized);
}
.menu[hidden] { display: none; }
.menu .mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--radius-md); cursor: pointer; text-align: left; font-size: 0.875rem; }
.menu .mi:hover { background: color-mix(in oklch, var(--foreground) 6%, transparent); }
.menu .mi .ph { color: var(--muted-foreground); }
.menu .mi.on .ph-check { margin-left: auto; color: var(--foreground); }
.menu .msep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu .mlabel { padding: 6px 10px 4px; font-size: .8125rem; font-weight: 600; color: var(--muted-foreground);  }
.menu .mhead { display: flex; gap: 10px; align-items: center; padding: 8px 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; margin: 2px 6px 6px; border-radius: 999px; background: var(--muted); }
.seg button { height: 28px; border: 0; background: none; border-radius: 999px; cursor: pointer; font-size: 0.8rem; font-weight: 500; color: var(--muted-foreground); display: inline-flex; gap: 5px; align-items: center; justify-content: center; }
.seg button.on { background: var(--card); color: var(--foreground); box-shadow: var(--elevation-1), var(--inset-top); }

/* Notifications tray */
.tray { right: 0; top: calc(100% + 8px); width: min(400px, 92vw); padding: 0; overflow: hidden; }
.tray-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tray-head .tabs { display: flex; gap: 4px; margin-left: 8px; }
.tray-list { max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif:hover { background: color-mix(in oklch, var(--foreground) 3%, transparent); }
.notif.unread { background: color-mix(in oklch, var(--foreground) 3.5%, transparent); }
.notif .icon-chip { width: 32px; height: 32px; flex: none; }
.notif p { font-size: 0.85rem; }
.notif time { font-size: .8125rem; color: var(--muted-foreground); }

/* ── Surfaces ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
  border-radius: var(--radius-xl);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 10px -3px rgb(0 0 0 / 0.05), 0 18px 36px -14px rgb(0 0 0 / 0.08);
}
.dark .card { border-color: color-mix(in oklch, white 7%, transparent); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.035), 0 1px 2px rgb(0 0 0 / 0.4), 0 20px 46px -16px rgb(0 0 0 / 0.6); }
.card.hover { transition: transform 0.25s var(--motion-emphasized), box-shadow 0.25s; cursor: pointer; }
.card.hover:hover { transform: translateY(-2px); box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 14px -4px rgb(0 0 0 / 0.06), 0 26px 50px -16px rgb(0 0 0 / 0.1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card-head p { color: var(--muted-foreground); font-size: 0.8125rem; margin-top: 2px; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.icon-chip { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md); background: color-mix(in oklch, var(--foreground) 5%, transparent); border: 1px solid color-mix(in oklch, var(--foreground) 5%, transparent); box-shadow: var(--inset-top); flex: none; }
.dark .icon-chip { background: color-mix(in oklch, white 6%, transparent); border-color: color-mix(in oklch, white 5%, transparent); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; }
.page-head p { color: var(--muted-foreground); margin-top: 6px; max-width: 70ch; }
.eyebrow-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted-foreground); font-size: 0.8125rem; font-weight: 500; margin-bottom: 8px; }
.eyebrow-link:hover { color: var(--foreground); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.stack { display: grid; gap: 16px; }
.stack-lg { display: grid; gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 16px; }

/* Metric cards (AFCA dashboard) */
.metric { padding: 18px; display: grid; gap: 10px; }
.metric .top { display: flex; align-items: center; justify-content: space-between; }
.metric .label { color: var(--muted-foreground); font-size: 0.8125rem; font-weight: 500; }
.metric .value { font-size: 1.7rem; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric .sub { font-size: 0.8rem; color: var(--muted-foreground); }
.metric .delta-up { color: var(--success); font-weight: 600; }
.bar { height: 6px; border-radius: 99px; background: var(--muted); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--foreground); }
.bar.teal > i, .bar.soft > i { background: color-mix(in oklch, var(--foreground) 45%, transparent); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  font-weight: 500; font-size: 0.875rem; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.04), var(--inset-top);
  transition: background 0.15s var(--motion-standard), transform 0.1s;
}
.btn:hover { background: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  color: var(--primary-foreground); background: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.08) inset, 0 1px 2px rgb(0 0 0 / 0.12);
}
.btn.primary:hover { background: color-mix(in oklch, var(--primary) 86%, var(--background)); }
.btn.ink { background: var(--brand-ink); color: var(--brand-paper); border-color: var(--brand-ink); }
.dark .btn.ink { background: var(--brand-paper); color: var(--brand-ink); border-color: var(--brand-paper); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: color-mix(in oklch, var(--foreground) 6%, transparent); }
.btn.danger { color: var(--destructive); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 0.8125rem; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn.xl { height: 64px; padding: 0 28px; font-size: 1.15rem; border-radius: var(--radius-xl); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
@media (pointer: coarse) { .btn { height: 44px; } .btn.sm { height: 38px; } }

/* ── Status tints: flat, muted colour. They carry meaning; no gradients. */
.tint { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.tint-success { background: oklch(0.95 0.035 165); color: oklch(0.42 0.08 168); border-color: oklch(0.88 0.05 168); }
.tint-warning { background: oklch(0.96 0.04 80); color: oklch(0.48 0.1 62); border-color: oklch(0.89 0.06 78); }
.tint-info { background: oklch(0.955 0.025 245); color: oklch(0.48 0.1 250); border-color: oklch(0.89 0.04 245); }
.tint-danger { background: oklch(0.955 0.025 25); color: oklch(0.5 0.13 27); border-color: oklch(0.89 0.05 25); }
.tint-pink { background: oklch(0.955 0.025 350); color: oklch(0.47 0.11 355); border-color: oklch(0.89 0.045 350); }
.tint-neutral { background: color-mix(in oklch, var(--foreground) 5%, var(--card)); color: var(--foreground); border-color: var(--border); }
.dark .tint-success { background: oklch(0.29 0.04 168); color: oklch(0.86 0.08 168); border-color: oklch(0.38 0.05 168); }
.dark .tint-warning { background: oklch(0.3 0.04 70); color: oklch(0.87 0.09 80); border-color: oklch(0.39 0.05 70); }
.dark .tint-info { background: oklch(0.29 0.04 250); color: oklch(0.86 0.07 250); border-color: oklch(0.38 0.05 250); }
.dark .tint-danger { background: oklch(0.3 0.05 27); color: oklch(0.86 0.08 27); border-color: oklch(0.4 0.06 27); }
.dark .tint-pink { background: oklch(0.3 0.045 355); color: oklch(0.86 0.07 355); border-color: oklch(0.4 0.05 355); }
.gloss-dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; }
.badge-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-size: .8125rem; font-weight: 600; background: color-mix(in oklch, var(--foreground) 9%, transparent); color: var(--foreground); }

/* ── Pill tabs with counts (AFCA PillTabs) ───────────────────── */
.pill-tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: color-mix(in oklch, var(--foreground) 5%, transparent); }
.pill-tabs button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: none; cursor: pointer; color: var(--muted-foreground); font-weight: 500; font-size: 0.8125rem; }
.pill-tabs button .c { font-size: .8125rem; padding: 0 6px; border-radius: 99px; background: color-mix(in oklch, var(--foreground) 7%, transparent); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.pill-tabs button.on { background: var(--card); color: var(--foreground); box-shadow: var(--elevation-1), var(--inset-top); }
.pill-tabs button.on .c { background: color-mix(in oklch, var(--foreground) 9%, transparent); color: var(--foreground); }

/* ── Library table (AFCA) ────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .left, .toolbar .right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field-search { position: relative; }
.field-search .ph { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); }
.field-search input { padding-left: 34px !important; width: 240px; }
.chip-select { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 0.8125rem; font-weight: 500; cursor: pointer; box-shadow: var(--inset-top); }
.chip-select .ph { color: var(--muted-foreground); font-size: 0.85rem; }
.chip-select b { font-weight: 600; }
.table-wrap { overflow-x: auto; container-type: inline-size; }
table.lib { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.lib th { text-align: left; padding: 10px 16px; font-size: .8125rem; font-weight: 500; color: var(--muted-foreground); border-bottom: 1px solid var(--border); white-space: nowrap; background: color-mix(in oklch, var(--foreground) 1.5%, var(--card)); }
table.lib th.sort { cursor: pointer; }
table.lib th.sort .ph { font-size: .8125rem; }
table.lib td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.lib tr:last-child td { border-bottom: 0; }
table.lib tbody tr { cursor: pointer; transition: background 0.12s; }
table.lib tbody tr:hover td { background: color-mix(in oklch, var(--foreground) 2.5%, transparent); }
table.lib tbody tr.selected td { background: color-mix(in oklch, var(--foreground) 5%, transparent); }
table.lib .r { text-align: right; }
table.lib .cb { width: 44px; padding-right: 0; }
table.lib .sub { display: block; font-size: .8125rem; color: var(--muted-foreground); }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--brand-ink); cursor: pointer; }
.dark input[type='checkbox'] { accent-color: var(--brand-paper); }
.lib-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--muted-foreground); }
@container (max-width: 760px) { .hide-sm { display: none; } }
@container (max-width: 560px) { .hide-xs { display: none; } }

.bulk-bar {
  position: sticky; bottom: 16px; z-index: 20; margin: 16px auto 0; width: fit-content;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--brand-ink); color: var(--brand-paper); box-shadow: var(--elevation-3); animation: rise 0.3s var(--motion-emphasized);
}
.dark .bulk-bar { background: var(--brand-paper); color: var(--brand-ink); }
.bulk-bar .btn { height: 32px; border-radius: 999px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* Claim (AFCA work claims) */
.claim { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.claim .avatar { width: 22px; height: 22px; border-radius: 7px; font-size: .8125rem; }
.claim-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--border); }

/* ── Record layout (AFCA RecordLayout) ───────────────────────── */
.record { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .record { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 9px 16px; margin: 0; font-size: 0.875rem; }
.facts dt { color: var(--muted-foreground); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding-bottom: 14px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: 13px; top: 26px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--muted); font-size: 0.85rem; }
.timeline p { font-size: 0.875rem; }
.timeline time { font-size: .8125rem; color: var(--muted-foreground); }

/* Lifecycle (Tread fulfilment task list) */
.lifecycle { display: grid; gap: 0; }
.stage { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.stage:last-child { border-bottom: 0; }
.stage .s-dot { width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; border: 1.5px solid var(--border); color: var(--muted-foreground); font-size: 0.8rem; }
.stage.done .s-dot { background: var(--foreground); border-color: var(--foreground); color: var(--background); }
.stage.current .s-dot { border-color: var(--foreground); color: var(--foreground); box-shadow: 0 0 0 4px color-mix(in oklch, var(--foreground) 10%, transparent); }
.stage.later { opacity: 0.5; }

/* ── Notices & empties ───────────────────────────────────────── */
.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); font-size: 0.875rem; }
.notice .ph { font-size: 1.2rem; flex: none; margin-top: 1px; }
.notice.info { background: var(--card); }
.notice.info .ph { color: var(--muted-foreground); }
.notice.warn { background: color-mix(in oklch, var(--warning) 5%, var(--card)); border-color: color-mix(in oklch, var(--warning) 18%, var(--border)); }
.notice.warn .ph { color: var(--warning); }
.notice.good { background: color-mix(in oklch, var(--success) 4%, var(--card)); border-color: color-mix(in oklch, var(--success) 15%, var(--border)); }
.notice.good .ph { color: var(--success); }
.notice.pink { background: var(--card); }
.notice.pink .ph { color: var(--muted-foreground); }
.empty { padding: 48px 24px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.empty .icon-chip { width: 48px; height: 48px; font-size: 1.4rem; }
.empty p { color: var(--muted-foreground); max-width: 44ch; }

/* ── Forms ───────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; }
.field .hint { font-size: .8125rem; color: var(--muted-foreground); }
.input, .select, .textarea {
  width: 100%; height: 38px; border-radius: var(--radius-md); border: 1px solid var(--input); background: var(--card);
  padding: 0 12px; font: inherit; font-size: 0.875rem; color: var(--foreground); outline: none;
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.03), inset 0 1px 0 rgb(255 255 255 / 0.45);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dark .input, .dark .select, .dark .textarea { background: color-mix(in oklch, white 3%, var(--card)); border-color: color-mix(in oklch, white 12%, transparent); }
.textarea { height: auto; min-height: 84px; padding: 9px 12px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: color-mix(in oklch, var(--primary) 60%, var(--input)); box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 22%, transparent); }
.select { appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2399a1af' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; background-size: 1rem; }
.suffix { display: flex; align-items: stretch; }
.suffix .input { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.suffix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--input); border-left: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; background: var(--muted); font-size: 0.8125rem; color: var(--muted-foreground); }
.prefix { display: flex; align-items: stretch; }
.prefix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--input); border-right: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); background: var(--muted); font-size: 0.8125rem; color: var(--muted-foreground); }
.prefix .input { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 16px; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--input); border: 0; cursor: pointer; flex: none; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 99px; background: white; box-shadow: var(--elevation-1); transition: transform 0.25s var(--motion-emphasized); }
.switch.on { background: var(--success); }
.switch.on::after { transform: translateX(16px); }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 10px; }
.radio-card { display: grid; gap: 4px; padding: 14px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); cursor: pointer; text-align: left; transition: border-color 0.15s, box-shadow 0.15s; }
.radio-card strong { font-size: 0.9rem; }
.radio-card span { font-size: 0.8rem; color: var(--muted-foreground); }
.radio-card.on { border-color: var(--brand-ink); box-shadow: 0 0 0 1px var(--brand-ink); }
.dark .radio-card.on { border-color: var(--brand-paper); box-shadow: 0 0 0 1px var(--brand-paper); }

/* ── Studio (AFCA StudioShell / StepRail) ────────────────────── */
.studio { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .studio { grid-template-columns: 1fr; } }
.rail { position: sticky; top: 16px; display: grid; gap: 4px; }
.rail-step { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-lg); border: 0; background: none; text-align: left; cursor: pointer; color: var(--muted-foreground); font-weight: 500; }
.rail-step .n { width: 26px; height: 26px; border-radius: 99px; display: grid; place-items: center; font-size: .8125rem; font-weight: 600; border: 1.5px solid var(--border); flex: none; background: var(--card); }
.rail-step.done { color: var(--foreground); }
.rail-step.done .n { background: var(--foreground); border-color: var(--foreground); color: var(--background); }
.rail-step.on { background: var(--card); color: var(--foreground); box-shadow: var(--ring-hairline), var(--elevation-1), var(--inset-top); }
.rail-step.on .n { border-color: var(--brand-ink); background: var(--brand-ink); color: var(--brand-paper); }
.dark .rail-step.on .n { border-color: var(--brand-paper); background: var(--brand-paper); color: var(--brand-ink); }
.rail-step[disabled] { cursor: default; }
.studio-section { display: grid; gap: 16px; padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.studio-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.studio-section > header p { color: var(--muted-foreground); font-size: 0.85rem; margin-top: 3px; }
.action-bar {
  position: sticky; bottom: 0; z-index: 15; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin-top: 16px; border-radius: var(--radius-xl);
  background: color-mix(in oklch, var(--card) 92%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--border); box-shadow: var(--elevation-3);
}
.action-bar .status { flex: 1; font-size: 0.875rem; }
.action-bar .status small { display: block; color: var(--muted-foreground); }

/* Dirty-state bar (AFCA prices editor) */
.dirty-bar { position: sticky; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; margin-top: 16px; border-radius: 999px; background: var(--brand-ink); color: var(--brand-paper); box-shadow: var(--elevation-3); animation: rise 0.3s var(--motion-emphasized); }
.dark .dirty-bar { background: var(--brand-paper); color: var(--brand-ink); }
.dirty-bar .status { flex: 1; font-weight: 500; }
.dirty-bar .btn { border-radius: 999px; }

/* ── Sheets & dialogs ────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgb(12 10 11 / 0.42); backdrop-filter: blur(2px); animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; z-index: 81; top: 8px; right: 8px; bottom: 8px; width: min(520px, calc(100vw - 16px)); display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius-xl); box-shadow: var(--elevation-3); animation: slide-in 0.35s var(--motion-emphasized); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.sheet-head p { color: var(--muted-foreground); font-size: 0.85rem; margin-top: 2px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 18px; align-content: start; }
.sheet-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.dialog { position: fixed; z-index: 81; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--card); border-radius: var(--radius-2xl); box-shadow: var(--elevation-3); padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; animation: pop 0.3s var(--motion-emphasized); }
.dialog.wide { width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(0.98); } }

/* Toast (AFCA notify) */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: grid; gap: 8px; }
.toast { display: flex; gap: 10px; align-items: flex-start; width: 340px; padding: 12px 14px; border-radius: var(--radius-xl); background: var(--popover); border: 1px solid var(--border); box-shadow: var(--elevation-3); animation: slide-in 0.35s var(--motion-emphasized); }
.toast .ph { font-size: 1.15rem; color: var(--success); margin-top: 1px; }
.toast[data-tone='warning'] .ph { color: var(--warning); }
.toast[data-tone='info'] .ph { color: var(--info); }
.toast strong { display: block; font-size: 0.875rem; }
.toast span { font-size: 0.8125rem; color: var(--muted-foreground); }

/* ── Mock-only annotation (review aid; never in the app) ─────── */
.mock-note { position: fixed; left: 16px; bottom: 16px; z-index: 90; max-width: 320px; padding: 10px 12px; border-radius: 12px; background: #fff7d6; color: #4a3b00; border: 1px solid #ecd27a; font-size: 13px; line-height: 1.45; box-shadow: var(--elevation-2); }
.mock-note b { display: block; margin-bottom: 2px; }
.mock-note button { position: absolute; top: 4px; right: 6px; border: 0; background: none; cursor: pointer; color: inherit; }

/* ── Responsive shell ────────────────────────────────────────── */
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 85; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform 0.3s var(--motion-emphasized); box-shadow: var(--elevation-3); width: 280px; }
  .app.menu-open .sidebar { transform: none; }
  .inset { margin: 0; border-radius: 0; height: 100svh; }
  .content { padding: 20px 16px 96px; }
  .search { width: 40px; }
  .search input { padding: 0; color: transparent; cursor: pointer; }
  .search input:not(:focus)::placeholder { color: transparent; }
  .search input:focus { position: fixed; left: 12px; right: 12px; top: 12px; width: auto; padding-left: 36px; color: var(--foreground); z-index: 90; height: 44px; }
  .hide-mobile { display: none !important; }
}

/* ── Info hint: help lives behind an "i", never as sub-copy ─────── */
.info-hint { position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 4px; padding: 0; border: 0; border-radius: 99px; background: none; color: var(--muted-foreground); cursor: help; vertical-align: -0.2em; }
.info-hint .ph { font-size: 15px; }
.info-hint:hover, .info-hint:focus-visible { color: var(--foreground); }
.info-hint [role='tooltip'] {
  position: absolute; z-index: 95; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: 260px; padding: 8px 10px; border-radius: var(--radius-md);
  background: var(--foreground); color: var(--background); font-size: .8125rem; font-weight: 400; line-height: 1.45; text-align: left; letter-spacing: 0; text-transform: none;
  display: none; pointer-events: none; box-shadow: var(--elevation-2); animation: fade 0.15s;
  transform: translateX(-50%);
}
/* Only laid out while shown, so a hint near the edge never widens the page. */
.info-hint:hover [role='tooltip'], .info-hint:focus-visible [role='tooltip'] { display: block; }

/* ── Colour field: swatch, picker and hex input ───────────────────── */
.color-field { display: flex; align-items: stretch; width: 100%; max-width: 260px; }
.color-field .swatch { position: relative; width: 40px; flex: none; border: 1px solid var(--input); border-right: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); overflow: hidden; cursor: pointer; }
.color-field .swatch input[type='color'] { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); border: 0; padding: 0; cursor: pointer; }
.color-field .hash { display: grid; place-items: center; padding: 0 0 0 10px; border-top: 1px solid var(--input); border-bottom: 1px solid var(--input); background: var(--card); color: var(--muted-foreground); font-family: ui-monospace, Menlo, monospace; }
.color-field .input { border-left: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; padding-left: 4px; }
.color-field .input[aria-invalid='true'] { border-color: var(--destructive); }
.color-presets { display: flex; gap: 6px; margin-top: 8px; }
.color-presets button { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; padding: 0; }

/* ── Record header facts: title + status, then short icon facts ───── */
.facts-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; color: var(--muted-foreground); font-size: 0.875rem; }
.facts-row span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.facts-row .ph { font-size: 1rem; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }

/* ── Breathing room (client: "Let it breathe") ──────────────────────
   One spacing scale for every workspace: 8 / 12 / 16 / 24 / 32 / 40. */
.content { padding: 36px 40px 96px; }
.page-head { margin-bottom: 32px; gap: 16px 32px; }
.page-head h1 + .facts-row, .title-row + .facts-row { margin-top: 12px; }
.title-row { gap: 12px 16px; }
h1 .tint, h2 .tint, h3 .tint { margin-left: 14px; vertical-align: 0.2em; }
h1 .info-hint { margin-left: 8px; }
.eyebrow-link { margin-bottom: 12px; }
.card-head { padding: 18px 24px; gap: 16px; }
.card-body { padding: 24px; }
.card-foot { padding: 16px 24px; }
.stack { gap: 20px; }
.stack-lg { gap: 32px; }
.grid-2, .grid-3, .grid-4 { gap: 24px; }
.metric { padding: 22px 24px; gap: 12px; }
.row { gap: 12px; }
.form-grid { gap: 20px; }
.field { gap: 8px; }
.toolbar { padding: 16px 20px; gap: 12px; }
table.lib th { padding: 12px 20px; }
table.lib td { padding: 14px 20px; }
.lib-foot { padding: 14px 20px; }
.studio { gap: 32px; }
.studio-section { gap: 20px; padding-bottom: 28px; margin-bottom: 28px; }
.sheet-body { padding: 24px; gap: 22px; }
.sheet-head { padding: 20px 24px; }
.sheet-foot { padding: 16px 24px; }
.dialog { padding: 26px; gap: 18px; }
.record { gap: 24px; }
.notice { padding: 16px 18px; }
.empty { padding: 56px 24px; gap: 12px; }
@media (max-width: 860px) {
  .content { padding: 24px 16px 104px; }
  .card-head { padding: 16px 18px; }
  .card-body { padding: 18px; }
  .grid-2, .grid-3, .grid-4 { gap: 16px; }
  table.lib td, table.lib th { padding-left: 16px; padding-right: 16px; }
}
.metric .value { white-space: nowrap; font-size: clamp(1.3rem, 1rem + 0.9vw, 1.75rem); }
.metric .top { gap: 12px; align-items: flex-start; }
.metric .label { line-height: 1.35; }
.metric .top .icon-chip { width: 32px; height: 32px; }
/* Metric rows never squeeze below a readable tile. */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 24px; }

/* Metric values scale with their own tile, so a sum never wraps. */
.metric { container-type: inline-size; }
.metric .value { font-size: clamp(1.15rem, 11cqi, 1.75rem); white-space: nowrap; }
.metric .top .label { min-width: 0; }

/* ── Responsive tables: never scroll sideways ────────────────────────
   Less important columns hide as the table narrows; below 640px every row
   becomes a stacked card, labelled where a bare value would be unclear. */
@container (max-width: 900px) { .hide-sm { display: none; } }
/* Below 640px of card width, rows stack with labels: see table.lib.stacked in polish.css (motion.js decides) */
@container (max-width: 640px) { .hide-xs { display: none !important; } }
.table-wrap { overflow-x: clip; }

/* ── Phones: tabs wrap, step rails compress, nothing scrolls sideways ── */
@media (max-width: 640px) {
  .pill-tabs { flex-wrap: wrap !important; overflow: visible !important; border-radius: 18px; max-width: 100%; }
  .pill-tabs button { flex: none; }
}
@media (max-width: 900px) {
  .rail { position: static; display: flex !important; flex-wrap: wrap; gap: 6px; overflow: visible !important; }
  .rail-step { padding: 6px 10px 6px 6px; }
  /* Only the current step keeps its name; the rest are numbered dots. */
  .rail-step:not(.on) { font-size: 0; gap: 0; padding: 4px; }
  .rail-step:not(.on) .n { font-size: .8125rem; }
  .rail-step:not(.on) .ph, .rail-step:not(.on) small { display: none; }
}

/* ── Client logo (the real wordmark, never an invented monogram) ──── */
.brand-logo { display: block; width: 132px; color: var(--foreground); line-height: 0; }
.brand-logo svg { display: block; width: 100%; height: auto; }
.sb-head { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 10px 8px; }
.sb-ws { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 500; color: var(--muted-foreground); }
.app.collapsed .brand-logo { display: none; }
.app.collapsed .sb-ws span { display: none; }
.app.collapsed .sb-head { align-items: center; padding: 14px 0 8px; }
.app.collapsed .sb-ws .ph { font-size: 1.3rem; color: var(--foreground); }

/* ── Header breathing room (all workspaces) ─────────────────────────── */
.hdr { height: 72px; padding: 0 24px; gap: 16px; }
.hdr .sep { margin: 0 8px 0 4px; }
.crumbs { gap: 10px; }
.hdr-right { gap: 12px; }
.search { width: clamp(200px, 24vw, 320px); }
.sb-head { gap: 12px; padding: 16px 12px 12px; }
.sb-scroll { padding-top: 10px; }
@media (max-width: 860px) { .hdr { height: 64px; padding: 0 12px; gap: 10px; } .hdr-right { gap: 8px; } }

/* Phones: the header search stays a round button until tapped. */
@media (max-width: 860px) { .search { width: 40px; flex: none; } }

/* ── "How this screen works" panels ─────────────────────────────── */
.bc-fr { padding: 24px 28px; margin-bottom: 28px; }
.bc-fr-in { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px 18px; align-items: start; }
.bc-fr-in .icon-chip { margin-top: 2px; }
.bc-fr-in h2 { margin: 4px 0 12px; font-size: 1.05rem; }
.bc-fr-steps { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; color: var(--foreground); line-height: 1.5; }
.bc-fr-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 18px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.bc-fr-never { display: inline-flex; align-items: center; gap: 10px; font-size: 0.875rem; color: var(--muted-foreground); cursor: pointer; }
.bc-fr-never input { width: 18px; height: 18px; accent-color: var(--foreground); }
.bc-fr-actions { display: flex; gap: 10px; margin-left: auto; }
@media (max-width: 640px) { .bc-fr { padding: 20px; } .bc-fr-in { grid-template-columns: minmax(0, 1fr) auto; } .bc-fr-in .icon-chip { display: none; } .bc-fr-actions { margin-left: 0; width: 100%; } .bc-fr-actions .btn { flex: 1; justify-content: center; } }

/* ── Metric cards (mcard) ─────────────────────────────────────────
   After the ISER dashboard stat tiles, kept monotone: a neutral icon tile
   beside the label, the figure with a quieter unit, then an optional
   delta chip (arrow + ink, never red/green), a context line, a thin ink
   sparkline or progress bar, and a footer link. Cards that open something
   lift on hover. Built by mcard() / mgrid() in shell.js. */
.mgrid { container-type: inline-size; min-width: 0; }
.mgrid-in { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@container (min-width: 500px) { .mgrid-in { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
@container (min-width: 720px) {
  .mgrid[data-n="3"] .mgrid-in, .mgrid[data-n="5"] .mgrid-in, .mgrid[data-n="6"] .mgrid-in { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
}
@container (min-width: 860px) {
  .mgrid[data-n="4"] .mgrid-in { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
}

.mcard { position: relative; display: flex; flex-direction: column; gap: 0; min-width: 0; padding: 20px; color: inherit; text-align: left; font: inherit; container-type: inline-size; }
button.mcard { cursor: pointer; width: 100%; }
.mcard.hover:hover .mc-go, .mcard.hover:focus-visible .mc-go { color: var(--foreground); transform: translate(2px, -2px); }
.mcard.hover:hover .mc-foot .ph, .mcard.hover:focus-visible .mc-foot .ph { transform: translateX(3px); }
.mcard.on { box-shadow: 0 0 0 2px var(--foreground); }

.mc-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mc-tile {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--foreground) 5%, var(--card));
  border: 1px solid color-mix(in oklch, var(--foreground) 7%, transparent);
  box-shadow: var(--inset-top);
  color: var(--foreground);
}
.mc-tile .ph { font-size: 1.15rem; }
.dark .mc-tile { background: color-mix(in oklch, white 7%, var(--card)); border-color: color-mix(in oklch, white 8%, transparent); color: var(--foreground); }
.mc-label { flex: 1; min-width: 0; font-size: 0.8125rem; font-weight: 500; line-height: 1.3; color: var(--muted-foreground); }
.mc-label .info-hint { vertical-align: -0.25em; margin-left: 2px; }
.mc-go { flex: none; align-self: flex-start; font-size: 1rem; color: var(--foreground); transition: transform 0.2s var(--motion-emphasized), color 0.2s; }

.mc-main { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-top: 18px; min-width: 0; }
.mc-value { min-width: 0; font-size: clamp(1.35rem, 14cqi, 2rem); font-weight: 600; letter-spacing: 0; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; max-width: 100%; }
.mc-value.text { font-size: clamp(1.05rem, 7cqi, 1.25rem); letter-spacing: 0; line-height: 1.25; white-space: normal; }
.mc-unit { margin-left: 4px; font-size: 0.55em; font-weight: 500; letter-spacing: 0; color: var(--muted-foreground); }
.mc-pre { margin-right: 4px; font-size: 0.55em; font-weight: 500; letter-spacing: 0; color: var(--muted-foreground); }
.mc-spark { flex: none; margin-left: auto; width: clamp(72px, 34cqi, 120px); height: 34px; color: var(--foreground); }
.mc-spark svg { display: block; width: 100%; height: 100%; overflow: visible; }
@container (max-width: 300px) { .mc-spark { width: 100%; height: 40px; margin-left: 0; } }
.mc-spark .area { fill: color-mix(in oklch, currentColor 7%, transparent); stroke: none; }
.mc-spark .line { fill: none; stroke: color-mix(in oklch, currentColor 72%, transparent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }

.mc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; font-size: 0.8125rem; color: var(--muted-foreground); line-height: 1.35; min-width: 0; }
.mc-delta { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px 0 6px; border-radius: 999px; font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--foreground); background: color-mix(in oklch, var(--foreground) 6%, var(--card)); border: 1px solid color-mix(in oklch, var(--foreground) 8%, transparent); white-space: nowrap; }
.mc-delta .ph { font-size: 0.85rem; }
.mc-delta.down { color: var(--foreground); }
.mc-delta.flat { color: var(--muted-foreground); }
.mc-note { min-width: 0; }
.mc-note strong { color: var(--foreground); font-weight: 600; }

.mc-bar { margin-top: 14px; height: 6px; border-radius: 99px; background: color-mix(in oklch, var(--foreground) 8%, var(--card)); overflow: hidden; }
.mc-bar > i { display: block; height: 100%; border-radius: inherit; background: var(--foreground); }
.mc-bar.soft > i { background: color-mix(in oklch, var(--foreground) 45%, transparent); }
.mc-bar.segs { display: flex; gap: 2px; background: none; }
.mc-bar.segs > i { border-radius: 99px; flex: none; }
.mc-bar.segs > i:nth-child(2) { background: color-mix(in oklch, var(--foreground) 45%, transparent); }
.mc-bar.segs > i:nth-child(3) { background: color-mix(in oklch, var(--foreground) 18%, transparent); }

.mcard:has(> .mc-foot) > :nth-last-child(2) { margin-bottom: 16px; }
.mc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid color-mix(in oklch, var(--border) 80%, transparent); font-size: 0.8125rem; font-weight: 500; color: var(--foreground); }
.mc-foot .ph { color: var(--muted-foreground); transition: transform 0.2s var(--motion-emphasized); }
a.mc-foot:hover .ph { transform: translateX(3px); color: var(--foreground); }

/* Grouped strip: one surface, hairline dividers, cells instead of cards. */
.mstrip { overflow: hidden; }
.mstrip .mgrid-in { gap: 0 !important; margin: 0 -1px -1px 0; }
.mstrip .mcard { background: var(--card); border-radius: 0; padding: 20px 22px; border-right: 1px solid var(--border) !important; border-bottom: 1px solid var(--border) !important; }
.mstrip a.mcard, .mstrip button.mcard { transition: background 0.2s; border-top: 0; border-left: 0; }
.mstrip a.mcard:hover, .mstrip button.mcard:hover { background: color-mix(in oklch, var(--foreground) 2.5%, var(--card)); }
.mstrip a.mcard:hover .mc-go { color: var(--foreground); transform: translate(2px, -2px); }
.mstrip .mc-main { margin-top: 14px; }
.mstrip .mc-tile { width: 34px; height: 34px; }
@container (min-width: 330px) and (max-width: 499px) { .mstrip .mgrid-in { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mstrip[data-n="3"] .mgrid-in { grid-template-columns: repeat(3, minmax(0, 1fr)); } .mstrip .mcard { padding: 16px; } .mstrip .mc-head { flex-direction: column; align-items: flex-start; gap: 10px; } .mstrip .mc-go { position: absolute; top: 16px; right: 16px; } }

@media (max-width: 860px) { .mcard { padding: 18px; } .mc-main { margin-top: 16px; } }
@media (prefers-reduced-motion: reduce) { .mc-go, .mc-foot .ph { transition: none; } }
.card > .mstrip:last-child { border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.card > .mstrip:first-child { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.card > .mstrip:only-child { border-radius: var(--radius-xl); }

/* ── Layout hardening (shared by the mock and the app) ───────────────
   Nothing in the header can paint over anything else: the header is a size
   container, the crumb shrinks and ellipsizes first, the search shrinks
   between 200 and 320px, then Switch workspace drops its label, then the
   search folds to a round button that opens over the header when tapped. */
.hdr { container: hdr / inline-size; }
.hdr > .icon-btn, .hdr > .sep { flex: none; }
.crumbs { flex: 1 1 160px; min-width: 0; overflow: hidden; }
.crumbs > * { flex: none; }
.crumbs .ws { flex: 0 100 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs .here { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-right { flex: 0 1 auto; min-width: 0; margin-left: auto; }
.hdr-right > * { flex: none; }
.hdr .search { flex: 0 3 320px; width: auto; min-width: 200px; }
.hdr .search input, .hdr .search input:focus { position: static; transform: none; width: 100%; height: 36px; padding: 0 14px 0 36px; color: var(--foreground); cursor: text; z-index: auto; }
.hdr .search input::placeholder, .hdr .search input:not(:focus)::placeholder { color: var(--muted-foreground); }
.hdr .search > .ph { pointer-events: none; }
.hdr .pill-btn span { display: inline; }
.hdr .pill-btn { width: auto; padding: 0 12px; justify-content: flex-start; }
@container hdr (max-width: 900px) {
  .crumbs .ws, .crumbs .ph-caret-right { display: none; }
  .hdr .pill-btn span { display: none; }
  .hdr .pill-btn { width: 36px; padding: 0; justify-content: center; }
}
@container hdr (max-width: 580px) {
  .hdr .search { flex: none; width: 36px; min-width: 0; }
  .hdr .search input { height: 36px; padding: 0; color: transparent; cursor: pointer; }
  .hdr .search > .ph { left: 50%; transform: translate(-50%, -50%); }
  .hdr .search input::placeholder, .hdr .search input:not(:focus)::placeholder { color: transparent; }
  .hdr .search input::-webkit-search-cancel-button { display: none; }
  /* Tapped: the field opens across the header (the header's backdrop
     filter makes it the containing block for fixed children). */
  .hdr .search input:focus, .hdr .search.open input {
    position: fixed; z-index: 90; left: 8px; right: 8px; top: 50%; transform: translateY(-50%); width: auto; height: 44px;
    padding-left: 38px; color: var(--foreground); cursor: text; background: var(--card);
  }
  .hdr .search input:focus::placeholder, .hdr .search.open input::placeholder { color: var(--muted-foreground); }
  .hdr .search:focus-within > .ph, .hdr .search.open > .ph { position: fixed; z-index: 91; left: 22px; transform: translateY(-50%); }
  .hdr .search.open .search-results { position: fixed; top: calc(100% + 4px); left: 8px; right: 8px; width: auto; max-height: 70vh; overflow-y: auto; }
}

/* ── Tables, lists and toolbars use their whole column ─────────────── */
.card, .stack > *, .stack-lg > *, .record > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.table-wrap { width: 100%; }
table.lib { width: 100%; table-layout: auto; font-variant-numeric: tabular-nums; }
table.lib th.r, table.lib td.r { text-align: right; }
/* Toolbars: filters left, search right, on one line when they fit; when
   they don't, each group wraps whole and the search takes the full row. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; row-gap: 12px; }
.toolbar > .left { flex: 1 1 22rem; min-width: 0; max-width: 100%; }
.toolbar > .right { flex: 0 1 auto; min-width: 0; max-width: 100%; margin-left: auto; }
.toolbar .field-search { min-width: 0; max-width: 100%; }
.toolbar .field-search input { max-width: 100%; }
@media (max-width: 640px) {
  .toolbar > .right { flex: 1 1 100%; margin-left: 0; }
  .toolbar > .right .field-search, .toolbar > .right .field-search input { width: 100%; flex: 1 1 auto; }
}
/* Segmented controls never wrap inside their own pill: they scroll. */
.pill-tabs, .pf-range, .tm-seg {
  flex-wrap: nowrap !important; overflow-x: auto !important; overflow-y: hidden !important; max-width: 100%; min-width: 0;
  border-radius: 999px !important; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
}
.pill-tabs::-webkit-scrollbar, .pf-range::-webkit-scrollbar, .tm-seg::-webkit-scrollbar { display: none; }
.pill-tabs > *, .pf-range > *, .tm-seg > * { flex: none; white-space: nowrap; }
.tm-setup .tm-prog > span { white-space: nowrap; }
.tm-setup .tm-prog .bar { flex: 0 1 180px; min-width: 60px; }
/* Filter bars: each group shrinks to its row so a tab strip scrolls inside the card. */
.bs-filters > *, .be-head-tools > *, .toolbar > .left > *, .toolbar > .right > * { min-width: 0; max-width: 100%; }
.metrics { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
@media (max-width: 480px) { .bs-bars > .col > span { font-size: .8125rem; overflow: hidden; text-overflow: clip; } }
