/* freya — the studio (spec 2026-09-18 F5)
   Light editorial: paper canvas with a soft light wash, serif display type,
   one green accent, white cards on hairlines. Every colour, radius, shadow
   and spacing step is a token in :root. Functionality is frozen: ids and the
   classes the scripts use are unchanged (tests/test_frontend_contract.py).   */

:root {
  /* canvas & surfaces */
  --canvas: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f2eee6;
  --surface-3: #e9e4da;
  /* ink */
  --ink: #17181c;
  --ink-2: #393a42;
  --muted: #6d6c76;
  --faint: #9d9ca5;
  /* lines */
  --line: #e6e1d8;
  --line-2: #d5cec2;
  /* the accent: the deep green of the Freya wordmark; coral is its companion for small highlights */
  --accent: #2a5f48;
  --accent-strong: #1f4d3a;
  --accent-soft: #e4f0ea;
  --accent-ink: #163a2c;
  --accent-glow: rgba(42, 95, 72, 0.28);
  --coral: #ef6876;
  --coral-strong: #d94f5f;
  --coral-soft: #fde9eb;
  --coral-ink: #a8323f;
  /* semantic */
  --success: #1f8a5b;
  --success-soft: #e2f3ea;
  --warning: #a86f16;
  --warning-soft: #fbf0d9;
  --danger: #bf3a2c;
  --danger-soft: #fbe6e2;
  --info: #2f63d6;
  --info-soft: #e8eefb;
  /* shape */
  --radius-s: 10px;
  --radius: 16px;
  --radius-l: 24px;
  --shadow-1: 0 1px 2px rgba(23, 24, 28, 0.04), 0 6px 20px rgba(23, 24, 28, 0.05);
  --shadow-2: 0 2px 6px rgba(23, 24, 28, 0.06), 0 16px 40px rgba(23, 24, 28, 0.10);
  --shadow-3: 0 8px 24px rgba(23, 24, 28, 0.12), 0 32px 80px rgba(23, 24, 28, 0.18);
  --ring: 0 0 0 3px var(--accent-glow);
  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px; --fs-16: 16px; --fs-18: 18px;
  --fs-20: 20px; --fs-24: 24px; --fs-28: 28px; --fs-36: 36px; --fs-48: 48px;
  /* spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px;
  --content: 1200px;
  --form-width: 920px;
  --header-h: 68px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-15);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* the light wash: a cool green light top-left, a warm one bottom-right */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 620px at -6% -18%, rgba(42, 95, 72, 0.14), transparent 62%),
    radial-gradient(900px 560px at 108% 112%, rgba(239, 104, 118, 0.11), transparent 60%),
    radial-gradient(700px 420px at 60% -30%, rgba(255, 255, 255, 0.9), transparent 70%);
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { display: block; max-width: 100%; }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-2); border-radius: 5px; padding: 1px 6px; }
.hidden { display: none !important; }
/* the HTML hidden attribute must beat any display rule (e.g. the lightbox compare pane, a .lb-stage flex box) */
[hidden] { display: none !important; }
::selection { background: rgba(42, 95, 72, 0.18); }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible, [tabindex]:focus-visible { outline: none; box-shadow: var(--ring); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 244, 238, 0.82);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(23, 24, 28, 0.06);
}
.topbar-inner {
  max-width: var(--content);
  height: var(--header-h);
  margin: 0 auto;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-5);
}
.brand { display: inline-flex; align-items: center; gap: var(--sp-3); text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { height: 42px; width: auto; flex: none; align-self: center; }
/* the serif wordmark is the fallback: it shows only when the logo file is missing (the img removes itself) */
.brand-mark + .brand-word { display: none; }
.brand-word {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}
.brand-by {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: var(--sp-3);
  border-left: 1px solid var(--line-2);
  line-height: 22px;
  height: 26px;
  white-space: nowrap;
}
/* First Club badge: square box, zoomed into the centred wordmark */
.brand-logo {
  display: inline-block;
  width: 22px;
  height: 22px;
  flex: none;
  background: #14422e url("logo_badge.png") center / 132% no-repeat;
  border-radius: 50%;
}
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; padding: 4px; background: rgba(23, 24, 28, 0.04); border-radius: 999px; }
.topnav-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600;
  font-size: var(--fs-14);
  padding: 8px 16px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.topnav-link:hover { color: var(--ink); background: rgba(255, 255, 255, 0.7); }
