/* =====================================================================
   ForaStack Design System: "Ink & Volt" (D-039)
   fora.css: tokens, reset, typography, components. Shared by every area.
   Light theme by default; dark only via the toggle ([data-theme="dark"]).
   Fonts: Geist + Geist Mono (SIL OFL, self-hosted). Icons: Lucide (ISC) sprite.
   ===================================================================== */

@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------------------------------------------------------------------
   1. Tokens
   --------------------------------------------------------------------- */
:root {
  /* Ink scale (cool neutrals) */
  --ink-950: #07080b;
  --ink-900: #0e1015;
  --ink-850: #14161c;
  --ink-800: #1a1d24;
  --ink-700: #262a33;
  --ink-600: #3b404b;
  --ink-500: #5b616d;
  --ink-400: #868c98;
  --ink-300: #b5bac3;
  --ink-200: #d9dce1;
  --ink-150: #e5e7eb;
  --ink-100: #eff0f3;
  --ink-50:  #f7f8fa;
  --white:   #ffffff;

  /* Volt (brand accent) */
  --volt-50:  #f8fde8;
  --volt-100: #f0fbcc;
  --volt-200: #e3f89a;
  --volt-300: #d6f76b;
  --volt-400: #c8f542;  /* brand */
  --volt-500: #b4e22c;
  --volt-600: #8fb81a;
  --volt-700: #4a6600;  /* text on white (AA) */
  --volt-800: #344800;

  /* Semantic */
  --red-50: #fef2f2;   --red-500: #e5484d;  --red-600: #cd2b31;  --red-700: #a51d22;
  --amber-50: #fff8eb; --amber-500: #f5a524; --amber-700: #8a5300;
  --blue-50: #eef3ff;  --blue-500: #3e63dd; --blue-700: #2443a8;

  /* Theme roles (light) */
  --bg:            var(--ink-50);
  --surface:       var(--white);
  --surface-2:     var(--ink-50);
  --surface-3:     var(--ink-100);
  --surface-inverse: var(--ink-900);
  --border:        var(--ink-150);
  --border-strong: var(--ink-200);
  --text:          var(--ink-900);
  --text-2:        var(--ink-600);
  --text-3:        var(--ink-500);
  --text-inverse:  var(--white);
  --accent:        var(--volt-400);
  --accent-hover:  var(--volt-500);
  --on-accent:     var(--ink-900);
  --accent-text:   var(--volt-700);
  --accent-soft:   var(--volt-100);
  --success-text:  var(--volt-700);
  --success-soft:  var(--volt-100);
  --danger:        var(--red-500);
  --danger-text:   var(--red-600);
  --danger-soft:   var(--red-50);
  --warning-text:  var(--amber-700);
  --warning-soft:  var(--amber-50);
  --info-text:     var(--blue-700);
  --info-soft:     var(--blue-50);
  --focus:         0 0 0 3px rgba(200, 245, 66, .55), 0 0 0 1px var(--ink-900);
  --overlay:       rgba(7, 8, 11, .48);

  /* Type */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: .75rem;    /* 12 */
  --fs-sm: .8125rem;  /* 13 */
  --fs-base: .9375rem;/* 15 */
  --fs-md: 1rem;      /* 16 */
  --fs-lg: 1.125rem;  /* 18 */
  --fs-xl: 1.375rem;  /* 22 */
  --fs-2xl: 1.75rem;  /* 28 */
  --fs-3xl: 2.25rem;  /* 36 */
  --fs-4xl: clamp(2.25rem, 4vw + 1rem, 3.5rem);
  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-normal: 1.55;
  --tracking-tight: -0.025em;
  --tracking-tighter: -0.04em;

  /* Space (8pt rhythm, 4pt steps) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px; --s-20: 80px;

  /* Shape & depth */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-full: 999px;
  --shadow-xs: 0 1px 2px rgba(7, 8, 11, .05);
  --shadow-sm: 0 1px 2px rgba(7, 8, 11, .06), 0 1px 1px rgba(7, 8, 11, .03);
  --shadow-md: 0 8px 24px -10px rgba(7, 8, 11, .18), 0 2px 6px -2px rgba(7, 8, 11, .06);
  --shadow-lg: 0 24px 48px -16px rgba(7, 8, 11, .28);

  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 160ms;

  --control-h: 44px;
  --control-h-sm: 36px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg:            #0a0b0e;
  --surface:       #111318;
  --surface-2:     #15181e;
  --surface-3:     #1b1e25;
  --surface-inverse: var(--white);
  --border:        #22262e;
  --border-strong: #2e333c;
  --text:          #f2f3f5;
  --text-2:        #b0b5bf;
  --text-3:        #868c98;
  --text-inverse:  var(--ink-900);
  --accent-text:   var(--volt-400);
  --accent-soft:   rgba(200, 245, 66, .12);
  --success-text:  var(--volt-400);
  --success-soft:  rgba(200, 245, 66, .12);
  --danger-text:   #ff6b70;
  --danger-soft:   rgba(229, 72, 77, .14);
  --warning-text:  #ffc15e;
  --warning-soft:  rgba(245, 165, 36, .14);
  --info-text:     #8ea8ff;
  --info-soft:     rgba(62, 99, 221, .16);
  --focus:         0 0 0 3px rgba(200, 245, 66, .5);
  --overlay:       rgba(0, 0, 0, .6);
  --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------------------------------------------------------------------
   2. Reset & base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(h1, h2, h3, h4, h5, p, ul, ol, figure, blockquote) { margin: 0; }
:where(ul, ol)[role="list"] { list-style: none; padding: 0; }
h1, h2, h3, h4 { line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); font-weight: 650; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
::selection { background: var(--volt-300); color: var(--ink-900); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--s-4); top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: var(--s-2) var(--s-4); border-radius: var(--r-sm); font-weight: 600; }
.skip-link:focus { top: var(--s-4); }

