:root {
  /* Layout: customer index on the left, one customer's price book on the right, styled after the carbon-copy invoice books. */
  --paper: #f3f4f7;
  --surface: #ffffff;
  --ink: #1a1e29;
  --muted: #5b6273;
  --line: #dde0e8;
  --carbon: #3340b0;
  --carbon-soft: #e9ebfa;
  --warn: #8a5300;
  --warn-soft: #fbefd8;
  --up: #b42318;
  --down: #17704a;
  --focus: #3340b0;
  --font-display: "Archivo", "Arial Narrow", Arial, sans-serif;
  --font-body: "Archivo", Arial, Helvetica, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111319;
    --surface: #181b23;
    --ink: #e6e8ef;
    --muted: #9aa0b1;
    --line: #2a2e3a;
    --carbon: #9aa5ff;
    --carbon-soft: #232849;
    --warn: #f2b85c;
    --warn-soft: #362a13;
    --up: #ff8b7f;
    --down: #6fd3a1;
    --focus: #9aa5ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111319;
  --surface: #181b23;
  --ink: #e6e8ef;
  --muted: #9aa0b1;
  --line: #2a2e3a;
  --carbon: #9aa5ff;
  --carbon-soft: #232849;
  --warn: #f2b85c;
  --warn-soft: #362a13;
  --up: #ff8b7f;
  --down: #6fd3a1;
  --focus: #9aa5ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  font-variation-settings: "wdth" 100;
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px 24px;
  align-items: center;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "wdth" 72;
  font-weight: 750;
  font-size: 22px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  line-height: 1;
}
.brand h1 span { color: var(--carbon); }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); }
.find { position: relative; max-width: 560px; width: 100%; justify-self: center; }
.find input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.find svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-right { display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button {
  border: 0; background: transparent; padding: 7px 11px; cursor: pointer; font-size: 13px; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--carbon); color: var(--surface); }
.sync {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.sync[data-s="live"] i { background: var(--down); }
.sync[data-s="readonly"] i, .sync[data-s="slow"] i { background: var(--warn); }
.sync[data-s="off"] i { background: var(--up); }
.linkbtn {
  border: 0; background: none; padding: 0; color: var(--carbon); cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; font-size: 13px;
}

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100% - 71px); }
aside.cust {
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column;
  min-height: 0;
  position: sticky; top: 0; height: 100vh; max-height: 100vh;
}
.cust-head { padding: 14px 16px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.cust-head .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label {
  font-family: var(--font-display); font-variation-settings: "wdth" 80; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px; color: var(--muted);
}
.cust-head input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
}
.cust-list { list-style: none; margin: 0; padding: 6px 8px 16px; overflow-y: auto; flex: 1; }
.cust-list button {
  width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: var(--radius);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; cursor: pointer;
  border-left: 3px solid transparent;
}
.cust-list button:hover { background: var(--paper); }
.cust-list button[aria-current="true"] { background: var(--carbon-soft); border-left-color: var(--carbon); }
.cust-list .nm { font-weight: 560; overflow-wrap: anywhere; }
.cust-list .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.cust-list .ed { font-size: 11px; color: var(--carbon); font-weight: 600; align-self: start; padding-top: 2px; }
.cust-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }

main { padding: 22px 26px 60px; min-width: 0; }

