/* ---------- Self-hosted fonts (latin subsets) ---------- */
@font-face { font-family: 'Lora'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/lora-500.woff2') format('woff2'); }
@font-face { font-family: 'Lora'; font-style: normal; font-weight: 600; font-display: swap; src: url('/static/fonts/lora-600.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/ibm-plex-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/ibm-plex-mono-500.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('/static/fonts/ibm-plex-mono-600.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url('/static/fonts/ibm-plex-mono-700.woff2') format('woff2'); }

/* ============================================================
   Quoter — single stylesheet
   Navy ink · coral action · cool gray ground
   Lora (display) · system sans (UI) · IBM Plex Mono (data)
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* color — core */
  --ink:            #1d3f66;  /* navy: top bar, table totals, stat keys */
  --ink-soft:       #a8bcd4;  /* muted text on navy */
  --ink-faint:      #6d87a8;  /* faintest text on navy */
  --action:         #b84e34;  /* deep coral: buttons, links, focus (AA on white) */
  --action-hover:   #a8462c;
  --accent:         #d96a4a;  /* bright coral: badges, stat keys, decorative */
  --accent-dark:    #a8462c;  /* coral text on tint */
  --accent-tint:    #fbeee9;
  --accent-border:  #ecc4b5;

  /* color — ground & text */
  --bg:             #f2f5f6;
  --surface:        #ffffff;
  --border:         #e0e4e6;
  --border-strong:  #c6cbd2;
  --text:           #1a2330;
  --text-2:         #66788c;
  --text-3:         #8d9aa9;

  /* color — semantic */
  --negative:       #b3261e;  /* negative money */
  --success:        #1e7a3c;
  --success-tint:   #e9f5ec;
  --success-border: #b9dec4;
  --danger:         #b3261e;
  --danger-tint:    #fbecea;
  --danger-border:  #eec5c0;
  --warn:           #9a6312;
  --warn-tint:      #faf3e6;
  --warn-border:    #e8cfa4;

  /* color — table */
  --thead:          #eef2f3;
  --row-alt:        #fafbfc;
  --row-border:     #edf0f4;

  /* type */
  --font-ui:      -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Lora", Georgia, serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fs-11: 11px;  --fs-12: 12px;  --fs-13: 13px;  --fs-14: 14px;
  --fs-16: 16px;  --fs-19: 19px;  --fs-23: 23px;

  /* spacing (4-base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 28px;  --sp-8: 32px;

  /* radii & elevation */
  --r-sm: 5px;  --r-md: 6px;  --r-lg: 8px;
  --shadow-card: 0 1px 3px rgba(26, 35, 48, 0.05);

  /* control metrics */
  --control-h: 38px;
  --row-h: 38px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-14);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--font-mono); }
.num { text-align: right; }
.u-hidden { display: none !important; }

a { color: var(--action); }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--action); outline-offset: 2px; border-radius: 2px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--action); outline-offset: 1px; border-color: var(--action);
}

