/* Upload File Suite v3 — console design system.
   Light tokens on :root; the dark set is declared twice on purpose: once for the OS preference
   (unless the user forced light) and once for an explicit data-theme="dark". */

:root {
  color-scheme: light;

  --bg: #fafafa;
  --bg-subtle: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f5;
  --surface-overlay: #ffffff;
  --sidebar-bg: #f7f7f8;
  --topbar-bg: rgb(250 250 250 / 0.82);

  --border: #e4e4e7;
  --border-subtle: #ececee;
  --border-strong: #d4d4d8;
  --border-input: #d4d4d8;
  --border-input-hover: #a1a1aa;
  --control-border: #a1a1aa;

  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;
  --text-4: #a1a1aa;
  --text-placeholder: #8b8b94;
  --text-on-accent: #ffffff;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-active: #3730a3;
  --accent-text: #4338ca;
  --accent-soft: #eef2ff;
  --accent-soft-2: #e0e7ff;
  --accent-border: #c7d2fe;
  --focus: #6366f1;
  --focus-ring: rgb(99 102 241 / 0.22);
  --brand: #4f46e5;
  --brand-fg: #ffffff;

  --success: #047857;
  --success-solid: #059669;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #b45309;
  --warning-solid: #d97706;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --orange: #c2410c;
  --orange-solid: #ea580c;
  --orange-soft: #fff7ed;
  --orange-border: #fed7aa;
  --danger: #b91c1c;
  --danger-solid: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #0369a1;
  --info-solid: #0284c7;
  --info-soft: #f0f9ff;
  --info-border: #bae6fd;
  --neutral: #52525b;
  --neutral-soft: #f4f4f5;
  --neutral-border: #e4e4e7;

  --hover: rgb(24 24 27 / 0.045);
  --hover-strong: rgb(24 24 27 / 0.07);
  --row-hover: #fafafa;
  --input-bg: #ffffff;
  --switch-off: #d4d4d8;
  --skeleton: #efeff1;
  --skeleton-hi: #f8f8f9;
  --tooltip-bg: #18181b;
  --tooltip-fg: #fafafa;
  --nav-active-bg: #ffffff;
  --nav-active-shadow: 0 1px 2px rgb(24 24 27 / 0.06), 0 0 0 1px rgb(24 24 27 / 0.06);
  --segmented-bg: #f1f1f3;
  --segmented-active: #ffffff;
  --scrollbar: #d4d4d8;
  --grid-line: rgb(24 24 27 / 0.05);
  --backdrop: rgb(9 9 11 / 0.42);

  --chart-accent: #4f46e5;
  --chart-grid: #ededf0;
  --chart-axis: #d4d4d8;
  --chart-label: #71717a;
  --chart-other: #a1a1aa;
  --chart-area-opacity: 0.1;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --heat-0: #f1f1f3;
  --heat-1: #cde2fb;
  --heat-2: #9ec5f4;
  --heat-3: #5598e7;
  --heat-4: #256abf;
  --heat-5: #104281;

  --shadow-xs: 0 1px 2px rgb(24 24 27 / 0.04);
  --shadow-sm: 0 1px 2px rgb(24 24 27 / 0.05), 0 1px 3px rgb(24 24 27 / 0.04);
  --shadow-md: 0 4px 12px -2px rgb(24 24 27 / 0.08), 0 2px 4px -2px rgb(24 24 27 / 0.04);
  --shadow-lg: 0 20px 44px -12px rgb(24 24 27 / 0.22), 0 6px 14px -6px rgb(24 24 27 / 0.08);
  --shadow-popover: 0 12px 30px -8px rgb(24 24 27 / 0.16), 0 2px 6px -2px rgb(24 24 27 / 0.06);

  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --font-sans: 'Inter Variable', 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 260ms;

  --sidebar-w: 248px;
  --rail-w: 64px;
  --topbar-h: 56px;
  --page-max: 1280px;
  --page-narrow: 880px;

  --z-topbar: 30;
  --z-sidebar: 40;
  --z-overlay: 70;
  --z-popover: 80;
  --z-toast: 90;
  --z-tooltip: 95;
  --z-dnd: 100;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #09090b;
    --bg-subtle: #0e0e11;
    --surface: #111114;
    --surface-2: #16161a;
    --surface-3: #1c1c21;
    --surface-overlay: #17171b;
    --sidebar-bg: #0c0c0f;
    --topbar-bg: rgb(9 9 11 / 0.78);
    --border: #26262b;
    --border-subtle: #1f1f24;
    --border-strong: #34343b;
    --border-input: #2e2e35;
    --border-input-hover: #46464f;
    --control-border: #52525b;
    --text: #f4f4f5;
    --text-2: #b4b4bd;
    --text-3: #8f8f99;
    --text-4: #5f5f69;
    --text-placeholder: #6e6e78;
    --accent: #5850ec;
    --accent-hover: #6761f0;
    --accent-active: #4f46e5;
    --accent-text: #a5b4fc;
    --accent-soft: rgb(99 102 241 / 0.14);
    --accent-soft-2: rgb(99 102 241 / 0.22);
    --accent-border: rgb(129 140 248 / 0.35);
    --focus: #818cf8;
    --focus-ring: rgb(129 140 248 / 0.28);
    --success: #34d399;
    --success-solid: #10b981;
    --success-soft: rgb(16 185 129 / 0.12);
    --success-border: rgb(52 211 153 / 0.28);
    --warning: #fbbf24;
    --warning-solid: #f59e0b;
    --warning-soft: rgb(245 158 11 / 0.12);
    --warning-border: rgb(251 191 36 / 0.28);
    --orange: #fb923c;
    --orange-solid: #f97316;
    --orange-soft: rgb(249 115 22 / 0.12);
    --orange-border: rgb(251 146 60 / 0.28);
    --danger: #f87171;
    --danger-solid: #dc2626;
    --danger-hover: #ef4444;
    --danger-soft: rgb(239 68 68 / 0.12);
    --danger-border: rgb(248 113 113 / 0.3);
    --info: #38bdf8;
    --info-solid: #0ea5e9;
    --info-soft: rgb(14 165 233 / 0.12);
    --info-border: rgb(56 189 248 / 0.28);
    --neutral: #a1a1aa;
    --neutral-soft: rgb(255 255 255 / 0.06);
    --neutral-border: rgb(255 255 255 / 0.1);
    --hover: rgb(255 255 255 / 0.05);
    --hover-strong: rgb(255 255 255 / 0.08);
    --row-hover: #15151a;
    --input-bg: #0e0e11;
    --switch-off: #3f3f46;
    --skeleton: #19191e;
    --skeleton-hi: #232329;
    --tooltip-bg: #2a2a30;
    --tooltip-fg: #f4f4f5;
    --nav-active-bg: rgb(255 255 255 / 0.07);
    --nav-active-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05);
    --segmented-bg: #17171b;
    --segmented-active: #2a2a31;
    --scrollbar: #34343b;
    --grid-line: rgb(255 255 255 / 0.035);
    --backdrop: rgb(0 0 0 / 0.62);
    --chart-accent: #818cf8;
    --chart-grid: #222227;
    --chart-axis: #3a3a41;
    --chart-label: #8f8f99;
    --chart-other: #52525b;
    --chart-area-opacity: 0.16;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --heat-0: #1a1a1f;
    --heat-1: #0d366b;
    --heat-2: #184f95;
    --heat-3: #256abf;
    --heat-4: #5598e7;
    --heat-5: #9ec5f4;
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35), 0 1px 3px rgb(0 0 0 / 0.2);
    --shadow-md: 0 6px 16px -4px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 28px 56px -16px rgb(0 0 0 / 0.7), 0 0 0 1px rgb(255 255 255 / 0.05);
    --shadow-popover: 0 14px 34px -10px rgb(0 0 0 / 0.65), 0 0 0 1px rgb(255 255 255 / 0.06);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #09090b;
  --bg-subtle: #0e0e11;
  --surface: #111114;
  --surface-2: #16161a;
  --surface-3: #1c1c21;
  --surface-overlay: #17171b;
  --sidebar-bg: #0c0c0f;
  --topbar-bg: rgb(9 9 11 / 0.78);
  --border: #26262b;
  --border-subtle: #1f1f24;
  --border-strong: #34343b;
  --border-input: #2e2e35;
  --border-input-hover: #46464f;
  --control-border: #52525b;
  --text: #f4f4f5;
  --text-2: #b4b4bd;
  --text-3: #8f8f99;
  --text-4: #5f5f69;
  --text-placeholder: #6e6e78;
  --accent: #5850ec;
  --accent-hover: #6761f0;
  --accent-active: #4f46e5;
  --accent-text: #a5b4fc;
  --accent-soft: rgb(99 102 241 / 0.14);
  --accent-soft-2: rgb(99 102 241 / 0.22);
  --accent-border: rgb(129 140 248 / 0.35);
  --focus: #818cf8;
  --focus-ring: rgb(129 140 248 / 0.28);
  --success: #34d399;
  --success-solid: #10b981;
  --success-soft: rgb(16 185 129 / 0.12);
  --success-border: rgb(52 211 153 / 0.28);
  --warning: #fbbf24;
  --warning-solid: #f59e0b;
  --warning-soft: rgb(245 158 11 / 0.12);
  --warning-border: rgb(251 191 36 / 0.28);
  --orange: #fb923c;
  --orange-solid: #f97316;
  --orange-soft: rgb(249 115 22 / 0.12);
  --orange-border: rgb(251 146 60 / 0.28);
  --danger: #f87171;
  --danger-solid: #dc2626;
  --danger-hover: #ef4444;
  --danger-soft: rgb(239 68 68 / 0.12);
  --danger-border: rgb(248 113 113 / 0.3);
  --info: #38bdf8;
  --info-solid: #0ea5e9;
  --info-soft: rgb(14 165 233 / 0.12);
  --info-border: rgb(56 189 248 / 0.28);
  --neutral: #a1a1aa;
  --neutral-soft: rgb(255 255 255 / 0.06);
  --neutral-border: rgb(255 255 255 / 0.1);
  --hover: rgb(255 255 255 / 0.05);
  --hover-strong: rgb(255 255 255 / 0.08);
  --row-hover: #15151a;
  --input-bg: #0e0e11;
  --switch-off: #3f3f46;
  --skeleton: #19191e;
  --skeleton-hi: #232329;
  --tooltip-bg: #2a2a30;
  --tooltip-fg: #f4f4f5;
  --nav-active-bg: rgb(255 255 255 / 0.07);
  --nav-active-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05);
  --segmented-bg: #17171b;
  --segmented-active: #2a2a31;
  --scrollbar: #34343b;
  --grid-line: rgb(255 255 255 / 0.035);
  --backdrop: rgb(0 0 0 / 0.62);
  --chart-accent: #818cf8;
  --chart-grid: #222227;
  --chart-axis: #3a3a41;
  --chart-label: #8f8f99;
  --chart-other: #52525b;
  --chart-area-opacity: 0.16;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --heat-0: #1a1a1f;
  --heat-1: #0d366b;
  --heat-2: #184f95;
  --heat-3: #256abf;
  --heat-4: #5598e7;
  --heat-5: #9ec5f4;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35), 0 1px 3px rgb(0 0 0 / 0.2);
  --shadow-md: 0 6px 16px -4px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 28px 56px -16px rgb(0 0 0 / 0.7), 0 0 0 1px rgb(255 255 255 / 0.05);
  --shadow-popover: 0 14px 34px -10px rgb(0 0 0 / 0.65), 0 0 0 1px rgb(255 255 255 / 0.06);
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--scrollbar) transparent;
}

