/* Mixing Portal — Yatu LV, NoMix and Valspar in one screen.
   The structure is the No Mix Eyenstein desktop app's (module bar, search rail, record grid, mix +
   detail + action panels, Set-Up tabs), carried over from the NoMix portal. The surface is a modern
   dark UI: flat panels, hairline rules, tabular numerals, one accent for actions — and one quiet hue
   per paint system, used only to say which book a record came from. */

:root {
  color-scheme: dark;

  --bg: #0c0e12;
  --panel: #12151b;
  --panel-2: #171b22;
  --panel-3: #1d222b;
  --line: #232833;
  --line-2: #2f3542;

  --text: #e9ecf1;
  --text-2: #aeb6c4;
  --muted: #7b8493;
  --dim: #58606e;

  --accent: #ffb43d;          /* primary action, selection bar */
  --accent-ink: #1a1204;
  --sel: #1d3a5c;             /* selected record row */
  --sel-2: #24507f;
  --link: #63b8ff;
  --ok: #4fc98a;
  --warn: #ffb43d;
  --bad: #ff6b6b;

  /* which book a record came from — chips and the rail switch only, never actions */
  --sys-yatu: #4fc98a;
  --sys-nomix: #63b8ff;
  --sys-valspar: #ff8a73;
  --sys-all: #c7a6ff;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;

  /* pane sizes — the splitters write these, loadLayout() restores them from localStorage */
  --rail-w: 272px;
  --bottom-h: 330px;
  --mix-w: 46%;
  --act-w: 128px;
  --side-w: 300px;

  --r: 10px;
  --r-sm: 7px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13.5px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--mono); }
.grow { flex: 1; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #2b313c; border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3a424f; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ───────────────────────────────────────────────────── app shell */
.app { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }

.titlebar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.mark { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.3px; font-size: 15px; white-space: nowrap; }
.mark .dot {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: conic-gradient(from 200deg, var(--sys-yatu) 0 33%, var(--sys-nomix) 33% 66%, var(--sys-valspar) 66% 100%);
  color: #0b0d11; font-size: 10px; font-weight: 900; letter-spacing: -.2px;
}
.mark small { font-weight: 500; color: var(--muted); letter-spacing: 0; font-size: 12px; }

.menubar { display: flex; gap: 2px; margin-left: 6px; }
.menubar > .menu { position: relative; }
.menubar button.m { background: none; border: 0; padding: 5px 11px; border-radius: var(--r-sm); color: var(--text-2); }
.menubar button.m:hover, .menubar .menu.open button.m { background: var(--panel-3); color: var(--text); }
.dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 232px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 5px;
}
.dropdown button {
  display: flex; justify-content: space-between; gap: 18px; width: 100%; text-align: left;
  background: none; border: 0; padding: 7px 10px; border-radius: var(--r-sm); color: var(--text-2);
}
.dropdown button:hover { background: var(--panel-3); color: var(--text); }
.dropdown button kbd { font: 11px var(--mono); color: var(--dim); background: none; border: 0; }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 5px 8px; }