.topnav-link.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(23, 24, 28, 0.08); }

/* settings */
.settings { position: relative; }
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line-2);
  border-radius: 50%;
  transition: background 0.15s ease, color 0.15s ease, transform 0.2s ease;
}
.icon-btn:hover { color: var(--ink); transform: rotate(30deg); }
.icon-btn .gear { font-size: 19px; line-height: 1; }
.settings-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }
.settings-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  min-width: 230px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: pop 0.14s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.settings-menu-item { text-align: left; padding: 10px 12px; background: transparent; border: none; border-radius: var(--radius-s); font-size: var(--fs-14); font-weight: 600; color: var(--ink); }
.settings-menu-item:hover { background: var(--surface-2); }
a.settings-menu-item { display: block; text-decoration: none; }
.settings-menu-user { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.settings-menu-user strong { font-size: var(--fs-14); color: var(--ink); }
.settings-menu-user small { font-size: var(--fs-12); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Page ---------- */
.container { flex: 1 0 auto; width: 100%; max-width: var(--content); margin: 0 auto; padding: var(--sp-7) var(--sp-6) var(--sp-9); }
.page-header { margin-bottom: var(--sp-6); }
.page-header h1 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-size: var(--fs-48);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--ink);
  text-wrap: balance;
}
.subtitle { margin: 0; max-width: 64ch; color: var(--muted); font-size: var(--fs-18); line-height: 1.55; }
.eyebrow { margin: 0 0 var(--sp-3); font-size: var(--fs-12); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.eyebrow::before { content: ""; display: inline-block; width: 22px; height: 3px; background: linear-gradient(90deg, var(--coral), var(--accent)); margin-right: 10px; vertical-align: middle; border-radius: 2px; }

/* how it works */
.steps {
  list-style: none;
  margin: var(--sp-6) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: var(--form-width);
}
.steps li { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-4) var(--sp-5); background: rgba(255, 255, 255, 0.72); }
.step-n {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--fs-15);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--coral) 0%, var(--accent) 100%);
}
.step-t { display: flex; flex-direction: column; gap: 2px; }
.step-t strong { font-size: var(--fs-14); font-weight: 700; color: var(--ink); }
.step-t small { font-size: var(--fs-13); color: var(--muted); line-height: 1.4; }

/* ---------- Segmented controls ---------- */
.mode-toggle, .queue-filters, .review-filters {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  background: rgba(23, 24, 28, 0.05);
  border-radius: 999px;
}
.mode-toggle { margin-bottom: var(--sp-5); }
.mode-tab, .filter-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-14);
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.mode-tab:hover, .filter-btn:hover { color: var(--ink); }
.mode-tab.active, .filter-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(23, 24, 28, 0.10); }

/* ---------- Cards ---------- */
.sheet-section, .queue-table-wrap, .result-card, .result-row.failed, .progress, .log-panel, .events-panel, .preview-grid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

