/* ============================================================================
   Project X — Design System
   ============================================================================
   Implements §61.32 (design system), §61.33 (design tokens) and §61.34
   (UI architecture: tokens → primitives → product components → features → pages).

   Architecture note: every visual decision resolves to a token defined in
   :root. Components below reference tokens only — no hardcoded colors, spacing,
   radii or durations. That is what makes the mobile-first breakpoint strategy
   (§61.1) coherent instead of a pile of one-off overrides.

   Responsiveness strategy (§61.2, §61.4):
     - layout is component-driven: grids use auto-fill/minmax so components adapt
       to their container rather than the viewport
     - Fluid breakpoints (§61.3) are introduced only where content actually
       restrains, not at device widths
     - Adaptive content uses fold / hide / reposition; primary mobile actions move
       to a sticky bottom action bar (§61.4)
   ============================================================================ */

/* ---------------------------------------------------------------- tokens --- */

:root {
  /* Spacing scale (§61.33) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-relaxed: 1.65;

  /* Radius */
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 13px;
  --r-xl: 18px;
  --r-full: 999px;

  /* Elevation */
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.28);
  --elev-2: 0 4px 14px rgba(0, 0, 0, 0.34);
  --elev-3: 0 12px 34px rgba(0, 0, 0, 0.46);

  /* Component dimensions — touch targets are >= 44px on small screens (§61.11) */
  --control-h: 40px;
  --control-h-touch: 46px;
  --control-h-sm: 32px;
  --sidebar-w: 244px;
  --topbar-h: 56px;

  /* Z-index scale (§61.33) */
  --z-base: 1;
  --z-sticky: 20;
  --z-drawer: 40;
  --z-modal: 60;
  --z-toast: 80;

  /* Motion — short and purpose-driven; respects reduced-motion below */
  --dur-fast: 110ms;
  --dur-base: 190ms;
  --dur-slow: 320ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Breakpoints are documented here as the contract components rely on:
     sm 480 · md 720 · lg 960 · xl 1200. Media queries use these values inline. */

  /* --- palette: dark-first, neutral, low-chroma so status colors carry meaning --- */
  --c-bg: #0a0e17;
  --c-surface: #111725;
  --c-surface-2: #161d2e;
  --c-surface-3: #1c2439;
  --c-border: #232c42;
  --c-border-strong: #303b56;

  --c-text: #e8ecf4;
  --c-text-muted: #9aa5bd;
  --c-text-faint: #6b7690;

  --c-accent: #5b8cff;
  --c-accent-hover: #6f9bff;
  --c-accent-soft: rgba(91, 140, 255, 0.13);
  --c-accent-text: #ffffff;

  --c-ok: #3ecf8e;
  --c-ok-soft: rgba(62, 207, 142, 0.13);
  --c-warn: #f0b849;
  --c-warn-soft: rgba(240, 184, 73, 0.13);
  --c-danger: #ff6b6b;
  --c-danger-soft: rgba(255, 107, 107, 0.13);
  --c-info: #63b3ed;
  --c-info-soft: rgba(99, 179, 237, 0.13);

  color-scheme: dark;
}

/* Light theme: only token values change, never component rules. */
:root[data-theme="light"] {
  --c-bg: #f7f8fb;
  --c-surface: #ffffff;
  --c-surface-2: #f2f4f8;
  --c-surface-3: #e8ebf2;
  --c-border: #dde1ea;
  --c-border-strong: #c3cad8;
  --c-text: #1a2033;
  --c-text-muted: #5a6480;
  --c-text-faint: #858da3;
  --c-accent: #3563e9;
  --c-accent-hover: #2a52c9;
  --c-accent-soft: rgba(53, 99, 233, 0.1);
  --c-ok: #16a163;
  --c-warn: #b8760a;
  --c-danger: #d93b3b;
  --c-info: #1f7ac4;
  --elev-1: 0 1px 2px rgba(16, 24, 40, 0.07);
  --elev-2: 0 4px 14px rgba(16, 24, 40, 0.09);
  --elev-3: 0 12px 34px rgba(16, 24, 40, 0.14);
  color-scheme: light;
}

/* ---------------------------------------------------------------- reset --- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: 620; }
p { margin: 0; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.92em; }
img, svg { max-width: 100%; }

/* A single, visible focus treatment everywhere (§61.11, §61.24). */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--sp-4); top: -100px;
  background: var(--c-accent); color: var(--c-accent-text);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  z-index: var(--z-toast); transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: var(--sp-4); }

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

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

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding-inline: clamp(var(--sp-3), 3vw, var(--sp-6));
  background: color-mix(in srgb, var(--c-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-border);
}

