/* Верстак UI — design D «Гібрид» (dark-first, collapsible sidebar). No framework, no build.
   Sections: tokens · base · shell · page · components · dialogs · forms/combos · item picker · print */

/* ---------- tokens ---------- */
:root {
  --bg: #0a0a0a; --panel: #0f0f10; --raised: #141416; --hover: #17171a; --sel: #1b1b1f;
  --line: #1f1f22; --line2: #2a2a2e; --line3: #3a3a40;
  --tx: #ededed; --tx2: #a1a1a8; --tx3: #6e6e76;
  --acc: #c6f432; --acc-tx: #0a0a0a; --acc-soft: #1c2410;
  --blue: #60a5fa; --green: #4ade80; --red: #f87171; --amber: #fbbf24; --cyan: #22d3ee; --violet: #c084fc; --gray: #8a8a93;
  /* status palette (own vars: spaced hues so neighbours never look alike) */
  --s-violet: #c084fc; --s-blue: #60a5fa; --s-sky: #22d3ee; --s-amber: #fbbf24; --s-lime: #c6f432;
  --s-teal: #2dd4bf; --s-green: #4ade80; --s-gray: #8a8a93; --s-rose: #fb7185; --s-tx: 72%;
  --red-soft: #2a1414; --green-soft: #12241a; --amber-soft: #2a2110; --blue-soft: #121c2c;
  --shadow: 0 24px 64px rgba(0, 0, 0, .55);
  --font: Geist, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 8px; --r-lg: 12px;
  --side-w: 232px; --side-w-min: 64px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fafafa; --panel: #fff; --raised: #fff; --hover: #f4f4f5; --sel: #eef0e6;
  --line: #eaeaea; --line2: #dcdcdc; --line3: #c4c4c8;
  --tx: #0a0a0a; --tx2: #5c5c63; --tx3: #8f8f96;
  --acc: #3f6212; --acc-tx: #fff; --acc-soft: #ecfccb;
  --blue: #2563eb; --green: #15803d; --red: #dc2626; --amber: #b45309; --cyan: #0e7490; --violet: #7e22ce; --gray: #6b6b73;
  --s-violet: #a855f7; --s-blue: #3b82f6; --s-sky: #06b6d4; --s-amber: #f59e0b; --s-lime: #84cc16;
  --s-teal: #14b8a6; --s-green: #22c55e; --s-gray: #8a8a93; --s-rose: #f43f5e; --s-tx: 58%;
  --red-soft: #fdecec; --green-soft: #e7f6ec; --amber-soft: #fdf3e1; --blue-soft: #e8f0fe;
  --shadow: 0 24px 64px rgba(0, 0, 0, .16);
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.45 var(--font); background: var(--bg); color: var(--tx); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--tx); text-decoration: underline; text-decoration-color: var(--line3); text-underline-offset: 3px; }
a.link:hover { text-decoration-color: var(--acc); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 15px; } h2 { font-size: 14px; } h3 { font-size: 13px; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--acc); color: var(--acc-tx); }
.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ic.lg { width: 18px; height: 18px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--tx3); }
.soft { color: var(--tx2); }
.danger-tx { color: var(--red); }
.ok-tx { color: var(--green); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.hstack { display: flex; align-items: center; gap: 8px; }
.hstack.wrap { flex-wrap: wrap; }
.vstack { display: flex; flex-direction: column; gap: 12px; }
.d-none { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.clamp-1, .clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { -webkit-line-clamp: 1; } .clamp-2 { -webkit-line-clamp: 2; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ---------- shell: sidebar + page ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; width: var(--side-w); flex: none;
  display: flex; flex-direction: column; gap: 2px; padding: 14px 12px;
  border-right: 1px solid var(--line); background: var(--bg);
  transition: width .18s ease, padding .18s ease; overflow: hidden;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; margin-bottom: 12px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.side-logo { width: 32px; height: 32px; border-radius: 50%; display: block; flex: none; }
.side-search { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 0 10px; height: 34px; border: 1px solid var(--line2); border-radius: var(--r); color: var(--tx3); background: transparent; cursor: text; }
.side-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--tx); }
.side-search input::placeholder { color: var(--tx3); }
.side-search:focus-within { border-color: var(--line3); }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line2); border-radius: 4px; color: var(--tx3); white-space: nowrap; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r); color: var(--tx2); white-space: nowrap; }
.side-nav a:hover { background: var(--hover); color: var(--tx); }
.side-nav a.on { background: var(--hover); color: var(--tx); box-shadow: inset 0 0 0 1px var(--line2); }
.side-nav a.on .ic { color: var(--acc); }
.side-nav .cnt { margin-left: auto; font: 12px var(--mono); color: var(--tx3); }
.side-sect { font-size: 11px; color: var(--tx3); padding: 14px 10px 4px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 6px 4px; color: var(--tx2); white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--hover); border: 1px solid var(--line2); display: grid; place-items: center; font-size: 11px; flex: none; color: var(--tx); }
.side-btn { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border: 0; border-radius: var(--r); background: transparent; color: var(--tx3); cursor: pointer; white-space: nowrap; width: 100%; text-align: left; }
.side-btn:hover { background: var(--hover); color: var(--tx); }
/* collapsed rail */
html.side-min .side { width: var(--side-w-min); padding: 14px 12px; }
html.side-min .side .lbl, html.side-min .side .cnt, html.side-min .side-sect, html.side-min .side-search, html.side-min .side-brand b { display: none; }
html.side-min .side-nav a, html.side-min .side-btn { justify-content: center; padding: 0; }
html.side-min .side-user { justify-content: center; padding: 6px 0; }