/* ---------------------------------------------------------------------
   3. Typography helpers
   --------------------------------------------------------------------- */
.display { font-size: var(--fs-4xl); letter-spacing: var(--tracking-tighter); line-height: 1.02; font-weight: 700; }
.h1 { font-size: var(--fs-2xl); letter-spacing: var(--tracking-tighter); }
.h2 { font-size: var(--fs-xl); }
.h3 { font-size: var(--fs-lg); }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.lead { font-size: var(--fs-md); color: var(--text-2); }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
/* Codes, keys, order numbers, SKUs, IPs: Geist Mono. Money and counts: Geist with even-width (tabular) digits,
   slightly heavier, so columns still line up but amounts read as prices, not code (owner decision, D-113). */
.mono, code, kbd { font-family: var(--font-mono); font-feature-settings: "tnum", "zero"; letter-spacing: -0.01em; }
.num { font-family: var(--font-sans); font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum", "lnum"; font-weight: 550; letter-spacing: -0.005em; }
.num.strong, strong.num, .strong .num { font-weight: 650; }
.input.num { font-weight: 500; }
.strong { font-weight: 600; }
.accent { color: var(--accent-text); }
.danger { color: var(--danger-text); }
kbd { font-size: .8em; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--surface); }
code { font-size: .875em; padding: 1px 5px; border-radius: var(--r-xs); background: var(--surface-3); }
pre code { font-size: inherit; padding: 0; border-radius: 0; background: none; color: inherit; } /* code blocks: no inline-code chip per line */

/* ---------------------------------------------------------------------
   4. Icons
   --------------------------------------------------------------------- */
.i {
  width: 18px; height: 18px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 28px; height: 28px; }