/* ---------- Form ---------- */
.sheet-section { max-width: var(--form-width); padding: 0; overflow: hidden; }
.form-group { padding: var(--sp-5) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
.form-group + .form-group { border-top: 1px solid var(--line); }
.form-group-title { margin: 0 0 var(--sp-1); font-family: var(--font-display); font-size: var(--fs-20); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); display: flex; align-items: baseline; gap: var(--sp-2); }
.form-group-note { font-family: var(--font); font-size: var(--fs-12); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.sheet-field { display: flex; flex-direction: column; gap: 7px; }
.rules-field { margin-top: var(--sp-1); }
.res-field { max-width: 300px; }
.ov-label { font-size: var(--fs-14); font-weight: 600; color: var(--ink-2); }
.ov-label em { font-style: normal; font-weight: 500; color: var(--faint); }
.sheet-input {
  width: 100%;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  font-size: var(--fs-15);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(23, 24, 28, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sheet-input::placeholder { color: var(--faint); }
.sheet-input:hover { border-color: #c2bbae; }
.sheet-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.rules-input { resize: vertical; min-height: 88px; line-height: 1.5; }
.res-input:disabled { opacity: 0.55; cursor: not-allowed; }
select.sheet-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236d6c76' stroke-width='1.8' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 15px center;
}
.sheet-hint { margin: -2px 0 0; color: var(--muted); font-size: var(--fs-13); line-height: 1.55; max-width: 80ch; }
.field-row { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.field-row .sheet-field { flex: 1 1 260px; }

.combo { position: relative; }
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  max-height: 280px;
  overflow-y: auto;
}
.suggestion { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: var(--radius-s); cursor: pointer; }
.suggestion:hover { background: var(--surface-2); }
.suggestion-name { font-size: var(--fs-14); font-weight: 600; color: var(--ink); }
.suggestion-url { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sheet-input.is-locked { background: var(--surface-2); color: var(--ink-2); cursor: default; }
.auth-notice { max-width: var(--form-width); margin: 0 0 var(--sp-6); padding: var(--sp-4) var(--sp-5); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--danger); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.auth-notice p { margin: 0 0 var(--sp-3); font-size: var(--fs-15); color: var(--ink); }
.auth-notice-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.form-message { max-width: var(--form-width); color: var(--danger); font-size: var(--fs-14); font-weight: 500; margin: var(--sp-4) 0 0; padding: 10px 14px; background: var(--danger-soft); border-radius: var(--radius-s); }
.form-message:empty { display: none; }

/* ---------- Buttons ---------- */
.actions { max-width: var(--form-width); margin-top: var(--sp-5); display: flex; justify-content: flex-end; gap: var(--sp-3); flex-wrap: wrap; }
#state-results .actions, #state-processing .actions { max-width: none; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #336b54 0%, var(--accent) 60%, var(--accent-strong) 100%); color: #fff; box-shadow: 0 1px 2px rgba(31, 77, 58, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(42, 95, 72, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.16); transform: translateY(-1px); }
#run-btn { padding: 14px 28px; font-size: var(--fs-16); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #c2bbae; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: rgba(191, 58, 44, 0.4); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { padding: 6px 13px; font-size: var(--fs-13); }
.btn.active { box-shadow: 0 0 0 2px var(--accent); }
.btn-danger.active { box-shadow: 0 0 0 2px var(--danger); }
.spinner { width: 14px; height: 14px; flex: none; border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chips & badges ---------- */
.chip, .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink-2);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.chip-check::before, .lb-verdict::before { display: none; }
.chip-queued { background: var(--surface-2); color: var(--muted); }
.chip-running { background: var(--accent-soft); color: var(--accent-ink); }
.chip-running::before { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
.chip-completed { background: var(--success-soft); color: var(--success); }
.chip-failed { background: var(--danger-soft); color: var(--danger); }
.chip-cancelled { background: var(--surface-2); color: var(--muted); }
.chip-check { background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; white-space: normal; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-failed { background: var(--danger-soft); color: var(--danger); }
.badge-partial { background: var(--warning-soft); color: var(--warning); }

/* ---------- Queue ---------- */
.queue-view { margin-top: var(--sp-1); }
.queue-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.queue-updated { font-size: var(--fs-12); color: var(--faint); font-variant-numeric: tabular-nums; }
.queue-notice { margin: 0 0 var(--sp-4); font-size: var(--fs-14); font-weight: 500; color: var(--accent-ink); background: var(--accent-soft); border-radius: var(--radius-s); padding: 11px 16px; }
.queue-notice:empty { display: none; }
.queue-notice.is-error { color: var(--danger); background: var(--danger-soft); }
.queue-table-wrap { overflow-x: auto; }
.queue-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-14); }
.queue-table th, .queue-table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.queue-table th:first-child, .queue-table td:first-child { padding-left: var(--sp-5); }
.queue-table th:last-child, .queue-table td:last-child { padding-right: var(--sp-5); }
.queue-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
}
.queue-table tbody tr:last-child td { border-bottom: none; }
.queue-table tbody tr { transition: background 0.12s ease; }
.queue-table tbody tr:hover { background: var(--canvas); }
.queue-table tr.row-highlight { background: var(--accent-soft); }
.queue-name strong { display: block; font-weight: 600; max-width: 250px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: var(--fs-15); }
.queue-name small { color: var(--faint); font-size: var(--fs-12); font-family: var(--font-mono); }
.queue-progress { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.queue-table td:last-child { white-space: normal; text-align: right; min-width: 236px; }
.queue-actions > .btn { margin: 2px 0 2px 4px; vertical-align: middle; }
.queue-actions .btn-sm { padding: 5px 11px; font-size: var(--fs-12); }
.queue-table th:nth-child(3), .queue-table td:nth-child(3) { color: var(--muted); }
.queue-pager { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); margin-top: var(--sp-4); }
.queue-page { font-size: var(--fs-13); color: var(--muted); }
#queue-empty { margin-top: var(--sp-4); text-align: center; padding: var(--sp-7) var(--sp-5); color: var(--muted); font-size: var(--fs-15); background: rgba(255, 255, 255, 0.6); border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ---------- Processing ---------- */
.progress { padding: var(--sp-5) var(--sp-6); margin-bottom: var(--sp-4); }
.progress-track { width: 100%; height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent) 55%, var(--coral));
  background-size: 200% 100%;
  animation: shimmer 2.4s linear infinite;
  transition: width 0.5s ease;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.progress-label { margin: var(--sp-3) 0 0; font-family: var(--font-display); font-size: var(--fs-24); font-weight: 600; letter-spacing: -0.01em; }
.progress .sheet-hint { margin: 4px 0 0; }
.current-sku { margin: 0 0 var(--sp-1); color: var(--ink-2); font-size: var(--fs-16); font-weight: 500; }
.error-text { color: var(--danger); font-weight: 600; }
#queue-position { margin: 0; }
.failed-count { margin: var(--sp-2) 0 0; color: var(--danger); font-size: var(--fs-14); font-weight: 600; }
.failed-count:empty { display: none; }

.events-panel { list-style: none; margin: var(--sp-4) 0 0; padding: var(--sp-3) var(--sp-5); max-height: 240px; overflow-y: auto; font-size: var(--fs-13); line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }
.event { display: flex; gap: var(--sp-3); align-items: baseline; }
.event::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); transform: translateY(-1px); }
.event-warning::before { background: var(--warning); }
.event-error::before { background: var(--danger); }
.event-time { color: var(--faint); font-variant-numeric: tabular-nums; flex: 0 0 auto; font-family: var(--font-mono); font-size: var(--fs-12); }
.event-msg { color: var(--ink-2); }
.event-warning .event-msg { color: var(--warning); }
.event-error .event-msg { color: var(--danger); }

