:root {
  --bg: #F2F4F6; --surface: #FFFFFF; --sunk: #E9EDF0; --ink: #16202B; --muted: #5A6774; --line: #D3DAE0;
  --accent: #A85F00; --lamp: #F2A20C; --lamp-ink: #1B1300;
  --good: #1D7A4C; --warn: #9A5B00; --crit: #B3261E;
  --f-head: "IBM Plex Sans Condensed", "Arial Narrow", Arial, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #10151B; --surface: #18202A; --sunk: #212B36; --ink: #E6EBF0; --muted: #94A1AE; --line: #2D3945;
  --accent: #F5B13D; --lamp: #F2A20C; --lamp-ink: #1B1300;
  --good: #5CC38D; --warn: #F0A848; --crit: #F2857D; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #10151B; --surface: #18202A; --sunk: #212B36; --ink: #E6EBF0; --muted: #94A1AE; --line: #2D3945;
  --accent: #F5B13D; --lamp: #F2A20C; --lamp-ink: #1B1300;
  --good: #5CC38D; --warn: #F0A848; --crit: #F2857D; color-scheme: dark }

* { box-sizing: border-box }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45 }
h1, h2, h3 { font-family: var(--f-head); font-weight: 600; margin: 0; text-wrap: balance }
h1 { font-size: 19px; letter-spacing: .01em }
h2 { font-size: 22px }
h3 { font-size: 16px }
p { margin: 0 }
.mono { font-family: var(--f-mono); font-size: 12.5px }
.muted { color: var(--muted) }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap }

.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line) }
.bar-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px }
.brand { display: flex; align-items: center; gap: 9px; padding-bottom: 10px }
.brand i { width: 10px; height: 18px; border-radius: 2px; background: var(--lamp); display: block }
.tabs { display: flex; gap: 2px; overflow-x: auto; min-width: 0 }
.tabs a { padding: 8px 12px 10px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--lamp) }
.tabs a:hover { color: var(--ink) }
.tabs .count { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); margin-left: 4px }

main { max-width: 1180px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 56px; display: flex; flex-direction: column; gap: 16px }
.head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px 16px }
.head p { max-width: 68ch; color: var(--muted); margin-top: 4px }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0 }
.panel > h3 + p { margin-top: -8px }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px }
.grow { flex: 1 1 auto; min-width: 0 }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px }
@media (max-width: 800px) { .two { grid-template-columns: minmax(0, 1fr) } }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0 }
input, select, textarea, button { font: inherit; color: inherit }
input[type=text], input[type=number], input[type=search], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; width: 100%; min-width: 0; color: var(--ink) }
textarea { resize: vertical; min-height: 60px }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
button, .btn { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap }
button:hover, .btn:hover { border-color: var(--muted) }
button.primary { background: var(--lamp); border-color: var(--lamp); color: var(--lamp-ink) }
button.danger { color: var(--crit) }
button.small { padding: 3px 8px; font-size: 12.5px }
button:disabled { opacity: .5; cursor: default }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500 }

.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px }
table { border-collapse: collapse; width: 100%; font-size: 13px }
th { text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--sunk); padding: 7px 9px; white-space: nowrap }
td { padding: 7px 9px; border-top: 1px solid var(--line); vertical-align: top }
td.wrap { min-width: 180px }
tr.click { cursor: pointer }
tr.click:hover td { background: var(--sunk) }
td input[type=text], td input[type=number], td select { padding: 4px 6px; font-size: 12.5px }
td input.mono { font-family: var(--f-mono) }
td input[data-price], td input[data-reprice], td input[data-pcrate] { width: 110px; text-align: right }
.w-s { width: 64px } .w-m { min-width: 96px } .w-l { min-width: 170px }

