/* E-Inventory — one stylesheet, no build step.
   Tokens first; light and dark themes; then layout, components, and page-specific parts. */
:root {
  color-scheme: light dark;
  --bg: #f4f3ef; --panel: #ffffff; --panel-2: #f8f7f4; --ink: #17191d; --muted: #61656e; --line: #e2dfd8;
  --accent: #d8791a; --accent-ink: #ffffff; --ok: #2b8048; --warn: #c2410c; --info: #2563a8;
  --radius: 12px; --shadow: 0 1px 2px #0000000d, 0 1px 1px #00000008;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111317; --panel: #1a1d22; --panel-2: #20242a; --ink: #ecebe7; --muted: #9ba1ab; --line: #2b3038;
    --accent: #f0a33b; --accent-ink: #17191d; --ok: #4fb36d; --warn: #f0773a; --info: #5b9be0; --shadow: none; }
}
* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 2px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 1.8rem 0 .7rem; letter-spacing: -.005em; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
.muted { color: var(--muted); }
.pad { padding: 1.2rem; }
.mono { font-family: var(--mono); }
.warn-t { color: var(--warn); }

/* icons: single-colour line icons from /static/icons.svg */
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; vertical-align: -.2em; }
.ic.big { width: 2.2rem; height: 2.2rem; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; min-height: 60px;
  background: #15171b; color: #e9e7e2; border-bottom: 1px solid #23272e; }
.brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; display: flex; align-items: center; gap: .6rem; letter-spacing: .01em; }
.chip { width: 18px; height: 18px; border-radius: 4px; background: #f0a33b; box-shadow: 0 0 0 3px #15171b, 0 0 0 5px #f0a33b55; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a { text-decoration: none; padding: .45rem .85rem; border-radius: 8px; color: #b8bcc5; font-size: .97rem; display: inline-flex; align-items: center; }
.topbar nav a:hover { color: #fff; }
.topbar nav a.active { background: #2a2e36; color: #fff; }
.topbar .ic { width: 1.25em; height: 1.25em; }
.add-btn { white-space: nowrap; }
.scan-btn { background: #2a2e36; color: #e9e7e2; border-color: #2a2e36; }
main { max-width: 1320px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.ro-banner { background: color-mix(in srgb, var(--info) 18%, var(--panel)); padding: .5rem 1rem; text-align: center; font-size: .92rem; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: .5rem .9rem; border-radius: 9px; cursor: pointer; font: inherit; font-size: .95rem; text-decoration: none; line-height: 1.3; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--warn); }
.btn.small { padding: .3rem .65rem; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; font-size: .97rem; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: .55rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 80px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; color: var(--muted); }
label.f > span { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem; }
label.f.empty input, label.f.empty select { border-style: dashed; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .95rem; cursor: pointer; white-space: nowrap; }
.check input { width: auto; }
details.more { grid-column: 1 / -1; font-size: .93rem; margin-bottom: .7rem; }
details.more summary { cursor: pointer; color: var(--muted); margin-bottom: .5rem; }

/* ---------- layout ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; overflow-x: auto; box-shadow: var(--shadow); }
.grid { display: grid; gap: .9rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; }
.row { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 760px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { gap: .4rem; padding: .5rem .7rem; } .topbar nav a { padding: .4rem .5rem; }
  .topbar nav { overflow-x: auto; } .brand-text { display: none; } .add-btn { padding: .45rem .65rem; }
  main { padding: 1rem .8rem 2.5rem; }
}

/* ---------- small pieces ---------- */
.stats { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem; text-decoration: none; min-width: 110px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.35rem; line-height: 1.2; }
.stat span { font-size: .82rem; color: var(--muted); }
.stat.warn b { color: var(--warn); }
.code { font-family: var(--mono); font-size: .86rem; color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; }
.tagline { font-size: .85rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: .2rem; font-size: .75rem; padding: .05rem .5rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: .35rem; vertical-align: .1em; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.info { color: var(--info); border-color: currentColor; }
.status { font-size: .8rem; padding: .12rem .6rem; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.st-ordered { background: #2563a822; color: var(--info); }
.st-arrived { background: #d8791a22; color: var(--accent); }
.st-verified, .st-ok { background: #2b804822; color: var(--ok); }
.st-issue { background: #c2410c22; color: var(--warn); }
.st-cancelled, .st-pending { background: var(--bg); color: var(--muted); }
.okmark { color: var(--ok); font-size: .85em; } .unchk { color: var(--muted); font-size: .85em; }
.h2note { font-weight: 400; font-size: .88rem; margin-left: .4rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.1rem; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: .65rem 1rem; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
table.t { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.t th, table.t td { text-align: left; padding: .6rem .65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
table.t tr:last-child td { border-bottom: none; }
.lightbox { position: fixed; inset: 0; background: #000d; display: grid; place-items: center; z-index: 20; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 92vh; }
#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 30; }
#toast div { background: #1b1d21; color: #fff; padding: .7rem 1.1rem; border-radius: 10px; margin-top: .45rem; box-shadow: 0 6px 20px #0005; font-size: .95rem; }
#toast div.err { background: var(--warn); }
.login { max-width: 400px; margin: 12vh auto; }
.modal { position: fixed; inset: 0; background: #0008; display: grid; place-items: center; z-index: 25; padding: 1rem; }
.modal-body { max-width: 680px; width: 100%; max-height: 90vh; overflow: auto; }
.spin { width: 15px; height: 15px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meter { width: 140px; height: 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; display: inline-block; }
.meter span { display: block; height: 100%; background: var(--accent); }
.swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 4px; background: var(--c); vertical-align: middle; }

/* ---------- inventory: sidebar + main ---------- */
.inv { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.inv-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; font-size: .96rem; padding-right: .2rem; }
.side-sec { margin-bottom: 1.3rem; }
.side-h { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .35rem .6rem; font-weight: 600; }
.side-a { display: flex; align-items: center; gap: .55rem; padding: .42rem .6rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.side-a .ic { color: var(--muted); }
.side-a:hover { background: var(--panel); }
.side-a.on { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); font-weight: 600; }
.side-a.on .ic { color: var(--accent); }
.side-a.saved a { text-decoration: none; flex: 1; display: inline-flex; align-items: center; gap: .55rem; }
.side-n { margin-left: auto; color: var(--muted); font-size: .82rem; display: inline-flex; align-items: center; gap: .35rem; font-variant-numeric: tabular-nums; }
.side-x { border: none; background: none; color: var(--muted); cursor: pointer; padding: 0 .2rem; opacity: 0; font-size: .9rem; }
.side-a:hover .side-x { opacity: 1; }
.side-tags { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0 .5rem; }
.lowdot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }
@media (max-width: 900px) {
  .inv { grid-template-columns: 1fr; gap: 1rem; }
  .inv-side { position: static; max-height: none; display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .4rem; }
  .side-sec { margin: 0; display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }
  .side-h { display: none; }
  .side-a { white-space: nowrap; background: var(--panel); border: 1px solid var(--line); }
  .side-tags { flex-wrap: nowrap; }
}

/* category mark: the category's single-colour line icon */
.cicon { display: inline-flex; align-items: center; color: var(--c); margin-right: .45em; }
.cicon .ic { width: 1.2em; height: 1.2em; }
.code .cicon { font-size: 1.05rem; }
/* tag chips: quiet, coloured text on a faint tint */
.tchip { display: inline-block; font-size: .76rem; line-height: 1.5; padding: 0 .5rem; border-radius: 99px; margin-left: .35rem; text-decoration: none; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 12%, transparent); color: color-mix(in srgb, var(--c) 75%, var(--ink)); font-family: var(--sans); font-weight: 500; }
a.tchip:hover { background: color-mix(in srgb, var(--c) 22%, transparent); }

.page-h { margin-bottom: 1rem; }
.inv-head { margin: 1.4rem 0 .8rem; }
.inv-head h1, .inv-head h2 { margin: 0; display: flex; align-items: center; gap: .4rem; }
.inv-head .count { color: var(--muted); font-size: .95rem; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 0 .6rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg button { border: none; background: none; padding: .45rem .8rem; cursor: pointer; color: var(--muted); font: inherit; font-size: .92rem; display: inline-flex; align-items: center; gap: .4rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }
@media (max-width: 760px) { .seg-l { display: none; } }
.filters2 { display: flex; gap: .6rem; margin-bottom: .7rem; align-items: center; }
.filters2 .search { flex: 1; font-size: 1rem; padding: .65rem .85rem; }

.fchips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.fchip { font-size: .88rem; padding: .2rem .7rem; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.fchip:hover { border-color: var(--muted); }
.fchip.clear { color: var(--muted); border-style: dashed; }
.facets { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .8rem; display: grid; gap: .5rem; box-shadow: var(--shadow); }
.facet { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.facet-k { font-size: .82rem; color: var(--muted); min-width: 9.5rem; font-weight: 600; }
.fc { font-size: .88rem; padding: .15rem .6rem; border-radius: 7px; border: 1px solid var(--line); text-decoration: none; display: inline-flex; gap: .35rem; align-items: center; }
.fc i { font-style: normal; color: var(--muted); font-size: .78rem; }
.fc.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fc.on i { color: inherit; opacity: .7; }
.fc:hover:not(.on) { border-color: var(--muted); }

/* overview */
.attn { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .4rem; }
.attn-c { display: inline-flex; align-items: center; gap: .5rem; font-size: .95rem; padding: .55rem .9rem; border-radius: 10px; background: var(--panel);
  border: 1px solid var(--line); text-decoration: none; box-shadow: var(--shadow); }
.attn-c .ic { color: var(--muted); } .attn-c b { font-size: 1.1rem; } .attn-c span { color: var(--muted); }
.attn-c:hover { border-color: var(--muted); }
.cat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .7rem; margin-bottom: .6rem; }
.cat-tile { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .8rem; align-items: center; padding: .85rem 1rem;
  border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); text-decoration: none; box-shadow: var(--shadow); }
.cat-tile:hover { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); }
.ct-i { grid-row: 1 / 3; color: var(--c); display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 10%, transparent); }
.ct-i .ic { width: 24px; height: 24px; }
.ct-n { font-weight: 600; font-size: .98rem; line-height: 1.25; }
.ct-m { font-size: .84rem; color: var(--muted); }

/* list rows */
.items { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.items > * + * { border-top: 1px solid var(--line); }
.item-row { display: grid; grid-template-columns: 64px 140px minmax(0, 1fr) 150px 96px 190px; gap: 1rem; align-items: center;
  padding: .75rem 1.1rem; min-height: 80px; background: var(--panel); text-decoration: none; color: inherit; box-shadow: inset 4px 0 0 transparent; }
.item-row:hover { background: var(--panel-2); }
.thumb { width: 64px; height: 56px; border-radius: 9px; background: var(--bg) center/cover no-repeat; border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--muted); }
.thumb .ic { width: 26px; height: 26px; opacity: .7; }
.item-row .name b { font-weight: 600; font-size: 1.02rem; line-height: 1.35; }
.item-row .name .tagline { margin-top: .15rem; }
.item-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.item-row .cost { color: var(--muted); }
.item-row .loc { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qty .qv { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: 1.02rem; justify-content: flex-end; }
.qty .coming { display: flex; align-items: center; gap: .25rem; justify-content: flex-end; font-size: .8rem; color: var(--info); margin-top: .1rem; }
.qty .coming.muted { color: var(--muted); }
.st-ic { display: inline-flex; }
@media (max-width: 760px) {
  .item-row { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "t n q" "t c q"; gap: .2rem .8rem; padding: .7rem .8rem; }
  .item-row .thumb { grid-area: t; width: 56px; height: 56px; } .item-row .code { grid-area: c; } .item-row .name { grid-area: n; }
  .item-row .qty { grid-area: q; } .item-row .cost, .item-row .loc { display: none; }
}
/* status: a stripe + an icon (never colour alone) */
.st-low.item-row, .st-low.card, .fam.st-low > .fam-h { box-shadow: inset 4px 0 0 var(--warn); }
.st-low .st-ic { color: var(--warn); }
.st-ordered.item-row, .st-ordered.card { box-shadow: inset 4px 0 0 var(--info); }
.st-ordered .st-ic { color: var(--info); }
.st-out.item-row, .st-out.card { box-shadow: inset 4px 0 0 var(--muted); }
.st-out.item-row > :not(.qty), .st-out.card .card-img { opacity: .55; }
.st-out .st-ic { color: var(--muted); }

/* table layout */
.tbl-wrap { padding: .3rem .5rem; }
table.spec-tbl td, table.spec-tbl th { white-space: nowrap; vertical-align: middle; }
table.spec-tbl td:nth-child(2) { white-space: normal; min-width: 14rem; font-weight: 500; }
table.spec-tbl td.qty { text-align: right; }
table.spec-tbl tbody tr { cursor: pointer; }
table.spec-tbl tbody tr:hover td { background: var(--panel-2); }
table.spec-tbl tr.sub td:first-child { padding-left: 1.6rem; }
table.spec-tbl tr.st-low td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
table.spec-tbl tr.st-ordered td:first-child { box-shadow: inset 4px 0 0 var(--info); }
table.spec-tbl tr.st-out td { opacity: .6; } table.spec-tbl tr.st-out td:first-child { box-shadow: inset 4px 0 0 var(--muted); }
.fam-tr td { background: var(--panel-2); }

/* families */
.fam { background: var(--panel); }
.fam-h { display: flex; align-items: center; gap: .6rem; width: 100%; border: none; background: none; padding: .85rem 1.1rem; cursor: pointer; font: inherit; color: var(--ink); text-align: left; }
.fam-h b { font-size: 1.02rem; }
.fam-t { color: var(--muted); width: 1rem; }
.fam-b { border-top: 1px dashed var(--line); }
.fam-b .item-row { padding-left: 2.2rem; }
.fam-cmp { display: block; padding: .55rem 2.2rem .7rem; font-size: .9rem; color: var(--muted); }
.sug { border-bottom: 1px solid var(--line); padding-top: .6rem; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; box-shadow: var(--shadow); }
.card:hover { border-color: var(--muted); }
.card-img { aspect-ratio: 4/3; background: var(--bg) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.card-img .ic { width: 42px; height: 42px; opacity: .55; }
.card-b { padding: .65rem .8rem .8rem; }
.card-n { font-weight: 600; font-size: .98rem; line-height: 1.3; margin: .2rem 0 .4rem; }
.card-m { font-size: .92rem; align-items: flex-start; }

/* by place */
.place { margin-bottom: 1.3rem; }
.place-h { display: flex; gap: .6rem; align-items: center; margin: 0 0 .45rem .3rem; font-weight: 600; font-size: 1.02rem; }
.tools { margin-top: 1rem; }

/* ---------- item page ---------- */
.item-head { display: grid; grid-template-columns: 1fr auto; gap: 1.2rem; align-items: start; margin-bottom: 1.2rem; }
.qr { width: 104px; height: 104px; background: #fff; padding: 5px; border-radius: 8px; }
.stock-box { display: flex; align-items: center; gap: .5rem; }
.stock-box .qtyv { font-size: 1.8rem; font-weight: 700; min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .7rem; }
.gallery figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; cursor: zoom-in; background: var(--bg); }
.gallery figcaption { font-size: .85rem; padding: .35rem .5rem; display: flex; gap: .35rem; align-items: center; }
.gallery figcaption span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 1rem; text-align: center; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.drop .ic { width: 28px; height: 28px; }
.drop.over { border-color: var(--accent); color: var(--accent); }
.preview-imgs { display: flex; gap: .5rem; overflow-x: auto; }
.preview-imgs img { height: 100px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.history li { font-size: .9rem; margin-bottom: .35rem; }
.src { display: inline-block; font-size: .72rem; padding: 0 .4rem; border-radius: 5px; margin-left: .3rem; vertical-align: 1px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); font-weight: 600; letter-spacing: .02em; }
.src-listing { color: var(--info); } .src-ai { color: #8a5cc2; border-style: dashed; }
.src-datasheet, .src-cad { color: var(--accent); } .src-measured { color: var(--ok); }
.src.ver { background: color-mix(in srgb, var(--ok) 14%, var(--panel)); color: var(--ok); border-color: var(--ok); }
.cov { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.chip-s { font-size: .8rem; padding: .08rem .55rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.chip-s.ok { color: var(--ok); border-color: currentColor; } .chip-s.warn { color: var(--warn); border-color: currentColor; }
table.specs td { vertical-align: middle; } table.specs td:first-child { width: 28%; }
table.specs input { padding: .35rem .55rem; }
table.specs tr.ghost td { color: var(--muted); } table.specs tr.ghost input { border-style: dashed; }
table.specs tr.removing td { opacity: .45; text-decoration: line-through; }
ul.measure { margin: 0; padding-left: 1.1rem; } ul.measure li { margin: .25rem 0; }
.enrich ul.steps, .enrich ul.cands { margin: .45rem 0 0; padding-left: 1.1rem; font-size: .92rem; }
.enrich ul.cands li { margin: .35rem 0; }

/* mechanical drawing */
.mech-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 760px) { .mech-grid { grid-template-columns: 1fr; } }
.mech-draw { background: var(--bg); border-radius: 10px; padding: .6rem; }
svg.mech { width: 100%; max-height: 440px; display: block; }
.mech-json { min-height: 380px; font-size: .82rem; line-height: 1.4; white-space: pre; tab-size: 2; font-family: var(--mono); }
ul.msum { list-style: none; padding: 0; margin: 0 0 .7rem; } ul.msum li { padding: .25rem 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
ul.msum li .muted { display: inline-block; min-width: 8rem; font-size: .86rem; }
#mechMsg .warn { color: var(--warn); }
.m-outline { fill: #2f6b4f; stroke: #1d4733; stroke-width: .4; }
.m-hole { fill: var(--bg); stroke: #c9a227; stroke-width: .5; }
.m-pin { fill: #e8c25a; stroke: #8a6d1f; stroke-width: .15; } .m-pin.one { fill: #f2a93b; }
.m-conn { fill: #b8bcc4; stroke: #6b6f78; stroke-width: .3; }
.m-comp { fill: none; stroke: #e9e7e2; stroke-width: .35; stroke-dasharray: 1 .6; }
.m-keep { fill: url(#hatch); stroke: var(--warn); stroke-width: .3; } .m-hatch { stroke: var(--warn); stroke-width: .5; }
.m-active { fill: #2c5f9e55; stroke: #2c5f9e; stroke-width: .3; }
.m-shaft { fill: #d0d3d9; stroke: #6b6f78; stroke-width: .4; }
.m-dim line { stroke: var(--muted); stroke-width: .25; } .m-dim text { fill: var(--muted); font-family: var(--sans); }
.m-origin { fill: var(--accent); }

/* ---------- orders, measuring ---------- */
.measure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem .7rem; align-items: end; }
.measure-grid .mf input { padding: .4rem .55rem; }
.mf-group { grid-column: 1 / -1; }
.mf-h { font-size: .86rem; color: var(--muted); display: block; margin-bottom: .25rem; }
.mf-row { display: grid; grid-template-columns: 100px repeat(3, minmax(0, 1fr)); gap: .45rem; }
.mf-row select, .mf-row input { padding: .4rem .55rem; }
@media (max-width: 760px) { .mf-row { grid-template-columns: 1fr 1fr; } }
table.order-lines tr[data-line] td { border-bottom: none; }
table.order-lines tr.mrow td { background: var(--panel-2); padding-bottom: .9rem; }

/* ---------- projects, shopping ---------- */
table.pparts td { vertical-align: middle; }
table.pparts tr.dnp td { opacity: .5; }
table.pparts input { padding: .3rem .45rem; }
.shop-group h2 { font-size: 1.05rem; }
.shop-group input { padding: .3rem .45rem; }
.merge-plan ul { padding-left: 1.1rem; } .merge-plan li { margin: .35rem 0; }
.newtok { border-color: var(--ok); margin-bottom: 1rem; }
.newtok td.mono { word-break: break-all; }

/* ---------- locations, scan ---------- */
.scan-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 760px) { .scan-grid { grid-template-columns: 1fr; } }
#scanVideo { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 4/3; object-fit: cover; }
.scan-card { margin-top: .9rem; border-color: var(--accent); }
.scan-card .qtyv { font-size: 1.8rem; font-weight: 700; min-width: 3ch; text-align: center; }
.scan-log { padding-left: 1rem; max-height: 260px; overflow: auto; }
table.loc-items td { vertical-align: middle; }

/* ---------- value grid ---------- */
table.vgrid { width: auto; } table.vgrid th, table.vgrid td { text-align: center; padding: .35rem .75rem; }
table.vgrid tbody th { text-align: right; font-family: var(--mono); font-size: .9rem; color: var(--ink); text-transform: none; letter-spacing: 0; }
table.vgrid td.has { background: color-mix(in srgb, var(--ok) 12%, var(--panel)); font-weight: 600; }
table.vgrid td.has.low { background: color-mix(in srgb, var(--warn) 14%, var(--panel)); }
table.vgrid td a { text-decoration: none; }
.vg-add { border: 1px dashed var(--line); background: none; color: var(--muted); border-radius: 5px; width: 2rem; height: 1.6rem; cursor: pointer; }
.vg-add:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- printable labels ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, 62mm); gap: 3mm; }
.label { width: 62mm; height: 29mm; border: 1px dashed #aaa; display: grid; grid-template-columns: 25mm 1fr; gap: 2mm; padding: 2mm; background: #fff; color: #000; overflow: hidden; }
.label img { width: 25mm; height: 25mm; }
.label .lc { font-family: var(--mono); font-weight: 700; font-size: 11pt; }
.label.loc .lc { font-family: var(--sans); font-size: 12pt; }
.label .ln { font-size: 8pt; line-height: 1.15; max-height: 3.5em; overflow: hidden; }
.label .ll { font-size: 7pt; color: #555; }
@media print {
  .topbar, .no-print, #toast { display: none !important; }
  body { background: #fff; } main { padding: 0; max-width: none; }
  .label { border-color: #ddd; break-inside: avoid; }
}