.preview-grid { margin: var(--sp-4) 0 0; padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.preview-grid:empty { display: none; }
.preview-row { display: flex; align-items: center; gap: var(--sp-4); }
.preview-sku { font-size: var(--fs-13); font-weight: 600; color: var(--ink-2); min-width: 120px; font-family: var(--font-mono); }
.preview-strip { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.preview-strip img { height: 80px; width: 80px; object-fit: cover; border-radius: var(--radius-s); background: var(--surface-2); box-shadow: var(--shadow-1); }

.log-panel { margin: var(--sp-4) 0 0; padding: var(--sp-4) var(--sp-5); font-family: var(--font-mono); font-size: var(--fs-13); line-height: 1.65; white-space: pre-wrap; min-height: 72px; max-height: 320px; overflow-y: auto; color: var(--ink-2); }
.log-panel:empty::before { content: "Waiting for the first product to finish…"; color: var(--faint); font-family: var(--font); }

/* ---------- Results ---------- */
#results-summary { font-size: var(--fs-36); }
#results-summary.all-failed { color: var(--danger); }
#results-summary.summary-notice { font-family: var(--font); font-size: var(--fs-16); font-weight: 500; line-height: 1.5; color: var(--ink); background: var(--danger-soft); border-left: 4px solid var(--danger); border-radius: var(--radius-s); padding: 14px 18px; letter-spacing: 0; }
#run-times { margin-top: 0; font-size: var(--fs-14); }

.stats { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); }
.stat { display: flex; align-items: baseline; gap: 8px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: var(--shadow-1); }
.stat strong { font-family: var(--font-display); font-size: var(--fs-24); font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.stat span { font-size: var(--fs-13); font-weight: 600; color: var(--muted); }
.stat-pass strong { color: var(--success); }
.stat-review strong { color: var(--warning); }
.stat-fail strong { color: var(--danger); }
.stat-flag strong { color: var(--danger); }
.checklist-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--sp-3); }
.checklist-title { font-size: var(--fs-12); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin-right: 4px; }

