/* ══════════════════════════════════════════════════════════════════════════
   SWU Tracker — Nocturne design system, retuned for the app.

   Tokens first (dark ground by default, light under [data-theme="light"]),
   then the component classes the templates use. Plain CSS on plain HTML;
   the only JS is the theme toggle and a few progressive enhancements.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Type: Inter, self-hosted variable face (no runtime CDN requests) ──── */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter/Inter-Variable.260c81a4759b.woff2") format("woff2");
}

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Ground */
  --color-bg:      #080a11;
  --color-surface: #10131d;
  --color-text:    #e6e8ee;
  --color-divider: color-mix(in srgb, #e6e8ee 14%, transparent);
  --page-glow:     radial-gradient(60rem 30rem at 0% 0%, #172645 0, transparent 70%);

  /* Neutral ramp (light → dark) */
  --color-neutral-100: #f1f3fa;
  --color-neutral-200: #dfe3ef;
  --color-neutral-300: #c6cbdb;
  --color-neutral-400: #a7adc0;
  --color-neutral-500: #868ca1;
  --color-neutral-600: #676d82;
  --color-neutral-700: #4b5064;
  --color-neutral-800: #323648;
  --color-neutral-900: #1e2130;

  /* Accent — holo blue */
  --color-accent:     #5b8def;
  --color-accent-100: #eef3ff;
  --color-accent-200: #d9e4ff;
  --color-accent-300: #b4c8fb;
  --color-accent-400: #86a7f5;
  --color-accent-500: #5b8def;
  --color-accent-600: #3f6fcc;
  --color-accent-700: #2f549c;
  --color-accent-800: #223c6d;
  --color-accent-900: #172645;

  /* Semantic — Rebel green (good) / Sith red (bad) */
  --color-good:        #8fd4a6;
  --color-good-fill:   #1b4a30;
  --color-good-strong: #2f8a55;
  --color-bad:         #f0a0a4;
  --color-bad-fill:    #5a1f24;
  --color-bad-strong:  #a9363e;

  /* Elevation */
  --shadow-sm: 0 0 0 1px #323648;
  --shadow-md: 0 0 0 1px #4b5064, 0 6px 18px rgba(0,0,0,.6);
  --shadow-lg: 0 0 0 1px #868ca1, 0 16px 40px rgba(0,0,0,.7);

  /* Type + rhythm */
  --font-heading: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading-weight: 500;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Menlo", monospace;

  --space-1: 2.8px;
  --space-2: 5.6px;
  --space-3: 8.4px;
  --space-4: 11.2px;
  --space-6: 16.8px;
  --space-8: 22.4px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --sidebar-w: 228px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-bg:      #f2f3f7;
  --color-surface: #fbfbfd;
  --color-text:    #151826;
  --color-divider: color-mix(in srgb, #151826 14%, transparent);
  --page-glow:     radial-gradient(60rem 30rem at 0% 0%, #d9e4ff 0, transparent 70%);

  --color-neutral-100: #1e2130;
  --color-neutral-200: #323648;
  --color-neutral-300: #4b5064;
  --color-neutral-400: #676d82;
  --color-neutral-500: #7d8398;
  --color-neutral-600: #a7adc0;
  --color-neutral-700: #c6cbdb;
  --color-neutral-800: #dfe3ef;
  --color-neutral-900: #eceef5;

  --color-accent:     #2f5fbd;
  --color-accent-100: #172645;
  --color-accent-200: #223c6d;
  --color-accent-300: #2f549c;
  --color-accent-400: #3f6fcc;
  --color-accent-500: #2f5fbd;
  --color-accent-600: #86a7f5;
  --color-accent-700: #b4c8fb;
  --color-accent-800: #d9e4ff;
  --color-accent-900: #eef3ff;

  --color-good:        #1f6b40;
  --color-good-fill:   #d3efdc;
  --color-good-strong: #2f8a55;
  --color-bad:         #9b2a32;
  --color-bad-fill:    #f7d9db;
  --color-bad-strong:  #c94b52;

  --shadow-sm: 0 0 0 1px #dfe3ef;
  --shadow-md: 0 0 0 1px #c6cbdb, 0 6px 18px rgba(21,24,38,.12);
  --shadow-lg: 0 0 0 1px #a7adc0, 0 16px 40px rgba(21,24,38,.18);
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  color: var(--color-text);
  background: var(--page-glow), var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: 30px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--color-accent-400); }
img { display: block; max-width: 100%; }
strong, b { font-weight: 500; }
code { font-family: var(--font-mono); font-size: .88em; background: color-mix(in srgb, var(--color-text) 7%, transparent); padding: .1em .35em; border-radius: var(--radius-sm); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--color-accent); }
[hidden] { display: none !important; }

/* Inline SVG icons (Phosphor, regular) */
.ph { width: 17px; height: 17px; flex: none; vertical-align: -3px; }
.ph-sm { width: 13px; height: 13px; vertical-align: -2px; }
.ph-lg { width: 32px; height: 32px; }

/* Text utilities */
.text-muted, .dim { color: var(--color-neutral-500); }
.text-sub { font-size: 12px; color: var(--color-neutral-500); }
.text-good { color: var(--color-good); }
.text-bad  { color: var(--color-bad); }
.text-accent { color: var(--color-accent-300); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hint {
  width: 13px; height: 13px; vertical-align: -1px; margin-left: 2px;
  color: var(--color-neutral-500); cursor: help;
}
.hint:hover { color: var(--color-accent-300); }

/* — rules — fade to transparent at both ends (Nocturne signature) */
.hr {
  height: 1px; border: 0; margin: var(--space-4) 0;
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent);
}
.hr-inline { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--color-neutral-600); }
.hr-inline .hr { flex: 1; margin: 0; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { color: var(--color-text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-danger { color: var(--color-bad); border-color: var(--color-bad-strong); }
.btn-danger:hover { color: var(--color-bad); background: color-mix(in srgb, var(--color-bad-strong) 16%, transparent); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; margin-top: var(--space-2); }
.btn-sm { padding: 3px 10px; font-size: 13px; }
.btn-back { margin-left: -4px; }
/* legacy alias */
.btn-accent { color: var(--color-accent); border-color: var(--color-accent); }
.btn-accent:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; }
.field > label, .field > .field-label, .field-label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
.input:disabled { opacity: .6; }
.input::placeholder { color: var(--color-neutral-600); }
select.input { appearance: auto; cursor: pointer; }
textarea.input { min-height: 90px; resize: vertical; }
.input-auto { width: auto; }
.input-compact { min-height: 30px; padding: 2px 8px; font-size: 13px; }
.input-num { width: 72px; text-align: right; }
.input-date { width: 130px; }
input[type=file].input { padding: 5px 10px; }
input[type=file].input::file-selector-button {
  font: inherit; font-size: 13px; cursor: pointer; margin-right: 10px;
  color: var(--color-text); background: transparent;
  border: 1px solid var(--color-divider); border-radius: var(--radius-sm); padding: 3px 10px;
}
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.form-hint { font-size: 12px; color: var(--color-neutral-500); margin: 0; line-height: 1.5; }
.form-error {
  font-size: 13px; color: var(--color-bad);
  background: color-mix(in srgb, var(--color-bad-strong) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-bad-strong) 50%, transparent);
  padding: 8px 10px; border-radius: var(--radius-md);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-neutral-300); cursor: pointer; }

