/* hopastudio admin. Draft, 25 Oct 2026.
   Layout, spacing, sizes and component structure copy the Cloudflare dashboard ("Kumo" design
   system), measured in api/research/cloudflare-dash/SPEC.md and TOKENS.md. Each token keeps
   Cloudflare's role and scale; the colours are hopastudio's (blue #2363E9, night #0B2E8A,
   paper #ECE6E8 / #E5E2E2, ink #111111), the font is Figtree, the mark is the Sweep hare.
   Cloudflare's neutral greys are swapped for the same steps tinted toward our warm paper. */

@font-face {
  font-family: Figtree;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("assets/fonts/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2318;
}
@font-face {
  font-family: Figtree;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("assets/fonts/figtree-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02D7-02D9, U+02DB, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* =========================================================================================
   Tokens. A comment names the Cloudflare value the token replaces (TOKENS.md).
   ========================================================================================= */
:root {
  color-scheme: light;

  /* brand ramp (hopastudio) */
  --blue-50: #eef3fd;
  --blue-100: #dce7fc;
  --blue-200: #bcd0f8;
  --blue-300: #8fb1f3;
  --blue-400: #5c8ff0;
  --blue-500: #2363e9;          /* brand */
  --blue-600: #1b52c8;
  --blue-700: #1946c2;
  --blue-800: #12379b;
  --blue-900: #0b2e8a;          /* night */
  --lilac-300: #c9c2ff;

  /* the landing page's blue button (hopa-landing/src/theme.css .hopa-primary), used for primary buttons and the
     active menu item (Ovidiu, 25 Oct 2026: "white mode with the gradient we have on the landing page") */
  --hopa-gradient: linear-gradient(#3d7bff, #1f55d6);
  --hopa-gradient-line: #1a4cc4;
  --hopa-gloss: inset 1px 1px 0.25px rgb(255 255 255 / 0.35), inset 0 2px 1px rgb(255 255 255 / 0.35);
  --hopa-glow: 0 4px 12px rgb(35 99 233 / 0.3);
  --hopa-glow-hover: 0 8px 18px rgb(35 99 233 / 0.4);

  /* surfaces */
  --color-canvas: #ffffff;      /* CF #fbfbfb  page, side menu and top bar: white mode (Ovidiu, 25 Oct 2026) */
  --color-elevated: #f8f5f6;    /* CF #f8f8f8  chart cards, hint bars */
  --color-recessed: #f2eeef;    /* CF #f3f3f3  active nav item, segmented track */
  --color-base: #ffffff;        /* CF #ffffff  cards, tables, inputs */
  --color-tint: #f5f2f3;        /* CF #f5f5f5  hover fill */
  --color-control: #ffffff;     /* CF #ffffff  menus, toasts */
  --color-fill: #e5e2e2;        /* CF #e5e5e5  table lines, grey badge (our paper) */
  --color-interact: #d5cfd1;    /* CF #d4d4d4 */
  --color-contrast: #111111;    /* CF #020202 */

  /* lines and focus */
  --color-line: rgb(36 22 28 / 0.11);   /* CF rgba(10,10,10,.10) */
  --color-hairline: #ebe7e8;            /* CF #e9e9e9 */
  --color-focus: var(--blue-900);       /* CF #0b0b0b, input focus ring at 50% */

  /* text */
  --text-default: #171415;      /* CF #171717 */
  --text-strong: #111111;       /* CF #0a0a0a, our ink */
  --text-subtle: #736b6e;       /* CF #737373 */
  --text-placeholder: #a39b9e;  /* CF #a1a1a1 */
  --text-inactive: #cfc8ca;     /* CF #d4d4d4 */
  --text-inverse: #fbf9f9;      /* CF #f5f5f5 */
  --text-link: var(--blue-700); /* CF #193cb8 */

  /* brand and primary button, built the way CF builds theirs */
  --color-brand: var(--blue-500);         /* CF #056dff */
  --color-brand-hover: var(--blue-600);   /* CF #1447e6 */
  --button-primary-bg: color-mix(in oklch, var(--color-brand), white 22%);
  --button-primary-from: color-mix(in oklch, var(--color-brand), white 12%);
  --button-primary-to: var(--color-brand);
  --button-primary-ring: color-mix(in oklch, var(--color-brand), black 12%);

  /* status: text, strong fill, tint (CF hues; info moved to our blue) */
  --text-info: var(--blue-700);   --color-info: var(--blue-500);   --color-info-tint: rgb(35 99 233 / 0.09);
  --text-success: #006045;        --color-success: #009966;        --color-success-tint: oklch(96.2% 0.043 156.7 / 0.75);
  --text-warning: #a35600;        --color-warning: #fa8900;        --color-warning-tint: oklch(95% 0.07 80 / 0.7);
  --text-danger: #c10007;         --color-danger: #e7000b;         --color-danger-tint: oklch(93.6% 0.032 17.7 / 0.6);
  --text-night: var(--blue-900);  --color-night-tint: rgb(201 194 255 / 0.32);

  /* charts (CF #4290f0 series 1, grid #dddddd) */
  --chart-1: var(--blue-500);
  --chart-1-hover: var(--blue-600);
  --chart-today: var(--blue-900);
  --chart-grid: #e2dddf;

  /* type: Figtree in CF's scale. CF weights 400 / 500 / 600 map to our 450 / 550 / 650. */
  --font-sans: Figtree, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 12px;    --leading-xs: 16px;
  --text-sm: 13px;    --leading-sm: 16px;
  --text-base: 14px;  --leading-base: 21px;
  --text-lg: 16px;    --leading-lg: 24px;
  --text-xl: 20px;    --leading-xl: 25px;
  --text-2xl: 24px;   --leading-2xl: 32px;
  --text-3xl: 30px;   --leading-3xl: 36px;
  --weight-regular: 450;
  --weight-medium: 550;
  --weight-semibold: 650;
  --weight-bold: 750;
  --tracking-ui: -0.16px;
  --tracking-title: -0.02em;

  /* spacing: CF 4 px unit */
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* borders and shadows (CF draws most borders as a 1 px box-shadow ring) */
  --ring: 0 0 0 1px var(--color-line);
  --shadow-xs: 0 1px 2px 0 rgb(17 17 17 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(17 17 17 / 0.1), 0 2px 4px -2px rgb(17 17 17 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(17 17 17 / 0.1), 0 4px 6px -4px rgb(17 17 17 / 0.1);
  --shadow-dialog: 0 20px 25px -5px rgb(17 17 17 / 0.06), 0 8px 10px -6px rgb(17 17 17 / 0.05);
  --shadow-card: var(--ring), var(--shadow-xs);
  --shadow-popover: var(--ring), var(--shadow-lg);
  --focus-ring: 0 0 0 2px var(--color-base), 0 0 0 4px var(--color-brand);
  --focus-ring-input: 0 0 0 1.5px color-mix(in srgb, var(--color-focus) 50%, transparent);
  --backdrop: color-mix(in srgb, var(--color-recessed) 80%, transparent);

  /* layers */
  --z-topbar: 20;
  --z-backdrop: 40;
  --z-sidebar: 50;
  --z-popover: 100;
  --z-toast: 9999;

  /* motion */
  --dur-1: 100ms;    /* default */
  --dur-2: 150ms;    /* popovers, menus, dialogs */
  --dur-3: 200ms;    /* tabs */
  --dur-4: 250ms;    /* sidebar, drawer, nav colour */
  --dur-5: 500ms;    /* toasts */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-sidebar: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-toast: cubic-bezier(0.22, 1, 0.36, 1);

  /* component sizes */
  --control-sm: 26px;
  --control-base: 36px;
  --control-lg: 40px;
  --control-topbar: 32px;
  --touch: 44px;
  --badge-h: 20px;
  --row-h: 40px;
  --table-head-h: 40px;
  --sidebar-w: 260px;
  --sidebar-w-icon: 57px;
  --sidebar-header-h: 58px;
  --sidebar-footer-h: 48px;
  --nav-item-h: 34px;
  --topbar-h: 58px;
  --page-panel-w: 400px;
  --page-gutter: 32px;
  --page-gutter-mobile: 16px;
  --section-gap: 24px;
  --content-max: 1536px;
  --palette-w: 672px;
  --dialog-sm: 384px;
  --dialog-md: 512px;
  --dialog-lg: 768px;
}

/* White mode only (Ovidiu, 25 Oct 2026: "I got dark mode", after asking for white mode). No dark theme. */

/* =========================================================================================
   Base
   ========================================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--color-canvas);
  letter-spacing: var(--tracking-ui);
}
html.no-scroll { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-base);
  color: var(--text-default);
  background: var(--color-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
::selection { background: color-mix(in srgb, var(--color-brand) 22%, transparent); }
[hidden] { display: 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; }
.noscript { padding: var(--space-6); }

/* utilities */
.muted { color: var(--text-subtle); }
.small { font-size: var(--text-xs); line-height: var(--leading-xs); }
.strong { font-weight: var(--weight-medium); color: var(--text-strong); }
.truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 40ch; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.tone-danger { color: var(--text-danger); }
.tone-warning { color: var(--text-warning); }
.tone-success { color: var(--text-success); }
.link { color: var(--text-link); display: inline-flex; align-items: center; gap: var(--space-1); overflow-wrap: anywhere; min-width: 0; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.link-strong { font-weight: var(--weight-medium); color: var(--text-strong); }
.link-strong:hover { color: var(--text-link); }
.icon-inline { opacity: 0.7; }
.code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0;
  background: var(--color-canvas);
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
  padding: 1px var(--space-1);
}
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-1);
  border: 1px solid var(--color-fill);
  border-radius: var(--radius-sm);
  background: var(--color-canvas);
  color: var(--text-subtle);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  letter-spacing: 0;
}

/* =========================================================================================
   Boot and sign-in
   ========================================================================================= */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-mark { border-radius: 9px; animation: pulse 1.2s var(--ease-standard) infinite alternate; }
@keyframes pulse { from { opacity: 0.35; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--page-gutter-mobile);
  padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
}
.auth-card { width: 100%; max-width: 400px; padding: var(--space-8); border-radius: var(--radius-xl); }
.auth-head { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-6); }
.auth-mark { width: 48px; height: 48px; border-radius: var(--radius-xl); }
.auth-title { font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-title); color: var(--text-strong); }
.auth-text { color: var(--text-subtle); }
.auth-form, .auth-actions { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-status:not(:empty) { margin-top: var(--space-4); }
.auth-foot { display: flex; align-items: center; gap: var(--space-1-5); color: var(--text-subtle); font-size: var(--text-xs); }
@media (max-width: 639px) { .auth-card { padding: var(--space-6); } }

/* =========================================================================================
   Shell: sidebar 260 (rail 57), top bar 58, content with 32 px gutters
   ========================================================================================= */
.shell { min-height: 100dvh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-sidebar);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--color-canvas);
  border-right: 1px solid var(--color-line);
  padding-top: env(safe-area-inset-top);
}
.main-col { margin-left: var(--sidebar-w); min-width: 0; }
@media (min-width: 768px) {
  .is-animating .sidebar { transition: width var(--dur-4) var(--ease-sidebar); }
  .is-animating .main-col { transition: margin-left var(--dur-4) var(--ease-sidebar); }
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--sidebar-header-h);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-line);
  flex-shrink: 0;
}
.account {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
  height: 34px;
  padding: 0 var(--space-1-5);
  border-radius: var(--radius-lg);
  transition: background-color var(--dur-1) var(--ease-standard);
}
.account:hover { background: var(--color-recessed); }
.account-mark { width: 24px; height: 24px; border-radius: 6px; }
.account-name { font-size: var(--text-base); font-weight: var(--weight-bold); letter-spacing: -0.01em; color: var(--text-strong); white-space: nowrap; }
.account-tag {
  height: 20px;
  padding: 0 var(--space-1-5);
  border-radius: var(--radius-full);
  box-shadow: inset 0 0 0 1px var(--color-fill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 20px;
  color: var(--text-subtle);
}
.sidebar-top .drawer-close { display: none; margin-left: auto; }

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-3) 14px var(--space-4);
}
.sidebar-search-wrap { margin-bottom: var(--space-4); }
.sidebar-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 32px;
  padding: 0 var(--space-1-5) 0 var(--space-2-5);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--color-base);
  box-shadow: var(--shadow-card);
  color: var(--text-placeholder);
  font-size: var(--text-sm);
  text-align: left;
}
.sidebar-search:hover { color: var(--text-subtle); }
.sidebar-search .nav-label { flex: 1; }

