/* ==========================================================================
   Arrival design system
   Tokens → base → layout → components → pages. --brand is set per tenant.
   ========================================================================== */

:root {
  --brand: #4f46e5;
  --brand-fg: #fff;
  --brand-soft: color-mix(in oklab, var(--brand) 10%, transparent);
  --brand-ring: color-mix(in oklab, var(--brand) 35%, transparent);

  --bg: #fafafa;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, color-mix(in oklab, var(--brand) 6%, transparent), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f6f6f7;
  --surface-3: #efeff1;
  --overlay: rgba(9, 9, 11, .45);
  --border: #e7e7ea;
  --border-strong: #d6d6db;
  --text: #0b0b0f;
  --text-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;

  --green: #059669; --green-soft: #ecfdf5; --green-border: #a7f3d0;
  --blue: #2563eb; --blue-soft: #eff6ff; --blue-border: #bfdbfe;
  --amber: #b45309; --amber-soft: #fffbeb; --amber-border: #fde68a;
  --red: #dc2626; --red-soft: #fef2f2; --red-border: #fecaca;
  --gray-soft: #f4f4f5;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgba(16, 16, 20, .04);
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, .05), 0 1px 3px rgba(16, 16, 20, .04);
  --shadow: 0 1px 2px rgba(16, 16, 20, .04), 0 4px 12px -2px rgba(16, 16, 20, .06);
  --shadow-lg: 0 2px 4px rgba(16, 16, 20, .04), 0 16px 40px -8px rgba(16, 16, 20, .16);
  --ring: 0 0 0 3px var(--brand-ring);

  --sidebar-w: 252px;
  --topbar-h: 60px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

