:root {
  --navy: #0F1B2D;
  --navy-700: #1A2842;
  --gold: #C9A66B;
  --gold-700: #A88450;
  --bg: #FAFAF7;
  --bg-soft: #F2F1EC;
  --surface: #FFFFFF;
  --border: #E7E5DF;
  --border-strong: #D6D3CB;
  --text: #1F2937;
  --text-soft: #6B7280;
  --text-mute: #9CA3AF;

  --st-pending-v1-bg: #FEF6DB;   --st-pending-v1-fg: #8A5A06;   --st-pending-v1-bd: #F4D77A;
  --st-validated-v1-bg: #DCFCE7; --st-validated-v1-fg: #15803D; --st-validated-v1-bd: #86EFAC;
  --st-rejected-v1-bg: #FEE2E2;  --st-rejected-v1-fg: #B91C1C;  --st-rejected-v1-bd: #FCA5A5;
  --st-pending-v2-bg: #DBEAFE;   --st-pending-v2-fg: #1D4ED8;   --st-pending-v2-bd: #93C5FD;
  --st-validated-v2-bg: #A7F3D0; --st-validated-v2-fg: #065F46; --st-validated-v2-bd: #34D399;
  --st-rejected-v2-bg: #FCA5A5;  --st-rejected-v2-fg: #7F1D1D;  --st-rejected-v2-bd: #EF4444;

  --shadow-xs: 0 1px 2px rgba(15,27,45,0.04), 0 1px 1px rgba(15,27,45,0.03);
  --shadow-sm: 0 4px 12px rgba(15,27,45,0.06), 0 1px 2px rgba(15,27,45,0.04);
  --shadow-md: 0 12px 28px rgba(15,27,45,0.08), 0 4px 8px rgba(15,27,45,0.04);
  --shadow-lg: 0 30px 80px rgba(15,27,45,0.18);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold-700); }

.container { max-width: 1320px; margin: 0 auto; padding: 0 24px; }
.main { padding: 28px 24px 80px; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 72px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand-mark {
  height: 32px; width: 32px;
  display: block; flex: 0 0 32px;
  border-radius: 8px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 17px; color: var(--navy);
  letter-spacing: 0.01em;
}
.brand-sub {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-soft); font-weight: 700;
}

.topbar-nav { display: flex; align-items: center; gap: 20px; }
.nav-link { color: var(--text-soft); font-weight: 500; font-size: 14px; }
.nav-link:hover { color: var(--navy); }

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 6px 12px 6px 6px; border-radius: 999px;
  font-weight: 500; font-size: 14px; color: var(--text); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.user-chip:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy); color: var(--gold);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-name { display: inline-flex; align-items: center; gap: 8px; }
.role-pill {
  background: var(--navy); color: var(--gold);
  font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; font-weight: 700;
}
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  min-width: 200px; padding: 6px; z-index: 100;
}
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; padding: 8px 12px; text-align: left;
  background: none; border: none; color: var(--text); font: inherit; cursor: pointer;
  border-radius: 6px;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-soft); }
.user-dropdown form { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; transition: all .15s ease;
  text-decoration: none; line-height: 1;
}
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger { background: #fff; color: #B91C1C; border-color: #FCA5A5; }
.btn-danger:hover { background: #FEE2E2; }

/* ---------- Page header ---------- */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-family: 'Fraunces', serif; font-size: 32px; font-weight: 700; margin: 0; color: var(--navy); }
.page-sub { margin: 4px 0 0; color: var(--text-soft); font-size: 14px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-xs);
  padding: 20px;
}

/* ---------- Filters ---------- */
.filters { margin-bottom: 24px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.search { position: relative; flex: 1 1 320px; min-width: 240px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-mute); }
.search .input { padding-left: 40px; }

.status-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: all .15s;
}
.chip:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--navy); color: #fff; }
.chip.is-active .chip-count { background: var(--gold); color: var(--navy); }
.chip-count {
  background: var(--border); color: var(--text-soft);
  padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}

/* ---------- Cards grid ---------- */
.cards {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
}
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; gap: 16px;
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.item-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-1px); }

.item-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ref-id {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  background: var(--bg-soft); color: var(--navy);
  padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--border);
}

