/* ManifestIQ design system
   Direction: calm commerce-admin (Polaris-inspired). Dark ink top bar, soft
   canvas, white cards with hairline borders, ink primary buttons, a single
   teal accent. Identifiers (ASIN / FNSKU / LPN) are set in mono so they scan.
   ------------------------------------------------------------------------ */

:root {
  --font-sans: "Instrument Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;

  /* canvas & surfaces */
  --bg: #f1f1f0;
  --bg-sidebar: #ebebea;
  --surface: #ffffff;
  --surface-sunken: #f7f7f6;
  --surface-hover: #f4f4f3;
  --surface-selected: #e4e4e2;
  --topbar: #16181a;
  --topbar-text: #e8e8e6;
  --topbar-muted: #8d9195;
  --topbar-field: #2a2d30;

  /* text */
  --text: #1c1d1f;
  --text-secondary: #5c5f62;
  --text-subdued: #8a8d91;
  --text-on-ink: #ffffff;

  /* lines */
  --border: #e1e1df;
  --border-strong: #c9cac7;
  --focus: #2b6de0;

  /* brand & status */
  --ink: #1c1d1f;
  --ink-hover: #34373a;
  --accent: #0d7d63;
  --accent-soft: #d8f1e8;
  --accent-text: #0a5f4b;
  --info: #2764c5;
  --info-soft: #e1ecfd;
  --warning: #9a5b00;
  --warning-soft: #fdf0d5;
  --critical: #b42318;
  --critical-soft: #fde7e4;
  --magic: #6d4ae0;
  --magic-soft: #efeafe;

  /* shape & depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 0 0 1px rgba(26, 26, 26, 0.07), 0 1px 0 rgba(26, 26, 26, 0.07);
  --shadow-raised: 0 1px 0 rgba(26, 26, 26, 0.06), 0 8px 24px -8px rgba(26, 26, 26, 0.18);
  --shadow-button: inset 0 -1px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  --shadow-secondary: inset 0 -1px 0 #d4d4d2, 0 0 0 1px rgba(26, 26, 26, 0.12);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  --topbar-h: 56px;
  --sidebar-w: 240px;
  --content-max: 1080px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #111213;
  --bg-sidebar: #161719;
  --surface: #1c1e20;
  --surface-sunken: #17181a;
  --surface-hover: #232528;
  --surface-selected: #2b2e31;
  --topbar: #0b0c0d;
  --topbar-field: #1f2123;
  --text: #ececea;
  --text-secondary: #a9acb0;
  --text-subdued: #7a7e83;
  --border: #2c2f32;
  --border-strong: #3d4145;
  --ink: #f1f1ef;
  --ink-hover: #d9d9d6;
  --text-on-ink: #141516;
  --accent: #35c29a;
  --accent-soft: #11342b;
  --accent-text: #6fe0bd;
  --info: #7aa7f5;
  --info-soft: #172640;
  --warning: #f0b453;
  --warning-soft: #3a2a0d;
  --critical: #ff8a7a;
  --critical-soft: #3d1714;
  --magic: #a891ff;
  --magic-soft: #251d45;
  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-raised: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  --shadow-button: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  --shadow-secondary: 0 0 0 1px rgba(255, 255, 255, 0.12);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }

/* ── Frame ──────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-4) 0 var(--space-5);
  background: var(--topbar); color: var(--topbar-text);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--topbar-text); min-width: calc(var(--sidebar-w) - 20px); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(145deg, #1fa37f, #0b6b55); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 6px rgba(0,0,0,.35);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-name b { color: #5fd9b3; font-weight: 700; }
.topbar-search {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px; border-radius: 9px;
  background: var(--topbar-field); color: var(--topbar-muted);
  border: 1px solid rgba(255,255,255,.06);
}
.topbar-search input {
  flex: 1; border: 0; outline: 0; background: transparent; color: var(--topbar-text);
  font: inherit; font-size: 13px;
}
.topbar-search input::placeholder { color: var(--topbar-muted); }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid rgba(255,255,255,.14); color: var(--topbar-muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-btn {
  height: 34px; min-width: 34px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 0; background: transparent; color: var(--topbar-text); cursor: pointer;
}
.topbar-btn:hover { background: rgba(255,255,255,.08); }
.avatar {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #0b3f33; background: #9be7cd;
}
.user-menu { position: relative; }
.user-trigger { display: flex; align-items: center; gap: 8px; padding: 2px 8px 2px 2px; height: 34px; border-radius: 9px; background: transparent; border: 0; color: var(--topbar-text); cursor: pointer; font: inherit; }
.user-trigger:hover { background: rgba(255,255,255,.08); }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px;
  background: var(--surface); color: var(--text); border-radius: var(--radius);
  box-shadow: var(--shadow-raised); display: none;
}
.popover.open { display: block; animation: pop .14s ease-out; }
.popover-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.popover-head small { color: var(--text-secondary); display: block; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-hover); text-decoration: none; }

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 20;
  padding: var(--space-3) var(--space-2) var(--space-4);
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.nav-section { margin: var(--space-4) var(--space-3) var(--space-1); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-subdued); }
.nav-link {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 var(--space-3);
  border-radius: 8px; color: var(--text-secondary); font-weight: 550; position: relative;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.nav-link.active .icon { color: var(--accent); }
.nav-soon { margin-left: auto; font-size: 10px; font-weight: 650; padding: 1px 6px; border-radius: 20px; background: var(--surface-selected); color: var(--text-subdued); letter-spacing: .02em; }
.sidebar-foot { margin-top: auto; padding: var(--space-4) var(--space-3) 0; font-size: 12px; color: var(--text-subdued); display: flex; justify-content: space-between; }

.main { margin-left: var(--sidebar-w); padding: calc(var(--topbar-h) + var(--space-6)) var(--space-6) var(--space-10); min-height: 100vh; }
.page { max-width: var(--content-max); margin: 0 auto; animation: rise .35s cubic-bezier(.2,.7,.2,1) both; }
.page-wide { max-width: 1320px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-secondary); margin-top: 4px; max-width: 64ch; }
.breadcrumb { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; margin-bottom: 6px; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ── Layout helpers ─────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--space-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)); }
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-4); align-items: start; }
.muted { color: var(--text-secondary); }
.subdued { color: var(--text-subdued); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Card ───────────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.card-section { padding: var(--space-4) var(--space-5); }
.card-section + .card-section { border-top: 1px solid var(--border); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5) 0; }
.card-title { font-size: 14px; font-weight: 650; }
.card-sub { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.card-footer { padding: var(--space-3) var(--space-5); background: var(--surface-sunken); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--space-2); }

/* ── Metric tiles ───────────────────────────────────────────────────── */
.metric { padding: var(--space-4) var(--space-5); }
.metric-label { text-transform: capitalize; font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.metric-foot { margin-top: 6px; font-size: 12.5px; color: var(--text-subdued); }
.metric-spark { height: 4px; border-radius: 4px; background: var(--surface-selected); margin-top: 12px; overflow: hidden; }
.metric-spark > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .6s cubic-bezier(.2,.7,.2,1); }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 13px; white-space: nowrap;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-secondary);
  transition: background .12s, transform .06s, box-shadow .12s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--text-on-ink); box-shadow: var(--shadow-button); }