/* ---------- Page scaffold ---------- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: var(--sp-8) var(--sp-8) 0; }
.main--wide { align-items: stretch; padding: 0; }
.main--narrow { justify-content: flex-start; padding-top: 64px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--ink); color: #fff; flex: none;
  display: flex; align-items: center; gap: 11px;
  padding: 0 var(--sp-7); height: 52px;
}
.mark {
  width: 26px; height: 26px; border-radius: 4px; flex: none;
  background: #fff; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 17px;
  padding-bottom: 1px; line-height: 1;
}
.product { font-family: var(--font-display); font-weight: 600; font-size: 16.5px; color: #fff; text-decoration: none; }
.tagline { color: var(--ink-soft); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-4); }
.topbar-link {
  color: var(--ink-soft); font-size: var(--fs-13); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.topbar-link:hover { color: #fff; }
.topbar-link:focus-visible { outline-color: #fff; }

/* ---------- Footer ---------- */
.footer {
  flex: none; text-align: center; color: var(--text-3);
  font-size: var(--fs-12); padding: var(--sp-5) 0 var(--sp-4);
}
.footer a { color: var(--text-3); text-decoration: none; }
.footer a:hover { color: var(--text-2); text-decoration: underline; }
.footer .sep { margin: 0 6px; color: var(--border-strong); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
.card--pad { padding: 30px 34px 26px; }
.card-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--fs-23); letter-spacing: -0.01em; margin: 0 0 4px;
}
.card-sub { color: var(--text-2); margin: 0 0 var(--sp-6); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--control-h); padding: 0 18px; border-radius: var(--r-md);
  font-family: var(--font-ui); font-size: var(--fs-14); font-weight: 650;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn--primary {
  background: var(--action); color: #fff; border: none;
  box-shadow: inset 0 -1.5px 0 rgba(0, 0, 0, 0.18);
}
.btn--primary:hover { background: var(--action-hover); }
.btn--secondary {
  background: var(--surface); color: #2c3a4d;
  border: 1px solid var(--border-strong); font-size: var(--fs-13); font-weight: 600;
}
.btn--secondary:hover { border-color: #aab3bd; background: #fafbfc; }
.btn--ghost {
  background: none; border: none; color: var(--text-2);
  font-size: var(--fs-13); font-weight: 600;
}
.btn--ghost:hover { color: var(--text); }
.btn--small { height: 34px; padding: 0 13px; }
.btn[disabled] { opacity: 0.55; cursor: default; pointer-events: none; }

/* ---------- Fields ---------- */
.field { margin-bottom: var(--sp-5); }
.label {
  display: block; font-size: 11.5px; font-weight: 650; color: #4c5a6b;
  letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-family: var(--font-ui); font-size: var(--fs-14); color: var(--text); background: var(--surface);
}
.input, .select { height: var(--control-h); padding: 0 11px; }
.textarea { padding: 8px 11px; resize: vertical; min-height: var(--control-h); }
.input--mono { font-family: var(--font-mono); font-size: var(--fs-13); }
.input[disabled] { background: #f7f9fa; color: var(--text-2); cursor: default; }
.field-hint { color: var(--text-2); font-size: 12.5px; margin-top: var(--sp-2); display: flex; align-items: center; gap: 7px; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: var(--sp-2); display: none; }
.field.is-invalid .select, .field.is-invalid .input { border-color: var(--danger); }
.field.is-invalid .field-error { display: flex; align-items: center; gap: 6px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  color: var(--accent-dark); background: var(--accent-tint);
  border: 1px solid var(--accent-border); border-radius: var(--r-sm); padding: 2px 8px;
  white-space: nowrap;
}
.badge--set { color: var(--success); background: var(--success-tint); border-color: var(--success-border); }
.badge--empty { color: var(--text-3); background: #f3f5f6; border-color: var(--border); }
.badge--down { color: var(--danger); background: var(--danger-tint); border-color: var(--danger-border); }

/* ---------- Import screen ---------- */
.import-card { width: 640px; max-width: 100%; }
.dropzone {
  border: 1.5px dashed #aebad0; border-radius: var(--r-lg);
  background: repeating-linear-gradient(-45deg, #fafbfd 0 14px, #f4f7f8 14px 28px);
  padding: 26px 24px; text-align: center; color: var(--text-2);
}
.dropzone .dz-cta { font-weight: 650; color: var(--text); }
.dropzone .dz-cta a { font-weight: 650; }
.dropzone .dz-types { font-size: var(--fs-12); color: var(--text-3); margin-top: 4px; font-family: var(--font-mono); }
.dropzone.is-dragover { border-color: var(--action); background: var(--accent-tint); }
.dropzone.is-filled {
  border-style: solid; border-color: var(--border-strong); background: var(--surface);
  display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px 18px;
}
.file-icon {
  width: 38px; height: 38px; border-radius: 7px; background: var(--ink); color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 700; font-family: var(--font-mono);
}
.file-name { font-weight: 650; }
.file-size { color: var(--text-2); font-size: var(--fs-12); font-family: var(--font-mono); }
.file-replace {
  margin-left: auto; color: var(--action); font-size: var(--fs-13); font-weight: 650;
  background: none; border: none; cursor: pointer; font-family: var(--font-ui);
}
.context-grid {
  margin: var(--sp-1) 0 var(--sp-6); border: 1px solid var(--border); border-radius: 7px;
  overflow: hidden; display: grid; grid-template-columns: 1fr 1fr;
}
.context-cell { padding: 11px 14px; background: #f7f9fa; }
.context-cell + .context-cell { border-left: 1px solid var(--border); }
.context-label { font-size: 10.5px; font-weight: 700; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
.context-value { font-size: var(--fs-13); color: #2c3a4d; margin-top: 3px; font-family: var(--font-mono); }
.card-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--sp-4); }

/* format-mismatch warning (warn, never block) */
.format-warn {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--warn-tint); border: 1px solid var(--warn-border); border-radius: var(--r-md);
  color: var(--warn); font-size: 12.5px; padding: 8px 12px; margin-top: var(--sp-2);
}

/* ---------- Progress screen ---------- */
.progress-card { width: 560px; max-width: 100%; text-align: center; padding: 52px 40px 44px; }
.progress-anim { display: flex; justify-content: center; gap: 10px; margin-bottom: 26px; }
.progress-anim span {
  width: 10px; height: 10px; border-radius: 50%; background: var(--ink);
  animation: q-pulse 1.4s ease-in-out infinite;
}
.progress-anim span:nth-child(2) { animation-delay: 0.18s; background: var(--accent); }
.progress-anim span:nth-child(3) { animation-delay: 0.36s; }
@keyframes q-pulse {
  0%, 70%, 100% { transform: scale(1); opacity: 0.35; }
  35% { transform: scale(1.45); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .progress-anim span { animation: none; opacity: 0.8; }
}
.progress-file { font-family: var(--font-mono); font-size: var(--fs-13); color: var(--text-2); margin-top: 6px; }
.progress-elapsed {
  font-family: var(--font-mono); font-size: var(--fs-16); color: var(--text);
  margin-top: var(--sp-5); font-variant-numeric: tabular-nums;
}
.progress-note { color: var(--text-3); font-size: 12.5px; margin-top: var(--sp-2); }

/* ---------- Review screen ---------- */
.action-band {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 15px var(--sp-7); display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.src-file { color: var(--text-2); font-size: 12.5px; font-family: var(--font-mono); }
.band-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.review-body { padding: var(--sp-5) var(--sp-7) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }

/* status banners */
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  border-radius: var(--r-lg); padding: 13px 16px; font-size: var(--fs-13);
}
.banner--success { background: var(--success-tint); border: 1px solid var(--success-border); color: var(--success); }
.banner--error { background: var(--danger-tint); border: 1px solid var(--danger-border); color: var(--danger); }
.banner b { font-weight: 700; }
.banner .banner-body { flex: 1; }
.banner .banner-detail {
  font-family: var(--font-mono); font-size: var(--fs-12); color: #7c2620;
  background: rgba(255, 255, 255, 0.6); border-radius: var(--r-sm);
  padding: 6px 9px; margin-top: 6px; white-space: pre-wrap;
}
.banner .btn { flex: none; }

/* header fields */
.headcard { padding: var(--sp-5) var(--sp-6); }
.headgrid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.6fr 1fr; gap: var(--sp-4) 18px; }
.headgrid .field { margin: 0; }
.notes-row { grid-column: 1 / -1; }

/* derived stats */
.stats { display: flex; align-items: stretch; gap: 14px; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 13px 20px; box-shadow: var(--shadow-card); border-top: 3px solid var(--ink);
}
.stat--accent { border-top-color: var(--accent); }
.stat-label { font-size: var(--fs-11); font-weight: 700; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
.stat-value {
  font-size: var(--fs-23); font-weight: 600; font-family: var(--font-mono);
  letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* line items table */
.tablecard { overflow: hidden; }
/* The review table needs a sticky header, and overflow:hidden would make
   the card itself the sticky scrollport (header pins inside the card, on
   top of the rows). Let it overflow and round the corners explicitly. */
.tablecard--sticky { overflow: visible; }
.tablecard--sticky .line-table thead th:first-child { border-top-left-radius: var(--r-lg); }
.tablecard--sticky .line-table thead th:last-child { border-top-right-radius: var(--r-lg); }
.tablecard--sticky .line-table tfoot td:first-child { border-bottom-left-radius: var(--r-lg); }
.tablecard--sticky .line-table tfoot td:last-child { border-bottom-right-radius: var(--r-lg); }
.line-table { width: 100%; border-collapse: collapse; }
.line-table th {
  text-align: left; font-size: var(--fs-11); font-weight: 700; color: #4c5a6b;
  letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--thead); border-bottom: 1px solid #d8dee6; padding: 8px 10px;
  /* Stick below the action band; JS keeps --band-h equal to the band's
     measured height so a wrapped (two-line) band can't overlap the header. */
  position: sticky; top: var(--band-h, 68px); z-index: 10;
}
.line-table td { border-bottom: 1px solid var(--row-border); padding: 0; height: var(--row-h); }
.line-table tbody tr:nth-child(even) td { background: var(--row-alt); }
.line-table td.rownum {
  color: #a3aeba; font-size: 11.5px; text-align: center; font-family: var(--font-mono);
}
.cell {
  width: 100%; height: var(--row-h); border: none; background: transparent;
  padding: 0 10px; font-size: 13.5px; font-family: var(--font-ui); color: var(--text);
}
.cell--mono { font-family: var(--font-mono); font-size: 12.5px; }
.cell--num { text-align: right; }
.cell--neg { color: var(--negative); }
.cell:focus { background: var(--surface); border-radius: 4px; }
/* description cells: single-line textarea that grows on focus */
textarea.cell {
  resize: none; overflow: hidden; line-height: var(--row-h);
  white-space: nowrap; text-overflow: ellipsis; display: block;
}
textarea.cell:focus {
  white-space: normal; line-height: 1.45; padding: 9px 10px;
  height: auto; min-height: var(--row-h); field-sizing: content;
  position: relative; z-index: 5; box-shadow: var(--shadow-card);
}

/* totals row */
.line-table tfoot td {
  background: var(--ink); color: #fff; border-bottom: none; height: 40px;
  font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-13);
  padding: 0 10px; font-variant-numeric: tabular-nums;
}
.line-table tfoot td.num { text-align: right; }
.foot-label {
  font-family: var(--font-ui); font-weight: 700; font-size: 10.5px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
}

/* zero-lines empty state */
.table-empty { padding: 44px 32px; text-align: center; }
.table-empty-title { font-family: var(--font-display); font-size: var(--fs-16); font-weight: 600; margin: 0 0 6px; }
.table-empty-sub { color: var(--text-2); font-size: var(--fs-13); margin: 0 auto; max-width: 52ch; }

/* raw JSON inspector */
.raw-json-row { display: flex; align-items: baseline; gap: var(--sp-4); margin-top: var(--sp-1); }
.raw-json-row .raw-json { flex: 1; margin-top: 0; }
.dev-link {
  flex: none; color: var(--text-3); font-size: 12.5px; font-family: var(--font-mono);
  text-decoration: none; padding: 4px 2px;
}
.dev-link:hover { color: var(--text); text-decoration: underline; }

/* developer guide page */
.devdoc p, .devdoc li { font-size: var(--fs-13); color: #2c3a4d; line-height: 1.6; }
.devdoc .code-block { margin: var(--sp-3) 0 var(--sp-4); }
.devdoc .data-table { margin: var(--sp-2) 0 var(--sp-5); }
.devdoc .data-table td { vertical-align: top; }
.devdoc-list { margin: var(--sp-2) 0 var(--sp-4); padding-left: 20px; }
.devdoc-list li { margin-bottom: 6px; }
.raw-json { margin-top: var(--sp-1); }
.raw-json summary {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  color: var(--text-2); font-size: 12.5px; font-family: var(--font-mono);
  list-style: none; padding: 4px 2px;
}
.raw-json summary::-webkit-details-marker { display: none; }
.raw-json summary:hover { color: var(--text); }
.raw-json[open] summary { color: var(--text); }
.raw-json pre {
  margin: var(--sp-2) 0 0; background: #21303f; color: #d5dde5;
  border-radius: var(--r-lg); padding: 16px 18px; overflow: auto;
  font-family: var(--font-mono); font-size: var(--fs-12); line-height: 1.6;
}

/* ---------- Error screens ---------- */
.error-card { width: 640px; max-width: 100%; }
.code-block {
  position: relative; background: #21303f; color: #d5dde5; border-radius: var(--r-lg);
  padding: 14px 16px; font-family: var(--font-mono); font-size: var(--fs-12);
  line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  margin: var(--sp-4) 0 var(--sp-6);
}
.code-copy {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255, 255, 255, 0.1); color: #d5dde5; border: none;
  border-radius: var(--r-sm); font-size: var(--fs-11); font-weight: 600;
  font-family: var(--font-ui); padding: 4px 9px; cursor: pointer;
}
.code-copy:hover { background: rgba(255, 255, 255, 0.2); }
.error-404 {
  font-family: var(--font-mono); font-size: 56px; font-weight: 600;
  color: var(--border-strong); margin: 0 0 var(--sp-2); letter-spacing: 0.04em;
}

/* ---------- Admin ---------- */
.login-card { width: 400px; max-width: 100%; }
.login-recovery {
  color: var(--text-3); font-size: var(--fs-12); line-height: 1.55;
  margin: var(--sp-5) 0 0; padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}
.login-recovery .mono { font-size: var(--fs-11); }
.admin-main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: var(--sp-8) var(--sp-8) 0; }
.admin-h1 { font-family: var(--font-display); font-size: var(--fs-23); font-weight: 600; margin: 0 0 4px; }
.admin-sub { color: var(--text-2); margin: 0 0 var(--sp-6); }
.breadcrumb { font-size: 12.5px; color: var(--text-3); margin-bottom: var(--sp-3); }
.breadcrumb a { color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 7px; color: var(--border-strong); }

/* admin home menu */
.menu-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-4); }
.menu-card {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); text-decoration: none; color: var(--text);
}
.menu-card:hover { border-color: var(--border-strong); }
.menu-icon {
  width: 40px; height: 40px; border-radius: var(--r-lg); flex: none;
  background: var(--accent-tint); color: var(--accent-dark); border: 1px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center;
}
.menu-title { font-weight: 650; }
.menu-desc { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.menu-hint { color: var(--text-3); font-size: 12.5px; margin-top: var(--sp-5); }

/* vendor list table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: var(--fs-11); font-weight: 700; color: #4c5a6b;
  letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--thead); border-bottom: 1px solid #d8dee6; padding: 8px 14px;
}
.data-table td { border-bottom: 1px solid var(--row-border); padding: 10px 14px; font-size: 13.5px; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--row-alt); }
.data-table a { font-weight: 650; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.data-table .mono { font-size: var(--fs-12); color: var(--text-2); }

/* playbook editor */
.pb-layout { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--sp-5); align-items: start; }
@media (max-width: 1100px) { .pb-layout { grid-template-columns: 1fr; } }
.form-section { padding: var(--sp-5) var(--sp-6); }
.section-title {
  font-family: var(--font-display); font-size: var(--fs-16); font-weight: 600; margin: 0 0 2px;
}
.section-sub { color: var(--text-2); font-size: 12.5px; margin: 0 0 var(--sp-4); }
.form-stack { display: flex; flex-direction: column; gap: var(--sp-4); }