.review-filters { align-items: center; margin: 0 0 var(--sp-5); }
.review-filters .queue-updated { padding: 0 var(--sp-3); }
.results-section { margin-top: var(--sp-6); }
.results-heading { margin: 0 0 var(--sp-3); font-size: var(--fs-12); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.results-list { display: flex; flex-direction: column; gap: var(--sp-5); }

/* one product */
.result-card { display: flex; flex-direction: column; overflow: hidden; }
.result-card > .result-row { border: none; border-radius: 0; box-shadow: none; background: transparent; }
.result-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); }
.result-row .result-sku { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-24); letter-spacing: -0.01em; }
.result-row .badge + .badge { margin-left: -4px; }
.result-row .drive-link { margin-left: auto; }
.result-row.failed .result-reason { flex: 1 1 auto; }
.result-row.failed .badge { margin-left: auto; }
.result-row.failed .result-sku { font-size: var(--fs-18); }
.result-row .result-reason { color: var(--muted); font-size: var(--fs-14); }
.drive-link { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-13); font-weight: 600; color: var(--accent); text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); transition: background 0.15s ease, border-color 0.15s ease; }
.drive-link:hover { background: var(--accent-soft); border-color: transparent; }
.shot-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--sp-5) var(--sp-4); }
.shot-links .drive-link { font-weight: 500; color: var(--muted); border-color: transparent; background: var(--surface-2); padding: 4px 10px; font-size: var(--fs-12); }
.shot-links .drive-link:hover { color: var(--accent); background: var(--accent-soft); }

/* reference photos strip */
.ref-strip { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); overflow-x: auto; }
.ref-strip-title { flex: none; display: flex; flex-direction: column; font-size: var(--fs-12); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-right: var(--sp-3); }
.ref-strip-title::after { content: "click to compare"; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); font-size: var(--fs-12); }
.ref-thumb {
  position: relative;
  flex: none;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  overflow: hidden;
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.ref-thumb:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.ref-thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-role { position: absolute; left: 5px; bottom: 5px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; background: rgba(23, 24, 28, 0.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); border-radius: 5px; padding: 2px 6px; max-width: calc(100% - 10px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* gallery */
.qc-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); padding: var(--sp-4) var(--sp-5) var(--sp-5); border-top: 1px solid var(--line); background: linear-gradient(180deg, var(--surface-2) 0%, rgba(242, 238, 230, 0) 120px); }
.qc-tile { position: relative; border: 1px solid transparent; border-radius: var(--radius); background: var(--surface); padding: 8px; cursor: pointer; box-shadow: var(--shadow-1); transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.15s ease; }
.qc-tile:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.qc-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radius-s); background: var(--surface-2); cursor: zoom-in; }
.qc-shot-label { margin-top: 10px; font-size: var(--fs-13); font-weight: 600; text-transform: capitalize; color: var(--ink-2); text-align: center; }
.qc-flag-badge { position: absolute; top: 16px; left: 16px; display: none; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--danger); color: #fff; box-shadow: var(--shadow-1); }
.qc-tile.flagged { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger), var(--shadow-1); }
.qc-tile.flagged .qc-flag-badge { display: inline-block; }
.qc-notes { width: 100%; margin-top: 8px; padding: 9px 11px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-s); font-size: var(--fs-13); line-height: 1.45; min-height: 52px; resize: none; overflow: hidden; cursor: text; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.qc-notes::placeholder { color: var(--faint); }
.qc-notes:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