.btn-primary:hover { background: var(--ink-hover); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: var(--shadow-button); }
.btn-accent:hover { filter: brightness(1.06); background: var(--accent); }
.btn-critical { background: var(--critical); color: #fff; box-shadow: var(--shadow-button); }
.btn-plain { background: transparent; box-shadow: none; color: var(--info); padding: 0 6px; }
.btn-plain:hover { background: var(--surface-hover); }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-selected); color: var(--text-secondary); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-success { background: var(--accent-soft); color: var(--accent-text); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-critical { background: var(--critical-soft); color: var(--critical); }
.badge-magic { background: var(--magic-soft); color: var(--magic); }
.badge-live::before { animation: pulse 1.4s ease-in-out infinite; }

/* ── Banners / flash ────────────────────────────────────────────────── */
.banner { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card); border-left: 4px solid var(--info); }
.banner .icon { margin-top: 1px; color: var(--info); }
.banner-success { border-left-color: var(--accent); } .banner-success .icon { color: var(--accent); }
.banner-warning { border-left-color: var(--warning); } .banner-warning .icon { color: var(--warning); }
.banner-critical { border-left-color: var(--critical); } .banner-critical .icon { color: var(--critical); }
.flash-stack { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.flash-close { margin-left: auto; border: 0; background: none; color: var(--text-subdued); cursor: pointer; padding: 2px; border-radius: 4px; }
.flash-close:hover { color: var(--text); background: var(--surface-hover); }

/* ── Forms ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--space-5); }
.label { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.help { font-size: 12.5px; color: var(--text-secondary); }
.error-text { font-size: 12.5px; color: var(--critical); display: flex; gap: 6px; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: 34px; padding: 6px 11px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; transition: border-color .12s, box-shadow .12s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-subdued); }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input[readonly], .input:disabled { background: var(--surface-sunken); color: var(--text-secondary); }
.textarea { min-height: 96px; resize: vertical; font-family: var(--font-mono); font-size: 12.5px; }
.input.mono { font-family: var(--font-mono); font-size: 12.5px; }
.has-error .input, .has-error .textarea, .has-error .select { border-color: var(--critical); }
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: var(--border-strong); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.path-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; min-height: 18px; }
.path-status .mono { color: var(--text-secondary); min-width: 0; }
.path-status > * { flex: none; }
.path-status > .truncate { flex: 1; }

/* settings layout */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + var(--space-6)); display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-secondary); font-weight: 550; }
.settings-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.settings-nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.settings-nav a.active .icon { color: var(--accent); }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: var(--space-4) var(--space-5); }
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.save-bar {
  position: sticky; bottom: 16px; z-index: 10; margin-top: var(--space-4);
  display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px 10px 16px;
  background: var(--topbar); color: var(--topbar-text); border-radius: 12px; box-shadow: var(--shadow-raised);
  transform: translateY(140%); opacity: 0; pointer-events: none; transition: transform .25s cubic-bezier(.2,.7,.2,1), opacity .2s;
}
.save-bar.visible { transform: none; opacity: 1; pointer-events: auto; }
.save-bar .btn { box-shadow: none; }
.save-bar .btn-ghost { background: rgba(255,255,255,.1); color: var(--topbar-text); }
.save-bar .btn-ghost:hover { background: rgba(255,255,255,.18); }
.save-bar .btn-save { background: #fff; color: #16181a; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--text-secondary); background: var(--surface-sunken); padding: 9px var(--space-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { color: var(--text); font-weight: 600; }

.progress { height: 6px; border-radius: 6px; background: var(--surface-selected); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ink); transition: width .4s ease; }
.progress.is-active > span { background: linear-gradient(90deg, var(--accent), #3fcf9f, var(--accent)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* ── Lists / checklist ──────────────────────────────────────────────── */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 11px var(--space-5); }
.checklist li + li { border-top: 1px solid var(--border); }
.tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed var(--border-strong); color: transparent; flex: none; }
.tick.done { border: 0; background: var(--accent); color: #fff; }
.tick svg { width: 13px; height: 13px; stroke-width: 2.6; }
.checklist .done-label { color: var(--text-subdued); text-decoration: line-through; text-decoration-color: var(--border-strong); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-subdued); flex: none; }
.status-dot.ok { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.status-dot.bad { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-soft); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }

/* ── Empty state / hero ─────────────────────────────────────────────── */
.empty { text-align: center; padding: 56px var(--space-6) 48px; }
.empty-art {
  width: 132px; height: 104px; margin: 0 auto var(--space-5); position: relative;
}
.empty-art .sheet { position: absolute; width: 84px; height: 100px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-raised); }
.empty-art .sheet:nth-child(1) { left: 6px; top: 6px; transform: rotate(-8deg); opacity: .7; }
.empty-art .sheet:nth-child(2) { left: 42px; top: 2px; transform: rotate(7deg); opacity: .85; }
.empty-art .sheet:nth-child(3) { left: 24px; top: 0; display: grid; place-items: center; color: var(--accent); }
.empty-art .sheet:nth-child(3) .icon { width: 34px; height: 34px; stroke-width: 1.4; }
.empty h2 { font-size: 18px; }
.empty p { color: var(--text-secondary); max-width: 52ch; margin: 8px auto 0; }