.chip { display: inline-block; font-family: var(--f-mono); font-size: 11.5px; padding: 1px 6px; border-radius: 3px; background: var(--sunk); color: var(--ink); white-space: nowrap }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap }
.pill.good { color: var(--good) } .pill.warn { color: var(--warn) } .pill.crit { color: var(--crit) } .pill.plain { color: var(--muted) } .pill.dk { color: #1B6B2A; border-color: #9CCFA8 }
.note { border-left: 3px solid var(--lamp); background: var(--sunk); padding: 9px 12px; border-radius: 0 4px 4px 0 }
.note.crit { border-left-color: var(--crit) }
.empty { border: 1px dashed var(--line); border-radius: 6px; padding: 28px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center }
.empty b { color: var(--ink); font-family: var(--f-head); font-size: 17px; font-weight: 600 }
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px }
.stat b { display: block; font-family: var(--f-head); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums }
.stat span { font-size: 12px; color: var(--muted) }
.drop { border: 1.5px dashed var(--line); border-radius: 6px; padding: 18px; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; color: var(--muted) }
.drop.over { border-color: var(--lamp); background: var(--sunk) }
tr.pick td { background: var(--sunk) } .rtabs { display: flex; gap: 4px; overflow-x: auto; position: sticky; top: 52px; z-index: 4; background: var(--bg); padding: 6px 0; border-bottom: 1px solid var(--line); margin-bottom: 4px }
table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px } table.mini td { border: 0; padding: 1px 0 1px 10px; text-align: right; white-space: nowrap } table.mini td:first-child { text-align: left; padding-left: 0; white-space: normal } table.mini tr.sum td { border-top: 1px solid var(--line); padding-top: 4px }
th.sec, td.sec { background: var(--sunk); font-size: 12.5px }
tr.tot td { border-top: 2px solid var(--line); font-weight: 600 }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--lamp); border-radius: 50%; animation: sp 1s linear infinite; flex: none }
@keyframes sp { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none } }
.lcats { display: flex; flex-direction: column; gap: 10px }
.lgrp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px }
.lgl { width: 130px; flex: none; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted) }
@media (max-width: 560px) { .lgl { width: 100% } }
button.lc { padding: 4px 10px; font-size: 13px; border-radius: 99px; background: var(--surface) }
button.lc span { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted) }
button.lc.on { background: var(--lamp); border-color: var(--lamp); color: var(--lamp-ink) } button.lc.on span { color: var(--lamp-ink) }
.lflags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
button.lflag { flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 12px; min-width: 120px; white-space: normal; text-align: left }
button.lflag b { font-family: var(--f-head); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums } button.lflag span { font-size: 12px; color: var(--muted) }
button.lflag.on { border-color: var(--lamp); box-shadow: inset 0 0 0 1px var(--lamp) }
button.lsort { border: 0; background: none; padding: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer }
table.ltbl td { white-space: nowrap } table.ltbl td.lsd { white-space: normal; min-width: 220px; font-size: 12.5px }
tr.libx > td { background: var(--bg); padding: 12px }
.libd { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 22px; white-space: normal }
.libd h4 { font-family: var(--f-head); font-size: 14px; font-weight: 600; margin: 0 0 6px } .libd h4 + * { margin-bottom: 10px } .libd > div { min-width: 0; display: flex; flex-direction: column }
.libd .lsrc { font-size: 12px; margin-top: 6px; word-break: break-word }
.lsrc2 { font-family: var(--f-body); font-size: 11px; color: var(--muted); white-space: nowrap }
td.lq { font-size: 12px; min-width: 130px; white-space: normal }
.libd .lsrc a { color: var(--accent) }
.lul { margin: 0 0 10px; padding-left: 16px; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px }
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 4px; max-width: calc(100% - 32px); z-index: 9 }

/* parts app additions */
body { margin: 0 }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; padding-bottom: 10px; font-size: 13px }
.who .chip { font-family: var(--f-body) }
.auth { max-width: 420px; margin: 40px auto 0; width: 100% }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px }
.fgrid .wide { grid-column: 1 / -1 }
label.f .err { color: var(--crit); font-weight: 500 }
label.f.bad input, label.f.bad select, label.f.bad textarea { border-color: var(--crit) }
label.tick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink) }
.ticks { display: flex; flex-wrap: wrap; gap: 6px 16px }
.crumb { font-size: 13px } .crumb a { color: var(--accent); text-decoration: none; font-weight: 500 }
.phead { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; justify-content: space-between }
.phead h2 { font-family: var(--f-mono); font-size: 20px; font-weight: 500; word-break: break-all }
.pills { display: flex; flex-wrap: wrap; gap: 6px }
.price-now b { font-family: var(--f-head); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums }
.keybox { font-family: var(--f-mono); font-size: 13px; background: var(--sunk); padding: 10px 12px; border-radius: 4px; word-break: break-all; user-select: all }
.hist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px }
.hist li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px } .hist li span:first-child { color: var(--muted) }
@media (max-width: 560px) { .hist li { grid-template-columns: 1fr } }
pre.code { font-family: var(--f-mono); font-size: 12px; background: var(--sunk); padding: 10px 12px; border-radius: 4px; overflow-x: auto; margin: 0; white-space: pre }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px } @media (max-width: 860px) { .split { grid-template-columns: minmax(0, 1fr) } }
td.act { white-space: nowrap; text-align: right }
tr.off td { color: var(--muted) }
.res-ok { border-left: 3px solid var(--good) } .res-no { border-left: 3px solid var(--crit) }
input[type=password], input[type=date], input[type=file] { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; width: 100%; min-width: 0; color: var(--ink) }
input[type=file] { padding: 5px }
a.btn { color: var(--ink) }
.who a { color: var(--ink); text-decoration: none; font-weight: 500 } .who a:hover { text-decoration: underline }
td a { color: var(--accent) }
.libd table.mini td { white-space: normal; overflow-wrap: anywhere } .libd table.mini td:last-child { padding-left: 12px }
details summary { cursor: pointer }
.libd table.mini td:first-child { overflow-wrap: normal; word-break: normal; white-space: nowrap; padding-right: 8px }
td.mono { white-space: nowrap }