.titlebar .meta { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; line-height: 1.35; }
.titlebar .meta b { color: var(--text-2); font-weight: 600; }
.whoami { display: flex; align-items: center; gap: 8px; margin-left: 14px; }
.whoami .role {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.whoami .role.admin { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.whoami .role.api { color: #0b0d11; background: var(--sys-all); border-color: var(--sys-all); }

/* module bar — the No Mix top buttons */
.modulebar {
  display: flex; align-items: center; gap: 4px; padding: 8px 14px;
  background: linear-gradient(var(--panel-2), var(--panel)); border-bottom: 1px solid var(--line);
}
.modulebar button {
  border: 1px solid transparent; background: none; color: var(--text-2);
  padding: 8px 16px; border-radius: var(--r-sm); font-weight: 600; letter-spacing: .1px; white-space: nowrap;
}
.modulebar button:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.modulebar button.active { background: var(--panel-3); color: var(--text); border-color: var(--line-2); box-shadow: inset 0 -2px 0 var(--accent); }
.modulebar .sp { flex: 1; }

/* ───────────────────────────────────────────────────── modules */
.modules { min-height: 0; overflow: hidden; }
.module { display: none; height: 100%; min-height: 0; }
.module.active { display: block; }
#m-search.module.active { display: grid; grid-template-columns: minmax(0, var(--rail-w)) auto minmax(0, 1fr); }

/* ───────────────────────────────────────────────────── splitters
   Every edge between two panes is a drag handle. minmax(0, …) on the sized track is what lets a pane
   shrink when the window is short instead of pushing the layout off screen. */
.split-v, .split-h { background: var(--line); position: relative; z-index: 6; }
.split-v { width: 5px; cursor: col-resize; }
.split-h { height: 5px; cursor: row-resize; }
.split-v::after, .split-h::after { content: ''; position: absolute; inset: -3px; }
.split-v:hover, .split-h:hover { background: var(--line-2); }
.split-v.drag, .split-h.drag { background: var(--accent); }
body.resizing { user-select: none; }

.rail { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.rail-scroll { overflow: auto; padding: 12px; flex: 1; }
.rail label.f, .rail div.f { display: block; margin-bottom: 9px; }
.rail .f > span {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 4px;
}
.rail .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* the paint-system switch */
.sysseg {
  display: grid; grid-template-columns: repeat(4, auto); gap: 3px; padding: 3px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-sm);
}
.sysseg button {
  border: 0; background: none; color: var(--text-2); padding: 6px 4px; border-radius: 5px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.sysseg button:hover { background: var(--panel-3); color: var(--text); }
.sysseg button.on { background: var(--panel-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--sys, var(--accent)); }
.sysseg button:disabled { color: var(--dim); cursor: not-allowed; }

.sys-yatu { --sys: var(--sys-yatu); }
.sys-nomix { --sys: var(--sys-nomix); }
.sys-valspar { --sys: var(--sys-valspar); }
.sys-all { --sys: var(--sys-all); }
.sys-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.sys-chip:empty { display: none; }
.sys-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--sys, var(--muted)); flex: none; }

input[type=text], input[type=search], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 7px 9px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--link); box-shadow: 0 0 0 3px rgba(99, 184, 255, .14); }
input::placeholder, textarea::placeholder { color: var(--dim); }
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--muted) 50%),
  linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
select[multiple] { background-image: none; padding-right: 9px; }

.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--text-2); }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

fieldset.group { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin: 12px 0; }
fieldset.group > legend { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); padding: 0 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 7px 12px; border-radius: var(--r-sm); font-weight: 500; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #242a34; border-color: #3b4150; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover:not(:disabled) { background: #ffc257; }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.btn.danger { color: var(--bad); border-color: #4a2a2e; background: transparent; }
.btn.danger:hover:not(:disabled) { background: #2a1a1d; }
.btn.sm { padding: 4px 9px; font-size: 12px; }

.rail-actions { padding: 10px 12px; border-top: 1px solid var(--line); background: var(--panel-2); }
.rail-actions .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.rail-actions .btn { width: 100%; font-size: 12.5px; }

/* workspace: navigator, cross-reference, grid, bottom panels */
.workspace { display: grid; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr) auto minmax(0, var(--bottom-h)); }
.workspace.mix-max { grid-template-rows: auto 0 0 0 minmax(0, 1fr); }
.workspace.mix-max .gridwrap, .workspace.mix-max .split-h, .workspace.mix-max .xref { display: none; }

.navbar { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.nav-btn {
  width: 28px; height: 26px; border-radius: 6px; border: 1px solid var(--line-2);
  background: var(--panel-3); color: var(--text-2); display: grid; place-items: center; font-size: 11px;
}
.nav-btn:hover:not(:disabled) { color: var(--text); border-color: #3b4150; }
.nav-btn:disabled { opacity: .35; cursor: default; }
.navbar .pos { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.navbar .pos input { width: 58px; text-align: center; padding: 4px 6px; }
.navbar .title { font-weight: 600; margin-left: 6px; }
.navbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-3); border: 1px solid var(--line-2); font-size: 12px; color: var(--text-2);
}
.chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.tiny { padding: 1px 7px; font-size: 11px; }

/* the same paint code, followed into the other books */
.xref {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 12px;
  border-bottom: 1px solid var(--line); background: var(--panel); font-size: 12.5px;
}
.xref .lab { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.xref .codes { font-family: var(--mono); color: var(--text); }
.xref .note { margin: 0; border: 0; padding: 0; font-size: 12px; }
.xchip {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2);
}
.xchip:hover { border-color: var(--sys, var(--line-2)); color: var(--text); }
.xchip b { color: var(--text); font-variant-numeric: tabular-nums; }
.xchip.none { opacity: .62; }
.xchip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--sys, var(--muted)); }

