:root {
  --bg: #f4f4f5; --surface: #ffffff; --surface-2: #efeff1; --border: #e4e4e7;
  --text: #18181b; --muted: #62626b; --accent: #c8102e; --accent-ink: #b30e29; --accent-soft: #fbe9ec; --accent-text: #fff;
  --info: #2563eb; --info-soft: #e6eefd; --bar: #18181b; --toast-action: #ff7a85;
  --ok: #1f9d55; --ok-soft: #e3f5ea; --bad: #d64545; --bad-soft: #fbe7e7;
  --warn: #c27c0e; --warn-soft: #fbf0dc; --idle: #6b6b76; --idle-soft: #ededf0;
  --done: #7c4dce; --done-soft: #efe8fa;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e10; --surface: #18181b; --surface-2: #222226; --border: #2e2e34;
    --text: #ececef; --muted: #a1a1aa; --accent: #dc2626; --accent-ink: #f87171; --accent-soft: #3b1518; --accent-text: #fff;
    --info: #6b9bff; --info-soft: #1d2a45; --bar: #0a0a0b; --toast-action: #b30e29;
    --ok: #3ccf7a; --ok-soft: #15301f; --bad: #f06a6a; --bad-soft: #3a1d1f;
    --warn: #e9a23b; --warn-soft: #382a14; --idle: #9a9aa6; --idle-soft: #26262b;
    --done: #a785ec; --done-soft: #2a2240;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e10; --surface: #18181b; --surface-2: #222226; --border: #2e2e34;
  --text: #ececef; --muted: #a1a1aa; --accent: #dc2626; --accent-ink: #f87171; --accent-soft: #3b1518; --accent-text: #fff;
  --info: #6b9bff; --info-soft: #1d2a45; --bar: #0a0a0b; --toast-action: #b30e29;
  --ok: #3ccf7a; --ok-soft: #15301f; --bad: #f06a6a; --bad-soft: #3a1d1f;
  --warn: #e9a23b; --warn-soft: #382a14; --idle: #9a9aa6; --idle-soft: #26262b;
  --done: #a785ec; --done-soft: #2a2240;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* top bar */
.topbar {
  --surface: var(--bar); --surface-2: #27272a; --border: #3a3a40; --text: #f4f4f5; --muted: #a1a1aa;
  --accent-soft: rgba(225, 29, 46, .22); --accent-ink: #ff8a93; color-scheme: dark;
  position: sticky; top: 0; z-index: 20; background: var(--bar); color: var(--text);
  border-bottom: 3px solid var(--accent);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text); }
.brand-mark { width: 30px; height: 30px; display: block; }
/* The tabs get their own row so they never squeeze against the controls on the right. */
nav.tabs { display: flex; gap: 2px; overflow-x: auto; order: 3; flex-basis: 100%; }
.brand { flex: 1; }
nav.tabs a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap;
}
nav.tabs a:hover { background: var(--surface-2); color: var(--text); }
nav.tabs a.active { background: var(--accent-soft); color: var(--accent-ink); }

main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; }
input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 64px; }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px; }
.stat .num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--idle-soft); color: var(--idle);
}
.b-working { background: var(--ok-soft); color: var(--ok); }
.b-damaged { background: var(--bad-soft); color: var(--bad); }
.b-missing { background: var(--warn-soft); color: var(--warn); }
.b-untested { background: var(--idle-soft); color: var(--idle); }
.b-harvested { background: var(--done-soft); color: var(--done); }
.b-exact { background: var(--ok-soft); color: var(--ok); }
.b-spec { background: var(--info-soft); color: var(--info); }
.b-model { background: var(--warn-soft); color: var(--warn); }
.role-Repair { background: var(--bad-soft); color: var(--bad); }
.role-Donor { background: var(--info-soft); color: var(--info); }
.role-Repaired { background: var(--ok-soft); color: var(--ok); }
.b-site { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 600; letter-spacing: .02em; }
.site-select { width: auto; max-width: 220px; padding: 5px 8px; font-weight: 600; text-overflow: ellipsis; }
.role-Scrapped { background: var(--idle-soft); color: var(--idle); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* device cards */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 5px 11px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.dcard { display: block; padding: 14px 16px; color: inherit; transition: border-color .15s, transform .15s; }
.dcard:hover { border-color: var(--accent); }
.dcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.dcard .title { font-weight: 650; font-size: 15px; }
.dcard .sub { color: var(--muted); font-size: 13px; }
.dcard .issue { margin: 8px 0 10px; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.healthbar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.healthbar span { display: block; height: 100%; }
.dcard .foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); }