html.is-scroll-locked {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

h1, h2, h3, h4 {
  color: var(--text);
  text-wrap: balance;
}

ul, ol {
  margin: 0;
  padding-left: 1.25em;
}

a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

code, kbd, pre, samp {
  font-family: var(--font-mono);
}

hr {
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--border-subtle);
}

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

svg.icon {
  display: inline-block;
  flex: none;
  vertical-align: -0.2em;
}

[hidden] {
  display: none !important;
}

.noscript {
  padding: 32px 16px;
  text-align: center;
  font-family: system-ui, sans-serif;
}

.clipboard-buffer {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* ---------- Utilities ---------- */

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-xs { gap: 4px; }
.stack-sm { gap: 8px; }
.stack-md { gap: 12px; }
.stack-lg { gap: 24px; }
.stack-xl { gap: 32px; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-xs { gap: 4px; }
.row-sm { gap: 6px; }
.row-lg { gap: 16px; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.row-center { justify-content: center; }
.row-top { align-items: flex-start; }
.row-nowrap { flex-wrap: nowrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.spacer { flex: 1 1 auto; }
.grow { flex: 1 1 auto; min-width: 0; }

.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-kpi { grid-template-columns: repeat(auto-fit, minmax(208px, 1fr)); }
/* Exactly four stat cards in a narrow column: 2 × 2 (or 1 × 4 when wide) instead of 3 + 1. Phones keep 2 per row. */
.grid-kpi-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }

.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.split-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.muted { color: var(--text-3); }
.subtle { color: var(--text-2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent-text); }
.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-md { font-size: 15px; }
.text-lg { font-size: 16px; }
.strong { font-weight: 600; }
.medium { font-weight: 500; }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.pre-line { white-space: pre-line; }
.center { text-align: center; }
.list-plain { margin: 0; padding: 0; list-style: none; }
.divider { height: 1px; margin: 0; border: 0; background: var(--border-subtle); }
.dot-sep::before { content: '·'; margin: 0 6px; color: var(--text-4); }

.link {
  color: var(--accent-text);
  font-weight: 500;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.code-block {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}

.prose p + p {
  margin-top: 0.75em;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--dur) var(--ease);
}

.skip-link:focus {
  transform: none;
}

/* Tones shared by icon tiles */
.tone-accent { --tone-fg: var(--accent-text); --tone-bg: var(--accent-soft); }
.tone-success { --tone-fg: var(--success); --tone-bg: var(--success-soft); }
.tone-warning { --tone-fg: var(--warning); --tone-bg: var(--warning-soft); }
.tone-orange { --tone-fg: var(--orange); --tone-bg: var(--orange-soft); }
.tone-danger { --tone-fg: var(--danger); --tone-bg: var(--danger-soft); }
.tone-info { --tone-fg: var(--info); --tone-bg: var(--info-soft); }
.tone-neutral { --tone-fg: var(--text-2); --tone-bg: var(--neutral-soft); }

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.btn:active:not(:disabled):not([aria-disabled='true']) {
  transform: translateY(0.5px);
}

.btn:disabled,
.btn[aria-disabled='true']:not(.is-loading) {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.is-loading {
  cursor: progress;
}

.btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-sm { height: 30px; padding: 0 10px; gap: 6px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { height: 42px; padding: 0 18px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }
.btn-icon-only { width: 36px; padding: 0; }
.btn-sm.btn-icon-only { width: 30px; }
.btn-lg.btn-icon-only { width: 42px; }

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.14), 0 1px 2px rgb(24 24 27 / 0.14);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-solid);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12), 0 1px 2px rgb(24 24 27 / 0.14);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-link {
  height: auto;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-weight: 500;
}

.btn-link:hover:not(:disabled) {
  text-decoration: underline;
}

.btn-link.btn-sm {
  font-size: 13px;
}

.btn .icon-btn-right,
.btn-icon-right {
  margin-right: -2px;
  opacity: 0.8;
}

.icon-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.btn-group {
  display: inline-flex;
}

.btn-group > .btn {
  border-radius: 0;
}

.btn-group > .btn:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}

.btn-group > .btn:last-child {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.btn-group > .btn + .btn {
  margin-left: -1px;
}

.copy-btn.is-copied {
  color: var(--success);
}

.btn-secondary.copy-btn.is-copied {
  border-color: var(--success-border);
}

/* ---------- Spinner, skeleton ---------- */

.spinner {
  display: inline-flex;
  flex: none;
}

.spinner svg {
  display: block;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-hi) 50%, var(--skeleton) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-text {
  display: grid;
  gap: 10px;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* ---------- Form controls ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
}

.field-required {
  margin-left: 3px;
  color: var(--danger);
}

.field-optional {
  margin-left: 6px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 400;
}

.field-hint,
.field-error {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
}

.field-hint {
  color: var(--text-3);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger);
}

.field-error .icon {
  margin-top: 1px;
}

.input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.input::placeholder {
  color: var(--text-placeholder);
}

.input:hover:not(:disabled):not(:focus) {
  border-color: var(--border-input-hover);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.input.is-invalid,
.input[aria-invalid='true'] {
  border-color: var(--danger-solid);
}

.input.is-invalid:focus,
.input[aria-invalid='true']:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger-solid) 22%, transparent);
}