.welcome {
  position: relative; overflow: hidden; border-radius: var(--radius-lg);
  background:
    radial-gradient(600px 220px at 100% 0%, rgba(53,194,154,.28), transparent 60%),
    radial-gradient(420px 200px at 0% 120%, rgba(43,109,224,.18), transparent 60%),
    var(--topbar);
  color: var(--topbar-text); padding: var(--space-6);
}
[data-theme="dark"] .welcome { box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.welcome::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 28px 28px; mask-image: linear-gradient(90deg, transparent, #000 60%);
}
.welcome h1 { font-size: 24px; letter-spacing: -0.02em; }
.welcome p { color: #b9bdc1; margin-top: 6px; max-width: 58ch; }
.pipeline { display: flex; align-items: center; gap: 8px; margin-top: var(--space-5); flex-wrap: wrap; position: relative; z-index: 1; }
.pipeline-step { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 30px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); font-size: 12.5px; font-weight: 600; }
.pipeline-step .num { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: rgba(95,217,179,.2); color: #7ee6c5; font-size: 11px; }
.pipeline-arrow { color: #6c7176; }

/* ── Auth ───────────────────────────────────────────────────────────── */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art {
  position: relative; overflow: hidden; padding: 48px; color: #e9ecea; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(700px 420px at 20% 10%, rgba(53,194,154,.35), transparent 60%),
    radial-gradient(600px 400px at 90% 90%, rgba(43,109,224,.22), transparent 60%),
    #0f1112;
}
.auth-art .brand-name { font-size: 18px; }
.auth-art h2 { font-size: 38px; line-height: 1.08; letter-spacing: -0.03em; max-width: 14ch; font-weight: 700; }
.auth-art p { color: #a7adb1; margin-top: 14px; max-width: 42ch; font-size: 15px; }
.ticket-stack { position: relative; height: 210px; margin: 28px 0; }
.ticket {
  position: absolute; left: 0; width: min(380px, 90%); padding: 14px 16px; border-radius: 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 12px; animation: drift 7s ease-in-out infinite;
}
.ticket:nth-child(1) { top: 0; }
.ticket:nth-child(2) { top: 70px; left: 36px; animation-delay: -2.3s; }
.ticket:nth-child(3) { top: 140px; left: 12px; animation-delay: -4.6s; }
.ticket .thumb { width: 38px; height: 38px; border-radius: 8px; background: linear-gradient(135deg, #2c3134, #1b1e20); display: grid; place-items: center; color: #7ee6c5; }
.ticket .t-title { font-size: 13px; font-weight: 600; color: #eef0ee; }
.ticket .t-meta { font-family: var(--font-mono); font-size: 11.5px; color: #8e959a; margin-top: 2px; }
.ticket .badge { margin-left: auto; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 24px; letter-spacing: -0.02em; }
.auth-card .muted { margin-top: 6px; }
.auth-form { margin-top: 28px; }

/* ── Imports ────────────────────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 150px; padding: var(--space-5); text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-sunken); transition: border-color .15s, background .15s, transform .15s;
}
.dropzone:hover { border-color: var(--text-subdued); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow-card); color: var(--accent); margin-bottom: 4px; }
.link-like { color: var(--info); text-decoration: underline; text-underline-offset: 2px; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-sunken); font-size: 13px; }
.file-list li.is-bad { background: var(--critical-soft); color: var(--critical); }
.file-remove { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--text-subdued); padding: 2px 4px; border-radius: 4px; }
.file-remove:hover { color: var(--text); background: var(--surface-hover); }
.upload-feedback { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.upload-feedback:empty { display: none; }
.scan-table { max-height: 300px; overflow-y: auto; }
.scan-table thead th { position: sticky; top: 0; z-index: 1; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 12px 0 0; }
.kv dt { color: var(--text-secondary); text-transform: capitalize; }
.kv dd { margin: 0; }

/* ── Motion ─────────────────────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .25; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes drift { 50% { transform: translateY(-6px); } }
.stagger > * { animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; }
.stagger > *:nth-child(5) { animation-delay: .2s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ── Products & index files ─────────────────────────────────────────── */
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.topbar-search label { display: inline-grid; place-items: center; cursor: text; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.product-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.metric-date { font-size: 20px; }
.metric-path { font-size: 16px; }
.search-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.search-bar .field { min-width: 150px; margin: 0; }
.search-bar .field.grow { flex: 1 1 320px; }
.search-actions { display: flex; gap: 8px; }
.thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: contain; background: #fff; border: 1px solid var(--border); display: block; }
.thumb-empty { display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-subdued); }
.thumb-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.product-hero { width: 100%; aspect-ratio: 1; max-width: 100%; object-fit: contain; border-radius: var(--radius); background: #fff; border: 1px solid var(--border); }
.month-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px var(--space-4) var(--space-4); }
.month-chip { display: flex; flex-direction: column; align-items: flex-start; min-width: 86px; padding: 8px 12px; border-radius: var(--radius); background: var(--surface-sunken); font-variant-numeric: tabular-nums; }
.month-chip strong { font-size: 18px; line-height: 1.2; }
.month-chip-label { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.code-list { display: flex; flex-wrap: wrap; gap: 4px 10px; word-break: break-all; }
.prose ul { margin: 0 0 10px; padding-left: 18px; }
.prose li + li { margin-top: 4px; }
.prose p { margin: 0; white-space: pre-line; }

/* ── Reports chart ───────────────────────────────────────────────────── */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding: 16px var(--space-4) 0; overflow-x: auto; }
.chart-col { flex: 1 1 0; min-width: 26px; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.chart-bar { width: 45%; max-width: 16px; border-radius: 4px 4px 0 0; height: 0; transition: height .5s cubic-bezier(.2,.7,.2,1); }
.chart-units { background: var(--accent); }
.chart-value { background: var(--info); opacity: .65; }
.chart-label { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch-units { background: var(--accent); }
.swatch-value { background: var(--info); opacity: .65; }

/* ── Responsive ─────────────────────────────────────────────────────── */
.menu-toggle { display: none; }
@media (max-width: 1080px) {
  .layout-aside, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-aside { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .menu-toggle { display: inline-grid; }
  .brand { min-width: 0; }
  .brand-name { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-raised); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; padding-left: var(--space-4); padding-right: var(--space-4); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
  .settings-nav a { white-space: nowrap; }
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .kbd { display: none; }
  .user-trigger .small { display: none; }
  .pipeline-arrow { display: none; }
  .topbar { gap: var(--space-2); padding-left: var(--space-3); }
}
@media (max-width: 560px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } .page-header { flex-direction: column; } }

/* ── Sheet (a dialog for the detail behind a number) ─────────────────── */
.sheet { width: min(980px, 94vw); max-height: 86vh; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-raised); overflow: hidden; }
.sheet::backdrop { background: rgb(15 23 42 / .45); backdrop-filter: blur(2px); }
.sheet-head, .sheet-foot { display: flex; align-items: center; gap: 12px;
  padding: 14px var(--space-4); border-bottom: 1px solid var(--border); }
.sheet-foot { border-bottom: 0; border-top: 1px solid var(--border); }
.sheet-body { max-height: 62vh; overflow: auto; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  cursor: pointer; text-align: inherit; border-radius: 4px; }
.link-button:hover { text-decoration: underline; }
.link-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-col.is-clickable { cursor: pointer; border-radius: 6px; }
.chart-col.is-clickable:hover .chart-bar { filter: brightness(1.12); }
.chart-col.is-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Tabs ─────────────────────────────────────────────────────────
   For a page that has grown several unrelated tables. Each panel is its
   own screen, so nothing competes for the top of the page and a table
   that is long for good reasons cannot bury what is above it. */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; appearance: none; background: none; border: 0;
  padding: 10px var(--space-4); font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; white-space: nowrap;
  border-radius: var(--radius) var(--radius) 0 0; transition: color .12s, background .12s; }
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab[aria-selected="true"] { color: var(--accent); }
/* Drawn on the element rather than as a border so the tab does not shift
   by a pixel when it becomes the selected one. */
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0;
  bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab-count { margin-left: 6px; font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--text-secondary); }
.tab-panel[hidden] { display: none; }
/* Without JavaScript every panel simply shows, one after another, which is
   the page exactly as it was before the tabs existed. */
.tab-panel { margin-top: var(--space-4); }