.icon-btn {
  width: 22px; height: 20px; border-radius: 5px; border: 1px solid transparent;
  background: none; color: var(--muted); display: grid; place-items: center; font-size: 12px;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); border-color: var(--line-2); }
.icon-btn.on { background: var(--panel-3); color: var(--accent); border-color: var(--line-2); }

.gridwrap { overflow: auto; min-height: 0; background: var(--panel); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  background: var(--panel-2); border-bottom: 1px solid var(--line-2);
  padding: 8px 10px; white-space: nowrap; cursor: pointer; user-select: none;
}
table.grid thead th.n { text-align: right; }
table.grid thead th:hover { color: var(--text-2); }
table.grid thead th .sort { color: var(--accent); margin-left: 3px; }
table.grid tbody td {
  padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 320px;
}
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: var(--panel-2); }
table.grid tbody tr.sel td { background: var(--sel); color: #fff; }
table.grid tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.grid tbody tr.noformula td { color: var(--dim); }
table.grid tbody tr.sel.noformula td { color: #c9d4e2; }
table.grid td.code, table.grid td.formula { font-family: var(--mono); font-size: 12.5px; }
table.grid .dot-mark { color: var(--accent); }
.grid-empty { padding: 40px; text-align: center; color: var(--dim); }
.grid-empty p { margin: 0 0 18px; }
.grid-empty .hint { font-size: 12px; color: var(--dim); }
kbd { font: 11px/1.6 var(--mono); background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; color: var(--text-2); }

.swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}
.swatch.lg { width: 30px; height: 18px; border-radius: 4px; margin: 0; }

.recents { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; max-width: 900px; margin: 0 auto; }
.recents .rc-head { width: 100%; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--dim); }
.rc {
  display: flex; align-items: baseline; gap: 7px; padding: 5px 11px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); font-size: 12.5px;
}
.rc:hover { border-color: var(--line-2); background: var(--panel-3); color: var(--text); }
.rc b { font-family: var(--mono); font-size: 12px; color: var(--text); }
.rc span { color: var(--dim); }

/* composition bar — every toner in the mix, in proportion. Segment colours are the toner's own
   screen colour where the book has one (Yatu) and a family read off the name where it does not; the
   make-up of the mix, not a preview of the finished colour. */
.comp { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.comp .bar { display: flex; height: 18px; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07); }
.comp .seg { position: relative; min-width: 3px; border: 0; padding: 0; overflow: hidden; font: 600 10px/18px var(--mono); letter-spacing: .2px; text-align: center; }
.comp .seg:hover { filter: brightness(1.3); }
.comp .seg.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.comp .seg .fx { position: absolute; inset: 0; pointer-events: none; }
.comp .seg.metallic .fx { background: repeating-linear-gradient(112deg, rgba(255,255,255,.22) 0 1px, transparent 1px 5px); }
.comp .seg.pearl .fx { background: repeating-linear-gradient(112deg, rgba(255,255,255,.14) 0 1px, transparent 1px 6px); }
.comp .seg.candy .fx { background: linear-gradient(160deg, rgba(255,255,255,.26), transparent 60%); }
.comp .capt { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 5px; font-size: 11px; color: var(--dim); }
table.mix tbody tr.flash td { animation: flash 1.1s ease-out; }
@keyframes flash { from { background: var(--sel-2); } to { background: transparent; } }