.map-row { border: 1px solid var(--border); border-radius: var(--r-md); }
.map-row + .map-row { margin-top: var(--sp-2); }
.map-head {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer;
  background: none; border: none; width: 100%; text-align: left; font-family: var(--font-ui);
}
.map-key { font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 600; color: var(--text); }
.map-summary { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.map-row.is-empty .map-summary { color: var(--text-3); font-style: italic; }
.map-chevron { color: var(--text-3); flex: none; transition: transform 0.15s; }
.map-row.is-open .map-chevron { transform: rotate(90deg); }
.map-body { display: none; padding: var(--sp-3) 12px var(--sp-4); border-top: 1px solid var(--row-border); }
.map-row.is-open .map-body { display: block; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-3); }
.map-grid .field { margin: 0; }
.map-grid .field--wide { grid-column: 1 / -1; }
.map-grid .label { font-size: 10.5px; }
.map-grid .input { height: 32px; font-size: var(--fs-13); }

/* chips (ignored columns) */
.chips {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef2f3; border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--fs-12); padding: 3px 8px;
}
.chip button { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 0; font-size: var(--fs-13); line-height: 1; }
.chip button:hover { color: var(--danger); }
.chips input {
  border: none; outline: none; flex: 1; min-width: 120px;
  font-family: var(--font-mono); font-size: var(--fs-12); padding: 3px 4px; background: none;
}