.nav-group + .nav-group { margin-top: var(--space-5); }
.nav-group-label {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-medium);
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
}
.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  width: 100%;
  min-height: var(--nav-item-h);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-default);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-medium);
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--dur-4) var(--ease-standard), color var(--dur-4) var(--ease-standard);
}
.nav-item:hover { background: var(--color-recessed); }
.nav-item.is-active {
  color: #fff;
  background-color: #2363e9;
  background-image: var(--hopa-gradient);
  box-shadow: 0 0 0 1px var(--hopa-gradient-line), var(--hopa-gloss), var(--hopa-glow);
}
.nav-icon { color: var(--text-subtle); }
.nav-item.is-active .nav-icon { color: #fff; }
.nav-item.is-active .nav-badge { background: rgb(255 255 255 / 0.22); color: #fff; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--color-info-tint);
  color: var(--text-info);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--sidebar-footer-h);
  padding: 0 var(--space-3);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--color-line);
}
.collapse-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-subtle);
  transition: background-color var(--dur-1) var(--ease-standard);
}
.collapse-toggle:hover { background: var(--color-recessed); color: var(--text-default); }

/* icon rail (desktop only; the drawer below 768 px always shows labels) */
@media (min-width: 768px) {
  .is-collapsed { --sidebar-w: var(--sidebar-w-icon); }
  .is-collapsed .account-name, .is-collapsed .account-tag, .is-collapsed .nav-label,
  .is-collapsed .nav-group-label, .is-collapsed .sidebar-search .kbd { display: none; }
  .is-collapsed .sidebar-top { padding: 0 var(--space-2); justify-content: center; }
  .is-collapsed .account { flex: 0 0 auto; padding: 0 5px; }
  .is-collapsed .sidebar-body { padding: var(--space-3) var(--space-2); }
  .is-collapsed .sidebar-search { justify-content: center; padding: 0; }
  .is-collapsed .nav-item { justify-content: center; padding: 0; position: relative; }
  .is-collapsed .nav-badge { position: absolute; top: 5px; right: 6px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; background: var(--color-brand); }
  .is-collapsed .nav-group + .nav-group { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--color-hairline); }
  .is-collapsed .sidebar-footer { justify-content: center; padding: 0; }
  .is-collapsed .collapse-toggle .icon { transform: scaleX(-1); }
}

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  background: var(--color-canvas);
  border-bottom: 1px solid var(--color-line);
}
.menu-toggle, .topbar-brand, .topbar-search { display: none !important; }
.breadcrumbs { flex: 1; min-width: 0; }
.breadcrumbs ol { display: flex; align-items: center; gap: var(--space-0-5); min-width: 0; font-size: var(--text-base); }
.breadcrumbs li { display: flex; align-items: center; gap: var(--space-0-5); min-width: 0; }
.breadcrumbs a, .breadcrumbs span { display: inline-flex; align-items: center; gap: var(--space-1-5); white-space: nowrap; }
.breadcrumbs a { color: var(--text-subtle); border-radius: var(--radius-md); padding: 2px var(--space-1-5); }
.breadcrumbs a:hover { color: var(--text-default); background: var(--color-recessed); }
.breadcrumbs .is-current { min-width: 0; }
.breadcrumbs .is-current span { font-weight: var(--weight-medium); color: var(--text-default); padding: 2px var(--space-1-5); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.breadcrumbs .is-current:not(:first-child) .crumb-icon { display: none; }
.crumb-icon { color: var(--text-subtle); }
.crumb-sep { color: var(--text-inactive); width: 20px; height: 20px; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; }
.topbar .btn { height: var(--control-topbar); }
.topbar-link { padding: 0 var(--space-3) 0 var(--space-2-5); font-size: var(--text-sm); }
.user-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
}
.user-btn:hover { background: var(--color-recessed); }
.user-btn .avatar { border-radius: var(--radius-md); width: 26px; height: 26px; }