.input:disabled {
  background: var(--surface-3);
  color: var(--text-3);
  cursor: not-allowed;
}

.input[readonly] {
  background: var(--surface-2);
}

.input-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-sm); }
.input-lg { height: 42px; font-size: 15px; }

.input[type='search']::-webkit-search-cancel-button,
.input[type='search']::-webkit-search-decoration {
  appearance: none;
}

.input[type='datetime-local'] {
  min-width: 0;
}

.input-number {
  font-variant-numeric: tabular-nums;
}

.textarea {
  height: auto;
  min-height: 84px;
  padding: 9px 12px;
  line-height: 1.5;
  resize: vertical;
}

.textarea-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
}

.textarea-wrap .textarea {
  padding-bottom: 26px;
}

.textarea-count {
  position: absolute;
  right: 10px;
  bottom: 7px;
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.textarea-count.is-full {
  color: var(--warning);
}

.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--input-bg);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.input-group:hover:not(:focus-within):not(.is-disabled) {
  border-color: var(--border-input-hover);
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.input-group.is-invalid {
  border-color: var(--danger-solid);
}

.input-group.is-disabled {
  background: var(--surface-3);
}

.input-group > .input {
  flex: 1 1 auto;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.input-group > .input:focus {
  box-shadow: none;
}

.input-group-sm {
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.input-group-sm > .input {
  font-size: 13px;
}

.input-affix {
  display: inline-flex;
  flex: none;
  align-items: center;
  color: var(--text-3);
  font-size: 13px;
  white-space: nowrap;
}

.input-suffix {
  padding-right: 6px;
}

.input-action {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
}

.input-action:hover {
  background: var(--hover);
  color: var(--text);
}

.caps-hint {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 11.5px;
  font-weight: 600;
}

.select {
  position: relative;
  display: inline-flex;
  width: 100%;
  min-width: 0;
}

.select select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow-xs);
  appearance: none;
  cursor: pointer;
  text-overflow: ellipsis;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.select select:hover:not(:disabled) {
  border-color: var(--border-input-hover);
}

.select select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

.select.is-invalid select {
  border-color: var(--danger-solid);
}

.select select:disabled {
  background: var(--surface-3);
  color: var(--text-3);
  cursor: not-allowed;
}

.select option {
  background: var(--surface);
  color: var(--text);
}

.select-chevron {
  position: absolute;
  top: 50%;
  right: 11px;
  color: var(--text-3);
  pointer-events: none;
  transform: translateY(-50%);
}

.select-sm select {
  height: 30px;
  padding: 0 28px 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.select-sm .select-chevron {
  right: 9px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.check-row > .checkbox,
.check-row > .switch {
  margin-top: 2px;
}

.check-row.is-disabled {
  opacity: 0.6;
}

.check-text {
  min-width: 0;
}

.check-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.check-description {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.45;
}

.checkbox,
.radio {
  display: inline-grid;
  flex: none;
  place-content: center;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--control-border);
  background: var(--input-bg);
  appearance: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.checkbox {
  border-radius: 5px;
}

.radio {
  border-radius: 50%;
}

.checkbox::before {
  content: '';
  width: 10px;
  height: 10px;
  background: #ffffff;
  clip-path: polygon(14% 44%, 0 62%, 42% 100%, 100% 18%, 84% 2%, 40% 66%);
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease);
}

.radio::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease);
}

.checkbox:checked,
.checkbox:indeterminate,
.radio:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.checkbox:checked::before,
.radio:checked::before {
  transform: scale(1);
}

.checkbox:indeterminate::before {
  width: 8px;
  height: 2px;
  border-radius: 1px;
  clip-path: none;
  transform: scale(1);
}

.checkbox:hover:not(:checked):not(:disabled),
.radio:hover:not(:checked):not(:disabled) {
  border-color: var(--text-3);
}

.checkbox:disabled,
.radio:disabled,
.switch:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.switch {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--switch-off);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.04);
  appearance: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}

.switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.22);
  transition: transform var(--dur) var(--ease);
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::before {
  transform: translateX(14px);
}

.switch-sm {
  width: 28px;
  height: 16px;
}

.switch-sm::before {
  width: 12px;
  height: 12px;
}

.switch-sm:checked::before {
  transform: translateX(12px);
}

.radio-group {
  display: grid;
  gap: 8px;
}

.radio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.radio-cols-2 .radio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.radio-cols-3 .radio-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.radio-card:hover {
  border-color: var(--border-strong);
}

.radio-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.radio-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.radio-card:has(.radio:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.radio-card .radio {
  margin-top: 2px;
}

.radio-card-text {
  min-width: 0;
}

.radio-card-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
}

.radio-card-description {
  display: block;
  margin-top: 2px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* --text-3 on --accent-soft is below 4.5:1 in the light theme. */
.radio-card.is-selected .radio-card-description {
  color: var(--text-2);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--segmented-bg);
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented-item {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.segmented-item:hover:not(:disabled) {
  color: var(--text);
}

.segmented-item.is-selected {
  background: var(--segmented-active);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.segmented-item:focus-visible {
  outline-offset: 0;
}

.segmented-sm .segmented-item {
  height: 24px;
  padding: 0 9px;
  font-size: 12.5px;
}

.otp-input {
  height: 54px;
  padding-left: 0.55em;
  font-family: var(--font-mono);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.55em;
  text-align: center;
}

.otp-input::placeholder {
  color: var(--text-4);
}

.recovery-input {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Cards, stats, key-value ---------- */

.card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.card-header + .card-body {
  padding-top: 0;
}

.card-header + .card-body-flush {
  border-top: 1px solid var(--border-subtle);
}

.card-heading {
  display: flex;
  flex: 1 1 220px;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.card-heading-text {
  min-width: 0;
}

.card-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.card-description {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 13px;
}

.card-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.card-body {
  min-width: 0;
  padding: 20px;
}

.card-body.card-body-flush {
  padding: 0;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface-2);
}

.card-pad {
  padding: 20px;
}

a.card.is-link {
  color: inherit;
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

a.card.is-link:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.stat-icon,
.popover-icon,
.modal-icon,
.drawer-icon,
.state-icon,
.notfound-icon,
.auth-step-icon,
.boot-error-icon {
  display: grid;
  flex: none;
  place-items: center;
}

.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--tone-bg, var(--accent-soft));
  color: var(--tone-fg, var(--accent-text));
}

.stat-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}

.stat-value {
  color: var(--text);
  font-size: 26px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.stat-spark {
  flex: none;
}

.stat-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  color: var(--text-3);
  font-size: 12.5px;
}

.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
}

.stat-delta.is-good { color: var(--success); }
.stat-delta.is-bad { color: var(--danger); }
.stat-delta.is-neutral { color: var(--text-3); }

.kv {
  display: grid;
}

.kv-row {
  display: grid;
  grid-template-columns: minmax(110px, 38%) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-label {
  color: var(--text-3);
  font-size: 13px;
}

.kv-hint {
  display: block;
  color: var(--text-3);
  font-size: 12px;
}

.kv-value {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
}

.kv-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kv-value.is-wrap .kv-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.kv-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 32px;
}

.kv-dense .kv-row {
  min-height: 34px;
  padding: 6px 0;
}

/* ---------- Badges, status dots ---------- */

.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 22px;
  padding: 0 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.badge > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-sm {
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  font-size: 11.5px;
}

.badge-neutral { border-color: var(--neutral-border); background: var(--neutral-soft); color: var(--neutral); }
.badge-accent { border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent-text); }
.badge-success { border-color: var(--success-border); background: var(--success-soft); color: var(--success); }
.badge-warning { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning); }
.badge-orange { border-color: var(--orange-border); background: var(--orange-soft); color: var(--orange); }
.badge-danger { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.badge-info { border-color: var(--info-border); background: var(--info-soft); color: var(--info); }

/* ApprovalBadge: the badge plus its short explanation, written out only where tooltips do not show (Responsive). */
.approval-badge {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  max-width: 100%;
  min-width: 0;
  vertical-align: middle;
}

.approval-badge-note {
  display: none;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.35;
}

.status-dot {
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.tone-success { background: var(--success-solid); color: var(--success-solid); }
.status-dot.tone-warning { background: var(--warning-solid); color: var(--warning-solid); }
.status-dot.tone-orange { background: var(--orange-solid); color: var(--orange-solid); }
.status-dot.tone-danger { background: var(--danger-solid); color: var(--danger-solid); }
.status-dot.tone-info { background: var(--info-solid); color: var(--info-solid); }
.status-dot.tone-accent { background: var(--accent); color: var(--accent); }
.status-dot.tone-neutral { background: var(--text-4); color: var(--text-4); }

.status-dot.is-pulsing {
  animation: dot-pulse 1.8s ease-out infinite;
}

@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 5px transparent; }
}