/* judge */
.judge-badge { position: absolute; top: 16px; right: 16px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: var(--muted); box-shadow: var(--shadow-1); max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.judge-pass { background: rgba(226, 243, 234, 0.95); color: var(--success); }
.judge-review { background: rgba(251, 240, 217, 0.95); color: var(--warning); }
.judge-fail { background: rgba(251, 230, 226, 0.95); color: var(--danger); }
.judge-none { background: rgba(242, 238, 230, 0.95); color: var(--muted); }
.judge-decide { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.judge-decide .btn-sm { padding: 4px 11px; font-size: var(--fs-12); }
.decision-note { font-size: var(--fs-12); color: var(--muted); }
.decision-note:empty { display: none; }
.qc-tile.decided-approved .qc-img { box-shadow: inset 0 0 0 3px var(--success); }
.qc-tile.decided-rejected { opacity: 0.6; }
.qc-tile.decided-rejected .qc-img { filter: grayscale(0.6); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(23, 24, 28, 0.74); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: var(--sp-5); }
.lightbox[hidden] { display: none; }
.lb-dialog { position: relative; display: flex; gap: var(--sp-4); align-items: stretch; width: min(1360px, 96vw); max-height: 92vh; background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-3); padding: var(--sp-6); animation: lift 0.18s ease; }
@keyframes lift { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.lb-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
.lb-nav { align-self: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 18px; transition: background 0.15s ease, transform 0.15s ease; }
.lb-nav:hover:not(:disabled) { background: var(--surface-2); transform: scale(1.05); }
.lb-nav:disabled { opacity: 0.3; cursor: default; }
.lb-stage { margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; flex: 1 1 auto; }
.lb-img { max-width: min(66vw, 940px); max-height: 78vh; border-radius: var(--radius); background: var(--surface-2); object-fit: contain; box-shadow: var(--shadow-1); }
.lb-counter { margin-top: var(--sp-3); font-size: var(--fs-13); font-weight: 600; color: var(--muted); }
.lb-dialog.is-compare .lb-stage { flex: 1 1 0; }
.lb-dialog.is-compare .lb-img { max-width: 100%; max-height: 68vh; width: 100%; aspect-ratio: 1 / 1; }
.lb-dialog.is-compare .lb-stage:not(.lb-compare) .lb-counter::before { content: "Output · "; color: var(--ink); }
.lb-compare { border-left: 1px solid var(--line); padding-left: var(--sp-4); }
.lb-compare .lb-counter { color: var(--accent-ink); }
.lb-side { flex: 0 0 320px; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-6) 4px 4px; overflow-y: auto; }
.lb-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-28); font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.lb-verdict { align-self: flex-start; }
.lb-checks { list-style: none; margin: 0; padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-radius: var(--radius-s); font-size: var(--fs-13); line-height: 1.5; display: flex; flex-direction: column; gap: 7px; }
.lb-check { display: flex; gap: 8px; }
.lb-mark { flex: 0 0 auto; font-weight: 700; }
.lb-check.pass .lb-mark { color: var(--success); }
.lb-check.fail .lb-mark { color: var(--danger); }
.lb-summary { margin: 0; font-size: var(--fs-13); color: var(--muted); }
.lb-summary:empty { display: none; }
.lb-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lb-hint { margin: auto 0 0; font-size: var(--fs-12); color: var(--faint); }
.lb-refs-panel { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); background: var(--surface-2); border-radius: var(--radius-s); }
.lb-refs-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.lb-refs-title { font-size: var(--fs-12); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lb-refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; }
.lb-refs.refs-collapsed { display: none; }
.lb-refs .ref-thumb { width: auto; height: auto; aspect-ratio: 1 / 1; background: var(--surface); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: var(--sp-5); background: rgba(23, 24, 28, 0.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal { width: 100%; max-width: 420px; padding: var(--sp-6); background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-3); display: flex; flex-direction: column; gap: var(--sp-4); animation: lift 0.18s ease; }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-28); font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.modal-close { width: 36px; height: 36px; border: none; border-radius: 50%; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; padding: 0; transition: background 0.15s ease, color 0.15s ease; }
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.settings-field { display: flex; flex-direction: column; gap: 7px; }
.settings-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); }
.apikey-msg { margin: 0; font-size: var(--fs-13); line-height: 1.4; }
.apikey-msg:empty { display: none; }
.apikey-msg.checking { color: var(--muted); }
.apikey-msg.ok { color: var(--success); }
.apikey-msg.err { color: var(--danger); }