/* content */
.content {
  container: content / inline-size;
  max-width: calc(var(--content-max) + 2 * var(--page-gutter));
  padding: var(--space-8) var(--page-gutter) var(--space-12);
}
.page { display: flex; flex-direction: column; gap: var(--section-gap); }

/* drawer below 768 px (CF md) */
.scrim { display: none; }
@media (max-width: 767px) {
  .sidebar {
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-101%);
    visibility: hidden;
    transition: transform var(--dur-4) var(--ease-sidebar), box-shadow var(--dur-4) var(--ease-sidebar), visibility 0s linear var(--dur-4);
  }
  .drawer-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform var(--dur-4) var(--ease-sidebar), box-shadow var(--dur-4) var(--ease-sidebar); }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-backdrop);
    background: var(--backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-4) var(--ease-sidebar);
  }
  .drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .main-col { margin-left: 0; }
  .sidebar-top .drawer-close { display: inline-flex; }
  .sidebar-footer { display: none; }
  .nav-item { min-height: var(--touch); font-size: var(--text-base); }
  .sidebar-search { height: var(--touch); font-size: var(--text-base); }
  .sidebar-search .kbd { display: none; }
  .topbar {
    height: 56px;
    gap: var(--space-1);
    padding: 0 max(var(--space-2), env(safe-area-inset-right)) 0 max(var(--space-2), env(safe-area-inset-left));
  }
  .menu-toggle, .topbar-search { display: inline-flex !important; }
  .topbar-brand { display: inline-flex !important; align-items: center; padding: 0 var(--space-1); }
  .topbar-brand img { border-radius: 6px; }
  .topbar-link { display: none !important; }
  .topbar .btn-icon, .user-btn { width: var(--touch); height: var(--touch); }
  .breadcrumbs li:not(:last-child) { display: none; }
  .breadcrumbs .crumb-icon { display: none; }
  .content { padding: var(--space-5) var(--page-gutter-mobile) max(var(--space-12), env(safe-area-inset-bottom)); }
  .page { gap: var(--space-4); }
}