/* Dark theme: data-theme is set before paint by an inline script (stored choice, else OS preference). */
:root[data-theme="dark"] {
  --bg: #08080a;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, color-mix(in oklab, var(--brand) 14%, transparent), transparent 60%);
  --surface: #111114;
  --surface-2: #17171b;
  --surface-3: #1f1f24;
  --overlay: rgba(0, 0, 0, .6);
  --border: #232329;
  --border-strong: #303037;
  --text: #f4f4f5;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #6b6b74;
  --brand-soft: color-mix(in oklab, var(--brand) 18%, transparent);
  --green: #34d399; --green-soft: rgba(16, 185, 129, .12); --green-border: rgba(16, 185, 129, .3);
  --blue: #60a5fa; --blue-soft: rgba(59, 130, 246, .12); --blue-border: rgba(59, 130, 246, .3);
  --amber: #fbbf24; --amber-soft: rgba(245, 158, 11, .12); --amber-border: rgba(245, 158, 11, .3);
  --red: #f87171; --red-soft: rgba(239, 68, 68, .12); --red-border: rgba(239, 68, 68, .3);
  --gray-soft: #1f1f24;
  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px -2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 50px -10px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
/* Component display rules (flex/grid) would otherwise override the hidden attribute that JS toggles. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01", "ss03";
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; font-weight: 600; line-height: 1.2; }
h1 { font-size: 24px; letter-spacing: -.025em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
::selection { background: var(--brand-soft); }
.icon { flex-shrink: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: 0; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tabular { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 12px; }
.row-sm { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.text-sm { font-size: 13px; } .text-xs { font-size: 12px; } .text-lg { font-size: 16px; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; }
.center { text-align: center; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------------------------------------------------------------- app shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 14px 12px;
  border-right: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  backdrop-filter: blur(12px);
  z-index: 30;
}
.workspace {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; margin-bottom: 14px;
  border-radius: var(--radius);
  cursor: pointer; list-style: none;
  transition: background .15s;
}
.workspace::-webkit-details-marker { display: none; }
.workspace:hover { background: var(--surface-3); }
.workspace-logo {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-fg);
  font-weight: 700; font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 1px 2px rgba(0,0,0,.15);
  overflow: hidden;
}
.workspace-logo img { width: 100%; height: 100%; object-fit: cover; }
.workspace-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.workspace-plan { font-size: 11.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: 11px; font-weight: 500; color: var(--faint);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 16px 10px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-link .icon { color: var(--muted); transition: color .12s; }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.nav-link.active .icon { color: var(--brand); }
.nav-link .count {
  margin-left: auto; font-size: 11.5px; font-weight: 600;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--surface-3); color: var(--muted);
}
.nav-link .count.live { background: var(--green-soft); color: var(--green); }
.nav-link.danger .icon { color: var(--red); }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.trial-card {
  margin: 0 2px 12px; padding: 12px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-soft), transparent);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.trial-bar { height: 4px; border-radius: 4px; background: var(--surface-3); margin: 8px 0; overflow: hidden; }
.trial-bar span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius);
  cursor: pointer; list-style: none;
}
.user-chip::-webkit-details-marker { display: none; }
.user-chip:hover { background: var(--surface-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: color-mix(in oklab, var(--bg) 75%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.crumbs a:hover { color: var(--text); }
.crumbs .current { color: var(--text); }
.search-trigger {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  height: 34px; width: 260px; padding: 0 8px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--faint);
  font: inherit; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger .kbd { margin-left: auto; }
.kbd {
  display: inline-flex; align-items: center; gap: 2px;
  height: 20px; padding: 0 6px;
  font: 500 11px var(--font); color: var(--muted);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface-2);
}
.icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--muted); background: none; border: 0; cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.dot {
  position: absolute; top: 6px; right: 6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.dot:empty, .dot[data-count="0"] { display: none; }
.content { padding: 8px 28px 64px; width: 100%; max-width: 1280px; margin: 0 auto; }
.content.narrow { max-width: 880px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 18px 0 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.mobile-only { display: none; }

.platform-banner {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 28px; font-size: 13px; font-weight: 500;
  background: var(--text); color: var(--bg);
}
.platform-banner > form, .platform-banner > .btn { margin-left: auto; }
.platform-banner.amber { background: var(--amber-soft); color: var(--amber); border-bottom: 1px solid var(--amber-border); }
.platform-banner + .topbar { top: 38px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  --_bg: var(--surface); --_fg: var(--text); --_bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  font: 500 13.5px/1 var(--font); letter-spacing: -.005em;
  color: var(--_fg); background: var(--_bg);
  border: 1px solid var(--_bd); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .08s, opacity .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn .icon { margin: 0 -2px; }
.btn-primary {
  --_bg: var(--brand); --_fg: var(--brand-fg); --_bd: transparent;
  background-image: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,0));
  box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.18), 0 0 0 1px color-mix(in oklab, var(--brand) 80%, black);
}
.btn-primary:hover { background-color: color-mix(in oklab, var(--brand) 90%, black); border-color: transparent; }
.btn-dark { --_bg: var(--text); --_fg: var(--bg); --_bd: transparent; }
.btn-dark:hover { background: color-mix(in oklab, var(--text) 88%, var(--bg)); }
.btn-ghost { --_bg: transparent; --_bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger { --_fg: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red-border); }
.btn-success { --_bg: var(--green); --_fg: #fff; --_bd: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px 0;
}
.card-head h2 { font-size: 14.5px; }
.card-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-link { font-size: 13px; font-weight: 500; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.card-link:hover { color: var(--text); }
.card.flush .card-body { padding: 0; }
.card.inset { background: var(--surface-2); box-shadow: none; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid-main-l { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }

/* ---------------------------------------------------------------- stat tiles */
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.stat-value { font-size: 30px; font-weight: 600; letter-spacing: -.035em; margin-top: 12px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.stat.live .stat-icon { background: var(--green-soft); color: var(--green); border-color: var(--green-border); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); position: relative; display: inline-block; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: var(--green); opacity: .35; animation: pulse 2s var(--ease) infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .5; } 100% { transform: scale(1.8); opacity: 0; } }
.delta { font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.delta.up { color: var(--green); background: var(--green-soft); }
.delta.down { color: var(--red); background: var(--red-soft); }

/* ---------------------------------------------------------------- chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; position: relative; }
.bar-fill {
  width: 100%; max-width: 28px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 85%, white), var(--brand));
  opacity: .9; transition: opacity .15s, transform .3s var(--ease);
  transform-origin: bottom; animation: grow .7s var(--ease) both;
}
.bar.weekend .bar-fill { opacity: .35; }
.bar.today .bar-fill { opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-ring); }
.bar.today .bar-label { color: var(--text); font-weight: 600; }
.bar:hover .bar-fill { opacity: 1; }
.bar-label { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.bar-tip {
  position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--text); color: var(--bg); font-size: 11.5px; font-weight: 500;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.bar:hover .bar-tip { opacity: 1; transform: translateX(-50%) translateY(0); }
@keyframes grow { from { transform: scaleY(0); } }

.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; gap: 2px; }
.meter span { display: block; height: 100%; }
.legend { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ---------------------------------------------------------------- badges / pills */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.green { background: var(--green-soft); color: var(--green); border-color: var(--green-border); }
.badge.blue { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-border); }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-border); }
.badge.red { background: var(--red-soft); color: var(--red); border-color: var(--red-border); }
.badge.gray { color: var(--muted); }
.type-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-2);
  padding: 2px 8px 2px 6px; border-radius: 6px;
  background: color-mix(in oklab, var(--c) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--c) 22%, transparent);
}
.type-tag::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }

/* ---------------------------------------------------------------- avatars */
.avatar {
  --hue: 234;
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
  color: hsl(var(--hue) 55% 32%);
  background: linear-gradient(135deg, hsl(var(--hue) 85% 92%), hsl(var(--hue) 70% 85%));
  box-shadow: inset 0 0 0 1px hsl(var(--hue) 40% 50% / .12);
  overflow: hidden;
}
[data-theme="dark"] .avatar { color: hsl(var(--hue) 80% 85%); background: linear-gradient(135deg, hsl(var(--hue) 35% 26%), hsl(var(--hue) 35% 20%)); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-xl { width: 88px; height: 88px; font-size: 28px; border-radius: 22px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  border-top: 1px solid var(--border);
  transition: background .12s;
}
.list-item:first-child { border-top: 0; }
a.list-item:hover, .list-item.hover:hover { background: var(--surface-2); }
.list-title { font-weight: 500; font-size: 13.5px; }
.list-sub { font-size: 12.5px; color: var(--muted); }
.list-meta { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 26px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .t-dot { position: absolute; left: 0; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline .t-dot.green { border-color: var(--green); background: var(--green-soft); }
.timeline .t-dot.blue { border-color: var(--blue); background: var(--blue-soft); }
.timeline .t-dot.red { border-color: var(--red); background: var(--red-soft); }
.timeline time { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 10px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th:first-child { border-top-left-radius: var(--radius-lg); }
.table th:last-child { border-top-right-radius: var(--radius-lg); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person-name { font-weight: 500; }
.person-sub { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- tabs / segmented / filters */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 12px; margin-bottom: -1px;
  font-weight: 500; font-size: 13.5px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab .count { font-size: 11.5px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); color: var(--muted); line-height: 18px; }
.tab.active .count { background: var(--text); color: var(--bg); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-3); }
.segmented a, .segmented label {
  padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s;
}
.segmented a.active, .segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input { display: none; }
.segmented label span { display: block; padding: 5px 12px; margin: -5px -12px; border-radius: 7px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input-icon { flex: 1; min-width: 220px; max-width: 360px; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field, .form-grid + .field, .field + .form-grid { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.form-grid > .field, .form-grid > div > .field { margin-top: 0; }
.form-grid .span-2 { grid-column: span 2; }
.label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.label .opt { color: var(--faint); font-weight: 400; }
.help { font-size: 12.5px; color: var(--muted); }
.error { font-size: 12.5px; color: var(--red); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]),
.field select, .field textarea, select.input {
  width: 100%; height: 38px; padding: 0 12px;
  font: 400 14px var(--font); color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.field textarea { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.field select, select.input {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: color-mix(in oklab, var(--border-strong) 60%, var(--muted)); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.input-sm, select.input-sm { height: 32px; font-size: 13px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.field input[type=color] { width: 56px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.field input[type=file] { font-size: 13px; color: var(--muted); }
.field input[type=file]::file-selector-button { font: 500 13px var(--font); padding: 7px 12px; margin-right: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; }

/* toggles */
.toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 14px 0; border-top: 1px solid var(--border); }
.toggle-row:first-child { border-top: 0; padding-top: 0; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background .2s var(--ease); }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s var(--ease); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

/* radio cards */
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.choice-cards label { position: relative; cursor: pointer; }
.choice-cards input { position: absolute; opacity: 0; }
.choice-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.choice-card .icon { color: var(--muted); margin-top: 1px; }
.choice-card strong { display: block; font-weight: 600; font-size: 13.5px; }
.choice-card small { color: var(--muted); font-size: 12.5px; }
.choice-cards input:checked + .choice-card { border-color: var(--brand); box-shadow: var(--ring); background: var(--brand-soft); }
.choice-cards input:checked + .choice-card .icon { color: var(--brand); }

/* ---------------------------------------------------------------- alerts / toasts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: 13.5px; }
.alert .icon { margin-top: 1px; }
.alert.red { background: var(--red-soft); border-color: var(--red-border); color: var(--red); }
.alert.amber { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber); }
.alert.green { background: var(--green-soft); border-color: var(--green-border); color: var(--green); }
.alert.blue { background: var(--blue-soft); border-color: var(--blue-border); color: var(--blue); }
.alert strong { color: inherit; }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 12px;
  min-width: 300px; max-width: 420px; padding: 12px 14px 12px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500;
  animation: toast-in .35s var(--ease) both;
}
.toast.leaving { animation: toast-out .25s var(--ease) both; }
.toast-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.toast.success .toast-icon { background: var(--green-soft); color: var(--green); }
.toast.error .toast-icon { background: var(--red-soft); color: var(--red); }
.toast.info .toast-icon, .toast.arrival .toast-icon { background: var(--brand-soft); color: var(--brand); }
.toast small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.toast .x { margin-left: auto; color: var(--faint); cursor: pointer; background: none; border: 0; padding: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------------------------------------------------------------- empty states */
.empty { text-align: center; padding: 48px 24px; }
.empty-icon {
  width: 48px; height: 48px; margin: 0 auto 14px;
  display: grid; place-items: center; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  box-shadow: var(--shadow-xs);
}
.empty h3 { font-size: 14.5px; }
.empty p { color: var(--muted); font-size: 13.5px; margin: 4px auto 16px; max-width: 340px; }
.empty.sm { padding: 28px 20px; }

/* ---------------------------------------------------------------- dropdowns / menus */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; z-index: 50; min-width: 220px;
  padding: 6px; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: pop .14s var(--ease);
}
.menu.up { bottom: calc(100% + 6px); margin: 0; }
.menu.right { right: 0; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border-radius: 7px;
  font: 500 13.5px var(--font); color: var(--text-2); text-align: left;
  background: none; border: 0; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-3); color: var(--text); }
.menu .icon { color: var(--muted); }
.menu hr { margin: 6px -6px; }
.menu-label { padding: 6px 10px 4px; font-size: 11.5px; color: var(--faint); font-weight: 500; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------------------------------------------------------------- command palette / dialogs */
dialog {
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 32px));
}
dialog::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .18s var(--ease); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; height: 52px; border: 0; background: none; font: 400 15px var(--font); color: var(--text); outline: none; }
.palette-list { max-height: 360px; overflow-y: auto; padding: 6px; }
.palette-list a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px;
  font-weight: 500; font-size: 13.5px; color: var(--text-2);
}
.palette-list a .icon { color: var(--muted); }
.palette-list a.sel { background: var(--surface-3); color: var(--text); }
.palette-list a .hint { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 400; }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.dialog-body { padding: 22px; }
.dialog-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 16px 16px; }

/* ---------------------------------------------------------------- detail pages */
.profile-head { display: flex; gap: 20px; align-items: center; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 12px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.photo-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 4/3; display: grid; place-items: center; color: var(--faint); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.sig-frame { border-radius: var(--radius); border: 1px dashed var(--border-strong); background: #fff; padding: 8px; }
[data-theme="dark"] .sig-frame img { filter: invert(1) hue-rotate(180deg); }
[data-theme="dark"] .sig-frame { background: var(--surface-2); }
.code-pill { font-family: var(--mono); font-weight: 600; letter-spacing: .18em; padding: 4px 10px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--border); }
.qr { width: 100%; height: auto; display: block; }
.qr path { fill: currentColor; }

.settings-nav { display: flex; flex-direction: column; gap: 1px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 13.5px; }
.settings-nav a:hover { background: var(--surface-3); color: var(--text); }
.settings-nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.section { display: grid; grid-template-columns: 260px 1fr; gap: 32px; padding: 28px 0; border-top: 1px solid var(--border); }
.section:first-child { border-top: 0; padding-top: 0; }
.section-intro h2 { font-size: 14.5px; }
.section-intro p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- evacuation */
.evac-hero {
  display: flex; align-items: center; gap: 24px;
  padding: 22px 24px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--red-soft), transparent 70%), var(--surface);
  border: 1px solid var(--red-border);
}
.evac-ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--surface-3) 0); position: relative; flex-shrink: 0; }
.evac-ring::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.evac-ring span { position: relative; z-index: 1; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.roll { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.roll-card {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
  transition: border-color .15s, background .15s, transform .1s;
}
.roll-card:active { transform: scale(.99); }
.roll-card .tick { margin-left: auto; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; color: transparent; transition: all .2s var(--ease); }
.roll-card.ok { border-color: var(--green-border); background: var(--green-soft); }
.roll-card.ok .tick { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------------------------------------------------------------- badge (print) */
.badge-sheet { display: grid; place-items: center; padding: 40px 0; }
.vbadge {
  width: 340px; border-radius: 18px; overflow: hidden;
  background: #fff; color: #0b0b0f; box-shadow: var(--shadow-lg); border: 1px solid #e7e7ea;
  font-family: var(--font);
}
.vbadge-top { padding: 18px 22px; display: flex; align-items: center; gap: 10px; color: #fff; background: var(--badge-c, #4f46e5); }
.vbadge-top strong { font-size: 14px; }
.vbadge-type { margin-left: auto; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.2); }
.vbadge-body { padding: 22px; display: flex; gap: 18px; align-items: center; }
.vbadge-photo { width: 92px; height: 92px; border-radius: 14px; overflow: hidden; background: #f4f4f5; flex-shrink: 0; display: grid; place-items: center; font-size: 30px; font-weight: 600; color: #71717a; }
.vbadge-photo img { width: 100%; height: 100%; object-fit: cover; }
.vbadge-name { font-size: 24px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.vbadge-company { color: #52525b; margin-top: 4px; font-size: 14px; }
.vbadge-foot { display: flex; align-items: flex-end; gap: 16px; padding: 0 22px 20px; font-size: 12px; color: #52525b; }
.vbadge-foot dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; flex: 1; }
.vbadge-foot dt { color: #a1a1aa; } .vbadge-foot dd { margin: 0; font-weight: 600; color: #0b0b0f; }
.vbadge-qr { width: 76px; color: #0b0b0f; }

/* ---------------------------------------------------------------- auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-panel { display: flex; flex-direction: column; padding: 32px 40px; }
.auth-form { width: 100%; max-width: 380px; margin: auto; }
.auth-form h1 { font-size: 26px; }
.auth-form > p { color: var(--muted); margin: 6px 0 28px; }
.auth-art {
  position: relative; overflow: hidden; margin: 12px; border-radius: 24px;
  background: radial-gradient(800px 500px at 20% 0%, color-mix(in oklab, var(--brand) 55%, white), transparent 60%),
              radial-gradient(700px 500px at 100% 100%, color-mix(in oklab, var(--brand) 75%, #0ea5e9), transparent 60%),
              var(--brand);
  color: #fff; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px;
}
.auth-art::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 75%); }
.auth-art > * { position: relative; }
.auth-art blockquote { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -.02em; line-height: 1.4; max-width: 460px; }
.auth-art cite { display: block; margin-top: 16px; font-style: normal; opacity: .8; font-size: 14px; }
.brand-mark { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-mark .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 20px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .section { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .25s var(--ease); background: var(--surface); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-only { display: grid; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .search-trigger { width: auto; } .search-trigger span, .search-trigger .kbd { display: none; }
  .grid-2, .grid-3, .grid-main-l, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  .hide-sm { display: none !important; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr 1fr; } .stat-value { font-size: 24px; } }

/* ---------------------------------------------------------------- print */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; }
  .badge-sheet { padding: 0; }
  .vbadge { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