.status {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.status-pending_v1   { background: var(--st-pending-v1-bg);   color: var(--st-pending-v1-fg);   border-color: var(--st-pending-v1-bd); }
.status-validated_v1 { background: var(--st-validated-v1-bg); color: var(--st-validated-v1-fg); border-color: var(--st-validated-v1-bd); }
.status-rejected_v1  { background: var(--st-rejected-v1-bg);  color: var(--st-rejected-v1-fg);  border-color: var(--st-rejected-v1-bd); }
.status-pending_v2   { background: var(--st-pending-v2-bg);   color: var(--st-pending-v2-fg);   border-color: var(--st-pending-v2-bd); }
.status-validated_v2 { background: var(--st-validated-v2-bg); color: var(--st-validated-v2-fg); border-color: var(--st-validated-v2-bd); }
.status-rejected_v2  { background: var(--st-rejected-v2-bg);  color: var(--st-rejected-v2-fg);  border-color: var(--st-rejected-v2-bd); }

.chip-pending_v1   { background: var(--st-pending-v1-bg);   color: var(--st-pending-v1-fg); }
.chip-validated_v1 { background: var(--st-validated-v1-bg); color: var(--st-validated-v1-fg); }
.chip-rejected_v1  { background: var(--st-rejected-v1-bg);  color: var(--st-rejected-v1-fg); }
.chip-pending_v2   { background: var(--st-pending-v2-bg);   color: var(--st-pending-v2-fg); }
.chip-validated_v2 { background: var(--st-validated-v2-bg); color: var(--st-validated-v2-fg); }
.chip-rejected_v2  { background: var(--st-rejected-v2-bg);  color: var(--st-rejected-v2-fg); }

.prompt {
  margin: 0; font-size: 14px; line-height: 1.55; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Versions (v1 / v2) ---------- */
.versions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.version { display: flex; flex-direction: column; gap: 8px; }
.version-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.version-label {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-soft); font-weight: 700;
}
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; cursor: pointer; line-height: 1;
  transition: all .15s;
}
.copy-btn:hover { border-color: var(--gold); color: var(--gold-700); background: #fff; }
.copy-btn.is-success { background: var(--st-validated-v1-bg); color: var(--st-validated-v1-fg); border-color: var(--st-validated-v1-bd); }

.version-img, .version-empty, .version-upload {
  display: block; aspect-ratio: 4 / 5; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--border);
  overflow: hidden; position: relative;
}
.version-img { cursor: zoom-in; }
.version-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.version-img:hover { border-color: var(--gold); }
.version-zoom {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(15,27,45,0.85); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  opacity: 0; transition: opacity .2s;
}
.version-img:hover .version-zoom { opacity: 1; }
.version-empty {
  display: grid; place-items: center; flex-direction: column;
  color: var(--text-mute); font-size: 12px; gap: 6px; padding: 12px;
  background-image: repeating-linear-gradient(45deg, transparent 0 8px, rgba(0,0,0,0.02) 8px 16px);
}
.version-empty svg { opacity: 0.5; }
.version-empty span { text-align: center; }

.version-upload { padding: 0; }
.version-upload .dropzone { width: 100%; height: 100%; }