/* ---------------------------------------------------------------------
   5. Brand
   --------------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.brand-word { font-weight: 640; font-size: 19px; letter-spacing: var(--tracking-tighter); line-height: 1; }
.brand-word b { font-weight: 640; }

/* ---------------------------------------------------------------------
   6. Buttons
   --------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--control-h); padding: 0 var(--s-5);
  border-radius: var(--r-sm); border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: var(--fs-base); letter-spacing: -0.01em; line-height: 1;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 80ms var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { --btn-bg: var(--surface-2); --btn-bd: var(--ink-300); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-bd: transparent; box-shadow: inset 0 -1px 0 rgba(7, 8, 11, .12); }
.btn-primary:hover { --btn-bg: var(--accent-hover); --btn-bd: transparent; }
.btn-dark { --btn-bg: var(--ink-900); --btn-fg: var(--white); --btn-bd: var(--ink-900); }
.btn-dark:hover { --btn-bg: var(--ink-700); --btn-bd: var(--ink-700); }
[data-theme="dark"] .btn-dark { --btn-bg: var(--white); --btn-fg: var(--ink-900); --btn-bd: var(--white); }
[data-theme="dark"] .btn-dark:hover { --btn-bg: var(--ink-150); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { --btn-bg: var(--surface-3); --btn-bd: transparent; }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--danger-text); --btn-bd: var(--border-strong); }
.btn-danger:hover { --btn-bg: var(--danger-soft); --btn-bd: var(--danger); }
.btn-sm { height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-xs); }
.btn-lg { height: 52px; padding: 0 var(--s-6); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn .i { margin: 0 -2px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link { color: var(--text); font-weight: 600; text-decoration: underline; text-decoration-color: var(--volt-500); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text); }
.link-quiet { color: var(--text-2); text-decoration: none; }
.link-quiet:hover { color: var(--text); text-decoration: underline; }

/* ---------------------------------------------------------------------
   7. Forms
   --------------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: var(--s-4); }
.grid > .field + .field, .cluster > .field + .field { margin-top: 0; } /* side-by-side fields stay aligned */
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); }
.label .link-quiet { font-weight: 500; }
.hint { font-size: var(--fs-xs); color: var(--text-3); }
.field-error { font-size: var(--fs-xs); color: var(--danger-text); font-weight: 500; display: flex; gap: 6px; align-items: center; }

.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 var(--s-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: var(--fs-md); /* 16px: no iOS zoom */
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur);
}
.textarea { height: auto; min-height: 112px; padding: var(--s-3); resize: vertical; line-height: var(--lh-normal); }
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink-900); box-shadow: 0 0 0 3px rgba(200, 245, 66, .45); }
[data-theme="dark"] .input:focus, [data-theme="dark"] .select:focus, [data-theme="dark"] .textarea:focus { border-color: var(--volt-400); box-shadow: 0 0 0 3px rgba(200, 245, 66, .18); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(229, 72, 77, .2); }
.input:disabled { background: var(--surface-3); color: var(--text-3); }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b616d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .i { position: absolute; left: 13px; color: var(--text-3); pointer-events: none; }
.input-wrap > .i ~ .input { padding-left: 40px; }
.input-wrap > .input-action { position: absolute; right: 4px; height: 36px; width: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-3); border-radius: var(--r-xs); }
.input-wrap > .input-action:hover { color: var(--text); background: var(--surface-3); }
.input-wrap > .input-action ~ .input, .input-wrap .input:has(~ .input-action) { padding-right: 44px; }

.input-otp { font-family: var(--font-mono); font-size: 26px; letter-spacing: .5em; text-align: center; height: 60px; padding-left: .5em; font-weight: 500; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.check input { appearance: none; flex: none; width: 18px; height: 18px; margin: 1px 0 0; border: 1.5px solid var(--ink-300); border-radius: 5px; background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: all var(--dur) var(--ease); }
.check input::after { content: ""; width: 10px; height: 10px; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); background: var(--ink-900); transform: scale(0); transition: transform 120ms var(--ease); }
.check input:checked { background: var(--accent); border-color: var(--ink-900); }
.check input:checked::after { transform: scale(1); }
.check input:focus-visible { box-shadow: var(--focus); }