/* ---------- File names ---------- */

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
}

.file-name-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--kind-bg, var(--surface-3));
  color: var(--kind-fg, var(--text-2));
}

.file-name-sm .file-name-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.file-name-lg .file-name-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.file-name-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}

.file-name-title {
  overflow: hidden;
  color: var(--text);
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name-meta {
  overflow: hidden;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kind-image { --kind-bg: #f3e8ff; --kind-fg: #7e22ce; }
.kind-video { --kind-bg: #fce7f3; --kind-fg: #be185d; }
.kind-audio { --kind-bg: #ffedd5; --kind-fg: #c2410c; }
.kind-archive { --kind-bg: #fef3c7; --kind-fg: #b45309; }
.kind-pdf { --kind-bg: #fee2e2; --kind-fg: #b91c1c; }
.kind-document { --kind-bg: #dbeafe; --kind-fg: #1d4ed8; }
.kind-spreadsheet { --kind-bg: #dcfce7; --kind-fg: #15803d; }
.kind-presentation { --kind-bg: #ffedd5; --kind-fg: #c2410c; }
.kind-code { --kind-bg: #e0e7ff; --kind-fg: #4338ca; }
.kind-executable { --kind-bg: #e4e4e7; --kind-fg: #3f3f46; }
.kind-font { --kind-bg: #f1f5f9; --kind-fg: #334155; }
.kind-text { --kind-bg: #f1f5f9; --kind-fg: #475569; }
.kind-other { --kind-bg: #f4f4f5; --kind-fg: #52525b; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .kind-image { --kind-bg: rgb(168 85 247 / 0.16); --kind-fg: #d8b4fe; }
  :root:not([data-theme='light']) .kind-video { --kind-bg: rgb(236 72 153 / 0.16); --kind-fg: #f9a8d4; }
  :root:not([data-theme='light']) .kind-audio { --kind-bg: rgb(249 115 22 / 0.16); --kind-fg: #fdba74; }
  :root:not([data-theme='light']) .kind-archive { --kind-bg: rgb(245 158 11 / 0.16); --kind-fg: #fcd34d; }
  :root:not([data-theme='light']) .kind-pdf { --kind-bg: rgb(239 68 68 / 0.16); --kind-fg: #fca5a5; }
  :root:not([data-theme='light']) .kind-document { --kind-bg: rgb(59 130 246 / 0.16); --kind-fg: #93c5fd; }
  :root:not([data-theme='light']) .kind-spreadsheet { --kind-bg: rgb(34 197 94 / 0.14); --kind-fg: #86efac; }
  :root:not([data-theme='light']) .kind-presentation { --kind-bg: rgb(249 115 22 / 0.16); --kind-fg: #fdba74; }
  :root:not([data-theme='light']) .kind-code { --kind-bg: rgb(99 102 241 / 0.18); --kind-fg: #a5b4fc; }
  :root:not([data-theme='light']) .kind-executable,
  :root:not([data-theme='light']) .kind-font,
  :root:not([data-theme='light']) .kind-text,
  :root:not([data-theme='light']) .kind-other { --kind-bg: rgb(255 255 255 / 0.07); --kind-fg: #d4d4d8; }
}

:root[data-theme='dark'] .kind-image { --kind-bg: rgb(168 85 247 / 0.16); --kind-fg: #d8b4fe; }
:root[data-theme='dark'] .kind-video { --kind-bg: rgb(236 72 153 / 0.16); --kind-fg: #f9a8d4; }
:root[data-theme='dark'] .kind-audio { --kind-bg: rgb(249 115 22 / 0.16); --kind-fg: #fdba74; }
:root[data-theme='dark'] .kind-archive { --kind-bg: rgb(245 158 11 / 0.16); --kind-fg: #fcd34d; }
:root[data-theme='dark'] .kind-pdf { --kind-bg: rgb(239 68 68 / 0.16); --kind-fg: #fca5a5; }
:root[data-theme='dark'] .kind-document { --kind-bg: rgb(59 130 246 / 0.16); --kind-fg: #93c5fd; }
:root[data-theme='dark'] .kind-spreadsheet { --kind-bg: rgb(34 197 94 / 0.14); --kind-fg: #86efac; }
:root[data-theme='dark'] .kind-presentation { --kind-bg: rgb(249 115 22 / 0.16); --kind-fg: #fdba74; }
:root[data-theme='dark'] .kind-code { --kind-bg: rgb(99 102 241 / 0.18); --kind-fg: #a5b4fc; }
:root[data-theme='dark'] .kind-executable,
:root[data-theme='dark'] .kind-font,
:root[data-theme='dark'] .kind-text,
:root[data-theme='dark'] .kind-other { --kind-bg: rgb(255 255 255 / 0.07); --kind-fg: #d4d4d8; }

/* ---------- Avatar ---------- */

.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  border-radius: 50%;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.01em;
  user-select: none;
}

.avatar-tone-0 { background: #e0e7ff; color: #3730a3; }
.avatar-tone-1 { background: #dbeafe; color: #1e40af; }
.avatar-tone-2 { background: #d1fae5; color: #065f46; }
.avatar-tone-3 { background: #fef3c7; color: #92400e; }
.avatar-tone-4 { background: #fce7f3; color: #9d174d; }
.avatar-tone-5 { background: #ede9fe; color: #5b21b6; }
.avatar-tone-6 { background: #cffafe; color: #155e75; }
.avatar-tone-7 { background: #ffe4e6; color: #9f1239; }

/* A non-human actor (the Redirection integration in the audit log): an icon instead of initials. */
.avatar-system { background: var(--info-soft); color: var(--info); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .avatar-tone-0 { background: rgb(99 102 241 / 0.22); color: #c7d2fe; }
  :root:not([data-theme='light']) .avatar-tone-1 { background: rgb(59 130 246 / 0.22); color: #bfdbfe; }
  :root:not([data-theme='light']) .avatar-tone-2 { background: rgb(16 185 129 / 0.2); color: #a7f3d0; }
  :root:not([data-theme='light']) .avatar-tone-3 { background: rgb(245 158 11 / 0.2); color: #fde68a; }
  :root:not([data-theme='light']) .avatar-tone-4 { background: rgb(236 72 153 / 0.2); color: #fbcfe8; }
  :root:not([data-theme='light']) .avatar-tone-5 { background: rgb(139 92 246 / 0.22); color: #ddd6fe; }
  :root:not([data-theme='light']) .avatar-tone-6 { background: rgb(6 182 212 / 0.2); color: #a5f3fc; }
  :root:not([data-theme='light']) .avatar-tone-7 { background: rgb(244 63 94 / 0.2); color: #fecdd3; }
}

:root[data-theme='dark'] .avatar-tone-0 { background: rgb(99 102 241 / 0.22); color: #c7d2fe; }
:root[data-theme='dark'] .avatar-tone-1 { background: rgb(59 130 246 / 0.22); color: #bfdbfe; }
:root[data-theme='dark'] .avatar-tone-2 { background: rgb(16 185 129 / 0.2); color: #a7f3d0; }
:root[data-theme='dark'] .avatar-tone-3 { background: rgb(245 158 11 / 0.2); color: #fde68a; }
:root[data-theme='dark'] .avatar-tone-4 { background: rgb(236 72 153 / 0.2); color: #fbcfe8; }
:root[data-theme='dark'] .avatar-tone-5 { background: rgb(139 92 246 / 0.22); color: #ddd6fe; }
:root[data-theme='dark'] .avatar-tone-6 { background: rgb(6 182 212 / 0.2); color: #a5f3fc; }
:root[data-theme='dark'] .avatar-tone-7 { background: rgb(244 63 94 / 0.2); color: #fecdd3; }

/* ---------- Tables, pagination ---------- */

.table-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  container-type: inline-size;
  container-name: table;
}

.table-card.is-bare {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.table-scroll {
  overflow-x: auto;
  transition: opacity var(--dur) var(--ease);
}

.table-scroll.is-refreshing {
  opacity: 0.55;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.table th {
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 550;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  vertical-align: middle;
}

.table th:first-child,
.table td:first-child {
  padding-left: 16px;
}

.table th:last-child,
.table td:last-child {
  padding-right: 16px;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:not(.row-state):not(.row-skeleton):hover td {
  background: var(--row-hover);
}

.table tbody tr.is-selected td {
  background: var(--accent-soft);
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.table tbody tr.is-clickable:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.table-dense th { height: 34px; }
.table-dense td { padding-top: 7px; padding-bottom: 7px; }

.table .align-right { text-align: right; }
.table .align-center { text-align: center; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 -6px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.th-sort:hover {
  background: var(--hover);
  color: var(--text);
}

.th-sort .icon {
  opacity: 0.45;
}

.th-sort.is-sorted {
  color: var(--text);
}

.th-sort.is-sorted .icon {
  color: var(--accent-text);
  opacity: 1;
}

.align-right .th-sort {
  flex-direction: row-reverse;
}

.cell-select {
  width: 44px;
}

.cell-actions {
  width: 56px;
  text-align: right;
}

.cell-primary {
  min-width: 180px;
  font-weight: 500;
}

.table-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
}

.table-link:hover .file-name-title,
.table-link:hover {
  color: var(--accent-text);
}

.row-state td {
  padding: 0 !important;
}

.row-skeleton td {
  padding-top: 15px;
  padding-bottom: 15px;
}

.table-bulkbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--accent-border);
  background: var(--accent-soft);
  font-size: 13px;
}

.table-bulkbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.table-inline-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.table-inline-error .btn {
  margin-left: auto;
}

.table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
}

.chart-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

@container table (max-width: 640px) {
  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tbody tr {
    position: relative;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .table tbody tr:last-child {
    border-bottom: 0;
  }

  .table tbody tr:has(> .cell-select) {
    padding-left: 46px;
  }

  .table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0 !important;
    border: 0;
    font-size: 13.5px;
    text-align: right;
  }

  .table td::before {
    content: attr(data-label);
    flex: none;
    max-width: 45%;
    color: var(--text-3);
    font-size: 12.5px;
    font-weight: 500;
    text-align: left;
  }

  .table td[data-label='']::before {
    content: none;
  }

  .table td.cell-primary {
    display: block;
    min-width: 0;
    padding: 0 40px 6px 0 !important;
    font-size: 14.5px;
    text-align: left;
  }

  .table td.cell-primary::before,
  .table td.cell-select::before,
  .table td.cell-actions::before {
    content: none;
  }

  .table td.cell-select {
    position: absolute;
    top: 15px;
    left: 16px;
    width: auto;
    padding: 0 !important;
  }

  .table td.cell-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    width: auto;
    padding: 0 !important;
  }

  .table tbody tr:not(.row-state):not(.row-skeleton):hover td {
    background: transparent;
  }

  .table tbody tr:not(.row-state):not(.row-skeleton):hover {
    background: var(--row-hover);
  }

  .table tr.row-state td,
  .table tr.row-skeleton td {
    display: block;
    text-align: left;
  }

  .table tr.row-skeleton td::before {
    content: none;
  }

  .table tr.row-skeleton td + td {
    margin-top: 8px;
  }

  .table tbody tr.row-state {
    padding: 0;
  }
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-3);
  font-size: 13px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination .select {
  width: auto;
}

.pagination-pages {
  display: inline-flex;
  gap: 2px;
}

.pagination-page {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.pagination-page:hover {
  background: var(--hover);
  color: var(--text);
}

.pagination-page.is-current {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.pagination-gap {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  color: var(--text-4);
}

.pagination-compact {
  display: none;
  min-width: 44px;
  color: var(--text-2);
  text-align: center;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.tabs-line {
  gap: 22px;
  box-shadow: inset 0 -1px 0 var(--border);
}

.tab {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}

.tab:hover:not(:disabled) {
  color: var(--text);
}

.tab:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.tab:focus-visible {
  border-radius: 6px;
  outline-offset: -2px;
}

.tabs-line .tab::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background-color var(--dur-fast) var(--ease);
}

.tabs-line .tab.is-active {
  color: var(--text);
}

.tabs-line .tab.is-active::after {
  background: var(--accent);
}

.tabs-pill {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--segmented-bg);
}

.tabs-pill .tab {
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
}

.tabs-pill .tab.is-active {
  background: var(--segmented-active);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
}

.tab-panel {
  border-radius: var(--radius-sm);
  outline: none;
}

.tab-panel:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

/* ---------- Overlays: modal, drawer ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  animation: fade-in var(--dur) var(--ease);
}

.overlay.is-closing .overlay-backdrop {
  animation: fade-out var(--dur-fast) var(--ease-in) forwards;
}

.overlay-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -4px -6px 0 auto;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
}

.overlay-close:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.overlay-close:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.modal-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-overlay);
  box-shadow: var(--shadow-lg);
  outline: none;
  animation: modal-in var(--dur-slow) var(--ease);
}

.overlay.is-closing .modal {
  animation: modal-out var(--dur-fast) var(--ease-in) forwards;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 20px 0 24px;
}

.modal-heading {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

.modal-title {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.modal-description {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--tone-bg, var(--accent-soft));
  color: var(--tone-fg, var(--accent-text));
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: 16px 24px 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0 0 16px 16px;
  background: var(--surface-2);
}

.confirm-dialog .modal-body {
  padding-top: 6px;
  padding-left: 78px;
}

.confirm-dialog .modal-body:empty {
  display: none;
}

.confirm-message {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.confirm-dialog .modal-body > * + * {
  margin-top: 14px;
}

.drawer-container {
  position: absolute;
  inset: 0;
  display: flex;
}

.drawer {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  height: 100%;
  background: var(--surface-overlay);
  box-shadow: var(--shadow-lg);
  outline: none;
}

.drawer-right {
  margin-left: auto;
  border-left: 1px solid var(--border);
  animation: drawer-in-right var(--dur-slow) var(--ease);
}

.drawer-left {
  margin-right: auto;
  border-right: 1px solid var(--border);
  animation: drawer-in-left var(--dur-slow) var(--ease);
}

.overlay.is-closing .drawer-right {
  animation: drawer-out-right var(--dur-fast) var(--ease-in) forwards;
}

.overlay.is-closing .drawer-left {
  animation: drawer-out-left var(--dur-fast) var(--ease-in) forwards;
}

.drawer-sm { max-width: 400px; }
.drawer-md { max-width: 520px; }
.drawer-lg { max-width: 720px; }
.drawer-nav { max-width: 288px; background: var(--sidebar-bg); }

.drawer-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-heading {
  flex: 1;
  min-width: 0;
}

.drawer-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--tone-bg, var(--accent-soft));
  color: var(--tone-fg, var(--accent-text));
}

.drawer-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.drawer-description {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 13px;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
}

.drawer-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes modal-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(6px) scale(0.985); } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { from { transform: none; } to { transform: translateY(100%); } }
@keyframes drawer-in-right { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out-right { from { transform: none; } to { transform: translateX(100%); } }
@keyframes drawer-in-left { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes drawer-out-left { from { transform: none; } to { transform: translateX(-100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes pop-in-up { from { opacity: 0; transform: translateY(4px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- Menus, popovers, tooltips ---------- */

.menu,
.popover {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-popover);
  max-width: calc(100vw - 16px);
  border: 1px solid var(--border);
  background: var(--surface-overlay);
  box-shadow: var(--shadow-popover);
  outline: none;
  animation: pop-in var(--dur) var(--ease);
}

.menu[data-side='top'],
.popover[data-side='top'] {
  animation-name: pop-in-up;
}

.menu {
  min-width: 200px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: min(440px, calc(100dvh - 16px));
  padding: 5px;
  overflow-y: auto;
  border-radius: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item.is-active,
.menu-item:focus-visible {
  background: var(--hover-strong);
  outline: none;
}

.menu-item-icon {
  color: var(--text-3);
}

.menu-item.is-active .menu-item-icon {
  color: var(--text-2);
}

.menu-item.is-danger,
.menu-item.is-danger .menu-item-icon {
  color: var(--danger);
}

.menu-item.is-danger.is-active {
  background: var(--danger-soft);
}

.menu-item.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.menu-item-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.menu-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item-description {
  color: var(--text-3);
  font-size: 12.5px;
  white-space: normal;
}

.menu-shortcut {
  margin-left: auto;
}

.menu-check {
  display: inline-grid;
  place-items: center;
  width: 16px;
  margin-left: auto;
  color: var(--accent-text);
}

.menu-divider {
  height: 1px;
  margin: 5px -5px;
  background: var(--border-subtle);
}

.menu-heading {
  padding: 8px 10px 4px;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover {
  max-height: calc(100dvh - 16px);
  overflow: auto;
  border-radius: 14px;
}

.popover-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
}

.popover-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tone-bg, var(--neutral-soft));
  color: var(--tone-fg, var(--text-2));
}

.popover-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.popover-subtitle {
  color: var(--text-3);
  font-size: 13px;
}

.popover-body {
  padding: 0 16px 8px;
}

.popover-note {
  margin: 0 16px 10px;
  color: var(--text-3);
  font-size: 12.5px;
}

.popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-tooltip);
  max-width: 280px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--tooltip-bg);
  color: var(--tooltip-fg);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  animation: fade-in var(--dur-fast) var(--ease);
}

/* ---------- Toasts ---------- */

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

body.has-modal .toast-region {
  top: 16px;
  right: auto;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-overlay);
  box-shadow: var(--shadow-popover);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease);
}

.toast.is-leaving {
  animation: toast-out var(--dur-fast) var(--ease-in) forwards;
}

.toast-icon {
  margin-top: 1px;
}

.toast-success .toast-icon { color: var(--success-solid); }
.toast-error .toast-icon { color: var(--danger-solid); }
.toast-warning .toast-icon { color: var(--warning-solid); }
.toast-info .toast-icon { color: var(--info-solid); }

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.toast-message {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.toast-title + .toast-message {
  margin-top: 1px;
  color: var(--text-2);
}

.toast-count {
  margin-left: 6px;
  color: var(--text-3);
  font-size: 12px;
}

.toast-action {
  flex: none;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}

.toast-action:hover {
  background: var(--surface-2);
}

.toast-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
}

.toast-close:hover {
  background: var(--hover);
  color: var(--text);
}

@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(4px) scale(0.98); } }

/* ---------- Empty, error, alerts, progress ---------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
}

.state-compact {
  padding: 32px 20px;
}

.state-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--tone-bg, var(--surface-3));
  color: var(--tone-fg, var(--text-3));
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}

.state-compact .state-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.state-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.state-description {
  max-width: 440px;
  color: var(--text-3);
  font-size: 13.5px;
  line-height: 1.5;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid;
  border-radius: var(--radius);
  font-size: 13.5px;
  line-height: 1.5;
}

.alert-icon {
  margin-top: 2px;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  color: var(--text);
  font-weight: 600;
}

.alert-text {
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.alert-title + .alert-text {
  margin-top: 1px;
}

.alert-action {
  flex: none;
  align-self: center;
}

.alert-dismiss {
  margin: -4px -6px -4px 0;
}

.alert-info { border-color: var(--info-border); background: var(--info-soft); }
.alert-info .alert-icon { color: var(--info); }
.alert-success { border-color: var(--success-border); background: var(--success-soft); }
.alert-success .alert-icon { color: var(--success); }
.alert-warning { border-color: var(--warning-border); background: var(--warning-soft); }
.alert-warning .alert-icon { color: var(--warning); }
.alert-danger { border-color: var(--danger-border); background: var(--danger-soft); }
.alert-danger .alert-icon { color: var(--danger); }
.alert-neutral { border-color: var(--border); background: var(--surface-2); }
.alert-neutral .alert-icon { color: var(--text-3); }
.alert-accent { border-color: var(--accent-border); background: var(--accent-soft); }
.alert-accent .alert-icon { color: var(--accent-text); }

.progress {
  --fill: var(--accent);
  display: grid;
  gap: 6px;
  min-width: 0;
}

.progress.tone-success { --fill: var(--success-solid); }
.progress.tone-warning { --fill: var(--warning-solid); }
.progress.tone-danger { --fill: var(--danger-solid); }
.progress.tone-info { --fill: var(--info-solid); }

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-3);
  font-size: 12.5px;
}

.progress-label {
  min-width: 0;
  overflow: hidden;
  color: var(--text-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-value {
  color: var(--text-2);
  font-weight: 550;
}

.progress-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fill) 15%, transparent);
}

.progress-sm .progress-track { height: 5px; }
.progress-lg .progress-track { height: 10px; }

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--fill);
  transition: width 260ms var(--ease);
}

.progress.is-indeterminate .progress-fill {
  width: 40%;
  animation: indeterminate 1.3s var(--ease) infinite;
}

@keyframes indeterminate {
  from { transform: translateX(-100%); }
  to { transform: translateX(260%); }
}

/* ---------- Copy field, QR ---------- */

.copy-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.copy-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.copy-field-row .input {
  flex: 1;
  font-size: 13px;
}

.qr {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-frame {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--border);
}

.qr-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-error {
  padding: 16px;
  color: #b91c1c;
  font-size: 13px;
  text-align: center;
}

/* ---------- Charts ---------- */

.chart {
  position: relative;
  min-width: 0;
}

.chart-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.chart-plot {
  position: relative;
  border-radius: 8px;
  outline: none;
  touch-action: pan-y;
  transition: opacity var(--dur) var(--ease);
}

.chart-plot:focus-visible {
  box-shadow: 0 0 0 2px var(--focus);
}

.chart-plot.is-refreshing {
  opacity: 0.55;
}

.chart-svg {
  display: block;
  overflow: visible;
}

.chart-grid line {
  stroke: var(--chart-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-grid line.is-base {
  stroke: var(--chart-axis);
}

.chart-axis text {
  fill: var(--chart-label);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: currentColor;
  stroke: none;
  opacity: var(--chart-area-opacity);
}

.chart-crosshair {
  stroke: var(--chart-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-dot {
  fill: currentColor;
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-bar {
  fill: currentColor;
  transition: opacity var(--dur-fast) var(--ease);
}

.chart-bar.is-dimmed {
  opacity: 0.45;
}

.chart-hit {
  fill: transparent;
}

.chart-empty {
  position: absolute;
  inset: 0 0 28px 40px;
  display: grid;
  place-items: center;
  padding: 0 16px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

.chart-empty span {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface);
}

.chart-empty-inline {
  padding: 20px 0;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

.chart-tooltip {
  position: absolute;
  top: 4px;
  z-index: 2;
  min-width: 120px;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-overlay);
  box-shadow: var(--shadow-popover);
  font-size: 12.5px;
  pointer-events: none;
  transform: translateX(12px);
}

.chart-tooltip.is-flipped {
  transform: translateX(calc(-100% - 12px));
}

.chart-tooltip-title {
  margin-bottom: 4px;
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}

.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-tooltip-row strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.chart-tooltip-label {
  overflow: hidden;
  color: var(--text-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-key-line {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 2px;
  border-radius: 2px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 10px;
  color: var(--text-2);
  font-size: 12.5px;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.barlist {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.barlist-row {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.barlist-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 13.5px;
}

.barlist-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
}

a.barlist-label:hover .barlist-text {
  color: var(--accent-text);
  text-decoration: underline;
}

.barlist-prefix {
  flex: none;
}

.barlist-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barlist-hint {
  min-width: 0;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barlist-value {
  flex: none;
  margin-left: auto;
  color: var(--text);
  font-weight: 550;
}

.barlist-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chart-accent) 12%, transparent);
}

.barlist-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--chart-accent);
}

.donut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
}

.donut-ring {
  position: relative;
  flex: none;
}

.donut-ring svg {
  display: block;
}

.donut-track {
  fill: none;
  stroke: var(--surface-3);
}

.donut-slice {
  fill: none;
  transition: opacity var(--dur-fast) var(--ease);
}

.donut-slice.is-dimmed {
  opacity: 0.35;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px;
  text-align: center;
  pointer-events: none;
}

.donut-value {
  color: var(--text);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.donut-label {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend {
  display: grid;
  flex: 1 1 200px;
  gap: 2px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.donut-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 13px;
}

.donut-legend-row.is-active {
  background: var(--hover);
}

.donut-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.donut-legend-label {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend-value {
  font-weight: 550;
  text-align: right;
}

.donut-legend-share {
  color: var(--text-3);
  font-size: 12.5px;
  text-align: right;
}

.sparkline {
  display: block;
  overflow: visible;
  color: var(--chart-accent);
}

.sparkline-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-area {
  fill: currentColor;
  opacity: var(--chart-area-opacity);
}

.sparkline-dot {
  fill: currentColor;
  stroke: var(--surface);
  stroke-width: 1.5;
}

.heatmap {
  display: grid;
  gap: 8px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 3px;
  border-radius: 6px;
  outline: none;
}

.heatmap-grid:focus-visible {
  box-shadow: 0 0 0 2px var(--focus);
}

.heatmap-cell {
  height: 30px;
  border-radius: 5px;
  transition: box-shadow var(--dur-fast) var(--ease);
}

.heatmap-cell.is-active {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--text-2);
}

.heat-0 { background: var(--heat-0); }
.heat-1 { background: var(--heat-1); }
.heat-2 { background: var(--heat-2); }
.heat-3 { background: var(--heat-3); }
.heat-4 { background: var(--heat-4); }
.heat-5 { background: var(--heat-5); }

.heatmap-axis {
  display: flex;
  justify-content: space-between;
  color: var(--chart-label);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.heatmap-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  color: var(--text-2);
  font-size: 12.5px;
}

.heatmap-scale {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 12px;
}

.heatmap-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.heatmap-swatch:first-of-type {
  margin-left: 4px;
}

.heatmap-swatch:last-of-type {
  margin-right: 4px;
}

/* ---------- Dropzone ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.dropzone:hover {
  border-color: var(--accent-border);
  background: var(--surface-2);
}

.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.dropzone.is-disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.dropzone-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.dropzone-hint {
  margin-top: 3px;
  color: var(--text-3);
  font-size: 13px;
}

.dropzone-compact {
  flex-direction: row;
  gap: 14px;
  padding: 16px 18px;
  text-align: left;
}

.dropzone-compact .dropzone-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.dropzone-compact .dropzone-text {
  flex: 1;
  min-width: 0;
}

.dropzone-compact .dropzone-title {
  font-size: 14px;
}

/* ---------- Page layout ---------- */

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.page-narrow { max-width: var(--page-narrow); }
.page-wide { max-width: none; }

.page-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  border-radius: 6px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.page-back:hover {
  color: var(--text);
}

.page-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-header-main {
  display: flex;
  flex: 1 1 320px;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.page-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
}

.page-heading {
  min-width: 0;
}

.page-title {
  font-size: 22px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.page-description {
  max-width: 720px;
  margin-top: 4px;
  color: var(--text-3);
  font-size: 14px;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-description {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 13px;
}

.section-actions {
  display: flex;
  gap: 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolbar-start,
.toolbar-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolbar-start {
  flex: 1 1 auto;
}

.toolbar .search-input {
  flex: 1 1 220px;
  width: auto;
  max-width: 340px;
}

.toolbar .select {
  width: auto;
  min-width: 150px;
}

/* ---------- App shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.shell.is-rail {
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
}

.shell.is-mobile {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-brand {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 10px 0 14px;
}

.sidebar-close {
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: -4px;
  padding: 4px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 78%, #ffffff), var(--brand));
  color: var(--brand-fg);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08), 0 1px 2px rgb(0 0 0 / 0.12);
}

.brand-mark svg {
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.brand-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-sub {
  color: var(--text-3);
  font-size: 12px;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 6px 10px 12px;
  overflow-y: auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-group-title {
  padding: 6px 10px 4px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--nav-active-bg);
  color: var(--text);
  font-weight: 550;
  box-shadow: var(--nav-active-shadow);
}

.nav-icon {
  color: var(--text-3);
}

.nav-item:hover .nav-icon {
  color: var(--text-2);
}

.nav-item.is-active .nav-icon {
  color: var(--accent-text);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
}

.sidebar-version {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.storage-meter {
  display: grid;
  gap: 6px;
  color: var(--text-3);
  font-size: 12px;
}

.storage-meter-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: var(--text-2);
  font-weight: 500;
}

.storage-meter-head span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.storage-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 8px;
  color: var(--text-3);
  font-size: 11px;
}

.shell.is-rail .sidebar-brand {
  justify-content: center;
  padding: 0;
}

.shell.is-rail .brand {
  margin: 0;
}

.shell.is-rail .brand-text,
.shell.is-rail .sidebar-version,
.shell.is-rail .sidebar-role {
  display: none;
}

.shell.is-rail .sidebar-nav {
  padding: 6px 0 12px;
}

.shell.is-rail .nav-group-title {
  height: 1px;
  margin: 6px 14px;
  padding: 0;
  overflow: hidden;
  background: var(--border-subtle);
  color: transparent;
}

.shell.is-rail .nav-item {
  justify-content: center;
  width: 40px;
  margin: 0 auto;
  padding: 0;
}

.shell.is-rail .nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell.is-rail .sidebar-footer {
  align-items: center;
  padding: 10px 0 12px;
}

.shell.is-rail .sidebar-meta {
  justify-content: center;
}

.shell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
}

.topbar-start,
.topbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-start {
  flex: 1 1 auto;
}

.topbar-end {
  flex: none;
}

.topbar-brand {
  display: inline-flex;
  border-radius: 8px;
  text-decoration: none;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(420px, 100%);
  height: 36px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-3);
  font-size: 14px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.search-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text-2);
}

.search-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-trigger-keys {
  display: inline-flex;
  gap: 4px;
}

.main {
  flex: 1;
  min-width: 0;
  outline: none;
}

.sync-pill,
.upload-indicator {
  display: inline-flex;
  flex: none;
  align-items: center;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.sync-pill {
  gap: 8px;
  padding: 0 12px 0 11px;
  color: var(--text-2);
}

.sync-pill:hover,
.sync-pill[aria-expanded='true'] {
  border-color: var(--border-strong);
  color: var(--text);
}

.sync-pill.is-compact {
  justify-content: center;
  width: 32px;
  padding: 0;
}

.upload-indicator {
  gap: 7px;
  padding: 0 11px 0 6px;
  color: var(--text-2);
}

.upload-indicator.is-active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.upload-indicator.has-error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.upload-indicator.is-done {
  border-color: var(--success-border);
  color: var(--success);
}

.progress-ring circle {
  fill: none;
  stroke-width: 2.5;
}

.progress-ring-track {
  stroke: color-mix(in srgb, currentColor 22%, transparent);
}

.progress-ring-fill {
  stroke: currentColor;
  stroke-linecap: round;
  transition: stroke-dasharray 300ms var(--ease);
}

.upload-mini-list {
  display: grid;
  gap: 12px;
  max-height: 320px;
  margin: 0;
  padding: 0 16px 12px;
  overflow-y: auto;
  list-style: none;
}

.upload-mini-item {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.upload-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.upload-mini-meta {
  color: var(--text-3);
  font-size: 12px;
}

.upload-mini-error {
  color: var(--danger);
  font-size: 12px;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 8px 0 4px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}

.user-trigger:hover,
.user-trigger[aria-expanded='true'] {
  background: var(--hover);
}

.user-trigger-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 150px;
  line-height: 1.2;
}

.user-trigger-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-trigger-role {
  color: var(--text-3);
  font-size: 11.5px;
}

.user-trigger-chevron {
  color: var(--text-3);
}

.shell-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  border-bottom: 1px solid var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.shell-banner > span {
  flex: 1;
  min-width: 0;
  color: var(--text-2);
}

.shell-banner strong {
  color: var(--danger);
}

.shell-banner-link {
  color: var(--danger);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.shell-banner-link:hover {
  text-decoration: underline;
}

.shell-banner-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  cursor: pointer;
}

.shell-banner-close:hover {
  background: var(--hover);
}

.dnd-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-dnd);
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  backdrop-filter: blur(3px);
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}

.dnd-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.dnd-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(560px, 100%);
  padding: 48px 32px;
  border: 2px dashed var(--accent);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.dnd-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.dnd-title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.dnd-hint {
  color: var(--text-3);
  font-size: 14px;
}

.shortcut-list {
  display: grid;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.shortcut-row:last-child {
  border-bottom: 0;
}

.shortcut-row dt {
  display: inline-flex;
  order: 2;
  gap: 4px;
}

.shortcut-row dd {
  color: var(--text-2);
  font-size: 14px;
}

/* ---------- Command palette ---------- */

.overlay-modal .modal-container:has(.palette-dialog) {
  align-items: flex-start;
  padding-top: 12vh;
}

.palette-dialog {
  max-width: 640px;
  overflow: hidden;
}

.palette {
  display: flex;
  flex-direction: column;
  max-height: min(560px, 76vh);
  max-height: min(560px, 76dvh);
}

.palette-search {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-3);
}

.palette-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.palette-input::placeholder {
  color: var(--text-placeholder);
}

.palette-results {
  flex: 1;
  min-height: 120px;
  padding: 6px;
  overflow-y: auto;
}

.palette-section + .palette-section {
  margin-top: 4px;
}

.palette-section-title {
  padding: 10px 10px 4px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 550;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 9px;
  color: var(--text);
  cursor: pointer;
}

.palette-item.is-active {
  background: var(--hover-strong);
}

.palette-item-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
}

.palette-item.is-active .palette-item-icon {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.palette-item-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.palette-item-label,
.palette-item-hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-item-label {
  font-size: 14px;
  font-weight: 500;
}

.palette-item-hint {
  color: var(--text-3);
  font-size: 12.5px;
}

.palette-item-enter {
  color: var(--text-4);
  opacity: 0;
}

.palette-item.is-active .palette-item-enter {
  opacity: 1;
}

.palette-empty {
  padding: 28px 16px;
  color: var(--text-3);
  font-size: 13.5px;
  text-align: center;
}

.palette-footer {
  display: flex;
  flex: none;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12px;
}

.palette-footer span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Login ---------- */

.auth {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 16px;
  overflow: hidden;
  background: var(--bg);
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1100px 520px at 50% -12%, color-mix(in srgb, var(--brand) 15%, transparent), transparent 70%),
    radial-gradient(700px 380px at 100% 110%, color-mix(in srgb, var(--brand) 7%, transparent), transparent 70%);
  pointer-events: none;
}

.auth-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse 70% 55% at 50% 0%, #000 30%, transparent 75%);
}

.auth-main {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 404px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 28px 26px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand .brand-mark {
  border-radius: 12px;
}

.auth-brand-text {
  min-width: 0;
}

.auth-site {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.auth-tagline {
  color: var(--text-3);
  font-size: 13px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-title {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  color: var(--text-3);
  font-size: 14px;
  line-height: 1.5;
}

.auth-step-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.auth-foot {
  color: var(--text-3);
  font-size: 12.5px;
  text-align: center;
  text-wrap: balance;
}

.auth-foot .icon {
  margin-right: 6px;
}

/* ---------- Boot, not found ---------- */

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
}

.boot .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  animation: boot-pulse 1.4s ease-in-out infinite;
}

.brand-mark-boot {
  background: linear-gradient(135deg, #6366f1, #4338ca);
}

@keyframes boot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.94); }
}

.boot-error .boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.boot-error-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
}

.boot-title {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 650;
}

.boot-text {
  margin-bottom: 8px;
  color: var(--text-3);
  font-size: 14px;
}

.notfound {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  padding: 72px 16px;
  text-align: center;
}

.notfound-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
}

.notfound-icon.tone-danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.notfound-code {
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.notfound-title {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.notfound-text {
  color: var(--text-3);
  font-size: 14.5px;
  line-height: 1.55;
}

.notfound-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.crash-detail {
  max-width: 100%;
  margin: 6px 0 0;
  padding: 10px 12px;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  text-align: left;
  white-space: pre-wrap;
}

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
  .hide-below-lg { display: none; }
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split,
  .split-even { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .hide-below-md { display: none; }
}

@media (max-width: 767.98px) {
  .page {
    gap: 20px;
    padding: 20px 16px 40px;
  }

  .page-title { font-size: 20px; }
  .page-actions { width: 100%; }
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kv-cols-2 { grid-template-columns: minmax(0, 1fr); }
  .radio-cols-2 .radio-grid,
  .radio-cols-3 .radio-grid { grid-template-columns: minmax(0, 1fr); }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .card-footer { padding: 12px 16px; }
  .hide-mobile { display: none !important; }

  .topbar {
    gap: 6px;
    padding: 0 8px;
  }

  .topbar-start,
  .topbar-end {
    gap: 4px;
  }

  .shell-banner { padding: 9px 16px; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .toolbar .search-input { max-width: none; flex-basis: 100%; }
  .heatmap-grid { gap: 2px; }
  .heatmap-cell { height: 24px; border-radius: 4px; }
}

@media (min-width: 768px) {
  .show-mobile { display: none !important; }
}

/* Phones and touch screens never show a tooltip (title): the approval badge says what it means in text. */
@media (max-width: 767.98px), (hover: none) {
  .approval-badge-note { display: inline; }
}

@media (max-width: 640px) {
  .hide-below-sm { display: none; }
  .pagination-pages { display: none; }
  .pagination-compact { display: inline-block; }

  .modal-container {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none !important;
    max-height: calc(100dvh - 24px);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    animation-name: sheet-in;
  }

  .overlay.is-closing .modal {
    animation-name: sheet-out;
  }

  .modal-header { padding: 18px 16px 0 18px; }
  .modal-body { padding: 14px 18px 18px; }

  .modal-footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
  }

  .modal-footer .btn { flex: 1 1 auto; }
  .confirm-dialog .modal-body { padding-left: 18px; }
  .drawer:not(.drawer-nav) { max-width: none; }

  .overlay-modal .modal-container:has(.palette-dialog) {
    align-items: flex-start;
    padding: 8px 8px 0;
  }

  .palette-dialog {
    max-height: calc(100dvh - 16px);
    border-bottom: 1px solid var(--border);
    border-radius: 16px;
    animation-name: modal-in;
  }

  .palette-footer { display: none; }

  .toast-region {
    top: max(12px, env(safe-area-inset-top, 0px));
    right: auto;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .auth-card { padding: 24px 20px; }
  .stat-spark { display: none; }
  .kv-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .donut { justify-content: center; }
}

/* ---------- Motion, forced colours, print ---------- */

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

  .spinner svg {
    animation: spin 1.6s linear infinite !important;
  }

  .skeleton {
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .btn,
  .input,
  .input-group,
  .select select,
  .card,
  .table-card,
  .badge,
  .menu,
  .popover,
  .modal,
  .drawer,
  .toast,
  .sync-pill,
  .upload-indicator,
  .search-trigger {
    border-color: CanvasText;
  }

  .nav-item.is-active,
  .tab.is-active,
  .segmented-item.is-selected,
  .pagination-page.is-current {
    outline: 2px solid Highlight;
  }

  .checkbox:checked,
  .radio:checked,
  .switch:checked,
  .progress-fill,
  .barlist-fill {
    background: Highlight;
  }

  .status-dot,
  .heatmap-cell,
  .donut-swatch,
  .qr-frame {
    forced-color-adjust: none;
  }
}

@media print {
  .sidebar,
  .topbar,
  .toast-region,
  .dnd-overlay,
  .shell-banner,
  .skip-link {
    display: none !important;
  }

  .shell {
    display: block;
  }

  body {
    background: #ffffff;
  }

  .card,
  .table-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
