/* Matches the WBI Invoice Maker: Satoshi, Winterborne blue #004eff, white header with logo */
:root {
  --blue: #004eff; --blue-ink: #0039bd; --ink: #1b2433; --muted: #5b6577;
  --line: #dfe3ea; --bg: #f5f6f8; --card: #ffffff; --tint: #f1f5ff; --err: #b42318;
  --ok: #067647; --ok-bg: #e7f4ec; --warn-bg: #fdecea;
  --r: 10px;
  /* comparison series: current = ink, proposed = brand blue */
  --color-A: #1b2433; --color-A-soft: #e9ecf1;
  --color-B: #004eff; --color-B-soft: #e3ebff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: 'Satoshi', system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
svg { display: block; max-width: 100%; }
input, button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* header — same as invoice maker */
header.top { display: flex; align-items: center; gap: 14px; padding: 18px 28px; background: var(--card); border-bottom: 1px solid var(--line); }
header.top img { height: 64px; width: auto; }
header.top h1 { font-size: 18px; margin: 0; font-weight: 700; }
header.top p { margin: 0; color: var(--muted); font-size: 13px; }

.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 28px; }
main.wrap { padding-bottom: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin: 24px 0; padding: 16px 22px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 500; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--blue); }

/* fields */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; }
.field.small input { width: 120px; }
.field.inline { margin-top: 14px; }
select, input[type=number], input:not([type]) {
  width: 100%; padding: 9px 11px; border: 1px solid #cdd3dd; border-radius: 8px; background: #fff; min-height: 40px;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* setups */
.setups { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; margin-bottom: 24px; }
.setup { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#setupA { border-top: 4px solid var(--color-A); }
#setupB { border-top: 4px solid var(--color-B); }
.setup-head { display: flex; align-items: center; gap: 4px; }
.setup-head .name { font-weight: 700; font-size: 17px; border: 1px solid transparent; padding: 4px 8px; background: transparent; min-height: 0; }
.setup-head .name:hover { border-color: var(--line); }
.grp { display: flex; flex-direction: column; gap: 8px; }
.grp-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.grp-title .muted { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 13px; }
.grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #fbfcfd; border: 1px solid var(--line); border-radius: 8px; padding-right: 6px; }
.chip input { width: 68px; border: none; background: transparent; min-height: 38px; font-weight: 700; }
.chip > span { font-size: 12px; color: var(--muted); }
.chip .x { width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 17px; line-height: 1; }
.chip .x:hover { color: var(--err); background: var(--warn-bg); }
.add { border: 1px dashed var(--blue); background: #fff; border-radius: 8px; padding: 8px 12px; font-size: 14px; color: var(--blue); font-weight: 700; min-height: 40px; }
.add:hover { background: var(--tint); }
.swap-col { display: flex; flex-direction: column; gap: 8px; padding-top: 56px; }
.ghost { background: #fff; color: var(--blue); border: 1px solid var(--blue); border-radius: 8px; padding: 8px 12px; font-size: 14px; font-weight: 700; min-height: 38px; white-space: nowrap; }
.ghost:hover { background: var(--tint); }

.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; margin-right: 8px; }
.swatch-A { background: var(--color-A); }
.swatch-B { background: var(--color-B); }

/* panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; margin-bottom: 24px; }
.panel-head { margin-bottom: 14px; }
.panel h2 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; font-weight: 700; }
.panel-head p { font-size: 13px; max-width: 80ch; }
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 18px; }
.insights p { background: var(--tint); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.table-scroll { overflow-x: auto; }

/* tables: blue header row like the invoice line items */
.summary th, .summary td, .matrix th, .matrix td, .match th, .match td { padding: 6px 10px; border-bottom: 1px solid #e3e7ee; font-size: 13px; white-space: nowrap; text-align: left; }
.summary thead th, .matrix thead th, .match thead th { background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; border-bottom: 0; }
.summary thead .swatch { box-shadow: 0 0 0 2px #fff; }
.summary tbody th { font-weight: 500; color: var(--muted); }
.summary td { font-weight: 500; }
.tag { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; margin-left: 4px; font-weight: 700; }
.tag.good { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--err); }

/* ladder */
.ladder { width: 100%; overflow: hidden; }
.ladder .grid { stroke: #e9ecf1; }
.ladder .tick { font-size: 12px; fill: var(--muted); }
.ladder .band { fill: var(--tint); }
.ladder .rowlab { font-size: 13px; fill: var(--muted); font-weight: 500; }
.ladder .rowlab.strong { fill: var(--ink); font-weight: 700; }
.ladder .setname { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ladder .setname-A { fill: var(--color-A); }
.ladder .setname-B { fill: var(--color-B); }
.ladder .rail { stroke-width: 2; opacity: .3; }
.ladder .rail-A { stroke: var(--color-A); }
.ladder .rail-B { stroke: var(--color-B); }
.ladder .sep { stroke: var(--line); stroke-dasharray: 3 4; }
.ladder .dot { stroke-width: 2; cursor: pointer; }
.ladder .dot-A { fill: var(--color-A); stroke: var(--color-A); }
.ladder .dot-B { fill: var(--color-B); stroke: var(--color-B); }
.ladder .dot.cross { fill: #fff; }
.ladder .dot:hover { stroke-width: 3.5; }
.ladder .tickmark { stroke-width: 3; stroke-linecap: round; }
.ladder .tm-A { stroke: var(--color-A); }
.ladder .tm-B { stroke: var(--color-B); }

.tip { position: absolute; z-index: 10; background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 12px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; box-shadow: 0 8px 24px rgba(27,36,51,.18); max-width: 280px; }
.tip em { color: #9db8ff; font-style: normal; font-weight: 700; }

/* matrices */
.matrices { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.matrices h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; flex-wrap: wrap; }
.matrices h3 .muted { font-weight: 500; font-size: 13px; margin-left: 4px; }
.matrix th, .matrix td { text-align: right; }
.matrix thead th:first-child, .matrix tbody th { text-align: left; }
.matrix tbody th { color: var(--muted); font-weight: 500; }
.matrix td { font-weight: 500; }
.matrix td.cross { color: #a4acba; background: repeating-linear-gradient(135deg, transparent 0 6px, #f5f6f8 6px 12px); }
.matrix td.step { color: var(--muted); font-weight: 400; font-size: 12px; }
#matrixA thead th { background: var(--color-A); }

.diff { font-weight: 700; padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.diff.ok { background: var(--ok-bg); color: var(--ok); }
.diff.mid { background: var(--tint); color: var(--blue-ink); }
.diff.far { background: var(--warn-bg); color: var(--err); }

.notes ul { padding-left: 20px; display: grid; gap: 4px; font-size: 13px; }
.foot { font-size: 12px; padding-block: 8px 40px; text-align: center; }

@media (max-width: 900px) {
  .setups { grid-template-columns: 1fr; }
  .swap-col { flex-direction: row; padding-top: 0; justify-content: center; }
  .matrices { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  header.top { padding: 14px 16px; }
  header.top img { height: 48px; }
  .wrap { padding-inline: 16px; }
  .toolbar { margin: 16px 0; }
}
@media (max-width: 480px) {
  .panel, .setup, .card { padding: 16px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 .field:first-child { grid-column: 1 / -1; }
  .toolbar .field:first-child { flex: 1 1 100%; }
}

.field.order { margin-top: 12px; max-width: 320px; }
.match .grouprow th { background: var(--tint); color: var(--blue-ink); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; padding: 6px 10px; border-bottom: 1px solid #e3e7ee; }
.match .xrow td { color: #a4acba; }
.match .xrow .diff { opacity: .55; }
.xtag { font-size: 11px; font-weight: 700; color: var(--muted); background: #f5f6f8; border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

/* ---------- output buttons ---------- */
.out-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.primary { background: var(--blue); color: #fff; border: 1px solid var(--blue); border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 700; min-height: 38px; white-space: nowrap; font-family: inherit; cursor: pointer; }
.primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.primary:disabled { opacity: .6; cursor: progress; }
.ghost { font-family: inherit; cursor: pointer; }
.status { flex-basis: 100%; text-align: right; font-size: 12px; color: var(--muted); min-height: 0; }
.status:empty { display: none; }
.status.ok { color: #067647; }
.status.err { color: var(--err); }
.print-date { display: none; }

/* ---------- print ---------- */
@media print {
  @page { size: letter; margin: 12mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff !important; font-size: 11px; }
  header.top { padding: 0 0 10px; border-bottom: 2px solid var(--blue); }
  header.top img { height: 48px; }
  .print-date { display: block; margin-left: auto !important; }
  .wrap { max-width: none; padding: 0; }
  .card { box-shadow: none !important; border: 1px solid var(--line); break-inside: avoid; }
  .out-btns, .swap-col { display: none !important; }
  .toolbar { margin: 10px 0; padding: 8px 12px; }
  input, select { border-color: var(--line) !important; }
  .ladder svg { width: 100% !important; height: auto !important; }
  .table-scroll { overflow: visible !important; }
  table { break-inside: auto; }
  tr, .grouprow { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  .tip, .tooltip { display: none !important; }
  .setups { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .matrices { grid-template-columns: 1fr 1fr !important; gap: 12px; }
  .grid3 { grid-template-columns: 1.4fr 1fr 1fr !important; }
  .setups .card { break-inside: avoid; }
}