/* ---------- Garments strip ---------- */
.garments-block { border-top: 1px dashed var(--border); padding-top: 12px; }
.garments-block summary {
  list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: baseline;
}
.garments-block summary::-webkit-details-marker { display: none; }
.garments-block summary > span:first-child {
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; font-size: 11px;
  color: var(--text-soft);
}
.garments-count { color: var(--text); font-size: 12px; font-weight: 500; }
.garments-strip {
  display: flex; gap: 8px; margin-top: 10px;
  overflow-x: auto; padding: 2px 0 4px;
}
.g-thumb { position: relative; flex: 0 0 72px; }
.g-thumb a { display: block; }
.g-thumb img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border); display: block;
  cursor: zoom-in;
}
.g-thumb img:hover { border-color: var(--gold); }
.g-remove {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer;
  display: grid; place-items: center; font-size: 14px; line-height: 1;
  box-shadow: var(--shadow-xs); padding: 0;
}
.g-remove:hover { color: #B91C1C; border-color: #FCA5A5; }
.g-thumb form { margin: 0; }

.g-add { flex: 0 0 72px; }
.g-add-label {
  width: 72px; height: 72px; border-radius: 8px;
  background: var(--bg-soft); border: 1px dashed var(--border-strong);
  display: grid; place-items: center; gap: 2px;
  color: var(--text-soft); cursor: pointer;
  font-size: 11px; font-weight: 600;
  transition: all .15s;
}
.g-add-label:hover { border-color: var(--gold); color: var(--gold-700); background: #fff; }
.g-add-label svg { display: block; }
.g-add input[type=file] { display: none; }

/* ---------- Quick status ---------- */
.quick-actions { display: flex; gap: 12px; align-items: center; }
.quick-status { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.quick-status select {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text);
  font-family: inherit;
}

/* ---------- Comments ---------- */
.comments-block { border-top: 1px dashed var(--border); padding-top: 12px; }
.comments-block summary {
  list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: baseline;
  font-size: 12px; color: var(--text-soft);
}
.comments-block summary::-webkit-details-marker { display: none; }
.comments-block summary > span:first-child {
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; font-size: 11px;
}
.comments-preview { color: var(--text); font-size: 12px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comments-block textarea {
  width: 100%; margin-top: 8px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 10px; font: inherit; resize: vertical; min-height: 60px;
}
.comments-block textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.comments-foot { display: flex; justify-content: flex-end; min-height: 16px; font-size: 11px; color: var(--text-soft); }

.item-foot {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border); padding-top: 12px;
  font-size: 12px;
}
.meta { color: var(--text-mute); }
.card-actions { display: flex; gap: 6px; }
.card-actions form { margin: 0; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 60px 24px; }
.empty h1, .empty h2 { font-family: 'Fraunces', serif; color: var(--navy); margin: 0 0 8px; }
.empty p { color: var(--text-soft); margin: 0 0 20px; }

/* ---------- Form ---------- */
.form-card { max-width: 920px; margin: 0 auto; }
.form-head h1 { font-family: 'Fraunces', serif; color: var(--navy); margin: 0 0 4px; font-size: 28px; }
.form-head p { color: var(--text-soft); margin: 0 0 24px; }

.form { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-half  { grid-column: span 3; }
.field-third { grid-column: span 2; }
.field-full  { grid-column: span 6; }
.field-label { font-size: 12px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.08em; }
.field-hint  { font-size: 12px; color: var(--text-mute); text-transform: none; letter-spacing: 0; font-weight: 400; }

.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  font: inherit; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { resize: vertical; min-height: 90px; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 166, 107, 0.25); }

.checkbox { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-soft); cursor: pointer; }

/* Dropzone (multi-file with previews + drag-and-drop) */
.dropzone {
  position: relative;
  background: var(--bg-soft);
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  transition: all .15s;
  overflow: hidden;
}
.dropzone:hover,
.dropzone.is-drop { background: #fff; border-color: var(--gold); }
.dropzone.is-drop { box-shadow: 0 0 0 4px rgba(201,166,107,0.15); }
.dropzone.is-uploading { opacity: 0.6; pointer-events: none; }
.dropzone.is-uploading::after {
  content: "Uploading…"; position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.7); color: var(--navy);
  font-weight: 600;
}
.dropzone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%; z-index: 1;
}
.dropzone-cta {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 26px 18px;
  color: var(--text-soft); cursor: pointer; text-align: center;
  pointer-events: none;
}
.dropzone-title { font-size: 14px; font-weight: 600; color: var(--text); }
.dropzone-hint { font-size: 12px; color: var(--text-mute); font-weight: 400; max-width: 420px; }
.dropzone-wide { margin-top: 10px; }
.file-list { font-size: 12px; color: var(--text-mute); font-weight: 400; }

.dropzone-previews {
  display: grid; gap: 10px; padding: 0 18px 18px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
.dropzone-previews:not(.has-files) { display: none; }
.preview-tile {
  position: relative; background: #fff;
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; box-shadow: var(--shadow-xs);
}
.preview-tile img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
}
.preview-tile-meta {
  font-size: 10px; color: var(--text-soft);
  padding: 6px 8px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}