.app-body { display: flex; flex: 1; min-height: 0; }

/* Mobile: navigation is a drawer (§61.5), opened from the top bar. */
.app-sidebar {
  position: fixed; inset: var(--topbar-h) auto 0 0;
  width: min(88vw, var(--sidebar-w));
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  padding: var(--sp-4) var(--sp-3);
  overflow-y: auto;
  transform: translateX(-102%);
  transition: transform var(--dur-base) var(--ease);
  z-index: var(--z-drawer);
}
.app-sidebar[data-open="true"] { transform: translateX(0); }

.sidebar-scrim {
  position: fixed; inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease);
  z-index: calc(var(--z-drawer) - 1);
}
.sidebar-scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

.nav-group + .nav-group { margin-top: var(--sp-6); }
.nav-group-label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--c-text-faint); padding-inline: var(--sp-3); margin-bottom: var(--sp-2);
}

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md);
  color: var(--c-text-muted); font-weight: 500;
  min-height: var(--control-h-touch);
}
.nav-item:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--c-accent-soft); color: var(--c-accent); }
.nav-item .nav-icon { width: 18px; flex-shrink: 0; text-align: center; opacity: 0.9; }

.app-main {
  flex: 1; min-width: 0;
  padding: clamp(var(--sp-4), 2.4vw, var(--sp-8));
  padding-bottom: var(--sp-16); /* room for the sticky mobile action bar */
}

/* Desktop: the sidebar becomes permanent and the drawer affordance disappears. */
@media (min-width: 960px) {
  .app-sidebar {
    position: sticky; top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    transform: none; z-index: var(--z-base);
    width: var(--sidebar-w); flex-shrink: 0;
  }
  .sidebar-scrim { display: none; }
  .nav-toggle { display: none; }
  .app-main { padding-bottom: var(--sp-8); }
  .mobile-action-bar { display: none !important; }
}

.page-header {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--sp-6);
}
.page-header h1 { font-size: var(--fs-xl); }
.page-subtitle { color: var(--c-text-muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }

/* ----------------------------------------------------------- primitives --- */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: clamp(var(--sp-4), 2vw, var(--sp-6));
}
.card + .card { margin-top: var(--sp-4); }
.card-header {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.card-title { font-size: var(--fs-md); font-weight: 620; }
.card-hint { color: var(--c-text-muted); font-size: var(--fs-sm); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background: var(--c-surface-2); color: var(--c-text);
  font-weight: 560; font-size: var(--fs-base);
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--c-surface-3); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--c-accent-hover); border-color: var(--c-accent-hover); }
.btn-danger { background: transparent; border-color: var(--c-danger); color: var(--c-danger); }
.btn-danger:hover:not(:disabled) { background: var(--c-danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--c-text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--c-surface-2); color: var(--c-text); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--control-h); }

/* On touch-sized viewports every control meets the 44px target (§61.11). */
@media (max-width: 719px) {
  .btn { min-height: var(--control-h-touch); }
  .btn-sm { min-height: var(--control-h); }
}

/* Forms (§61.12, §61.13) */
.field { margin-bottom: var(--sp-4); }
.field-label {
  display: block; font-weight: 560; font-size: var(--fs-sm);
  margin-bottom: var(--sp-2);
}
.field-hint { color: var(--c-text-muted); font-size: var(--fs-xs); margin-top: var(--sp-1); line-height: var(--lh-relaxed); }

.input, .textarea, .select {
  width: 100%; min-height: var(--control-h);
  padding: var(--sp-2) var(--sp-3);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-size: var(--fs-base); font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--c-accent); background: var(--c-surface);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-faint); }
.input[aria-invalid="true"] { border-color: var(--c-danger); }
.textarea { min-height: 110px; resize: vertical; line-height: var(--lh-relaxed); font-family: var(--font-mono); font-size: var(--fs-sm); }
@media (max-width: 719px) { .input, .select { min-height: var(--control-h-touch); } }

.field-error {
  color: var(--c-danger); font-size: var(--fs-xs);
  margin-top: var(--sp-1); display: flex; gap: var(--sp-1); align-items: flex-start;
}