/* 1.2.0: filters, selection tray, compare, supplier */
.ffil{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:8px 0}
.ffil select,.ffil input{width:auto;min-width:120px}
.tick{display:inline-flex;gap:6px;align-items:center;font-size:.9rem}
.tick input{width:auto}
td.sel,th.sel{width:34px;text-align:center}
.tray{position:sticky;bottom:0;z-index:20;display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:10px 14px;background:var(--panel,#fff);border-top:2px solid var(--accent,#2457c5);box-shadow:0 -4px 14px rgba(0,0,0,.12)}
.tray[hidden]{display:none}
.cmpt th,.cmpt td{vertical-align:top;min-width:150px}
.cmpt tbody th{text-align:left;font-weight:600;position:sticky;left:0;background:var(--panel,#fff);min-width:130px}
.cmpt tr.dif td,.cmpt tr.dif th{background:rgba(255,196,0,.16)}
.sfix{display:grid;gap:4px;margin:8px 0}
.sfix textarea{width:100%}
.note.crit{border-left-color:#b3261e}
.ffil input[type=checkbox],.tick input[type=checkbox],td.sel input{min-width:0;width:auto;flex:none}

/* ---------- parameter schema (1.3.0) ---------- */
.tier { display: inline-block; font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; line-height: 1; padding: 2px 4px; border-radius: 3px; border: 1px solid currentColor; vertical-align: 1px }
.tier.tA { color: var(--accent) } .tier.tB { color: var(--ink) } .tier.tC { color: var(--muted) }
.src { display: inline-block; font-family: var(--f-body); font-size: 11px; line-height: 1.3; padding: 0 6px; border-radius: 99px; background: var(--sunk); color: var(--muted); white-space: nowrap }
.src.s-datasheet { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good) }
.src.s-supplier { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent) }
.src.s-manual { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink) }
.srcs { margin-top: 6px; line-height: 2 }
.meter { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; vertical-align: middle }
.meter.wide { width: 100%; max-width: 220px }
.meter i { display: block; height: 100%; background: var(--lamp) }
.mtxt { margin-left: 6px; font-size: 11.5px; color: var(--muted) }
.cbars { display: flex; flex-wrap: wrap; gap: 8px 28px }
.cbar { display: flex; align-items: center; gap: 10px; min-width: 230px; font-size: 12.5px }
.cbar > span:first-child { white-space: nowrap; min-width: 82px }
table.ptbl tr.tsep th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 0 3px; border-bottom: 1px solid var(--line) }
table.ptbl tr.tsep:first-child th { padding-top: 0 }
table.ptbl tr.empty td:first-child { color: var(--muted) }
.pgroup { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px }
.pgroup h4 { font-family: var(--f-head); font-size: 15px; font-weight: 600; margin: 0 }
.pgroup details > summary { cursor: pointer; padding: 4px 0; font-size: 13px }
.pgroup details[open] > summary { margin-bottom: 8px }
tr.on > td { background: var(--sunk) }
.chg { display: inline-block; margin-right: 10px; white-space: nowrap }
.chg s { color: var(--muted) }
@media (max-width: 600px) { .cbar { min-width: 0; width: 100% } .meter.wide { max-width: none } }

/* 1.4.3: banner while a supplier check runs or the server is busy */
.runbar { position: sticky; top: 0; z-index: 30; display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: #E8F1FB; border-bottom: 1px solid #9DBCE0; color: var(--ink, #1b2733); font-size: 14px; line-height: 1.4 }
.runbar.warn { background: #FFF4E5; border-bottom-color: #E8B66B }
.runbar .grow { flex: 1; min-width: 0 }
.runbar[hidden] { display: none }

/* 1.5.0 CAD library */
.cadcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px }
.cadcard { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0 }
.cadcard h4 { font-family: var(--f-head); font-size: 14px; font-weight: 600; margin: 0 }
.cadcard p { margin: 0; overflow-wrap: anywhere } .cadcard.empty { background: var(--sunk) }
.cadimg { display: flex; align-items: center; justify-content: center; height: 170px; background: #fff; border: 1px solid var(--line); border-radius: 4px; overflow: hidden }
.cadimg img { max-width: 100%; max-height: 100%; display: block }
.cad3d { flex-direction: column; gap: 4px; background: var(--sunk); color: var(--muted); font-family: var(--f-mono) } .cad3d b { font-size: 22px; color: var(--ink) }
.cad3d.big { height: 260px }
img.cadbig { width: 100%; max-height: 520px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 4px }
.cadup { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px }
.cadup h4 { font-family: var(--f-head); font-size: 14px; font-weight: 600; margin: 0 }
ul.cadchk { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px }
ul.cadchk li { display: flex; gap: 8px; align-items: baseline } ul.cadchk .pill { min-width: 52px; justify-content: center }
.cadfilt select { width: auto; max-width: 220px } .cadfilt input { max-width: 260px }
.cad3dbox { position: relative; height: 170px; background: linear-gradient(#FBFCFD, #E9EDF1); border: 1px solid var(--line); border-radius: 4px; overflow: hidden }
.cad3dbox.big { height: 380px } .cad3dbox canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none }
.cad3dbox .v3dbar { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; opacity: .85 } .cad3dbox .v3dbar button { padding: 1px 6px; font-size: 11px }
.cad3dbox .v3dmsg { position: absolute; left: 8px; top: 6px; font-size: 12px; pointer-events: none }