/* quirks list */
.quirk { display: flex; gap: var(--sp-2); align-items: flex-start; }
.quirk .textarea { flex: 1; }
.quirk-remove {
  flex: none; background: none; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  width: 32px; height: 32px; color: var(--text-3); cursor: pointer; font-size: var(--fs-14);
}
.quirk-remove:hover { color: var(--danger); border-color: var(--danger-border); }
.add-link {
  background: none; border: none; color: var(--action); font-weight: 650;
  font-size: var(--fs-13); cursor: pointer; padding: 0; font-family: var(--font-ui);
}

/* compiled prose preview */
.pb-preview { position: sticky; top: 84px; }
.pb-preview-card { padding: var(--sp-5) var(--sp-6); }
.pb-preview-note { color: var(--text-3); font-size: var(--fs-12); margin: 0 0 var(--sp-3); }
.prose {
  font-size: var(--fs-13); line-height: 1.7; color: #2c3a4d;
  background: #f7f9fa; border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px 18px; max-height: 560px; overflow: auto;
}
.prose h4 { font-family: var(--font-display); font-size: var(--fs-13); margin: 14px 0 4px; }
.prose h4:first-child { margin-top: 0; }
.prose code { font-family: var(--font-mono); font-size: var(--fs-12); background: #eef2f3; border-radius: 3px; padding: 1px 4px; }
.prose ul { margin: 4px 0; padding-left: 18px; }

/* save bar */
.save-bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-4) 0 var(--sp-8); }