.switch { position: relative; display: inline-flex; width: 40px; height: 24px; flex: none; }
.switch input { appearance: none; position: absolute; inset: 0; margin: 0; border-radius: var(--r-full); background: var(--ink-200); cursor: pointer; transition: background var(--dur); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.switch input:checked { background: var(--ink-900); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent); }

.form-actions { display: flex; gap: var(--s-3); align-items: center; margin-top: var(--s-6); flex-wrap: wrap; }

.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.strength span { height: 3px; border-radius: 2px; background: var(--ink-150); transition: background var(--dur); }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--red-500); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--amber-500); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--volt-500); }
.strength[data-score="4"] span { background: var(--volt-600); }

/* ---------------------------------------------------------------------
   8. Surfaces
   --------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-xs); }
.card-body { padding: var(--s-6); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: var(--fs-md); font-weight: 650; letter-spacing: -0.015em; }
.card-header p { font-size: var(--fs-sm); color: var(--text-3); margin-top: 2px; }
.card-footer { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); display: flex; justify-content: flex-end; gap: var(--s-3); }
.card-inverse { background: var(--ink-900); color: var(--white); border-color: var(--ink-900); }
[data-theme="dark"] .card-inverse { background: var(--surface-3); border-color: var(--border-strong); }

.panel-list { display: grid; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--border); }
.panel-row:first-child { border-top: 0; }
.panel-row-main { display: flex; align-items: center; gap: var(--s-4); min-width: 0; }
.panel-row-title { font-weight: 600; font-size: var(--fs-base); }
.panel-row-sub { font-size: var(--fs-sm); color: var(--text-3); }
.icon-tile { width: 40px; height: 40px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-3); color: var(--text); border: 1px solid var(--border); }
.icon-tile.is-accent { background: var(--accent); color: var(--on-accent); border-color: transparent; }

/* ---------------------------------------------------------------------
   9. Feedback
   --------------------------------------------------------------------- */
.alert { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); border: 1px solid; font-size: var(--fs-sm); line-height: var(--lh-snug); align-items: flex-start; }
.alert .i { margin-top: 1px; }
.alert-title { font-weight: 600; display: block; margin-bottom: 2px; }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: color-mix(in srgb, var(--volt-600) 35%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--red-500) 30%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: color-mix(in srgb, var(--amber-500) 35%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: color-mix(in srgb, var(--blue-500) 25%, transparent); }
.alert a { color: inherit; font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .01em; white-space: nowrap; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-volt { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info-text); border-color: transparent; }
.badge-ink { background: var(--ink-900); color: var(--white); border-color: transparent; }
.badge-outline { background: transparent; }
.badge-soon { background: transparent; border-style: dashed; color: var(--text-3); font-weight: 500; }

.toast-stack { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 90; display: grid; gap: var(--s-2); width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--ink-900); color: var(--white); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: toast-in 240ms var(--ease); }
.toast .i { color: var(--volt-400); margin-top: 1px; }
.toast.is-error .i { color: #ff8a8e; }
.toast-close { margin-left: auto; background: none; border: 0; color: var(--ink-300); padding: 0; }
[data-theme="dark"] .toast { background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------------------------------------------------------------
   10. Data display
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-weight: 600; font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num, .table .t-right { text-align: right; }

.stat { padding: var(--s-5) var(--s-6); display: grid; gap: var(--s-2); }
.stat-label { font-size: var(--fs-sm); color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-value { font-family: var(--font-sans); font-feature-settings: "tnum", "lnum"; font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-meta { font-size: var(--fs-xs); color: var(--text-3); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-6); font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; }

.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 650; font-size: 13px; letter-spacing: -0.02em; background: var(--ink-900); color: var(--volt-400); }
[data-theme="dark"] .avatar { background: var(--volt-400); color: var(--ink-900); }

.code-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); padding: var(--s-4); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: var(--fs-base); }
.code-grid span { padding: 4px 8px; }

.empty { text-align: center; padding: var(--s-12) var(--s-6); display: grid; justify-items: center; gap: var(--s-3); }
.empty .icon-tile { width: 52px; height: 52px; border-radius: var(--r-md); }
.empty h3 { font-size: var(--fs-md); }
.empty p { color: var(--text-3); font-size: var(--fs-sm); max-width: 360px; }