/* Search input with a leading icon */
.search { position: relative; flex: 1; min-width: 220px; }
.search .ph { position: absolute; left: 10px; top: 10px; color: var(--color-neutral-500); width: 15px; height: 15px; }
.search .input { padding-left: 32px; }

/* Radio (custom dot) */
.radio { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 14px; }
.radio input, .seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.radio .dot { width: 16px; height: 16px; flex: none; border-radius: 50%; margin-top: 3px; border: 1.5px solid var(--color-divider); }
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot { border-color: var(--color-accent); background: var(--color-accent); box-shadow: inset 0 0 0 4px var(--color-bg); }
.radio input:focus-visible + .dot { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.radio-stack { display: flex; flex-direction: column; gap: 10px; }
.radio strong { font-weight: 500; }
.radio .text-sub { display: block; }

/* Segmented control — works for radios and for plain links */
.seg { display: inline-flex; overflow: hidden; border: 1px solid var(--color-divider); border-radius: var(--radius-md); }
.seg-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 13px; cursor: pointer; color: var(--color-text);
  position: relative; white-space: nowrap;
}
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked), .seg-opt[aria-current] { color: var(--color-accent); box-shadow: inset 0 0 0 1px var(--color-accent); }
.seg-opt:not(:has(input:checked)):not([aria-current]):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.seg-opt .text-sub { font-size: 11px; }