/* device page */
.device-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.sticky { position: sticky; top: 72px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.meta-grid .span-3 { grid-column: span 3; }
.fru-group { padding: 6px 16px 2px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.fru-row { display: grid; grid-template-columns: 160px auto minmax(0,1fr); gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.fru-row:last-child { border-bottom: 0; }
.fru-name { font-weight: 550; }
.fru-name .kind { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.fru-fields { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 6px; }
.fru-fields input { padding: 5px 8px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 5px 8px; cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--muted); border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg .s { display: none; }
.seg button:hover { background: var(--surface-2); }
.seg button.on.s-working { background: var(--ok-soft); color: var(--ok); }
.seg button.on.s-untested { background: var(--idle-soft); color: var(--text); }
.seg button.on.s-damaged { background: var(--bad-soft); color: var(--bad); }
.seg button.on.s-missing { background: var(--warn-soft); color: var(--warn); }
.seg button.on.s-harvested { background: var(--done-soft); color: var(--done); }

.ptabs { display: flex; border-bottom: 1px solid var(--border); }
.ptabs button { flex: 1; border: 0; background: none; padding: 11px 8px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.ptabs button.on { color: var(--accent-ink); border-bottom-color: var(--accent); }
.need { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.need:last-child { border-bottom: 0; }
.need-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.donor { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); margin-top: 6px; }
.donor .who { min-width: 0; }
.donor .who b { display: block; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donor .who span { font-size: 12px; color: var(--muted); }
.none { font-size: 12.5px; color: var(--muted); padding: 6px 0; }
.check { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.opp { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.opp .arrow { color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: span 2; }
.type-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-pick label { border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; text-align: center; font-weight: 600; }
.type-pick input { display: none; }
.type-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.hint { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; transition: .2s; z-index: 50; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

@media (max-width: 1000px) {
  .device-layout, .two-col { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .topbar-inner { gap: 8px 12px; }
  .brand { flex: 1; }
  nav.tabs { order: 3; flex-basis: 100%; }
  .fru-row { grid-template-columns: 1fr; gap: 8px; }
  .fru-fields { grid-template-columns: 1fr 1fr; }
  .fru-fields .notes { grid-column: span 2; }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .meta-grid .span-3 { grid-column: span 2; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: span 1; }
  .seg { display: flex; }
  .seg button { flex: 1; padding: 6px 4px; }
  .seg .l { display: none; }
  .seg .s { display: inline; }
  .tbl th, .tbl td { padding: 8px 10px; }
}

/* signed-out state & auth screens */
body.signed-out #nav, body.signed-out #siteview, body.signed-out #addbtn, body.signed-out #userchip, body.signed-out #bell { display: none; }
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card p { margin: 6px 0 0; color: var(--muted); }
.stack { display: grid; gap: 14px; margin-top: 18px; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.form-error:empty { display: none; }
.form-ok { background: var(--ok-soft); color: var(--ok); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.form-ok:empty { display: none; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* user chip */
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid var(--border); font-weight: 500; white-space: nowrap; }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.users-tbl td { vertical-align: middle; }
.users-tbl select { width: auto; padding: 4px 8px; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; }
.inline-form input { padding: 5px 8px; }
@media (max-width: 700px) {
  .user-chip .name { display: none; }
  .user-chip { padding: 3px; }
  .auth-card { padding: 20px; }
}


/* laptop key map */
.keys-extra { grid-column: 1 / -1; display: grid; gap: 10px; min-width: 0; }
.keys-summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.keymap-wrap { display: grid; gap: 8px; min-width: 0; }
.keymap-wrap[hidden] { display: none; }
.seg.brush { flex-wrap: wrap; justify-self: start; }
.keymap { --u: 36px; display: grid; gap: 4px; overflow-x: auto; padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; max-width: 100%; }
.keymap .krow { display: flex; gap: 4px; }
.key {
  flex: 0 0 auto; width: calc(var(--u) * var(--w) + 4px * (var(--w) - 1)); height: var(--u);
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 0 4px; white-space: nowrap; overflow: hidden;
}
.key:hover { border-color: var(--accent); }
.key.k-cap { background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); }
.key.k-nib { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.key.k-pulled { background: var(--done-soft); color: var(--done); border: 1px dashed var(--done); text-decoration: line-through; }
@media (max-width: 700px) { .seg.brush button { flex: 1 1 45%; } .site-select { max-width: 140px; } }
.key[style*="--w:0.88"] { font-size: 10px; padding: 0 1px; letter-spacing: -0.02em; }

/* device details (read-only) and the add/edit form */
.details-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
.details dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.details dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.details .wide { grid-column: 1 / -1; }
.details .pre dd { white-space: pre-wrap; }
.savestate { color: var(--ok); margin-top: 2px; }
@media (max-width: 700px) { .details { grid-template-columns: 1fr 1fr; } }

/* in-app popup */
dialog.modal { border: none; padding: 0; background: transparent; color: var(--text); width: min(540px, calc(100vw - 32px)); max-width: none; }
dialog.modal::backdrop { background: rgba(10, 12, 16, .55); }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); padding: 20px; display: grid; gap: 16px; }
.modal-card h2 { font-size: 17px; }
.modal-body { display: grid; gap: 12px; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.move-flow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; }
.move-end { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); min-width: 0; }
.move-end .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.move-end b { display: block; overflow-wrap: anywhere; }
.move-arrow { color: var(--muted); }
.policy-warn { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.result-list { margin: 0; padding-left: 18px; font-size: 13px; }
.keychips { display: flex; flex-wrap: wrap; gap: 4px; }
.keychip { border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; background: var(--surface-2); }
@media (max-width: 520px) { .move-flow { grid-template-columns: minmax(0, 1fr); } .move-arrow { transform: rotate(90deg); justify-self: center; } }

.modal-body .field input { margin-top: 2px; }
.btn[disabled].danger-solid, .btn[disabled].primary { opacity: .45; cursor: not-allowed; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow-y: auto; padding: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.tag-list code { font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }

/* device records status on the add/edit form */
.rec { margin-top: 12px; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.rec-ok { background: var(--ok-soft); color: var(--ok); }
.rec-warn { background: var(--warn-soft); color: var(--warn); }

/* parts pool: filter by model family or model number */
.toolbar .model-filter { max-width: 260px; }
.toolbar .seg button { white-space: nowrap; padding: 6px 10px; }

/* scan to add */
.scanbox { padding: 12px; margin-bottom: 16px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); display: grid; gap: 6px; }
.scan-row { display: flex; gap: 8px; }
.scan-row input { flex: 1; min-width: 0; font-size: 15px; }
.scan-video { width: 100%; max-height: 50vh; background: #000; border-radius: 8px; object-fit: cover; }

/* reports */
.reports { margin-bottom: 16px; max-width: 1100px; }
.reports-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.reports-actions { display: flex; gap: 8px; }
.reports-actions select { width: auto; }
.report-stats { margin-bottom: 16px; }
.report-stats .stat { box-shadow: none; background: var(--surface-2); }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.report-grid .wide { grid-column: 1 / -1; }
.report-grid h3 { margin-bottom: 6px; }
.report-grid .tbl th, .report-grid .tbl td { padding: 6px 10px; }
.report-grid .table-wrap { border: 1px solid var(--border); border-radius: 8px; }
.part-values { margin-top: 16px; }
.part-values summary { cursor: pointer; font-weight: 600; }
.values-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.values-grid input { padding: 5px 8px; }
.values-save { grid-column: 1 / -1; }
@media (max-width: 800px) { .report-grid { grid-template-columns: 1fr; } }

/* known interchange match */
.b-interchange { background: var(--done-soft); color: var(--done); }

/* toast with an Undo button */
.toast.has-action { pointer-events: auto; display: flex; gap: 14px; align-items: center; }
.toast button { background: none; border: 0; color: var(--toast-action); font-weight: 700; cursor: pointer; padding: 0; }

/* issue presets */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.presets .chip { font-size: 12.5px; padding: 3px 10px; }
.preset-note { flex-basis: 100%; }

/* select mode and bulk actions */
.bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 12px; position: sticky; top: 64px; z-index: 5; }
.bulkbar select { width: auto; padding: 4px 8px; }
.bulk-sep { flex: 1; }
.device-grid.selecting .dcard { position: relative; padding-left: 44px; }
.dcard .pick { position: absolute; left: 14px; top: 16px; width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 5px; background: var(--surface); }
.dcard.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dcard.picked .pick { background: var(--accent); border-color: var(--accent); }
.dcard.picked .pick::after { content: ''; position: absolute; left: 4px; top: 0; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* history */
.history li.undone > .hist-row > div:first-child { text-decoration: line-through; color: var(--muted); }
.hist-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }

/* known interchanges */
.ix-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.ix-row .badge { margin: 2px 2px 2px 0; }
.ix-form { padding: 16px; border-top: 1px solid var(--border); display: grid; gap: 12px; }
.ix-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ix-fams { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
@media (max-width: 700px) { .ix-grid { grid-template-columns: 1fr; } }

/* notices bell */
.bell { position: relative; }
.bell-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.bell-count[hidden] { display: none; }
#notices li.unread { background: var(--accent-soft); }

/* site picker popup */
.site-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; max-height: 50vh; overflow-y: auto; padding: 4px 0; }
.site-check { display: flex; gap: 6px; align-items: baseline; font-size: 13px; cursor: pointer; }
.site-check[hidden] { display: none; }
dialog.modal:has(.site-checks) { width: min(760px, calc(100vw - 32px)); }

/* storage locations */
.loc-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; }
.loc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#locfilter { width: auto; max-width: 260px; }

/* comments */
.comment-form { padding: 12px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; }
.comment-form textarea { min-height: 52px; }
.comment-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.history li.comment { background: var(--surface-2); }
.comment-body { white-space: pre-wrap; margin: 4px 0 2px; overflow-wrap: anywhere; }

/* pull list */
.pull-groups { display: grid; gap: 12px; }
.pull-item { display: flex; gap: 12px; align-items: center; }
.pull-item .pi-main { flex: 1; min-width: 0; }
.pull-item .tick { width: 16px; height: 16px; border: 2px solid var(--border); border-radius: 4px; flex-shrink: 0; }

/* labels (Avery 5160: 3 x 10 labels of 2.625in x 1in on US Letter) */
.label-preview { overflow-x: auto; display: grid; gap: 16px; justify-content: center; }
.label-page { width: 8.5in; height: 11in; box-sizing: border-box; padding: 0.5in 0.1875in 0; background: #fff; color: #000;
  display: grid; grid-template-columns: repeat(3, 2.625in); grid-auto-rows: 1in; column-gap: 0.125in; align-content: start; box-shadow: var(--shadow); }
.label { display: flex; align-items: center; gap: 0.08in; padding: 0.06in 0.1in; overflow: hidden; outline: 1px dashed #ccc; }
.label .qr { width: 0.84in; height: 0.84in; flex-shrink: 0; }
.label .qr svg { width: 100%; height: 100%; display: block; }
.label-text { font: 8.5pt/1.25 system-ui, sans-serif; min-width: 0; overflow: hidden; }
.label-text b { display: block; font-size: 10pt; overflow-wrap: anywhere; }

/* printing: light colours, no app chrome */
@media print {
  :root, :root[data-theme] { --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --muted: #444; --border: #999; --accent: #000; color-scheme: light; }
  .topbar, .no-print, #toast, dialog { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .label-preview { display: block; overflow: visible; }
  .label-page { box-shadow: none; break-after: page; margin: 0; }
  .label { outline: none; }
  @page { margin: 0.4in; }
}
/* Label sheets print edge to edge so the labels line up with the sheet. */
.label-page { page: labels; }
@page labels { size: letter; margin: 0; }

/* top bar: the tabs get their own row when space runs out, without a visible scrollbar */
nav.tabs { scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
.topbar-inner { row-gap: 8px; }
.part-values h3 { margin: 14px 0 2px; font-size: 14px; }
.pv-fams { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.pv-pick { max-width: 320px; margin-top: 6px; }

/* warranty, stock, activity log, work order */
.b-warranty { background: var(--info-soft); color: var(--info); }
.stock-fit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.log-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.log-actions { display: flex; gap: 8px; }
.turnaround { margin-top: 4px; }
.workorder { max-width: 820px; }
.workorder h2 { font-size: 15px; margin: 18px 0 6px; }
.wo-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 12px; }
.wo-head h1 { font-size: 26px; margin: 4px 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.wo-qr { width: 96px; height: 96px; flex-shrink: 0; }
.wo-qr svg { width: 100%; height: 100%; }
.wo-details { margin-bottom: 8px; }
.wo-text { white-space: pre-wrap; margin: 0; }
.wo-table .wo-check { width: 28px; }
.wo-table .tick { display: inline-block; width: 14px; height: 14px; border: 1.5px solid var(--text); border-radius: 3px; }
.wo-lines span { display: block; border-bottom: 1px solid var(--border); height: 28px; }
.wo-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 28px; font-size: 12px; color: var(--muted); }
.wo-sign span { display: block; border-bottom: 1px solid var(--text); height: 28px; margin-bottom: 4px; }
@media print {
  .workorder { border: 0; padding: 0; max-width: none; }
  .wo-lines span { border-color: #999; }
}
.docs-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; }
.docs-pages { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.wo-manual { margin: 10px 0 0; word-break: break-all; }
.audit-scanbar { margin-bottom: 16px; }
.audit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.audit-col .card-head h2 { display: flex; align-items: center; gap: 8px; }
@media (max-width: 800px) { .audit-grid { grid-template-columns: 1fr; } }

/* ---------- Inventory ---------- */
.side-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.side-switch a { padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.side-switch a + a { border-left: 1px solid var(--border); }
.side-switch a:hover { background: var(--surface-2); color: var(--text); }
.side-switch a.on { background: var(--accent-soft); color: var(--accent-ink); }
.as-deployed { background: var(--ok-soft); color: var(--ok); }
.as-spare { background: var(--idle-soft); color: var(--idle); }
.as-repair { background: var(--bad-soft); color: var(--bad); }
.as-donor { background: var(--info-soft); color: var(--info); }
.as-surplus { background: var(--warn-soft); color: var(--warn); }
.as-disposed { background: var(--done-soft); color: var(--done); }
.as-lost { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); }
.inv-stats { grid-template-columns: repeat(4, 1fr); }
.inv-stats .stat { color: inherit; }
.inv-stats .stat.warn .num { color: var(--warn); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover td { background: var(--surface-2); }
.inv-toolbar input[type=search] { max-width: 360px; flex: 1 1 220px; }
.asset-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .asset-layout { grid-template-columns: 1fr; } .inv-stats { grid-template-columns: repeat(2, 1fr); } }
.as-missing { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.scan-panel .scan-row { display: flex; gap: 8px; }
.scan-panel .scan-row input { flex: 1; font-size: 18px; padding: 10px 12px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.scan-last { margin-top: 10px; min-height: 24px; overflow-wrap: anywhere; }
.inline-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--border); }
.inline-add input { width: auto; flex: 1 1 120px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-ink); cursor: pointer; text-decoration: underline; }
tr.muted td { color: var(--muted); }
@media (max-width: 900px) { .two-col[style] { grid-template-columns: 1fr !important; } }