/* ---------- Additions beyond the design package ---------- */

/* Vendor Active toggle (admin list) — green=on to match badge--set semantics */
.switch {
  position: relative; width: 38px; height: 22px; flex: none;
  border-radius: 11px; border: 1px solid var(--border-strong);
  background: #dde2e6; cursor: pointer; padding: 0; transition: background 0.15s, border-color 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(26,35,48,0.25); transition: left 0.15s;
}
.switch[aria-checked="true"] { background: var(--success); border-color: var(--success); }
.switch[aria-checked="true"]::after { left: 18px; }
.switch[disabled] { opacity: 0.5; cursor: default; }

/* Compiled-playbook preview shows render_prose() verbatim */
.prose--raw { white-space: pre-wrap; font-family: var(--font-mono); font-size: var(--fs-12); line-height: 1.65; }

/* Feedback (fourth stat card on the review screen) */
.stat--feedback { border-top-color: var(--ink); }
.stat-thumbs { display: flex; gap: var(--sp-2); margin-top: 5px; }
.stat--feedback.is-done .stat-sub { color: var(--success); font-weight: 600; }
.thumb {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-2); cursor: pointer; padding: 0;
}
.thumb:hover { color: var(--success); border-color: var(--success-border); background: var(--success-tint); }
.thumb--down:hover { color: var(--danger); border-color: var(--danger-border); background: var(--danger-tint); }
.thumb[disabled] { cursor: default; opacity: 0.55; }
.thumb.is-selected { opacity: 1; }
.thumb.is-selected,
.thumb.is-selected[disabled] { color: var(--success); border-color: var(--success-border); background: var(--success-tint); opacity: 1; }
.thumb--down.is-selected,
.thumb--down.is-selected[disabled] { color: var(--danger); border-color: var(--danger-border); background: var(--danger-tint); }