/* Badges & status (§61.15) */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-neutral { background: var(--c-surface-3); color: var(--c-text-muted); border-color: var(--c-border); }
.badge-ok { background: var(--c-ok-soft); color: var(--c-ok); border-color: color-mix(in srgb, var(--c-ok) 32%, transparent); }
.badge-warn { background: var(--c-warn-soft); color: var(--c-warn); border-color: color-mix(in srgb, var(--c-warn) 32%, transparent); }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); border-color: color-mix(in srgb, var(--c-danger) 32%, transparent); }
.badge-info { background: var(--c-info-soft); color: var(--c-info); border-color: color-mix(in srgb, var(--c-info) 32%, transparent); }
.badge-accent { background: var(--c-accent-soft); color: var(--c-accent); border-color: color-mix(in srgb, var(--c-accent) 32%, transparent); }

/* Status dot with a label — pairs color with text so meaning never depends on
   color alone (§61.24). */
.status { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.status-dot { width: 7px; height: 7px; border-radius: var(--r-full); flex-shrink: 0; background: currentColor; }
.status-ready { color: var(--c-ok); }
.status-progress { color: var(--c-info); }
.status-failed { color: var(--c-danger); }
.status-idle { color: var(--c-text-faint); }

/* Alerts */
.alert {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  font-size: var(--fs-sm); line-height: var(--lh-relaxed);
}
.alert-info { border-color: color-mix(in srgb, var(--c-info) 34%, transparent); background: var(--c-info-soft); }
.alert-warn { border-color: color-mix(in srgb, var(--c-warn) 34%, transparent); background: var(--c-warn-soft); }
.alert-danger { border-color: color-mix(in srgb, var(--c-danger) 34%, transparent); background: var(--c-danger-soft); }
.alert-ok { border-color: color-mix(in srgb, var(--c-ok) 34%, transparent); background: var(--c-ok-soft); }
.alert-title { font-weight: 620; margin-bottom: var(--sp-1); }
.alert + .alert { margin-top: var(--sp-2); }

/* ------------------------------------------------------ product comps --- */

/* Project / deployment grids — container-driven, not viewport-driven (§61.2) */
.grid-cards {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
.grid-split {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.project-card {
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--sp-4);
  transition: border-color var(--dur-fast) var(--ease);
}
.project-card:hover { border-color: var(--c-border-strong); }
.project-card-name { font-weight: 620; font-size: var(--fs-md); }
.project-card-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.project-card-footer {
  display: flex; gap: var(--sp-2); align-items: center;
  margin-top: auto; padding-top: var(--sp-3); border-top: 1px solid var(--c-border);
}

/* Definition rows — label/value pairs that fold to stacked on narrow screens */
.def-list { display: grid; gap: var(--sp-3); }
.def-row {
  display: grid; gap: 2px;
  grid-template-columns: 1fr;
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--c-border);
}
.def-row:last-child { border-bottom: none; padding-bottom: 0; }
.def-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-faint); }
.def-value { font-size: var(--fs-base); word-break: break-word; }
@media (min-width: 560px) {
  .def-row { grid-template-columns: minmax(140px, 200px) 1fr; gap: var(--sp-4); align-items: baseline; }
}

/* Responsive tables (§61.17): real tables on desktop; each row becomes a labelled
   card on mobile, so no horizontal scrolling and no hidden columns. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.data td { text-align: left; padding: var(--sp-3); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
table.data th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-faint); font-weight: 600; }
table.data tbody tr:hover { background: var(--c-surface-2); }

@media (max-width: 719px) {
  table.data.responsive thead { display: none; }
  table.data.responsive, table.data.responsive tbody, table.data.responsive tr, table.data.responsive td { display: block; width: 100%; }
  table.data.responsive tr {
    border: 1px solid var(--c-border); border-radius: var(--r-md);
    padding: var(--sp-3); margin-bottom: var(--sp-2); background: var(--c-surface-2);
  }
  table.data.responsive td { border: none; padding: var(--sp-1) 0; display: flex; gap: var(--sp-3); justify-content: space-between; }
  table.data.responsive td::before {
    content: attr(data-label);
    font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--c-text-faint); flex-shrink: 0;
  }
}

/* Log viewer (§61.18) */
.log-viewer {
  background: #070a12;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.7;
  max-height: 460px; overflow-y: auto;
  overscroll-behavior: contain;
}
:root[data-theme="light"] .log-viewer { background: #0d1220; color: #dbe3f0; }
.log-line { display: flex; gap: var(--sp-3); padding: 1px 0; }
.log-seq { color: var(--c-text-faint); min-width: 2.5em; text-align: right; flex-shrink: 0; }
.log-phase { color: var(--c-info); min-width: 8.5em; flex-shrink: 0; }
.log-msg { flex: 1; word-break: break-word; white-space: pre-wrap; }
.log-error .log-msg { color: var(--c-danger); }
.log-warn .log-msg { color: var(--c-warn); }

/* Findings (§61.30) — the four severities must be instantly distinguishable */
.finding {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--c-border);
  border-left-width: 3px;
  border-radius: var(--r-md);
  background: var(--c-surface-2);
}
.finding + .finding { margin-top: var(--sp-2); }
.finding-blocking { border-left-color: var(--c-danger); }
.finding-security { border-left-color: var(--c-warn); }
.finding-config { border-left-color: var(--c-info); }
.finding-recommendation { border-left-color: var(--c-text-faint); }
.finding-body { flex: 1; min-width: 0; }
.finding-title { font-weight: 600; margin-bottom: var(--sp-1); }
.finding-detail { color: var(--c-text-muted); font-size: var(--fs-sm); line-height: var(--lh-relaxed); }
.finding-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); align-items: center; }
.finding-loc {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  background: var(--c-surface-3); padding: 2px var(--sp-2); border-radius: var(--r-sm);
  color: var(--c-text-muted); word-break: break-all;
}
.finding-action {
  margin-top: var(--sp-3); padding: var(--sp-3);
  background: var(--c-surface-3); border-radius: var(--r-sm);
  font-size: var(--fs-sm); line-height: var(--lh-relaxed);
}
.finding-evidence {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--c-text-faint); word-break: break-all; margin-top: var(--sp-2);
}