/* command bar (⌘K) */
.palette { position: fixed; inset: 0; z-index: 300; background: rgba(4, 6, 9, .55); backdrop-filter: blur(2px); }
.palette-box { width: min(720px, 92vw); margin: 10vh auto 0; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.palette-box > input { width: 100%; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); background: var(--panel-2); padding: 15px 18px; font-size: 15px; }
.palette-box > input:focus { box-shadow: none; border-color: var(--line); }
.pal-list { max-height: 52vh; overflow: auto; padding: 6px; }
.pal-list .sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim); padding: 9px 10px 5px; }
.pal-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; color: var(--text-2); padding: 8px 10px; border-radius: var(--r-sm); }
.pal-item .k { font-family: var(--mono); font-size: 12px; color: var(--text); min-width: 74px; }
.pal-item .d { color: var(--muted); font-size: 12.5px; }
.pal-item.on { background: var(--sel); color: #fff; }
.pal-item.on .d { color: #c9d4e2; }
.pal-foot { display: flex; gap: 14px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel-2); font-size: 11.5px; color: var(--dim); }

/* bottom: mix | detail | actions */
.bottom { display: grid; min-height: 0; background: var(--panel); grid-template-columns: minmax(0, var(--mix-w)) auto minmax(230px, 1fr) auto minmax(0, var(--act-w)); }
.bottom > section { min-width: 0; display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); border-bottom: 1px solid var(--line); }
.panel-body { overflow: auto; flex: 1; min-height: 0; }

.layers { display: flex; gap: 3px; margin-left: 4px; }
.layers button { border: 1px solid var(--line-2); background: none; color: var(--text-2); border-radius: 5px; padding: 1px 8px; font-size: 11px; text-transform: none; letter-spacing: 0; }
.layers button.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.layers select { width: auto; padding: 1px 22px 1px 6px; font-size: 11px; text-transform: none; letter-spacing: 0; }