/* Chip (filter pill) */
.chip {
  cursor: pointer; font-size: 12px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--color-divider); background: transparent;
  color: var(--color-neutral-300); font: inherit; font-size: 12px; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.chip:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.chip[aria-pressed='true'], .chip.is-on { color: var(--color-accent); border-color: var(--color-accent); }
select.chip { appearance: none; padding-right: 22px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%23868ca1'><path d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/></svg>") no-repeat right 8px center / 11px;
}
select.chip.is-on { color: var(--color-accent); border-color: var(--color-accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-surface);
}
.card-row { flex-direction: row; align-items: center; gap: var(--space-4); }
.card-pad { padding: var(--space-6); gap: var(--space-4); }
.card-kicker, .kicker { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-accent); }
.card-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 17px; line-height: 1.2; }
.card-body { margin: 0; font-size: 13px; opacity: .8; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.card .btn-ghost { align-self: flex-start; }
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* Card art — <img> from cdn.swu-db.com, or a neutral placeholder <span> */
.thumb {
  flex: none; display: block; border-radius: 4px; object-fit: cover; object-position: top;
  background: linear-gradient(160deg, var(--color-neutral-800), var(--color-neutral-900));
}
.thumb-sm { width: 26px; height: 36px; border-radius: 3px; }
.thumb-md { width: 42px; height: 59px; }
.thumb-lg { width: 56px; height: 78px; border-radius: 5px; }
.thumb-xl { width: 220px; height: 308px; border-radius: 10px; max-width: 100%; }
.thumb-wide.thumb-sm { width: 36px; height: 26px; }
.thumb-wide.thumb-md { width: 59px; height: 42px; }
.thumb-wide.thumb-lg { width: 78px; height: 56px; }
.thumb-wide.thumb-xl { width: 308px; height: 220px; }
.thumb-grid { width: 100%; height: 100%; border-radius: 0; }

/* Hover / tap preview of card art */
.art-pop {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 4px; border-radius: 12px; background: var(--color-surface); box-shadow: var(--shadow-lg);
}
.art-pop img { display: block; width: 300px; max-width: calc(100vw - 48px); height: auto; border-radius: 9px; }
.art-pop img.is-wide { width: 420px; }
img.thumb { cursor: zoom-in; }

/* Collection grid view */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-4); }
.grid-card { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.grid-art { position: relative; aspect-ratio: 5 / 7; border-radius: 8px; overflow: hidden; background: var(--color-surface); }
.grid-art.is-wide { aspect-ratio: 7 / 5; }
.grid-art .tag { position: absolute; pointer-events: none; }
.grid-art .tag-qty { top: 6px; right: 6px; }
.grid-art .tag-owner { bottom: 6px; left: 6px; font-size: 11px; font-weight: 500; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.grid-art .tag-owner.tag-accent { background: var(--color-accent); color: #fff; }
.grid-art .tag-owner.tag-neutral { background: var(--color-neutral-200); color: var(--color-neutral-900); }
.grid-card.is-theirs .grid-art { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--color-neutral-500) 60%, transparent); }
.grid-owner { font-size: 12px; color: var(--color-neutral-400); }
.grid-owner strong { color: var(--color-accent-300); }
.grid-card .row-check { position: absolute; top: 6px; left: 6px; z-index: 1; }
.grid-title { font-size: 13px; font-weight: 500; line-height: 1.2; }
.grid-meta { font-size: 11px; color: var(--color-neutral-500); display: flex; justify-content: space-between; gap: 6px; }
.grid-actions { display: flex; gap: 4px; }
.grid-subtitle { display: block; font-size: 11px; font-weight: 400; color: var(--color-neutral-500); }
.grid-card .group-check { position: absolute; top: 6px; left: 6px; z-index: 1; }
.grid-versions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.grid-version {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 6px;
  font-size: 11px; color: var(--color-neutral-500); padding: 3px 6px; border-radius: 6px;
}
.grid-version:not(:has(.row-check)) { grid-template-columns: 1fr auto auto; }
.has-versions .grid-version { background: color-mix(in srgb, var(--color-surface) 70%, transparent); }
.has-versions .grid-version:hover { background: var(--color-surface); color: var(--color-neutral-300); }
.grid-version-main { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-version-nums { white-space: nowrap; display: inline-flex; gap: 6px; }
.grid-version .row-check { position: static; margin: 0; }
.btn-xs { padding: 1px 6px; font-size: 11px; line-height: 1.4; }

/* Add-card / edit layout */
.printing-form { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-8); align-items: start; }
.stack-list .row-item { padding: 6px 0; }

/* Metric tiles */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.metric { gap: 2px; padding: var(--space-4); }
.metric-label { font-size: 11px; color: var(--color-neutral-500); display: flex; gap: 4px; align-items: center; }
.metric-value { font-size: 28px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.metric-value-sm { font-size: 22px; }
.metric-delta { font-size: 12px; color: var(--color-accent-300); }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; letter-spacing: .02em; padding: 3px 10px; white-space: nowrap;
  border-radius: calc(var(--radius-md) * .75); line-height: 1.4;
}
.tag-accent  { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-100); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
.tag-good    { background: var(--color-good-fill); color: var(--color-good); }
.tag-bad     { background: var(--color-bad-fill); color: var(--color-bad); }
.tag-muted   { border: 1px solid var(--color-divider); color: var(--color-neutral-500); }
.tag-tier    { width: 28px; padding-inline: 0; font-weight: 500; }
.tag-mini    { font-size: 10px; padding: 2px 7px; }

/* Status colours (string-keyed from model status fields) */
.status-pending, .status-running, .status-request { color: var(--color-accent-300); }
.status-succeeded, .status-confirmed, .status-active, .status-returned { color: var(--color-good); }
.status-failed, .status-rejected, .status-cancelled, .status-declined { color: var(--color-bad); }
.status-gift, .status-trade, .status-lend, .status-lend_return { color: var(--color-neutral-400); }
.tag.status-pending, .tag.status-running { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag.status-succeeded, .tag.status-confirmed, .tag.status-active { background: var(--color-good-fill); color: var(--color-good); }
.tag.status-failed, .tag.status-rejected, .tag.status-cancelled, .tag.status-declined { background: var(--color-bad-fill); color: var(--color-bad); }
.tag.status-returned { background: var(--color-neutral-800); color: var(--color-neutral-100); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { min-width: 0; overflow-x: auto; }
.table, .data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .data-table th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 500;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: var(--space-2); border-bottom: 1px solid transparent; white-space: nowrap;
}
.table td, .data-table td { padding: var(--space-2); border-bottom: 1px solid transparent; vertical-align: middle; }
.table thead tr, .data-table thead tr {
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr, .data-table tbody tr {
  background: linear-gradient(to right,
    transparent, color-mix(in srgb, var(--color-text) 8%, transparent) 48px,
    color-mix(in srgb, var(--color-text) 8%, transparent) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr:hover, .data-table tbody tr:hover {
  background:
    linear-gradient(color-mix(in srgb, var(--color-text) 4%, transparent),
                    color-mix(in srgb, var(--color-text) 4%, transparent)) no-repeat 0 0 / 100% 100%,
    linear-gradient(to right,
      transparent, color-mix(in srgb, var(--color-text) 8%, transparent) 48px,
      color-mix(in srgb, var(--color-text) 8%, transparent) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table-tight { font-size: 13px; }
.table .col-check { width: 32px; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .cell-title { font-weight: 500; }
.table .cell-sub { font-size: 12px; color: var(--color-neutral-500); }
.table .cell-set { font-size: 12px; color: var(--color-neutral-400); white-space: nowrap; }
.table .cell-set .set-code { color: var(--color-accent-300); }
.table .cell-dim { font-size: 13px; color: var(--color-neutral-400); }
.table .cell-idx { color: var(--color-neutral-600); font-size: 12px; }
.table .cell-card { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table .cell-card > div { min-width: 0; }
tr.row-link { cursor: pointer; }
tr.row-in-aspect  td:first-child { box-shadow: inset 3px 0 0 var(--color-good-strong); }
tr.row-off-aspect td:first-child { box-shadow: inset 3px 0 0 var(--color-bad-strong); }
tr.row-off-aspect { opacity: .8; }
.sort-link { color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.sort-link:hover, .sort-link.is-sorted { color: var(--color-text); }
.sort-arrow { font-size: 10px; }
.foil-mark { color: var(--color-accent-300); }
.variant-tag { display: inline-flex; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--color-divider); color: var(--color-neutral-400); }
.stamp { font-size: 12px; color: var(--color-neutral-500); }
.reserved-hint { font-size: 11px; color: var(--color-neutral-500); margin-left: 4px; }

/* Inline meter (share / similarity / coverage) */
.bar { display: flex; align-items: center; gap: 8px; }
.bar-track { width: 80px; height: 4px; border-radius: 2px; background: var(--color-neutral-800); overflow: hidden; flex: none; }
.bar-fill { height: 100%; background: var(--color-accent); }
.bar-label { font-size: 12px; color: var(--color-neutral-400); font-variant-numeric: tabular-nums; }

/* Row lists — request rows with a fading rule under each row */
.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  padding: 9px 0;
  background: linear-gradient(to right, transparent, var(--color-divider) 24px,
    var(--color-divider) calc(100% - 24px), transparent) no-repeat bottom / 100% 1px;
}
.row-item:last-child { background: none; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .sub { font-size: 12px; color: var(--color-neutral-500); }
.row-item .val { font-size: 15px; color: var(--color-neutral-400); white-space: nowrap; }
.row-item .actions { display: flex; gap: 6px; flex: none; }
.row-rank { display: grid; grid-template-columns: 24px minmax(0,1fr) auto; gap: 10px; align-items: center; }
.row-rank .tag { padding: 2px 0; }
a.row-item, a.row-rank { color: inherit; }
a.row-item:hover, a.row-rank:hover { color: inherit; }
a.row-rank:hover .title { color: var(--color-accent-300); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: var(--space-4); }
.timeline .rail { display: flex; flex-direction: column; align-items: center; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--color-neutral-700); }
.timeline .dot-accent { background: var(--color-accent); }
.timeline .dot-good { background: var(--color-good-strong); }
.timeline .dot-bad { background: var(--color-bad-strong); }
.timeline .line { flex: 1; width: 1px; background: linear-gradient(var(--color-divider), transparent); }
.timeline li:last-child .line { display: none; }
.timeline .title { font-size: 14px; }
.timeline .meta { font-size: 12px; color: var(--color-neutral-500); }

/* Drop zone (import) */
.dropzone {
  border: 1px dashed var(--color-neutral-700); border-radius: var(--radius-lg);
  padding: 32px var(--space-8); display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.dropzone .ph-lg { color: var(--color-accent); }
.dropzone-title { font-size: 15px; }
.dropzone .input { max-width: 320px; margin-top: 6px; }

/* Empty states */
.empty-state {
  text-align: center; padding: 48px var(--space-6);
  border: 1px dashed var(--color-neutral-700); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
}
.empty-state h2 { font-size: 18px; margin: 0; }
.empty-state p { color: var(--color-neutral-500); font-size: 14px; margin: 0; max-width: 46ch; }
.empty-state .btn { margin-top: var(--space-2); }

/* Log output */
.log-pre {
  background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-4);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; color: var(--color-neutral-300);
  white-space: pre-wrap; max-height: 60vh; overflow: auto; margin: 0;
}
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--color-neutral-500); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; word-break: break-all; }

/* Aspect pips — single-letter swatches in the SWU palette. */
.aspect-icon {
  display: inline-block; width: 16px; height: 18px; object-fit: contain;
  margin-right: 2px; vertical-align: middle;
}
.aspect-icon-lg { width: 22px; height: 24px; }
.aspect-pip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: 9px; font-weight: 700; margin-right: 2px;
  border: 1px solid rgba(0,0,0,.35); vertical-align: middle;
}
.aspect-vigilance  { background: #2c79c8; color: #fff; }
.aspect-command    { background: #2da551; color: #fff; }
.aspect-aggression { background: #c8302c; color: #fff; }
.aspect-cunning    { background: #e0c324; color: #1a1a1a; }
.aspect-heroism    { background: #ececec; color: #1a1a1a; }
.aspect-villainy   { background: #1a1a1a; color: #ececec; border-color: var(--color-neutral-600); }

/* ── Dialog-ish surfaces: toasts, selection bar ──────────────────────────── */
.toast-stack { position: fixed; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 28px)); }
.toast {
  background: var(--color-surface); box-shadow: var(--shadow-md);
  padding: 9px 14px; border-radius: var(--radius-md); font-size: 13.5px;
  border-left: 3px solid var(--color-accent);
}
.toast-success { border-left-color: var(--color-good-strong); }
.toast-warning { border-left-color: var(--color-accent-400); }
.toast-error, .toast-danger { border-left-color: var(--color-bad-strong); }

.selection-bar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: min(920px, calc(100vw - 32px)); z-index: 20;
  background: var(--color-surface); box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
}
.selection-bar-inner { padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.selection-count { font-size: 14px; }
.selection-count strong { color: var(--color-accent-300); margin-right: 4px; }
.selection-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Shell: sidebar + main ───────────────────────────────────────────────── */
.shell { min-height: 100vh; display: flex; }
.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  background: linear-gradient(to bottom, transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent) no-repeat right / 1px 100%;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar nav, .nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-neutral-600); padding: 0 10px 6px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--color-text); font-size: 15px; font-weight: 500; padding: 6px 10px; border-radius: var(--radius-md); }
.brand:hover { color: var(--color-text); background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--color-accent);
  display: grid; place-items: center; color: var(--color-accent); font-size: 11px; font-weight: 600; flex: none;
}
.navlink {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-md);
  font-size: 14px; color: var(--color-neutral-300); cursor: pointer; border: 0; background: transparent;
  width: 100%; text-align: left; font: inherit; font-size: 14px; white-space: nowrap;
}
.navlink:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); color: var(--color-text); }
.navlink[aria-current='page'] { color: var(--color-accent-300); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nav-badge { margin-left: auto; font-size: 11px; color: var(--color-accent-300); }
.nav-trail { margin-left: auto; font-size: 12px; color: var(--color-neutral-600); }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--color-accent-800); color: var(--color-accent-100);
  display: grid; place-items: center; font-size: 11px;
}
.logout-form { margin: 0; }

.main {
  flex: 1; min-width: 0; padding: var(--space-8) 36px 64px;
  display: flex; flex-direction: column; gap: var(--space-8); max-width: 1240px; width: 100%;
}
.main-wide { max-width: 1400px; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-col > .main { flex: 1; }
.site-footer {
  padding: var(--space-4) 36px var(--space-6); max-width: 1240px; width: 100%;
  font-size: 11px; line-height: 1.5; color: var(--color-neutral-500);
  border-top: 1px solid var(--color-divider);
}
.site-footer a { color: inherit; text-decoration: underline; }

/* Page header block */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); flex-wrap: wrap; }
.page-head h1, .page-title { font-size: 30px; margin: 6px 0 0; }
.page-head .kicker + h1 { margin-top: 6px; }
.page-sub, .lead { font-size: 14px; color: var(--color-neutral-500); margin: 4px 0 0; max-width: 72ch; }
.lead-sm { font-size: 13px; color: var(--color-neutral-500); margin: 0; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.page-head-media { display: flex; gap: var(--space-4); align-items: center; }
.page-head-media .thumbs { display: flex; gap: 6px; }
.page-head-media .thumb { width: 64px; height: 46px; border-radius: 5px; }

/* Toolbar */
.toolbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.toolbar .push { margin-left: auto; }
.toolbar-form { display: contents; }

/* Sections + layouts */
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-lg { gap: var(--space-6); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); }
.section-head h2, .section-title { font-size: 16px; margin: 0; }
.section-head a { font-size: 13px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.two-col-even { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: var(--space-8); }
.with-aside { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-8); align-items: start; }
.with-aside > .form, .with-aside > .stack { max-width: 560px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4); align-items: stretch; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }
.tool-card { color: inherit; gap: var(--space-2); padding: var(--space-6); transition: box-shadow .12s, transform .12s; }
a.tool-card:hover { color: inherit; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tool-card.is-disabled { opacity: .5; }
.tool-card .ph-lg { color: var(--color-accent); width: 26px; height: 26px; }
.pager-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--color-neutral-500); gap: var(--space-3); flex-wrap: wrap; }
.pager { display: flex; gap: 4px; }
.sub-nav { display: flex; gap: var(--space-4); flex-wrap: wrap; }