.page { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel); }
.page-head { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.page-head h1 { white-space: nowrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.page-body { padding: 16px 24px 32px; display: flex; flex-direction: column; gap: 14px; }
.page-body.flush { padding: 0 0 32px; gap: 0; }
.page-body.flush > .bar, .page-body.flush > .stats, .page-body.flush > .flashes { margin: 12px 24px 0; }
.page-body.flush > .bar { margin-bottom: 12px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 18px; align-self: stretch; }
.tabs a { display: flex; align-items: center; gap: 6px; color: var(--tx3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--tx); }
.tabs a.on { color: var(--tx); border-color: var(--acc); }
.tabs .cnt { font: 12px var(--mono); color: var(--tx3); }

/* ---------- buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line2);
  background: transparent; color: var(--tx); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.button:hover { background: var(--hover); border-color: var(--line3); }
.button.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-tx); font-weight: 600; }
.button.primary:hover { filter: brightness(1.08); }
.button.ghost { border-color: transparent; color: var(--tx2); }
.button.ghost:hover { color: var(--tx); background: var(--hover); }
.button.danger { color: var(--red); }
.button.danger:hover { background: var(--red-soft); border-color: var(--red); }
.button.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.button.icon { width: 32px; padding: 0; }
.button.sm.icon { width: 28px; }
.button[disabled] { opacity: .45; cursor: default; }

/* ---------- status / tags / chips ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 7px; border-radius: 6px; font: 12px var(--mono); white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--gray)) 14%, transparent); color: color-mix(in srgb, var(--c, var(--gray)) var(--s-tx), var(--tx)); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c, var(--gray)); flex: none; }
.status:empty { padding: 0 7px; gap: 0; }
/* Status palette — the colour says whose move it is (see status_palette() in lib/helpers.php) */
.c-violet { --c: var(--s-violet); } .c-blue { --c: var(--s-blue); } .c-sky { --c: var(--s-sky); } .c-amber { --c: var(--s-amber); }
.c-lime { --c: var(--s-lime); } .c-teal { --c: var(--s-teal); } .c-green { --c: var(--s-green); } .c-gray { --c: var(--s-gray); } .c-rose { --c: var(--s-rose); }
/* colour picker: radio swatches */
.swatches { display: inline-flex; gap: 4px; flex-wrap: nowrap; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches label { width: 20px; height: 20px; border-radius: 6px; background: var(--c); cursor: pointer; outline: 2px solid transparent; outline-offset: 2px; }
.swatches input:checked + label { outline-color: var(--tx); }
.swatches input:focus-visible + label { outline-color: var(--acc); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line2); font-size: 12px; color: var(--tx2); white-space: nowrap; }
.tag.acc { border-color: transparent; background: var(--acc-soft); color: var(--acc); }
.red { color: var(--red); } /* overdue / negative numbers in stats and tables */
.tag.red { border-color: transparent; background: var(--red-soft); color: var(--red); }
.tag.green { border-color: transparent; background: var(--green-soft); color: var(--green); }
.tag.amber { border-color: transparent; background: var(--amber-soft); color: var(--amber); }

/* filter bar: compact selects/inputs styled as chips */
.bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--r); color: var(--tx2); background: transparent; white-space: nowrap; }
.chip:hover { border-color: var(--line3); color: var(--tx); }
.chip.set { color: var(--tx); border-color: var(--tx3); background: var(--hover); }
.chip select, .chip input { border: 0; outline: 0; background: transparent; color: inherit; height: 28px; padding: 0; cursor: pointer; max-width: 180px; }
.chip select option { background: var(--raised); color: var(--tx); }
.chip input[type="date"] { width: 118px; color-scheme: inherit; }
.chip.search { flex: 1 1 200px; cursor: text; }
.chip.search input { flex: 1; max-width: none; cursor: text; }
.chip .lbl { color: var(--tx3); }
.vstack > .chip.search { flex: none; }
/* row actions that only show on hover (delete in reference lists) */
.dt .row-act { opacity: 0; transition: opacity .1s; }
.dt tr:hover .row-act, .dt .row-act:focus-within { opacity: 1; }