/* Severity rollup chips */
.severity-summary { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.severity-chip {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--c-border); background: var(--c-surface-2);
  min-width: 96px; flex: 1;
}
.severity-chip .count { font-size: var(--fs-xl); font-weight: 680; line-height: 1; }
.severity-chip .label { font-size: var(--fs-xs); color: var(--c-text-muted); }
.severity-chip[data-severity="BLOCKING"] { border-color: color-mix(in srgb, var(--c-danger) 40%, transparent); }
.severity-chip[data-severity="BLOCKING"] .count { color: var(--c-danger); }
.severity-chip[data-severity="SECURITY_ISSUE"] .count { color: var(--c-warn); }
.severity-chip[data-severity="CONFIGURATION_REQUIRED"] .count { color: var(--c-info); }
.severity-chip[data-severity="RECOMMENDATION"] .count { color: var(--c-text-faint); }

/* Import progress (§61.29) */
.stage-list { display: flex; flex-direction: column; gap: var(--sp-1); }
.stage {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md);
  color: var(--c-text-faint); font-size: var(--fs-sm);
}
.stage[data-state="active"] { background: var(--c-accent-soft); color: var(--c-accent); font-weight: 600; }
.stage[data-state="done"] { color: var(--c-text-muted); }
.stage[data-state="failed"] { color: var(--c-danger); font-weight: 600; }
.stage-icon { width: 18px; text-align: center; flex-shrink: 0; }
.stage-detail { margin-left: auto; font-size: var(--fs-xs); color: var(--c-text-faint); }

/* Dropzone (§61.10 hybrid input) */
.dropzone {
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-8) var(--sp-4);
  text-align: center;
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  cursor: pointer;
}
.dropzone:hover, .dropzone[data-dragover="true"] {
  border-color: var(--c-accent); background: var(--c-accent-soft); color: var(--c-text);
}
.dropzone-title { font-weight: 620; color: var(--c-text); margin-bottom: var(--sp-1); }

/* Tabs (§61.11 roving-tabindex pattern) */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--c-border); overflow-x: auto; margin-bottom: var(--sp-4); }
.tab {
  padding: var(--sp-3) var(--sp-4);
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  color: var(--c-text-muted); font-weight: 560; cursor: pointer;
  white-space: nowrap; min-height: var(--control-h);
}
.tab:hover { color: var(--c-text); }
.tab[aria-selected="true"] { color: var(--c-accent); border-bottom-color: var(--c-accent); }

/* Skeleton loading (§61.19) */
.skeleton {
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-surface-3) 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 0.85em; margin-bottom: var(--sp-2); }
.skeleton-card { height: 132px; border-radius: var(--r-lg); }