/* =========================================================================================
   Page header (list variant: title 30/36, subtitle 14/21 8 px under, 36 px to the content)
   ========================================================================================= */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-3); }
.page-heading { min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.page-title { font-size: var(--text-3xl); line-height: var(--leading-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-title); color: var(--text-strong); overflow-wrap: anywhere; }
.page-subtitle { color: var(--text-subtle); }
.page-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
@media (max-width: 767px) {
  .page-header { margin-bottom: 0; }
  .page-title { font-size: var(--text-2xl); line-height: var(--leading-2xl); }
}

/* =========================================================================================
   Buttons: sm 26, base 36, lg 40; radius 8 (sm 6)
   ========================================================================================= */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  height: var(--control-base);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  transition: background-color var(--dur-1) var(--ease-standard), color var(--dur-1) var(--ease-standard), box-shadow var(--dur-1) var(--ease-standard), filter var(--dur-1) var(--ease-standard);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.btn-sm { height: var(--control-sm); padding: 0 var(--space-2); gap: var(--space-1); border-radius: var(--radius-md); font-size: var(--text-xs); }
.btn-lg { height: var(--control-lg); padding: 0 var(--space-4); gap: var(--space-2); }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-base); padding: 0; }
.btn-icon.btn-sm { width: var(--control-sm); }
.btn-primary {
  color: #fff;
  background-color: #2363e9;
  background-image: var(--hopa-gradient);
  box-shadow: 0 0 0 1px var(--hopa-gradient-line), var(--hopa-gloss), var(--hopa-glow);
  transition: transform var(--dur-2, 0.2s) var(--ease-standard), box-shadow var(--dur-2, 0.2s) var(--ease-standard);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--hopa-gradient-line), var(--hopa-gloss), var(--hopa-glow-hover); }
.btn-primary:active:not(:disabled) { transform: none; filter: brightness(0.94); }
.btn-primary:focus-visible { box-shadow: 0 0 0 1px var(--hopa-gradient-line), var(--hopa-gloss), var(--focus-ring); }
@media (prefers-reduced-motion: reduce) { .btn-primary:hover:not(:disabled) { transform: none; } }
.btn-secondary { background: var(--color-base); color: var(--text-default); box-shadow: var(--shadow-card); }
.btn-secondary:hover:not(:disabled) { background: var(--color-tint); }
.btn-secondary:focus-visible { box-shadow: var(--ring), var(--focus-ring); }
.btn-ghost { background: transparent; color: var(--text-default); }
.btn-ghost:hover:not(:disabled) { background: var(--color-tint); }
.btn-danger {
  color: #fff;
  background-color: color-mix(in oklch, var(--color-danger), white 18%);
  background-image: linear-gradient(180deg, color-mix(in oklch, var(--color-danger), white 10%), var(--color-danger));
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--color-danger), black 12%), var(--shadow-xs);
}
.btn-danger:hover:not(:disabled) { filter: brightness(0.95); }
.btn-danger-ghost { background: var(--color-base); color: var(--text-danger); box-shadow: var(--shadow-card); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--color-danger-tint); }
.btn.is-busy { cursor: progress; }
.btn.is-busy .icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
@media (pointer: coarse), (max-width: 767px) {
  .btn { height: var(--touch); padding: 0 var(--space-4); }
  .btn-sm { height: 36px; padding: 0 var(--space-3); font-size: var(--text-sm); }
  .btn-icon { width: var(--touch); padding: 0; }
  .btn-icon.btn-sm { width: 36px; }
}

/* =========================================================================================
   Badges (20 px pill, 12/550, tint fill and status text), chips, avatar
   ========================================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--badge-h);
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: var(--badge-bg, var(--color-fill));
  color: var(--badge-fg, var(--text-default));
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  vertical-align: middle;
  letter-spacing: 0;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { --badge-fg: var(--text-default); --badge-bg: var(--color-recessed); box-shadow: inset 0 0 0 1px var(--color-fill); }
.badge-neutral .badge-dot { background: var(--text-subtle); }
.badge-success { --badge-fg: var(--text-success); --badge-bg: var(--color-success-tint); }
.badge-warning { --badge-fg: var(--text-warning); --badge-bg: var(--color-warning-tint); }
.badge-danger { --badge-fg: var(--text-danger); --badge-bg: var(--color-danger-tint); }
.badge-info { --badge-fg: var(--text-info); --badge-bg: var(--color-info-tint); }
.badge-accent { --badge-fg: var(--text-night); --badge-bg: var(--color-night-tint); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); margin-top: var(--space-1); }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); color: var(--text-subtle); }
.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--blue-900) 0%, var(--blue-500) 55%, var(--lilac-300) 100%);
  color: #fff;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }

/* =========================================================================================
   Cards: white, radius 8, 1 px ring and xs shadow; header bar on the canvas, title 14/550
   ========================================================================================= */