/* ---------- stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stats > * { padding: 12px 16px; border-right: 1px solid var(--line); display: block; }
.stats > *:last-child { border-right: 0; }
.stats > a:hover { background: var(--hover); }
.stats small { display: block; color: var(--tx3); font-size: 12px; }
.stats b { font: 600 20px var(--mono); }
.stats b.c { color: var(--c); }
.dash3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; align-items: stretch; }
@media (max-width: 1100px) { .dash3 { grid-template-columns: 1fr; } }
/* the three «whose move» columns share one height (the tallest, capped); long lists scroll inside */
.dash3 > .panel { display: flex; flex-direction: column; min-height: 200px; max-height: 380px; }
.panel-head .count { font: 500 12px var(--mono); color: var(--tx3); }
.panel-head > .status:empty { height: 18px; padding: 0 5px; background: transparent; }
.jobs { flex: 1; overflow: auto; }
.job { display: block; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.job:hover { background: var(--hover); }
.job-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.job-due { margin-left: auto; font-size: 12px; white-space: nowrap; }
.job-meta { display: block; color: var(--tx3); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs-empty { padding: 28px 14px; text-align: center; color: var(--tx3); }
.today { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; margin-top: 12px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--tx2); font-size: 13px; }
.today b { color: var(--tx); font: 600 13px var(--mono); }
.today-lbl { display: inline-flex; align-items: center; gap: 6px; color: var(--tx); font-weight: 600; }
.today-lbl svg { width: 15px; height: 15px; }
.dash-low { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; margin-top: 14px; }
.dash-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
/* the feed takes exactly the left column's height and scrolls inside (absolute → no influence on the row) */
.feed-wrap { position: relative; min-height: 320px; }
.feed-panel { position: absolute; inset: 0; display: flex; flex-direction: column; }
@media (max-width: 1100px) { .dash-low { grid-template-columns: 1fr; } .feed-wrap { min-height: 420px; } }
.feed { flex: 1; overflow: auto; }
.feed-row { display: flex; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.feed-at { font-size: 11px; padding-top: 4px; white-space: nowrap; }
.feed-main { min-width: 0; font-size: 13px; }
.feed-sub { font-size: 12px; margin-top: 2px; }
/* chart (dataviz: one axis, thin rounded bars, recessive grid, hover tooltip, table view) */
:root { --ch-issued: #3b82f6; --ch-paid: #65a30d; }
.legend { display: inline-flex; gap: 14px; margin-left: auto; font-weight: 400; font-size: 12px; color: var(--tx2); }
.legend i, .chart .tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.chart .base { stroke: var(--line2); }
.chart .axis { fill: var(--tx3); font: 10px var(--mono); }
.chart .axis.now { fill: var(--tx); font-weight: 600; }
.chart .bar.issued { fill: var(--ch-issued); } .chart .bar.paid { fill: var(--ch-paid); }
.chart .hit { fill: transparent; }
.chart .cg.on .hit { fill: var(--hover); }
.chart .tip { position: absolute; top: 0; padding: 8px 10px; background: var(--raised); border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; pointer-events: none; white-space: nowrap; }
.chart .tip b { display: block; margin-bottom: 4px; }
.chart .tip span { font-family: var(--mono); margin-left: 8px; color: var(--tx); }
.chart .tip div { color: var(--tx2); }
.chart-table { margin-top: 8px; font-size: 12px; }
.chart-table summary { cursor: pointer; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }

/* ---------- data table ---------- */
.table-wrap { overflow-x: auto; }
.dt { width: 100%; border-collapse: collapse; }
.dt th.right { text-align: right; }
.th-sort { display: inline-flex; align-items: center; gap: 2px; color: inherit; }
.th-sort:hover, .th-sort.on { color: var(--tx); }
.th-sort svg { width: 13px; height: 13px; } /* beats the left default below for numeric columns */
.dt th { text-align: left; font-weight: 500; font-size: 12px; color: var(--tx3); padding: 8px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; z-index: 1; }
.dt td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dt tbody tr:hover td { background: var(--hover); }
.dt tr.sel td { background: var(--sel); }
.dt td.n { font: 12px var(--mono); white-space: nowrap; }
.dt td.n a { color: var(--tx); }
.dt td.n a:hover { color: var(--acc); }
.dt .sub { display: block; color: var(--tx3); font-size: 12px; }
.dt .sub.mono { font-size: 11px; }
.dt input[type="checkbox"] { accent-color: var(--acc); }
.dt .empty td { text-align: center; color: var(--tx3); padding: 32px; }
.dt.compact td { padding: 7px 10px; } .dt.compact th { padding: 6px 10px; }
.dt tfoot td { border-bottom: 0; font-weight: 600; }

/* list cells: one-line ellipsis with sane minimum widths */
.ell { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-dev { min-width: 190px; max-width: 260px; }
.cell-fault { min-width: 130px; max-width: 200px; }
.cell-client { min-width: 150px; max-width: 220px; }
.cell-addr { min-width: 170px; max-width: 240px; font-size: 12px; }

/* selection bar above table */
.selbar { display: flex; align-items: center; gap: 10px; padding: 0 24px 10px; color: var(--tx3); font-size: 12px; }

/* pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px; color: var(--tx3); }
.pager a, .pager span.p { min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r); font: 12px var(--mono); padding: 0 6px; }
.pager a:hover { background: var(--hover); color: var(--tx); }
.pager .on { background: var(--hover); color: var(--tx); box-shadow: inset 0 0 0 1px var(--line2); }
.pager .total { margin-right: 12px; font-size: 12px; }

/* ---------- panels / key-value ---------- */
.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.panel-head .actions { margin-left: auto; display: flex; gap: 6px; }
.panel-body { padding: 14px; }
.section-title { font-size: 11px; color: var(--tx3); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.section-title .actions { margin-left: auto; text-transform: none; letter-spacing: 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--tx3); }
.kv dd { margin: 0; min-width: 0; }
.lines > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line2); }
.lines > div:last-child { border-bottom: 0; }
.timeline { display: flex; flex-direction: column; }
.timeline > div { display: grid; grid-template-columns: 122px 1fr; gap: 10px; padding: 5px 0; color: var(--tx2); }
.timeline time { font: 12px var(--mono); color: var(--tx3); }
.timeline b { font-weight: 500; color: var(--tx); }

/* ---------- workflow steps (sale card) ---------- */
.steps { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; counter-reset: st; }
.steps li { flex: 1; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 2px solid var(--line2); color: var(--tx3); font-size: 12px; white-space: nowrap; counter-increment: st; }
.steps li::before { content: counter(st); font: 11px var(--mono); }
.steps li.done { border-color: var(--tx3); color: var(--tx2); }
.steps li.on { border-color: var(--acc); color: var(--tx); font-weight: 600; }

/* ---------- flashes ---------- */
.flashes { display: flex; flex-direction: column; gap: 6px; }
.flash { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--raised); }
.flash::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--gray)); flex: none; }
.flash.success { --c: var(--green); } .flash.danger { --c: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line2)); }
.flash.warning { --c: var(--amber); } .flash.info { --c: var(--blue); }
.flash .x { margin-left: auto; border: 0; background: transparent; color: var(--tx3); cursor: pointer; }