table.mix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.mix thead th {
  position: sticky; top: 0; background: var(--panel-2); z-index: 1; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; color: var(--muted); text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--line-2);
}
table.mix thead th.n { text-align: right; }
table.mix td { padding: 5px 9px; border-bottom: 1px solid var(--line); }
table.mix tbody tr:hover td { background: var(--panel-2); }
table.mix tbody tr.off td { color: var(--warn); }
table.mix tfoot td { padding: 7px 9px; border-top: 1px solid var(--line-2); font-weight: 650; background: var(--panel-2); position: sticky; bottom: 0; }
table.mix .empty-cell { padding: 18px; text-align: center; }
.tintchip {
  display: inline-block; min-width: 54px; text-align: center; padding: 2px 7px; border-radius: 5px;
  background: var(--sel-2); color: #fff; font: 600 11.5px/1.5 var(--mono); letter-spacing: .2px; white-space: nowrap;
}
.tintchip.unknown { background: #4a2a2e; }
.cum { font-weight: 650; }

/* detail panel */
.detail-grid { padding: 9px 12px; display: flex; flex-direction: column; gap: 7px; }
.drow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drow > label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.drow input, .drow select { padding: 5px 8px; }
.presets { gap: 5px; }
.presets:empty { display: none; }
.presets button { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2); border-radius: 999px; padding: 1px 9px; font-size: 11.5px; }
.presets button:hover { color: var(--text); border-color: #3b4150; }
.presets button.on { border-color: var(--accent); color: var(--accent); }
/* `input[type=number]` is (0,1,1) — an attribute selector outranks a bare class — so the width utilities name the element */
.w-xs, input.w-xs, select.w-xs { width: 64px; }
.w-sm, input.w-sm, select.w-sm { width: 96px; }
.w-md, input.w-md, select.w-md { width: 136px; }
.w-lg, input.w-lg, select.w-lg { width: 184px; }
.cat { font-size: 12px; color: var(--muted); }
.cat b { color: var(--text); font-style: normal; }
.box { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; width: 100%; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.box > .lab { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.voc-tbl { font-size: 12px; border-collapse: collapse; }
.voc-tbl th { font-weight: 500; color: var(--muted); text-align: left; padding: 2px 10px 2px 0; font-size: 11px; }
.voc-tbl td { padding: 2px 10px 2px 0; font-variant-numeric: tabular-nums; }
.voc-tbl td b { font-weight: 650; }
.pricebox { margin-left: auto; text-align: right; padding-left: 14px; }
.pricebox + .pricebox { margin-left: 0; }
.pricebox .big { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.pricebox .lab { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
textarea.note { min-height: 40px; resize: vertical; font-size: 12.5px; }
.warnings { border: 1px solid #5a4420; background: #221a0d; color: #ffd08a; border-radius: var(--r-sm); padding: 6px 10px; font-size: 12px; line-height: 1.45; }
.warnings div + div { margin-top: 3px; }
.warnings.bad { border-color: #5a2f38; background: #22141a; color: #ff9ba6; }

.actions { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.actions .btn { width: 100%; }
.actions .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.actions hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 4px 0; }

/* ───────────────────────────────────────────────────── generic module page */
.page { height: 100%; display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.page-head { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.page-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }
.page-body { overflow: auto; padding: 16px; min-height: 0; }
.page-split { display: grid; min-height: 0; height: 100%; grid-template-columns: minmax(0, var(--side-w)) auto minmax(0, 1fr); }
.page-split > .side { background: var(--panel); overflow: auto; padding: 12px; }
.page-split > .main { overflow: auto; min-height: 0; }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.card h3 { margin: 0; font-size: 14px; }
.card p { margin: 0; color: var(--muted); font-size: 12.5px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; min-width: 120px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.rows { display: flex; flex-direction: column; }
.rowitem {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 12px;
  border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0;
  text-align: left; color: inherit; width: 100%; text-decoration: none;
}
.rowitem:hover { background: var(--panel-2); }
.rowitem.sel { background: var(--sel); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.rowitem .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rowitem.sel .n { color: #c9d4e2; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 600; background: var(--panel-3); color: var(--text-2); border: 1px solid var(--line-2); }
.tag.sds { background: #3a2027; color: #ff9ba6; border-color: #5a2f38; }
.tag.tds { background: #17303f; color: #7cc7f5; border-color: #23485f; }
.tag.ok { background: #16321f; color: #7fdda6; border-color: #23492f; }
.tag.warn { background: #33280f; color: #ffd08a; border-color: #5a4420; }

.note { color: var(--muted); font-size: 12.5px; line-height: 1.55; border-left: 2px solid var(--line-2); padding-left: 10px; margin: 12px 0; }
.note b { color: var(--text-2); }

.empty-state { display: grid; place-items: center; height: 100%; padding: 40px; }
.empty-inner { max-width: 580px; text-align: center; }
.empty-inner .big {
  font-size: 40px; font-weight: 800; letter-spacing: -1.5px; margin-bottom: 4px;
  background: linear-gradient(96deg, var(--sys-yatu), var(--sys-nomix) 50%, var(--sys-valspar));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.empty-inner p { color: var(--text-2); }

/* tabs inside a module (Set-Up) */
.tabbar { display: flex; gap: 3px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); overflow-x: auto; }
.tabbar button { background: none; border: 0; padding: 9px 13px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; font-size: 13px; }
.tabbar button:hover { color: var(--text-2); }
.tabbar button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabbar.small button { padding: 6px 11px; font-size: 12.5px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; max-width: 1060px; }
.form-grid label { display: block; }
.form-grid label > span, .field > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 4px; }
.form-grid label.wide { grid-column: 1 / -1; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.section-title:first-child { margin-top: 0; }

/* dialogs */
dialog { border: 1px solid var(--line-2); background: var(--panel); color: var(--text); border-radius: 14px; padding: 0; box-shadow: var(--shadow); max-width: min(980px, 94vw); width: 100%; }
dialog::backdrop { background: rgba(4, 6, 9, .66); backdrop-filter: blur(2px); }
dialog .dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
dialog .dlg-head h2 { margin: 0; font-size: 15px; }
dialog .dlg-body { padding: 18px; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 14px 14px; }
dialog.narrow { max-width: 520px; }
.pin-input { font: 700 28px/1 var(--mono); letter-spacing: 10px; text-align: center; padding: 12px; }

/* toast */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 999px; padding: 9px 18px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 400; font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: #5a2f38; color: #ff9ba6; }

/* scale / pour view */
.pour { display: flex; flex-direction: column; gap: 10px; max-width: 780px; margin: 0 auto; }
.pour-row { display: grid; grid-template-columns: 34px 92px 1fr 130px 130px; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.pour-row.done { opacity: .5; }
.pour-row.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pour-row .target { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.pour-row .cumv { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.pour-row .step { color: var(--dim); font-variant-numeric: tabular-nums; }

/* the shop-formula builder */
table.mix.builder td { vertical-align: middle; }
table.mix.builder select { min-width: 190px; }
table.mix.builder input.qty { width: 110px; text-align: right; }
.builder-sum { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 10px 0; font-size: 12.5px; color: var(--text-2); }
.builder-sum b { color: var(--text); font-variant-numeric: tabular-nums; }
textarea.paste { font: 12px/1.5 var(--mono); min-height: 64px; }

/* print */
@media print {
  body { overflow: visible; background: #fff; color: #000; }
  .app, .toast, .palette { display: none !important; }
  #printarea { display: block !important; }
  .swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
#printarea { display: none; }

/* Set-Up price grid: fixed columns so the editable cells stay narrow */
table.grid.prices { table-layout: fixed; }
table.grid.prices col.c-tint { width: 96px; }
table.grid.prices col.c-desc { width: auto; }
table.grid.prices col.c-den { width: 90px; }
table.grid.prices col.c-uses { width: 72px; }
table.grid.prices col.c-price { width: 100px; }
table.grid.prices col.c-size { width: 76px; }
table.grid.prices col.c-unit { width: 120px; }
table.grid.prices col.c-cpg { width: 90px; }
table.grid.prices col.c-src { width: 230px; }
table.grid.prices td input, table.grid.prices td select { width: 100%; padding: 4px 6px; }
table.grid.prices select.warn-unit { border-color: #5a4420; color: var(--warn); }
table.grid.prices tr.changed td { background: #1c2536; }

/* ───────────────────────────────────────────────────── Colour Match */
.mt-filters { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 8px; }
.mt-count { font-size: 12px; margin: 8px 2px 0; }
.mt-row { justify-content: flex-start; }
.mt-sw { width: 18px; height: 18px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.mt-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mt-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-main .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-top { display: inline-flex; flex-direction: column; align-items: flex-end; font: 11px/1.25 var(--mono); color: var(--muted); flex: none; }
.mt-top b { font-size: 12.5px; color: var(--text-2); }
.mt-top.pass b { color: var(--ok); }
.mt-lede { color: var(--text-2); max-width: 820px; margin: 0 0 12px; }
.mt-dim { color: var(--dim); font-size: 12px; }
.mt-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.mt-big { width: 58px; height: 58px; border-radius: 12px; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.mt-title h3 { margin: 0 0 2px; font-size: 16px; }
.mt-title b { color: var(--text-2); }
.mt-fields { margin-bottom: 8px; }
.mt-savebar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 4px; }
.mt-spec { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: start; margin-top: 12px; }
.mt-chart { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 6px; min-width: 0; }
.mt-svg { width: 100%; height: auto; display: block; }
.mt-svg text { fill: var(--muted); font: 10.5px var(--sans); }
.mt-svg text.axis { fill: var(--dim); }
.mt-svg .gl { stroke: var(--line); stroke-width: 1; }
.mt-lab td, .mt-lab th { text-align: right; }
.mt-lab th:first-child { text-align: left; }
.mt-photo { max-width: 100%; max-height: 240px; border-radius: var(--r); border: 1px solid var(--line); margin-top: 12px; }
.mt-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.mt-controls label > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 4px; }
.mt-controls select { width: auto; }
.mt-hits-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin: 14px 0 8px; }
.mt-tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); }
table.grid.mt-hits tbody tr { cursor: default; }
table.grid.mt-hits td.mt-name { max-width: 300px; }
table.grid.mt-hits td.mt-codes { max-width: 220px; }
.mt-pass { color: var(--ok); }
.mt-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; vertical-align: middle; margin-right: 7px; }
.mt-bars i { width: 6px; border-radius: 2px; background: var(--muted); }
.mt-bars i.ok { background: var(--ok); }
.mt-bars i.mid { background: var(--warn); }
.mt-bars i.bad { background: var(--bad); }
.mt-barn { font: 11px var(--mono); color: var(--muted); }
.mt-acts { display: flex; gap: 4px; }
table.grid.mt-hits .xchip { padding: 1px 8px; font-size: 11.5px; }
.mt-verdict { display: inline-block; padding: 6px 12px; border-radius: var(--r-sm); font-weight: 600; margin-bottom: 10px; }
.mt-verdict.ok { background: #16321f; color: #7fdda6; border: 1px solid #23492f; }
.mt-verdict.no { background: #33280f; color: #ffd08a; border: 1px solid #5a4420; }
.mt-decompare { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.mt-decompare td, .mt-fade td { text-align: right; }
table.mix.mt-formula { max-width: 640px; border: 1px solid var(--line); border-radius: var(--r); }
.mt-sigs { margin: 10px 0; padding-left: 18px; color: var(--text-2); }
.mt-sigs li { margin-bottom: 4px; }
.mt-photo-row { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 8px; }
.mt-thumb { width: 180px; max-height: 180px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line-2); flex: none; }
.mt-else { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
table.grid.mt-sticker td { max-width: 260px; }
.mt-ocr { margin-top: 12px; color: var(--muted); }
.mt-ocr pre, .ai-pre { font: 12px/1.5 var(--mono); white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; color: var(--text-2); }

/* ───────────────────────────────────────────────────── ✦ Ask */
#btn-ask.on { border-color: var(--accent); color: var(--accent); }
.ask {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 90;
  display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line-2); box-shadow: -18px 0 50px rgba(0, 0, 0, .4);
}
@media (min-width: 1280px) {
  body.ask-open .app { margin-right: 460px; }
  body.ask-open .ask { box-shadow: none; }
}
.ask-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.ask-title { font-size: 14px; letter-spacing: -.1px; }
.ask-model { font: 11.5px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-status { font-size: 12px; color: var(--muted); padding: 6px 14px; border-bottom: 1px solid var(--line); line-height: 1.45; }
.ask-status:empty { display: none; }
.ask-status b { color: var(--text-2); font-weight: 600; }
.ask-status.bad, .ask .bad { color: var(--bad); }
.ask-log { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 12px; border-radius: var(--r); font-size: 13.5px; line-height: 1.5; max-width: 100%; }
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 4px 0 6px 18px; padding: 0; }
.msg code { font: 12px var(--mono); background: var(--panel-3); padding: 0 4px; border-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--panel-3); border: 1px solid var(--line-2); white-space: pre-wrap; max-width: 92%; }
.msg.user .ctx { font-size: 11.5px; color: var(--muted); margin-top: 4px; white-space: normal; }
.msg.user img.thumb { display: block; max-width: 220px; max-height: 160px; border-radius: var(--r-sm); margin-bottom: 6px; }
.msg.bot { background: var(--bg); border: 1px solid var(--line); }
.msg.bot.intro { color: var(--text-2); }
.msg .examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg .examples button { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.msg .examples button:hover { color: var(--text); border-color: #3b4150; }
.msg .trace { font: 11.5px/1.45 var(--mono); color: var(--muted); margin-bottom: 3px; word-break: break-word; }
.msg .trace .tt { color: var(--link); }
.msg .trace .ta { color: var(--dim); }
.msg .meta { font-size: 11px; color: var(--dim); margin-top: 6px; }
.msg.working .dots { color: var(--muted); font-style: italic; }
.msg.working .dots::after { content: ' ' attr(data-secs); font-style: normal; color: var(--dim); }
.keylink { color: var(--link); text-decoration: none; font-family: var(--mono); }
.keylink:hover { text-decoration: underline; }
.approval { border: 1px solid #5a4420; background: #221a0d; border-radius: var(--r-sm); padding: 8px 10px; margin: 6px 0; }
.approval b { color: #ffd08a; }
.approval .appr-what { margin: 4px 0; }
.approval .appr-lines { font: 12px/1.5 var(--mono); color: var(--text-2); max-height: 160px; overflow: auto; }
.approval .appr-foot { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.ask-ctx { padding: 6px 14px; border-top: 1px solid var(--line); font-size: 12px; }
.ask-ctx .check { margin: 0; align-items: flex-start; }
.ask-ctx #ask-ctx-text { color: var(--text-2); }
.ask-chip { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.ask-chip img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); }
.ask-chip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel-2); align-items: flex-end; }
.ask-form textarea { flex: 1; resize: none; min-height: 40px; max-height: 160px; }
@media print { .ask { display: none !important; } }

/* Set-Up ▸ AI, and drafting in the builder */
.ai-tests { display: flex; gap: 8px; flex-wrap: wrap; }
#ai-test-out { margin-top: 10px; max-width: 1060px; }
#ai-test-out p { margin: 6px 0; }
.field > textarea { min-height: 96px; }
.ai-draft { display: flex; gap: 8px; align-items: center; }
.ai-draft input { flex: 1; }

/* Online (edge/): the Worker signs people in, so the bench's PIN, API keys and imports are not offered */
body.edge .bench-only { display: none !important; }
.edge-only { display: none !important; }
body.edge .edge-only { display: revert !important; }