.card {
  background: var(--color-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-width: 0;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 40px;
  padding: var(--space-1-5) var(--space-4);
  background: var(--color-canvas);
  border-bottom: 1px solid var(--color-line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-heading { min-width: 0; }
.card-title { font-size: var(--text-base); line-height: var(--leading-base); font-weight: var(--weight-medium); color: var(--text-strong); }
.card-subtitle { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-subtle); }
.card-actions { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }
.card-body { padding: var(--space-4); }
.card-flush > .card-body { padding: 0; }
.card-table { overflow: hidden; }
.card-toolbar { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-fill); display: flex; align-items: center; gap: var(--space-3); overflow-x: auto; }

/* stat cards: label 12/16 subtle, value 24/32 semibold */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); }
.stats-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.stat-link { transition: box-shadow var(--dur-1) var(--ease-standard); }
.stat-link:hover { box-shadow: var(--ring), var(--shadow-md); }
.stat-label { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-subtle); font-weight: var(--weight-medium); }
.stat-value { font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-semibold); color: var(--text-strong); letter-spacing: var(--tracking-title); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-value.tone-danger { color: var(--text-danger); }
.stat-value.tone-warning { color: var(--text-warning); }
.stat-hint { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-subtle); }
@media (max-width: 639px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { padding: var(--space-3); }
}

.grid-3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@container content (min-width: 640px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container content (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.section + .section { margin-top: var(--space-4); }
.section-title { margin-bottom: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium); color: var(--text-subtle); }

/* =========================================================================================
   Chart and bar lists
   ========================================================================================= */
.card-chart { background: var(--color-elevated); }
.card-chart > .card-header { background: transparent; border-bottom: 0; padding-top: var(--space-3); }
.card-chart > .card-body { padding-top: 0; }
.chart { display: flex; flex-direction: column; gap: var(--space-2); }
.chart-readout { font-size: var(--text-sm); color: var(--text-subtle); min-height: 20px; }
.chart-readout strong { color: var(--text-strong); font-weight: var(--weight-semibold); }
.chart-frame { display: grid; grid-template-columns: 22px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: var(--space-2); height: 168px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--text-subtle); text-align: right; font-variant-numeric: tabular-nums; margin: -7px 0; }
.chart-plot { position: relative; min-width: 0; min-height: 0; }
.chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-axis { stroke: var(--chart-grid); stroke-width: 1; }
.chart-bar { fill: var(--chart-1); transition: fill var(--dur-1) var(--ease-standard); }
.chart-bar.is-today { fill: var(--chart-today); }
.chart-hit { fill: transparent; }
.chart-col { outline: none; }
.chart-col:hover .chart-bar, .chart-col:focus .chart-bar { fill: var(--chart-1-hover); }
.chart-col:hover .chart-hit, .chart-col:focus .chart-hit { fill: color-mix(in srgb, var(--color-brand) 7%, transparent); }
.chart-x { display: flex; justify-content: space-between; padding-left: 30px; font-size: 11px; color: var(--text-subtle); }

.bar-list { display: flex; flex-direction: column; gap: var(--space-0-5); }
.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label count" "track track";
  gap: var(--space-1) var(--space-2);
  padding: var(--space-1-5) var(--space-2);
  margin: 0 calc(-1 * var(--space-2));
  border-radius: var(--radius-md);
  min-height: 40px;
}
a.bar-row { transition: background-color var(--dur-1) var(--ease-standard); }
a.bar-row:hover { background: var(--color-tint); }
.bar-label { grid-area: label; font-size: var(--text-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-count { grid-area: count; font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.bar-track { grid-area: track; height: 4px; border-radius: var(--radius-full); background: var(--color-recessed); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--chart-1); min-width: 2px; }

/* =========================================================================================
   Lists inside cards (rows split by 1 px lines)
   ========================================================================================= */
.list { display: flex; flex-direction: column; }
.list-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(0, 1.4fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2-5) var(--space-4);
  border-bottom: 1px solid var(--color-fill);
}
.list-row:last-child { border-bottom: 0; }
.list-when, .list-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-main { align-items: flex-start; }
.list-side { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }
.grid-3 .list-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "when side" "main main"; row-gap: var(--space-1); }
.grid-3 .list-when { grid-area: when; }
.grid-3 .list-main { grid-area: main; }
.grid-3 .list-side { grid-area: side; }
@container content (max-width: 639px) {
  .list-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "when side" "main main"; }
  .list-when { grid-area: when; }
  .list-main { grid-area: main; }
  .list-side { grid-area: side; }
}
.load-more { display: flex; justify-content: center; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-fill); }

/* =========================================================================================
   Inputs: 36 px, radius 8, 1 px ring; focus adds a 1.5 px ring of the focus colour at 50%
   ========================================================================================= */