.garments-edit-grid {
  display: grid; gap: 10px; margin-top: 8px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.garment-edit { position: relative; }
.garment-edit img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border);
}
.checkbox-overlay {
  position: absolute; top: 6px; left: 6px;
  background: rgba(255,255,255,0.92); padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.image-uploader { display: flex; flex-direction: column; gap: 10px; }
.preview {
  width: 100%; aspect-ratio: 4 / 5;
  background: var(--bg-soft); border: 1px dashed var(--border-strong); border-radius: 10px;
  overflow: hidden; display: grid; place-items: center; color: var(--text-mute); font-size: 13px;
}
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview-empty { background-image: repeating-linear-gradient(45deg, transparent 0 8px, rgba(0,0,0,0.02) 8px 16px); }

.file-input { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-input input[type=file] { display: none; }
.file-name { font-size: 12px; color: var(--text-soft); flex: 1; }

.versions-readonly { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.version-readonly { position: relative; }
.version-readonly img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.version-readonly .tag {
  position: absolute; top: 8px; left: 8px;
  background: var(--navy); color: var(--gold);
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700;
}

.form-actions {
  grid-column: span 6;
  display: flex; justify-content: flex-end; gap: 12px;
  border-top: 1px solid var(--border); padding-top: 18px; margin-top: 6px;
}
.form-section { font-family: 'Fraunces', serif; color: var(--navy); margin: 8px 0 4px; font-size: 18px; }

.back-link { display: inline-block; margin-bottom: 16px; color: var(--text-soft); font-size: 13px; font-weight: 500; }
.back-link:hover { color: var(--navy); }

/* ---------- Alerts / Flash ---------- */
.alert {
  padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: #FEF2F2; color: #991B1B; border-color: #FCA5A5; }
.alert-success { background: #ECFDF5; color: #065F46; border-color: #6EE7B7; }

.flash {
  position: fixed; top: 88px; right: 24px; z-index: 200;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--gold);
  border-radius: 10px; padding: 12px 18px; box-shadow: var(--shadow-md);
  font-weight: 500; font-size: 14px;
  animation: flash-in .3s ease, flash-out .4s ease 3.5s forwards;
}
.flash-success { border-left-color: #10B981; }
.flash-error { border-left-color: #EF4444; }
@keyframes flash-in { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flash-out { to { transform: translateY(-20px); opacity: 0; } }

/* ---------- Compare modal (input vs output) ---------- */
.compare {
  position: fixed; inset: 0; z-index: 280;
  background: rgba(15, 27, 45, 0.78);
  backdrop-filter: blur(10px);
  display: grid; place-items: center;
  padding: 28px;
  overflow-y: auto;
  animation: fade-in .2s ease;
}
.compare[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.compare-shell {
  width: 100%; max-width: 1400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: slide-up .25s ease;
}
@keyframes slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.compare-close {
  position: fixed; top: 24px; right: 28px; z-index: 290;
  background: rgba(255,255,255,0.14); color: #fff; border: none;
  width: 44px; height: 44px; border-radius: 50%; font-size: 26px;
  cursor: pointer; display: grid; place-items: center;
}
.compare-close:hover { background: rgba(255,255,255,0.28); }

.compare-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
}
.compare-id { display: flex; align-items: center; gap: 12px; }
.compare-id .ref-id { font-size: 14px; padding: 6px 12px; }

.compare-tabs {
  display: inline-flex; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px;
  gap: 2px;
}
.compare-tab {
  background: transparent; border: none; cursor: pointer;
  padding: 7px 18px; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 700;
  color: var(--text-soft);
  letter-spacing: 0.06em; text-transform: uppercase;
  transition: all .15s;
}
.compare-tab:hover { color: var(--text); }
.compare-tab.is-active { background: var(--navy); color: var(--gold); box-shadow: var(--shadow-xs); }
.compare-tab[hidden] { display: none; }

.compare-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
}
.compare-side {
  background: var(--surface);
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0;
}
.compare-side-input { background: linear-gradient(180deg, #FAFAF7 0%, #FFFFFF 100%); }
.compare-side-output { background: linear-gradient(180deg, #F8FAFC 0%, #FFFFFF 100%); }

.compare-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-soft); font-weight: 700;
}
.compare-eyebrow .dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.dot-input  { background: var(--gold); box-shadow: 0 0 0 3px rgba(201,166,107,0.2); }
.dot-output { background: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.compare-slot {
  margin-left: 6px;
  background: var(--navy); color: var(--gold);
  padding: 2px 8px; border-radius: 4px; font-weight: 700;
  font-size: 10px; letter-spacing: 0.12em;
}

.compare-main {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  display: grid; place-items: center;
  position: relative;
}
.compare-main img {
  width: 100%; height: 100%;
  object-fit: contain;
  background:
    linear-gradient(45deg, rgba(0,0,0,0.025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0,0,0,0.025) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.025) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.025) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.compare-strip {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.compare-strip:empty { display: none; }
.compare-strip button {
  flex: 0 0 64px; width: 64px; height: 64px;
  padding: 0; border-radius: 8px; overflow: hidden;
  background: var(--bg-soft);
  border: 2px solid var(--border); cursor: pointer;
  transition: border-color .15s;
}
.compare-strip button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.compare-strip button:hover { border-color: var(--gold); }
.compare-strip button.is-active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,166,107,0.25); }

.compare-output-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding-top: 4px;
}

.compare-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
  border-top: 1px solid var(--border);
}
.compare-meta-col {
  background: var(--surface);
  padding: 18px 24px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.compare-meta-label {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-soft); font-weight: 700;
}
.compare-meta-col p {
  margin: 0; font-size: 14px; color: var(--text); line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-height: 160px; overflow-y: auto;
}
.compare-meta-col[data-empty] p::before {
  content: "—"; color: var(--text-mute);
}

@media (max-width: 880px) {
  .compare { padding: 0; }
  .compare-shell { border-radius: 0; min-height: 100vh; max-width: 100vw; }
  .compare-grid, .compare-meta { grid-template-columns: 1fr; }
  .compare-side, .compare-meta-col { padding: 16px 18px; }
  .compare-header { padding: 14px 18px; flex-wrap: wrap; }
  .compare-close { top: 12px; right: 12px; }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 27, 45, 0.88); backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 40px;
}
.lightbox[hidden] { display: none; }
.lightbox figure {
  margin: 0; display: flex; flex-direction: column; align-items: center; gap: 18px;
  max-width: 100%; max-height: 100%;
}
.lightbox img {
  max-width: 92vw; max-height: 80vh; border-radius: 12px;
  box-shadow: var(--shadow-lg); background: var(--surface);
}
.lightbox figcaption {
  display: flex; align-items: center; gap: 16px;
  color: #fff; font-size: 14px;
  background: rgba(0,0,0,0.35); padding: 10px 16px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.lightbox-actions { display: flex; gap: 8px; }
.lightbox-actions .btn-ghost { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.25); }
.lightbox-actions .btn-ghost:hover { background: rgba(255,255,255,0.28); }
.lightbox-actions .is-success { background: var(--gold); color: var(--navy); border-color: var(--gold); }

.lightbox-close {
  position: absolute; top: 24px; right: 32px;
  background: rgba(255,255,255,0.14); color: #fff; border: none;
  width: 44px; height: 44px; border-radius: 50%; font-size: 28px;
  cursor: pointer; display: grid; place-items: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.28); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.14); color: #fff; border: none;
  width: 52px; height: 52px; border-radius: 50%; font-size: 32px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; padding: 0;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.28); }
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }
.lightbox-nav[disabled] { opacity: 0.25; cursor: default; pointer-events: none; }

/* ---------- Login page ---------- */
.page-login {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(201,166,107,0.16), transparent),
    radial-gradient(800px 500px at 10% 110%, rgba(15,27,45,0.10), transparent),
    var(--bg);
}
.login-shell { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px; width: 100%; max-width: 460px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  padding: 40px 36px; border-radius: var(--radius-lg);
  width: 100%; box-shadow: var(--shadow-md);
  text-align: center;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-logo { height: 72px; width: auto; display: block; }
.login-tagline {
  display: inline-block;
  color: var(--navy); font-size: 11px; letter-spacing: 0.22em;
  text-transform: uppercase; font-weight: 700;
  padding: 4px 12px; border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.login-card .form { text-align: left; }
.login-footnote { color: var(--text-mute); font-size: 12px; margin: 20px 0 0; }
.login-tag { color: var(--text-mute); font-size: 12px; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .field-half, .field-third { grid-column: span 2; }
  .form-actions { grid-column: span 2; }
  .page-title { font-size: 26px; }
  .topbar-inner { height: 60px; }
  .brand-sub { display: none; }
  .nav-link { display: none; }
  .versions-readonly { grid-template-columns: 1fr; }
  .lightbox-nav { width: 40px; height: 40px; font-size: 24px; }
  .lightbox-prev { left: 8px; } .lightbox-next { right: 8px; }
}