/* ---------- dialogs (native <dialog>) ---------- */
dialog { border: 0; padding: 0; color: var(--tx); background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
:root[data-theme="light"] dialog::backdrop { background: rgba(10, 10, 10, .28); }
dialog.dlg { width: min(640px, calc(100vw - 32px)); margin: 8vh auto auto; }
dialog.dlg.wide { width: min(880px, calc(100vw - 32px)); }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; width: min(680px, 100vw); }
dialog.drawer.wide { width: min(760px, 100vw); }
.dlg-box { background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 84vh; }
dialog.drawer .dlg-box { border-radius: 0; border-width: 0 0 0 1px; height: 100%; max-height: none; }
.dlg-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 20px 14px; border-bottom: 1px solid var(--line); }
.dlg-head .meta { font-size: 12px; color: var(--tx3); margin-bottom: 4px; }
.dlg-head .title { display: flex; align-items: center; gap: 10px; font: 600 18px var(--mono); }
.dlg-head .title.sans { font: 600 16px var(--font); }
.dlg-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.dlg-body { padding: 16px 20px 20px; overflow: auto; display: flex; flex-direction: column; gap: 20px; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.dlg-loading { padding: 48px; text-align: center; color: var(--tx3); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dlg-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog.drawer[open] .dlg-box { animation: drawer-in .16s ease-out; }
dialog.dlg[open] .dlg-box { animation: dlg-in .14s ease-out; }
body:has(dialog[open]) { overflow: hidden; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; color: var(--tx2); }
.field .req { color: var(--red); }
.hint, .field .hint { font-size: 12px; color: var(--tx3); }
.input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--r);
  background: var(--bg); color: var(--tx); outline: 0;
}
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
select.input { cursor: pointer; }
select.input option { background: var(--raised); }
.input:hover { border-color: var(--line3); }
.input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 18%, transparent); }
.input::placeholder { color: var(--tx3); }
.input.sm { height: 28px; font-size: 12px; padding: 0 8px; }
.input.num { text-align: right; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { accent-color: var(--acc); width: 15px; height: 15px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; cursor: pointer; color: var(--tx2); }
.seg a { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; color: var(--tx2); }
.seg a:hover { color: var(--tx); }
.seg a.on, .seg input:checked + label { background: var(--hover); color: var(--tx); box-shadow: inset 0 -2px 0 var(--acc); }
.inline-form { display: flex; gap: 8px; align-items: center; }

/* combobox (logic in form scripts: .nd-combo/.nd-list/.nd-item) */
.nd-combo { position: relative; }
.nd-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; max-height: 260px; overflow-y: auto; background: var(--raised); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); display: none; padding: 4px; }
.nd-list.open { display: block; }
.nd-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nd-item:hover, .nd-item.active { background: var(--hover); }
.nd-item.nd-create { color: var(--acc); font-weight: 500; }
.nd-item.nd-empty { color: var(--tx3); cursor: default; }
.nd-item.nd-empty:hover { background: transparent; }
.fault-combo { position: relative; }
.fault-combo-box { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 34px; padding: 4px 8px; background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r); cursor: text; }
.fault-combo-box:focus-within { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 18%, transparent); }
.fault-combo-input { flex: 1 1 10rem; min-width: 8rem; border: 0; outline: 0; background: transparent; color: var(--tx); padding: 2px 0; }
.fault-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 24px; padding: 0 8px; background: var(--acc-soft); color: var(--acc); border-radius: 6px; font-size: 12px; }
.fault-chip-x { border: 0; background: transparent; padding: 0; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; opacity: .7; }
.fault-chip-x:hover { opacity: 1; color: var(--red); }