.field { display: flex; flex-direction: column; gap: var(--space-1-5); min-width: 0; }
.field-label { font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium); color: var(--text-default); }
.field-hint { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-subtle); }
.input, .select, .textarea {
  width: 100%;
  height: var(--control-base);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-lg);
  background-color: var(--color-base);
  box-shadow: var(--ring);
  color: var(--text-default);
  font-size: var(--text-base);
  min-width: 0;
  transition: box-shadow var(--dur-1) var(--ease-standard);
}
.input::placeholder, .textarea::placeholder { color: var(--text-placeholder); }
.input:hover, .select:hover, .textarea:hover { box-shadow: 0 0 0 1px var(--color-interact); }
.input:focus, .select:focus, .textarea:focus,
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { box-shadow: var(--ring), var(--focus-ring-input); }
.textarea { height: auto; min-height: 84px; padding: var(--space-2) var(--space-3); line-height: var(--leading-base); resize: vertical; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("assets/select-chevron.svg");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.select-sm { height: var(--control-sm); border-radius: var(--radius-md); padding: 0 26px 0 var(--space-2); font-size: var(--text-xs); width: auto; background-position: right 8px center; }
.input-affix { display: flex; align-items: stretch; box-shadow: var(--ring); border-radius: var(--radius-lg); background: var(--color-base); }
.input-affix:focus-within { box-shadow: var(--ring), var(--focus-ring-input); }
.input-affix .affix { display: grid; place-items: center; padding: 0 var(--space-3); background: var(--color-canvas); border-right: 1px solid var(--color-line); border-radius: var(--radius-lg) 0 0 var(--radius-lg); color: var(--text-subtle); }
.input-affix .input, .input-affix .input:hover, .input-affix .input:focus { box-shadow: none; border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
.form-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.form-status { flex: 1; min-width: 0; }
.inline-form { display: flex; flex-direction: column; gap: var(--space-3); max-width: 480px; }
.inline-error { display: flex; align-items: flex-start; gap: var(--space-1-5); color: var(--text-danger); font-size: var(--text-sm); line-height: 18px; }
.inline-error .icon { margin-top: 1px; }
@media (pointer: coarse), (max-width: 767px) {
  .input, .select { height: var(--touch); font-size: var(--text-lg); }
  .textarea { font-size: var(--text-lg); }
  .select-sm { height: 36px; font-size: var(--text-lg); }
}
@container content (max-width: 479px) { .form-row { grid-template-columns: 1fr; } }

/* =========================================================================================
   Toolbar above a table (CF: search up to 500 px, then controls 8 px apart)
   ========================================================================================= */
.toolbar, .filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.page > .toolbar, .page > .filter-bar { margin-bottom: calc(-1 * var(--space-2)); }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.toolbar-right { margin-left: auto; }
.filter-search { position: relative; flex: 1 1 280px; max-width: 500px; margin-right: var(--space-1); }
.filter-search .input-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.input-search { padding-left: 34px; }
.filter-fields { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.filter-fields .select { width: auto; min-width: 132px; }
.filter-source .input { width: 150px; }
.filter-dates { display: flex; align-items: center; gap: var(--space-1-5); }
.filter-dates .input { width: 150px; }
@media (max-width: 767px) {
  .filter-search { flex-basis: 100%; max-width: none; margin-right: 0; }
  .filter-fields { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .filter-fields .select, .filter-source .input { width: 100%; min-width: 0; }
  .filter-dates { grid-column: 1 / -1; }
  .filter-dates .input { flex: 1; width: auto; }
  .filter-fields > .btn { grid-column: 1 / -1; }
}

/* =========================================================================================
   Tables: head 40 (white, 14/650), rows 40, cell padding 0 12, 1 px lines, hover canvas
   ========================================================================================= */
.results { position: relative; transition: opacity var(--dur-2) var(--ease-standard); }
.results.is-loading { opacity: 0.55; pointer-events: none; }
.results > .loading { padding: var(--space-4); }
.results > .empty { padding: var(--space-10) var(--space-6); }
.table-summary {
  display: flex;
  align-items: center;
  min-height: 37px;
  padding: var(--space-2) var(--space-4);
  background: var(--color-canvas);
  border-bottom: 1px solid var(--color-line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  color: var(--text-subtle);
  font-size: var(--text-base);
}
.table-summary:empty, .table-summary:has(> :empty:only-child) { display: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-base); }
.table th {
  height: var(--table-head-h);
  padding: 0 var(--space-3);
  background: var(--color-base);
  border-bottom: 1px solid var(--color-fill);
  color: var(--text-strong);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  text-align: left;
  white-space: nowrap;
}
.table th:first-child, .table td:first-child { padding-left: var(--space-4); }
.table th:last-child, .table td:last-child { padding-right: var(--space-4); }
.table td {
  height: var(--row-h);
  padding: var(--space-1-5) var(--space-3);
  border-bottom: 1px solid var(--color-fill);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur-1) var(--ease-standard); }
.table tbody tr:hover { background: var(--color-canvas); }
.table .row-link { cursor: pointer; }
.table .align-end { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { width: 1%; white-space: nowrap; }
.table .col-name { min-width: 240px; }
.name-cell { display: flex; align-items: center; gap: var(--space-2-5); min-width: 0; }
.name-text { min-width: 0; max-width: 300px; }
.person-cell { min-width: 0; max-width: 300px; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--color-fill);
  font-size: var(--text-sm);
}
.pagination-count { color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.pagination-controls { display: flex; align-items: center; gap: var(--space-4); }
.pagination-size { display: flex; align-items: center; gap: var(--space-2); color: var(--text-subtle); }
.pager { display: inline-flex; align-items: stretch; height: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); background: var(--color-base); }
.pager-btn { display: grid; place-items: center; width: 36px; padding: 0; border: 0; border-right: 1px solid var(--color-line); background: transparent; color: var(--text-default); }
.pager-btn:first-child { border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.pager-btn:last-child { border-right: 0; border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
.pager-btn:hover:not(:disabled) { background: var(--color-tint); }
.pager-btn:disabled { background: var(--color-canvas); color: var(--text-inactive); cursor: not-allowed; }
.pager-btn:focus-visible { position: relative; z-index: 1; }
.pager-page { display: grid; place-items: center; min-width: 54px; padding: 0 var(--space-2); border-right: 1px solid var(--color-line); font-variant-numeric: tabular-nums; color: var(--text-default); font-size: var(--text-sm); }

/* Under 720 px of content a row becomes a card: the first cell is the title, the rest label and value. */
@container content (max-width: 719px) {
  .table, .table tbody { display: block; }
  .table thead { display: none; }
  .table tr { display: flex; flex-direction: column; gap: var(--space-1-5); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-fill); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); height: auto; min-height: 24px; padding: 0 !important; border: 0; min-width: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--text-subtle); font-size: var(--text-sm); text-align: left; flex-shrink: 0; }
  .table td > * { min-width: 0; }
  .table td.cell-primary { justify-content: flex-start; text-align: left; margin-bottom: var(--space-1); }
  .table td.cell-primary::before { display: none; }
  .table td.col-actions { width: auto; justify-content: flex-end; }
  .table td.col-actions::before { display: none; }
  .table td.hide-mobile { display: none; }
  .table td:empty { display: none; }
  .table .col-name { min-width: 0; }
  .name-text, .person-cell { max-width: none; }
  .table-footer { justify-content: center; }
  .pagination-count { width: 100%; text-align: center; }
  .pagination-size { display: none; }
}
@media (pointer: coarse), (max-width: 767px) {
  .pager { height: var(--touch); }
  .pager-btn { width: var(--touch); }
}

/* =========================================================================================
   Segmented tabs: track 36 (recessed, radius 8, padding 0 2), items 32 (radius 6, 14/550)
   ========================================================================================= */
.tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 0 2px;
  border-radius: var(--radius-lg);
  background: var(--color-recessed);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-fill) 70%, transparent);
  flex-shrink: 0;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  height: 32px;
  padding: 0 var(--space-2-5);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-subtle);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  transition: background-color var(--dur-3) var(--ease-standard), color var(--dur-3) var(--ease-standard), box-shadow var(--dur-3) var(--ease-standard);
}
.tab:hover { color: var(--text-default); }
.tab.is-active { background: var(--color-base); color: var(--text-strong); box-shadow: var(--ring), var(--shadow-xs); }
.tab-count { font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
@media (pointer: coarse), (max-width: 767px) {
  .tabs { height: var(--touch); }
  .tab { height: 40px; padding: 0 var(--space-3); }
}

/* =========================================================================================
   States: empty (title 16/650, text 14 subtle), error, skeleton
   ========================================================================================= */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-8) var(--space-6); }