/* ---------- Tutorial drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: 440px; max-width: 92vw; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(23, 24, 28, 0.12); }
.drawer-header { flex: none; display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.drawer-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-24); font-weight: 600; color: var(--ink); }
.drawer-body { padding: var(--sp-4) var(--sp-5) var(--sp-8); overflow-y: auto; font-size: var(--fs-14); color: var(--ink-2); }
.drawer-lead { margin: 0 0 var(--sp-2); color: var(--muted); font-size: var(--fs-15); }
.drawer-body h3 { margin: var(--sp-5) 0 var(--sp-2); font-family: var(--font-display); font-size: var(--fs-18); font-weight: 600; color: var(--ink); }
.drawer-body ul, .drawer-body ol { margin: 6px 0; padding-left: 20px; }
.drawer-body li { margin: 5px 0; }
.drawer-note { margin: var(--sp-2) 0 0; font-size: var(--fs-13); color: var(--muted); }
.drawer-faq-heading { margin: var(--sp-5) 0 var(--sp-2); font-family: var(--font); font-size: var(--fs-12); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.faq-item { margin: var(--sp-2) 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); overflow: hidden; }
.faq-item summary { padding: 10px 12px; font-size: var(--fs-14); font-weight: 600; color: var(--ink); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.faq-item summary:hover { background: var(--surface-2); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "\276F"; display: inline-block; font-size: 10px; color: var(--faint); transition: transform 0.15s ease; }
.faq-item[open] summary::before { transform: rotate(90deg); }
.faq-item > :not(summary) { padding: 0 12px; }
.faq-item > :last-child { padding-bottom: 12px; }
.faq-item .faq-a { margin-top: 10px; }
.faq-a { margin: 0; color: var(--muted); }
.drawer-video { display: block; width: 100%; margin: 6px 0 4px; border-radius: var(--radius-s); background: #000; }
@media (min-width: 1000px) {
  body { transition: padding-right 0.2s ease; }
  body.drawer-open { padding-right: 440px; }
}

/* ---------- Footer ---------- */
.site-footer { flex: none; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); padding: var(--sp-5) var(--sp-6) var(--sp-6); font-size: var(--fs-13); color: var(--faint); border-top: 1px solid rgba(23, 24, 28, 0.06); }
.footer-mark { height: 22px; width: 22px; }
.footer-brand { font-family: var(--font-display); font-size: var(--fs-18); font-weight: 600; letter-spacing: -0.02em; color: var(--ink-2); }
.footer-sep { color: var(--line-2); }
.footer-link { border: none; background: none; padding: 0; color: var(--muted); font-size: var(--fs-13); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.footer-link:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ---------- Responsive ---------- */
@media (min-width: 1800px) {
  :root { --content: 1320px; }             /* very wide screens: room for the queue's provider column */
}
@media (max-width: 1100px) {
  .qc-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .brand-by { display: none; }
}
@media (max-width: 1800px) {
  .queue-table th:nth-child(3), .queue-table td:nth-child(3) { display: none; }   /* provider column only on very wide screens; the batch page shows it */
}
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr; }
  .lb-dialog { flex-direction: column; overflow-y: auto; max-height: 94vh; padding: var(--sp-4); }
  .lb-side { flex: 0 0 auto; padding-top: var(--sp-2); }
  .lb-img { max-width: 100%; max-height: 50vh; }
  .lb-dialog.is-compare .lb-img { max-height: 40vh; }
  .lb-compare { border-left: none; border-top: 1px solid var(--line); padding-left: 0; padding-top: var(--sp-3); }
  .lb-nav { position: absolute; top: 40%; z-index: 2; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}
@media (max-width: 720px) {
  .container { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
  .topbar-inner { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .brand-word { font-size: 28px; }
  .page-header h1 { font-size: var(--fs-36); }
  .subtitle { font-size: var(--fs-16); }
  .form-group { padding: var(--sp-4); }
  .qc-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); padding: var(--sp-3) var(--sp-4) var(--sp-4); }
  .queue-toolbar { flex-direction: column; align-items: flex-start; }
  .queue-actions { flex-wrap: wrap; justify-content: flex-start; }
  .result-row { gap: var(--sp-2); }
  .result-row .drive-link { margin-left: 0; }
  .actions { justify-content: stretch; }
  .actions .btn { flex: 1 1 auto; }
  .site-footer { flex-wrap: wrap; text-align: center; }
}