/* ---------- item picker (ticket / sale card) ---------- */
.picker-search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--bg); }
.picker-search:focus-within { border-color: var(--acc); }
.picker-search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--tx); }
.item-tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--line); margin-top: 8px; }
.item-tab { border: 0; background: transparent; color: var(--tx3); padding: 6px 0; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.item-tab:hover { color: var(--tx); }
.item-tab.active { color: var(--tx); border-color: var(--acc); }
.item-results { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r) var(--r); }
.item-section-title { position: sticky; top: 0; z-index: 1; padding: 6px 12px; font-size: 11px; color: var(--tx3); letter-spacing: .06em; text-transform: uppercase; background: var(--raised); border-bottom: 1px solid var(--line); }
.item-group-title { padding: 8px 12px 2px; font-size: 11px; color: var(--tx3); }
.item-row { display: flex; width: 100%; align-items: center; gap: 12px; padding: 7px 12px; border: 0; background: transparent; color: var(--tx); text-align: left; cursor: pointer; }
.item-row:hover { background: var(--hover); }
.item-row:disabled { opacity: .5; }
.item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font: 12px var(--mono); color: var(--tx3); white-space: nowrap; }
.item-empty { padding: 16px; text-align: center; color: var(--tx3); }
.items-table td .input.sm { width: 64px; }
.items-table td:not(:first-child) { white-space: nowrap; width: 1%; }
.items-table td:first-child .ic { margin-right: 4px; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: min(360px, 100%); display: flex; flex-direction: column; gap: 16px; }