/* ---------- buttons, chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: var(--radius);
  cursor: pointer; font-size: 13.5px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--carbon); border-color: var(--carbon); color: var(--surface); }
.btn.danger { color: var(--up); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 1.5;
}
.chip.edit { background: var(--carbon-soft); color: var(--carbon); }
.chip.added { border-color: var(--carbon); color: var(--carbon); }
.chip.check { background: var(--warn-soft); color: var(--warn); }
.chip.gone { background: var(--paper); color: var(--muted); border-color: var(--line); }

/* ---------- customer header (styled after the invoice's account box) ---------- */
.acct {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 24px; align-items: end;
  padding-bottom: 16px; border-bottom: 2px solid var(--ink); margin-bottom: 16px;
}
.acct h2 {
  margin: 4px 0 6px;
  font-family: var(--font-display); font-variation-settings: "wdth" 70; font-weight: 760;
  font-size: clamp(26px, 3.4vw, 38px); line-height: 1.02; text-transform: uppercase; letter-spacing: 0.005em;
  text-wrap: balance;
}
.acct .facts { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--muted); }
.acct .facts b { color: var(--ink); font-weight: 600; }
.acct .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] {
  flex: 1 1 220px; max-width: 340px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; cursor: pointer;
  font-size: 13px; display: inline-flex; gap: 6px; align-items: center;
}
.filters button .n { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.filters button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.filters button[aria-pressed="true"] .n { color: var(--surface); opacity: 0.75; }

/* ---------- price table ---------- */
.book { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.thead, .trow {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) 150px 128px 150px;
  gap: 0 14px; align-items: start; padding: 10px 16px;
}
.thead {
  background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.thead > div { font-family: var(--font-display); font-variation-settings: "wdth" 80; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px; color: var(--muted); }
.thead .r, .trow .r { text-align: right; }
.trow { border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.trow.open { background: var(--paper); }
.trow.removed .desc-btn, .trow.removed .price-val { text-decoration: line-through; color: var(--muted); }
.code { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); padding-top: 2px; overflow-wrap: anywhere; }
.desc-btn {
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font-weight: 520; color: var(--ink);
  overflow-wrap: anywhere;
}
.desc-btn:hover { color: var(--carbon); }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.note-line { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price-btn {
  border: 1px dashed transparent; background: none; cursor: pointer; padding: 1px 6px; margin: -2px -7px 0 0; border-radius: 4px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; color: var(--carbon);
}
.price-btn:hover { border-color: var(--carbon); }
.price-btn[disabled] { cursor: default; border-color: transparent; }
.price-input {
  width: 120px; text-align: right; padding: 4px 6px; border: 1.5px solid var(--carbon); border-radius: 4px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 15px; background: var(--surface);
}
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.last { font-size: 13.5px; }
.status { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }

.detail {
  grid-column: 1 / -1; margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 18px;
}
.detail h3 { margin: 0 0 8px; }
.hist { width: 100%; border-collapse: collapse; font-size: 13px; }
.hist th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 0 6px 4px 0; }
.hist td { padding: 3px 6px 3px 0; border-top: 1px solid var(--line); }
.hist .r { text-align: right; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.log li { border-left: 2px solid var(--carbon); padding-left: 8px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form input, .form textarea {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
}
.form textarea { min-height: 60px; resize: vertical; }
.form .btns { display: flex; flex-wrap: wrap; gap: 8px; }
.flagbox { background: var(--warn-soft); color: var(--warn); padding: 8px 10px; border-radius: var(--radius); font-size: 13px; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- search + changes views ---------- */
.view-title {
  font-family: var(--font-display); font-variation-settings: "wdth" 72; font-weight: 760; text-transform: uppercase;
  font-size: 28px; margin: 4px 0 4px; line-height: 1.05;
}
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.group-head {
  display: flex; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; align-items: baseline;
  padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.group-head strong { font-weight: 620; }
.range { font-size: 13px; color: var(--muted); }
.range b { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
.hit {
  display: grid; grid-template-columns: minmax(0, 1fr) 140px 120px; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line);
  width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; align-items: baseline;
}
.hit:last-child { border-bottom: 0; }
.hit:hover { background: var(--carbon-soft); }
.hit .p { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--carbon); }
.hit .d { text-align: right; font-size: 13px; color: var(--muted); }
.changes .hit { grid-template-columns: 150px minmax(0, 1fr) 220px; }

/* ---------- dialog, toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(440px, calc(100% - 32px));
  background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(10, 12, 20, 0.45); }
dialog h3 { margin: 0 0 12px; font-family: var(--font-display); font-variation-settings: "wdth" 75; text-transform: uppercase; font-size: 20px; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: var(--radius); font-size: 14px; z-index: 50; max-width: calc(100% - 32px);
}
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 14px; }

/* ---------- narrow screens ---------- */
.cust-toggle { display: none; }
@media (max-width: 860px) {
  .top { grid-template-columns: minmax(0, 1fr) auto; }
  .find { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  aside.cust { position: static; height: auto; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .cust-toggle { display: inline-flex; }
  aside.cust[data-collapsed="true"] .cust-list,
  aside.cust[data-collapsed="true"] .cust-foot,
  aside.cust[data-collapsed="true"] .cust-search { display: none; }
  .cust-list { max-height: 45vh; }
  main { padding: 16px 16px 60px; }
  .detail { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .top { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  .find { grid-column: 1; grid-row: auto; }
  .top-right { justify-content: space-between; }
  .thead { display: none; }
  .trow { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .trow .code { grid-column: 1; grid-row: 1; }
  .trow .desc { grid-column: 1; grid-row: 2; }
  .trow .pricecell { grid-column: 2; grid-row: 1 / span 2; }
  .trow .last { grid-column: 1; grid-row: 3; text-align: left; font-size: 12.5px; }
  .trow .status { grid-column: 2; grid-row: 3; }
  .acct { grid-template-columns: minmax(0, 1fr); }
  .acct .actions { justify-content: flex-start; }
  .hit, .changes .hit { grid-template-columns: minmax(0, 1fr) auto; }
  .hit .d { grid-column: 1 / -1; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- server app additions ---------- */
[hidden] { display: none !important; }
.top { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 7px 11px; border-radius: var(--radius); font-size: 14px; font-weight: 560;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover { color: var(--ink); background: var(--paper); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--carbon-soft); }
.badge { background: var(--carbon); color: var(--surface); border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.badge.warn { background: var(--warn); }
.usermenu { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.page { padding: 22px 26px 60px; max-width: 1400px; }
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 26px;
  display: grid; gap: 14px;
}
.login-card h1 { margin: 0; font-family: var(--font-display); font-variation-settings: "wdth" 72; font-weight: 760; text-transform: uppercase; font-size: 26px; line-height: 1; }
.login-card h1 span { color: var(--carbon); }
.err { color: var(--up); font-size: 13px; margin: 0; }
.drop {
  border: 2px dashed var(--line); border-radius: 10px; background: var(--surface); padding: 22px; display: grid; gap: 8px;
  justify-items: start;
}
.drop.over { border-color: var(--carbon); background: var(--carbon-soft); }
.drop strong { font-size: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 12px; }
.tabs a {
  text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center;
}
.tabs a[aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tabs a .n { font-family: var(--font-mono); font-size: 12px; opacity: 0.75; }
.jobs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.job {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.3fr) 110px 120px 130px; gap: 12px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.job:last-child { border-bottom: 0; }
a.job:hover { background: var(--carbon-soft); }
.job .nm { overflow-wrap: anywhere; font-weight: 540; }
.job .r { text-align: right; }
.chip.ok { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
.chip.bad { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(520px, 1.05fr); gap: 18px; align-items: start; }
.photo-panel {
  position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: grid; grid-template-rows: auto 1fr; max-height: calc(100vh - 24px);
}
.photo-bar { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.photo-scroll { overflow: auto; min-height: 300px; background: #222; }
.photo-scroll img { display: block; width: 100%; cursor: zoom-in; }
.photo-scroll.zoom img { width: 220%; max-width: none; cursor: zoom-out; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea, .lines input, .lines select, .map select, .page select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
  min-width: 0; width: 100%;
}
.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 0 4px 6px; font-weight: 600; }
.lines td { padding: 3px 4px; vertical-align: top; border-top: 1px solid var(--line); }
.lines td.num input { text-align: right; font-family: var(--font-mono); }
.lines .st { width: 26px; text-align: center; padding-top: 9px; font-weight: 700; }
.lines .st.ok { color: var(--down); }
.lines .st.bad { color: var(--warn); }
.lines .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 6px; }
.lines .matchnote { font-size: 11.5px; color: var(--muted); padding: 2px 2px 0; }
.totals { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.warnbox { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: var(--radius); font-size: 13.5px; display: grid; gap: 6px; }
.okbox { background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); padding: 10px 12px; border-radius: var(--radius); font-size: 13.5px; }
.map { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 8px 12px; align-items: center; font-size: 13.5px; }
.preview-table { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.preview-table table { border-collapse: collapse; font-size: 12.5px; width: max-content; }
.preview-table td, .preview-table th { border-bottom: 1px solid var(--line); padding: 5px 9px; white-space: nowrap; text-align: left; }
.preview-table th { background: var(--paper); font-weight: 600; }
.users { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
.users th, .users td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.users th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--paper); }
@media (max-width: 1100px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .photo-panel { position: static; max-height: 70vh; }
}
@media (max-width: 860px) {
  .top { grid-template-columns: minmax(0, 1fr) auto; }
  .nav { grid-column: 1 / -1; grid-row: 2; }
  .find { grid-column: 1 / -1; grid-row: 3; }
  .page { padding: 16px 16px 60px; }
  .job { grid-template-columns: minmax(0, 1fr) auto; }
  .job .hide-s { display: none; }
  .map { grid-template-columns: minmax(0, 1fr); }
}