/* Empty & error states (§61.27, §61.28) */
.state-block {
  text-align: center; padding: var(--sp-12) var(--sp-4);
  border: 1px dashed var(--c-border); border-radius: var(--r-lg);
  background: var(--c-surface);
}
.state-icon { font-size: 1.75rem; margin-bottom: var(--sp-3); opacity: 0.65; }
.state-title { font-weight: 620; font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.state-detail { color: var(--c-text-muted); max-width: 46ch; margin-inline: auto; line-height: var(--lh-relaxed); }
.state-actions { margin-top: var(--sp-4); display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; }

/* Toast (§61.26) */
.toast-region {
  position: fixed; z-index: var(--z-toast);
  left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none;
}
@media (min-width: 720px) {
  .toast-region { left: auto; right: var(--sp-6); bottom: var(--sp-6); width: min(380px, 90vw); }
}
.toast {
  pointer-events: auto;
  display: flex; gap: var(--sp-3); align-items: flex-start;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border-strong);
  border-left-width: 3px;
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--elev-3);
  font-size: var(--fs-sm);
  animation: toast-in var(--dur-base) var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast-ok { border-left-color: var(--c-ok); }
.toast-error { border-left-color: var(--c-danger); }
.toast-warn { border-left-color: var(--c-warn); }
.toast-info { border-left-color: var(--c-info); }
.toast-close { background: none; border: none; color: var(--c-text-faint); cursor: pointer; padding: 0; font-size: var(--fs-md); line-height: 1; }
.toast-close:hover { color: var(--c-text); }

/* Modal / drawer / bottom sheet (§61.25) */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62);
  z-index: var(--z-modal);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: fade-in var(--dur-fast) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%; max-height: 92vh; overflow-y: auto;
  padding: var(--sp-6);
  box-shadow: var(--elev-3);
  animation: sheet-up var(--dur-base) var(--ease);
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* Above the mobile breakpoint it becomes a centered dialog (§61.25) */
@media (min-width: 720px) {
  .modal-scrim { align-items: center; padding: var(--sp-6); }
  .modal { border-radius: var(--r-xl); max-width: 560px; max-height: 86vh; }
  .modal-lg { max-width: 780px; }
}
.modal-header { display: flex; gap: var(--sp-3); align-items: flex-start; justify-content: space-between; margin-bottom: var(--sp-4); }
.modal-title { font-size: var(--fs-lg); font-weight: 640; }
.modal-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-6); flex-wrap: wrap; }
@media (max-width: 719px) {
  .modal-actions { position: sticky; bottom: 0; background: var(--c-surface); padding-top: var(--sp-3); }
  .modal-actions .btn { flex: 1; }
}

/* Sticky mobile action bar (§61.4 reposition) */
.mobile-action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky);
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--c-surface) 96%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--c-border);
}
.mobile-action-bar .btn { flex: 1; }

/* Copy-to-clipboard field for one-time tokens */
.token-reveal {
  display: flex; gap: var(--sp-2); align-items: stretch;
  background: var(--c-surface-3); border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md); padding: var(--sp-2);
}
.token-reveal code {
  flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap;
  font-size: var(--fs-xs); padding: var(--sp-2); display: flex; align-items: center;
}

/* Code block */
.code-block {
  background: var(--c-surface-3); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: var(--sp-3);
  font-family: var(--font-mono); font-size: var(--fs-xs);
  overflow-x: auto; white-space: pre; line-height: var(--lh-relaxed);
}

/* Landing page */
.landing { max-width: 1120px; margin: 0 auto; padding: clamp(var(--sp-6), 5vw, var(--sp-16)) clamp(var(--sp-4), 3vw, var(--sp-8)); }
.landing-hero { max-width: 60ch; margin-bottom: var(--sp-12); }
.landing-hero h1 { font-size: clamp(var(--fs-2xl), 5vw, var(--fs-3xl)); margin-bottom: var(--sp-4); }
.landing-hero p { color: var(--c-text-muted); font-size: var(--fs-md); line-height: var(--lh-relaxed); }
.landing-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-6); }
.feature-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.feature { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--sp-4); }
.feature h3 { font-size: var(--fs-base); margin-bottom: var(--sp-2); }
.feature p { color: var(--c-text-muted); font-size: var(--fs-sm); line-height: var(--lh-relaxed); }

/* Centered auth/verify screens */
.centered-page {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--sp-6) var(--sp-4);
}
.auth-card { width: 100%; max-width: 420px; }
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 680; letter-spacing: -0.01em; }
.brand-mark {
  width: 24px; height: 24px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--c-accent), var(--c-info));
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* Utility */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--sp-2); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--c-text-muted); }
.faint { color: var(--c-text-faint); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break-all { word-break: break-all; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.hidden { display: none !important; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.flex-1 { flex: 1; }