/* ---------- narrow screens (phone): sidebar = icon rail, heads wrap, tables scroll inside ---------- */
@media (max-width: 760px) {
  .side, html.side-min .side { width: var(--side-w-min); padding: 12px 8px; }
  .side .lbl, .side .cnt, .side-sect, .side-search, .side-brand b, .side kbd { display: none; }
  .side-nav a, .side-btn { justify-content: center; padding: 0; }
  .side-user { justify-content: center; padding: 6px 0; }
  .page-head { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; min-height: 0; }
  .page-head .actions { margin-left: 0; flex-wrap: wrap; }
  .tabs { max-width: 100%; overflow-x: auto; min-height: 34px; }
  .page-body { padding: 12px 12px 24px; }
  .page-body.flush > .bar, .page-body.flush > .stats, .page-body.flush > .flashes { margin: 12px 12px 0; }
  .panel, .page-body > section { overflow-x: auto; }
  .form-row { grid-template-columns: 1fr !important; }
  .kv { grid-template-columns: 110px 1fr; }
  .chip select, .chip input { max-width: 130px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > * { border-bottom: 1px solid var(--line); }
}

/* ---------- print ---------- */
@media print {
  .side, .no-print, .flashes, .page-head .tabs { display: none !important; }
  .print-only { display: block !important; }
  body, .page { background: #fff !important; color: #000 !important; }
}