.page > .empty { background: var(--color-control); box-shadow: var(--ring); border-radius: var(--radius-xl); padding: var(--space-16) var(--space-10); }
.empty-icon { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: var(--space-1); border-radius: var(--radius-lg); background: var(--color-recessed); color: var(--text-subtle); }
.empty-title { font-size: var(--text-lg); line-height: var(--leading-lg); font-weight: var(--weight-semibold); color: var(--text-strong); }
.empty-text { color: var(--text-subtle); max-width: 560px; overflow-wrap: anywhere; text-wrap: balance; }
.empty .btn { margin-top: var(--space-2); }
.empty-error .empty-icon { color: var(--text-danger); background: var(--color-danger-tint); }
.loading { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4) 0; }
.skeleton { height: 14px; width: 72%; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--color-recessed) 0%, var(--color-fill) 50%, var(--color-recessed) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton-wide { width: 38%; height: 24px; }
.skeleton:nth-child(3n) { width: 56%; }
.skeleton:nth-child(4n) { width: 86%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* key-value list: label subtle, value beside it, rows split by 1 px lines */
.kv { display: flex; flex-direction: column; }
.kv-row { display: grid; grid-template-columns: minmax(96px, 34%) minmax(0, 1fr); gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--color-fill); }
.kv-row:first-child { padding-top: 0; }
.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv dt { color: var(--text-subtle); font-weight: var(--weight-medium); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.block + .block { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-line); }
.block-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-2); }

/* =========================================================================================
   Person page: main column and a 400 px panel when the content is 880 px or wider
   ========================================================================================= */
.person-header { align-items: flex-start; }
.person-id { display: flex; gap: var(--space-4); min-width: 0; flex: 1; }
.person-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.contact-list { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.contact-list li { display: flex; align-items: center; gap: var(--space-1-5); min-width: 0; color: var(--text-subtle); }
.contact-list .link { min-height: 28px; }
.detail-grid { display: flex; flex-direction: column; gap: var(--space-4); }
.detail-main, .detail-side { display: contents; }
.card-deal { order: 1; }
.detail-main > :nth-child(1) { order: 2; }
.card-notes { order: 3; }
.detail-main > :nth-child(2) { order: 4; }
.detail-main > :nth-child(3) { order: 5; }
.detail-main > :nth-child(n + 4) { order: 6; }
.detail-side > :last-child { order: 7; }
@container content (min-width: 880px) {
  .detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--page-panel-w); gap: var(--section-gap); align-items: start; }
  .detail-main, .detail-side { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
}
@container content (max-width: 639px) {
  .person-id { gap: var(--space-3); }
  .person-header .page-actions { width: 100%; }
  .person-header .page-actions .btn { flex: 1; }
}
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); position: relative; padding-bottom: var(--space-4); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:not(:last-child)::after { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: 2px; width: 1px; background: var(--color-fill); }
.timeline-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--color-canvas); box-shadow: var(--ring); color: var(--text-subtle); }
.timeline-body { display: flex; flex-direction: column; gap: 2px; padding-top: 3px; min-width: 0; }
.timeline-title { font-weight: var(--weight-medium); color: var(--text-strong); }
.notes { display: flex; flex-direction: column; margin-top: var(--space-4); }
.note { padding: var(--space-3) 0; border-top: 1px solid var(--color-fill); }
.note:last-child { padding-bottom: 0; }
.note-body { color: var(--text-default); }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-1); }

/* free videos */
.requests { display: flex; flex-direction: column; }
.request { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--color-fill); }
.request:last-child { border-bottom: 0; }
.request-who, .request-when { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; align-items: flex-start; }
.request-action { min-width: 0; }
.send-form { display: flex; flex-direction: column; gap: var(--space-2); }
@container content (min-width: 880px) { .request { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.8fr) minmax(0, 1.4fr); gap: var(--space-4); } }

/* =========================================================================================
   Overlays: dialog (radius 12, 384 / 512 / 768), palette (672, top 89), menu (pad 6), toast
   ========================================================================================= */
