/* Tokens — accent is the blue of a copper-peptide solution; copper is the secondary. */
:root {
  --ground: #F2F5F6; --surface: #FFFFFF; --sunk: #E7ECEE; --line: #D5DDE0;
  --ink: #13201F; --muted: #5A6A6C;
  --accent: #1E4BD2; --accent-ink: #FFFFFF; --accent-soft: #E3EAFB;
  --copper: #A9562B; --copper-soft: #F6E9E1;
  --ok: #1D7A4F; --bad: #B3261E;
  --shadow: 0 10px 30px rgba(19, 32, 31, .12);
  --display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0D1315; --surface: #151D20; --sunk: #1C272B; --line: #2A373C;
    --ink: #E7EEED; --muted: #94A5A7;
    --accent: #8FA8FF; --accent-ink: #0B1330; --accent-soft: #1B2547;
    --copper: #E39A70; --copper-soft: #33221A;
    --ok: #6DD3A0; --bad: #FF8A80;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --ground: #0D1315; --surface: #151D20; --sunk: #1C272B; --line: #2A373C;
  --ink: #E7EEED; --muted: #94A5A7;
  --accent: #8FA8FF; --accent-ink: #0B1330; --accent-soft: #1B2547;
  --copper: #E39A70; --copper-soft: #33221A;
  --ok: #6DD3A0; --bad: #FF8A80;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin-inline: auto; padding-inline: 16px; }

/* Header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--ground); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 12px; padding-block: 10px; flex-wrap: wrap; }
.mark { font: 700 20px/1 var(--display); color: var(--ink); text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.mark span { color: var(--accent); padding-inline: 1px; }
.mark em { font: 500 11px/1 var(--mono); font-style: normal; color: var(--copper); background: var(--copper-soft); padding: 3px 6px; border-radius: 3px; margin-left: 6px; vertical-align: 3px; text-transform: uppercase; letter-spacing: .06em; }
.search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; color: var(--muted); min-width: 0; }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 9px 0; outline: none; color: var(--ink); }
.search kbd { font: 500 11px var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 14px; font-weight: 600; white-space: nowrap; }
a.btn { text-decoration: none; color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost:hover { border-color: var(--ink); }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; padding-block: 24px 40px; align-items: start; }
.intro h1 { font: 700 34px/1.05 var(--display); letter-spacing: -.02em; margin: 0 0 6px; text-wrap: balance; }
.intro p { margin: 0; color: var(--muted); max-width: 60ch; }
.shipfrom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 18px; }
.lbl { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.shipfrom .seg button { padding: 6px 12px; background: var(--surface); font-weight: 600; }
.shipfrom .seg button small { font-weight: 400; }
.linkbtn { border: 0; background: transparent; color: var(--accent); text-decoration: underline; padding: 0; font: inherit; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.count { font: 400 12px var(--mono); color: var(--muted); margin: 14px 0 0; }
.empty { color: var(--muted); padding-block: 30px; }

/* Order-sheet rows */
.group { margin-top: 22px; }
.group > h2 { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; display: flex; gap: 8px; }
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.row { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.5fr) auto; gap: 14px 18px; align-items: center; padding: 14px 16px; }
.row + .row { border-top: 1px solid var(--line); }
.p-name { font: 700 17px/1.2 var(--display); margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.p-meta { margin: 3px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.sku { font-family: var(--mono); font-size: 12px; }
.tag { font: 500 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 3px 5px; border-radius: 3px; background: var(--sunk); color: var(--muted); }
.tag.coa { background: var(--copper-soft); color: var(--copper); }
a.tag.coa { text-decoration: underline; text-underline-offset: 2px; }
a.tag.coa:hover { background: var(--copper); color: var(--surface); }
.tag.sample { border: 1px dashed var(--line); background: transparent; }
.pick { display: grid; gap: 7px; min-width: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 4px 9px; font-size: 13px; line-height: 1.3; text-align: left; }
.seg button small { display: block; font: 400 11px var(--mono); color: var(--muted); }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.seg button[aria-pressed="true"] small { color: var(--ink); }
.buy { display: flex; align-items: center; gap: 10px; justify-self: end; }
.price { font: 500 17px var(--mono); font-variant-numeric: tabular-nums; min-width: 8ch; text-align: right; }
.price small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.step { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.step button { border: 0; background: transparent; width: 30px; height: 34px; font-size: 17px; line-height: 1; }
.step button:hover { background: var(--sunk); }
.step output { min-width: 26px; text-align: center; font: 500 14px var(--mono); }
.add { padding: 8px 14px; }
.add.did { background: var(--ok); border-color: var(--ok); }

/* Cart */
.cart { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 100px); }
.cart-head { display: flex; justify-content: space-between; align-items: center; }
.cart h2 { font: 700 20px var(--display); margin: 0; }
.x { display: none; border: 0; background: transparent; font-size: 26px; line-height: 1; padding: 0 6px; }
.lines { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: 10px; }
.ship { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; font: 500 11.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--sunk); border-radius: 6px; padding: 6px 8px; }
.ship b { margin-left: auto; color: var(--ink); font-weight: 500; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.line b { font-weight: 600; }
.line .l-sub { font-size: 12px; color: var(--muted); }
.line .l-amt { font: 500 14px var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.line .l-ctl { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; }
.line .step button { width: 26px; height: 28px; }
.rm { border: 0; background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 0; }
.cart-empty { color: var(--muted); margin: 0; }
.cart-foot { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.total { display: flex; justify-content: space-between; align-items: baseline; }
.total strong { font: 500 22px var(--mono); font-variant-numeric: tabular-nums; }
.note-l { font-size: 12px; color: var(--muted); }
textarea, .dlg input { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--ground); padding: 8px 10px; resize: vertical; }
.fine { font-size: 12px; color: var(--muted); margin: 0; }

.bar { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); z-index: 25; display: none; align-items: center; gap: 12px; background: var(--ink); color: var(--ground); border: 0; border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow); }
.bar strong { font: 500 15px var(--mono); margin-left: auto; }
.bar-go { font-weight: 600; text-decoration: underline; }

/* Dialogs + toast */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 14, 16, .55); }
.dlg { display: grid; gap: 10px; padding: 22px; }
.dlg h2 { font: 700 22px var(--display); margin: 0; }
.dlg p { margin: 0; color: var(--muted); }
.dlg label { font-size: 13px; font-weight: 600; }
.dlg input[type="checkbox"] { width: auto; padding: 0; }
.dlg a, .admin a { color: var(--accent); }
.dlg-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.err { color: var(--bad) !important; font-size: 13px; }
pre { font: 400 12px/1.55 var(--mono); background: var(--ground); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 0; overflow-x: auto; max-height: 40vh; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 76px); z-index: 40; background: var(--ink); color: var(--ground); padding: 9px 14px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.foot { font: 400 12px var(--mono); color: var(--muted); padding-block: 0 90px; }

dialog.wide { width: min(620px, calc(100vw - 32px)); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fld { display: grid; gap: 4px; } .fld.wide { grid-column: 1 / -1; }
.my-list { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.my { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.my summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-size: 14px; }
.my summary .amt { margin-left: auto; font-family: var(--mono); }
.my p { margin: 8px 0; color: var(--ink); }
.stage { font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 4px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.stage.s-completed, .stage.s-cancelled { background: var(--sunk); color: var(--muted); }
.stage.s-shipped, .stage.s-paid { background: transparent; color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.stage.s-hold, .stage.s-awaiting { background: var(--copper-soft); color: var(--copper); }
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .cart { position: fixed; inset: auto 0 0 0; top: auto; z-index: 30; border-radius: 16px 16px 0 0; max-height: 82vh; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); transform: translateY(105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .cart.open { transform: none; }
  .x { display: block; }
  .bar:not([hidden]) { display: flex; }
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .intro h1 { font-size: 28px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .buy { justify-self: stretch; }
  .price { text-align: left; margin-right: auto; }
  .search kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { .cart { transition: none; } }