/* Combobox (leader / base pickers on Similar cards) */
.combobox { position: relative; min-width: 260px; flex: 1; }
.combobox-input { padding-right: 30px; }
.combobox-chevron {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--color-neutral-500); cursor: pointer; padding: 6px; line-height: 1;
}
.combobox-chevron:hover { color: var(--color-text); }
.combobox-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  max-height: 320px; overflow: hidden;
}
.combobox-list { list-style: none; margin: 0; padding: 4px 0; max-height: 320px; overflow-y: auto; }
.combobox-group {
  padding: 6px 12px 2px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 500;
  color: var(--color-neutral-500); background: var(--color-surface); position: sticky; top: 0;
}
.combobox-option { padding: 6px 12px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.combobox-option:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.combobox-clear { color: var(--color-neutral-500); font-style: italic; }
.combobox-option .opt-sub { color: var(--color-neutral-500); }

/* Deck context strip (Similar cards) */
.deck-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.deck-card-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--color-divider); border-radius: 99px; padding: 3px 10px; }
.deck-card-sub { color: var(--color-neutral-500); }
.deck-coverage { color: var(--color-neutral-500); margin-left: auto; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.owner-pill { display: inline-flex; gap: 4px; border: 1px solid var(--color-divider); border-radius: 99px; padding: 1px 8px; font-size: 12px; margin-right: 4px; }
.owner-pill strong { color: var(--color-accent-300); }

/* ── Auth ────────────────────────────────────────────────────────────────── */
.auth { flex: 1; min-height: 100vh; display: grid; place-items: center; padding: var(--space-8); }
.auth-box { width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--space-6); }
.auth-box h1 { font-size: 28px; margin: 6px 0 4px; }
.auth-foot { font-size: 12px; color: var(--color-neutral-600); margin: 0; line-height: 1.5; }
.auth .btn-ghost { align-self: flex-start; margin-left: -4px; }
.mfa-qr { background: #fff; padding: 12px; border-radius: var(--radius-md); align-self: flex-start; }
.mfa-qr svg { display: block; width: 200px; height: 200px; }
.recovery-codes { list-style: none; margin: 0; padding: var(--space-4); display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md); font-size: 14px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .two-col, .with-aside { grid-template-columns: minmax(0, 1fr); }
  .with-aside > aside { max-width: 560px; }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static; width: auto; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: var(--space-2); padding: var(--space-3) var(--space-4);
    background: linear-gradient(to right, transparent, var(--color-divider) 48px,
      var(--color-divider) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
  }
  .sidebar nav, .nav-group, .sidebar-foot { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .nav-group-label { display: none; }
  .navlink { width: auto; padding: 6px 9px; font-size: 13px; }
  .nav-trail { display: none; }
  .sidebar .brand { padding-left: 4px; }
  .main { padding: var(--space-6) var(--space-4) 48px; gap: var(--space-6); }
  .page-head h1, .page-title { font-size: 24px; }
  .form-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .metric-value { font-size: 24px; }
  .card-row { flex-wrap: wrap; }
  .printing-form { grid-template-columns: 1fr; }
  .thumb-xl { width: 160px; height: 224px; }
  .card-row > .btn { margin-left: auto; }
}

/* ── Decks ───────────────────────────────────────────────────────────────── */
.bar-track.bar-stacked { display: flex; width: 100%; height: 6px; border-radius: 3px; }
.bar-fill-good { background: var(--color-good-strong); }
.bar-fill-accent { background: var(--color-accent); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 2px; }
.legend-good { background: var(--color-good-strong); }
.legend-accent { background: var(--color-accent); }
.legend-bad { background: var(--color-bad-strong); }
.deck-coverage-card .metrics { gap: var(--space-2); }
.deck-coverage-card .metric { padding: var(--space-2) 0; }
.deck-tile { gap: var(--space-3); }
.deck-tile-head { display: flex; gap: var(--space-3); align-items: center; }
.deck-tile-head .thumbs { display: flex; gap: 4px; flex: none; }
.deck-tile .bar-track { width: 100%; }
.qty-ctl { display: inline-flex; align-items: center; gap: 2px; }
.qty-ctl form { display: contents; }
.qty-ctl .btn-icon { width: 26px; height: 26px; }
.deck-table .row-missing td:first-child { box-shadow: inset 3px 0 0 var(--color-bad-strong); }
.deck-table .row-partner td:first-child { box-shadow: inset 3px 0 0 var(--color-accent); }


/* Deck analysis: legality + stats */
.deck-analysis { align-items: start; }
.issue-list { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.4; }
.issue-error { color: var(--color-bad); }
.issue-warning { color: var(--color-neutral-300); }
.issue-warning svg { color: var(--color-accent-300); }
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; height: 132px; align-items: end; }
.curve-col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.curve-val { font-size: 11px; color: var(--color-neutral-500); min-height: 14px; }
.curve-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.curve-bar { width: 100%; background: var(--color-accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.curve-lbl { font-size: 11px; color: var(--color-neutral-500); }
.breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-4); margin-top: var(--space-4); }
.breakdown-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-neutral-500); margin-bottom: 6px; }
.breakdown-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr auto; align-items: center; gap: 8px; font-size: 12px; padding: 2px 0; }
.breakdown-row > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breakdown-bar { display: block; height: 4px; border-radius: 2px; background: var(--color-neutral-800); overflow: hidden; }
.breakdown-bar > span { display: block; height: 100%; background: var(--color-accent); border-radius: 2px; }
.export-box { width: 100%; min-height: 320px; resize: vertical; font-size: 12px; white-space: pre; }