dialog { color: var(--text-default); }
.modal {
  width: min(var(--dialog-md), calc(100vw - 32px));
  max-height: calc(100dvh - 128px);
  margin: 64px auto auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--color-base);
  box-shadow: var(--ring), var(--shadow-dialog);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal:not([open]) { display: none; }
.modal-sm { width: min(var(--dialog-sm), calc(100vw - 32px)); }
.modal-lg { width: min(var(--dialog-lg), calc(100vw - 32px)); height: calc(100dvh - 128px); }
.modal::backdrop, .palette::backdrop { background: var(--backdrop); }
.palette::backdrop { background: color-mix(in srgb, var(--color-canvas) 80%, transparent); }
.modal[open], .palette[open] { animation: pop var(--dur-2) var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5); }
.modal-title { font-size: var(--text-lg); line-height: var(--leading-lg); font-weight: var(--weight-semibold); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 0 var(--space-5) var(--space-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3); flex: 1; min-height: 0; }
.modal-body > p { color: var(--text-subtle); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-line); background: var(--color-canvas); }
.modal-lg .modal-header { border-bottom: 1px solid var(--color-line); }
.modal-lg .modal-body { padding: 0; }
.preview-frame { width: 100%; height: 100%; min-height: 360px; border: 0; background: #fff; display: block; }
@media (max-width: 639px) {
  .modal, .modal-sm, .modal-lg { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-lg { height: 92dvh; }
  .modal-footer { padding-bottom: max(var(--space-3), env(safe-area-inset-bottom)); }
  .modal-footer .btn { flex: 1; }
}

.palette {
  width: min(var(--palette-w), calc(100vw - 32px));
  margin: 89px auto auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--color-base);
  box-shadow: var(--ring), var(--shadow-lg);
  overflow: hidden;
}
.palette-field { display: flex; align-items: center; gap: var(--space-3); height: 47px; padding: 0 var(--space-4); border-bottom: 1px solid var(--color-line); color: var(--text-subtle); }
.palette-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: var(--text-base); color: var(--text-default); }
.palette-input::placeholder { color: var(--text-placeholder); }
.palette-input:focus, .palette-input:focus-visible { box-shadow: none; }
.palette-input::-webkit-search-cancel-button { display: none; }
.palette-list { max-height: min(440px, 56dvh); overflow-y: auto; padding: var(--space-2); }
.palette-group { padding: var(--space-1) var(--space-2); font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-subtle); font-weight: var(--weight-semibold); }
.palette-group:not(:first-child) { margin-top: var(--space-2); }
.palette-item { display: flex; align-items: center; gap: var(--space-3); min-height: 36px; padding: var(--space-1-5) var(--space-2); border-radius: var(--radius-lg); cursor: pointer; color: var(--text-subtle); }
.palette-item.is-active { background: var(--color-recessed); }
.palette-label { color: var(--text-default); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-sub { flex: 1; font-size: var(--text-sm); color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-empty { padding: var(--space-6); text-align: center; color: var(--text-subtle); }
.palette-foot { display: flex; align-items: center; gap: var(--space-4); height: 44px; padding: 0 var(--space-4); border-top: 1px solid var(--color-line); background: var(--color-elevated); font-size: var(--text-xs); color: var(--text-subtle); }
.palette-foot span { display: inline-flex; align-items: center; gap: var(--space-1); }
@media (max-width: 639px) {
  .palette { margin-top: var(--space-4); }
  .palette-input { font-size: var(--text-lg); }
  .palette-item { min-height: var(--touch); }
  .palette-foot { display: none; }
}

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  z-index: var(--z-popover);
  min-width: 220px;
  padding: var(--space-1-5);
  border-radius: var(--radius-lg);
  background: var(--color-control);
  box-shadow: var(--shadow-popover);
  animation: pop var(--dur-2) var(--ease-out);
  transform-origin: top right;
}
.menu-end { right: 0; }
.menu-start { left: 0; transform-origin: top left; }
.menu-item { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 33px; padding: var(--space-1-5) var(--space-2); border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-default); font-size: var(--text-base); text-align: left; }
.menu-item .icon { color: var(--text-subtle); }
.menu-item:hover, .menu-item:focus-visible { background: var(--color-tint); box-shadow: none; }
.menu-item.tone-danger, .menu-item.tone-danger .icon { color: var(--text-danger); }
.menu-divider { height: 1px; margin: var(--space-1) calc(-1 * var(--space-1-5)); background: var(--color-hairline); }
@media (pointer: coarse), (max-width: 767px) { .menu-item { min-height: var(--touch); } }

.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: max(var(--space-4), env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-control);
  color: var(--text-default);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-popover);
  animation: toast-in var(--dur-5) var(--ease-toast);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(150%); } to { opacity: 1; transform: none; } }
.toast .icon { color: var(--text-subtle); }
.toast-success .icon { color: var(--color-success); }
.toast-danger .icon { color: var(--color-danger); }
.toast-warning .icon { color: var(--color-warning); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--dur-4) var(--ease-in), transform var(--dur-4) var(--ease-in); }
@media (max-width: 639px) { .toasts { left: var(--space-4); right: var(--space-4); max-width: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* deal card: the stage hint and its reset link */
.stage-hint { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-1) var(--space-2); margin-top: calc(-1 * var(--space-1)); }
.stage-hint .btn { margin-left: calc(-1 * var(--space-2)); }

/* forms that sit inside a card body: the button stays at the left, under the fields */
.inline-form .form-actions { justify-content: flex-start; }
.inline-form .form-actions .btn { order: -1; }
.kv + .button-row { margin-top: var(--space-4); }

/* the page title takes focus after each route change, for screen readers; it needs no visible ring */
.page-title:focus, .page-title:focus-visible { box-shadow: none; outline: none; }