/* Admin usage screen */
.usage-head {
  display: flex; align-items: stretch; gap: var(--sp-6);
  padding: var(--sp-4) var(--sp-6);
}
.usage-window { flex: none; }
.window-toggle { display: flex; gap: 6px; margin-top: 7px; }
.window-opt {
  display: inline-flex; align-items: center; justify-content: center;
  height: 30px; padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font-size: var(--fs-13); font-weight: 650;
  font-family: var(--font-mono); text-decoration: none;
}
.window-opt:hover { border-color: #aab3bd; }
.window-opt.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.usage-kpis { display: flex; gap: var(--sp-8); margin-left: auto; }
.usage-kpi .stat-value { font-size: var(--fs-23); }
.usage-chart { width: 100%; height: auto; display: block; margin-top: var(--sp-2); }
.chart-wrap { position: relative; }
.chart-hover { fill: transparent; cursor: default; }
.chart-hover:hover { fill: rgba(29, 63, 102, 0.07); }
.chart-tip {
  position: absolute; z-index: 30; pointer-events: none;
  min-width: 230px; max-width: 320px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: 0 4px 16px rgba(26, 35, 48, 0.14);
  padding: 10px 12px; font-size: var(--fs-12);
}
.chart-tip-head {
  display: flex; justify-content: space-between; gap: var(--sp-4);
  font-weight: 700; margin-bottom: 6px; font-size: var(--fs-13);
}
.chart-tip-total { font-family: var(--font-mono); }
.chart-tip-row { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.chart-tip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tip-amt { font-family: var(--font-mono); color: var(--text-2); font-variant-numeric: tabular-nums; }
.chart-axis { font-family: var(--font-mono); font-size: 12px; fill: var(--text-3); }
.chart-label { font-family: var(--font-mono); font-size: 11px; fill: var(--text-3); }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: var(--sp-4);
  font-size: var(--fs-13); color: var(--text);
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-chip { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend-total { color: var(--text-3); font-family: var(--font-mono); font-size: var(--fs-12); }

/* Admin feedback review table */
.fb-when { white-space: nowrap; font-size: var(--fs-12); color: var(--text-2); }
.fb-file { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-file a { font-weight: 500; }
.fb-issue { max-width: 320px; font-size: var(--fs-13); white-space: pre-wrap; }

/* Thumbs-down issue panel */
.feedback-panel { padding: var(--sp-4) var(--sp-5); }
.feedback-panel .textarea { margin-top: 2px; }
.feedback-panel-actions { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.feedback-error { color: var(--danger); font-size: 12.5px; font-weight: 600; }
.feedback-fineprint { color: var(--text-3); font-size: var(--fs-11); margin: var(--sp-2) 0 0; }