.divider-text { display: flex; align-items: center; gap: var(--s-3); color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; margin: var(--s-6) 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.qr { background: var(--white); padding: 12px; border-radius: var(--r-md); border: 1px solid var(--border); width: 196px; height: 196px; }

/* Menus */
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: 6px; display: none; }
.menu.is-open .menu-panel { display: block; animation: toast-in 140ms var(--ease); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-xs); font-size: var(--fs-sm); color: var(--text); text-decoration: none; background: none; border: 0; text-align: left; }
.menu-item:hover { background: var(--surface-3); }
.menu-item .i { color: var(--text-3); }
.menu-item.is-danger { color: var(--danger-text); }
.menu-item.is-danger .i { color: currentColor; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

/* ---------------------------------------------------------------------
   11. Layout utilities
   --------------------------------------------------------------------- */
.stack { display: grid; gap: var(--s-4); }
.stack-sm { display: grid; gap: var(--s-2); }
.stack-lg { display: grid; gap: var(--s-8); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.grid { display: grid; gap: var(--s-4); }
.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)); }
@media (max-width: 960px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.w-full { width: 100%; }
.hide-sm { } @media (max-width: 720px) { .hide-sm { display: none !important; } }
.show-sm { display: none !important; } @media (max-width: 720px) { .show-sm { display: initial !important; } }

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

.link-button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.span-2 { grid-column: span 2; }
@media (max-width: 960px) { .span-2 { grid-column: 1 / -1; } }

/* ---------- Catalog primitives (Phase 6) ---------- */
.region-badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: var(--r-full); background: var(--ink-900); color: var(--white); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.region-badge .i { width: 14px; height: 14px; color: var(--volt-400); }
[data-theme="dark"] .region-badge { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.thumb { width: 40px; height: 40px; flex: none; border-radius: var(--r-sm); background: var(--surface-3); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; color: var(--text-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.accent-text { color: var(--accent-text); font-weight: 600; }
.success-text { color: var(--success-text); }
.clamp-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.cluster-end { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.grid-2-1 { display: grid; gap: var(--s-6); grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-2-1 { grid-template-columns: minmax(0, 1fr); } }
.input-pair { display: flex; }
.input-pair .input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.input-pair .select { width: auto; flex: none; border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.input-sm, .select-sm { height: var(--control-h-sm); font-size: var(--fs-sm); }
.card-accent { box-shadow: inset 0 3px 0 var(--volt-400), var(--shadow-xs); }

/* Responsive safety net (production audit, D-109): grid/flex children may shrink below their content width,
   so a long word, URL, badge or table never widens the page on phones. */
.grid > *, .grid-2-1 > *, .card-header > *, .page-head > *, .between > * { min-width: 0; }
.card-header > div:first-child { flex: 1 1 12rem; }
.page-head .badge { white-space: normal; height: auto; min-height: 22px; padding-top: 3px; padding-bottom: 3px; line-height: 1.35; }
.card-header h2, .card-header p, .page-head h1, .page-head p { overflow-wrap: anywhere; }
.stack > *, .stack-sm > *, .stack-lg > *, .panel-row-main > div { min-width: 0; }
.panel-row-title, .panel-row-sub { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .card-header { flex-wrap: wrap; padding: var(--s-4); }
  .card-body { padding: var(--s-4); }
  .card-footer { padding: var(--s-4); }
  .panel-row { flex-wrap: wrap; padding: var(--s-4); }
  .panel-row > form, .panel-row > .btn { margin-left: auto; }
  .page-head { margin-bottom: var(--s-6); }
}

img.avatar { display: block; object-fit: cover; background: var(--ink-900); box-shadow: 0 0 0 1px var(--border); }
img.avatar.avatar-lg { width: 48px; height: 48px; }
.user-btn img.avatar { width: 32px; height: 32px; }
