/* Inventar – design tokens */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --surface-3: #e8eaee;
  --text: #16181d;
  --text-2: #4b5160;
  --muted: #6b7280;
  --border: #e3e5ea;
  --border-strong: #cfd3da;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #e8efff;
  --primary-ink: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fef4e6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --shadow-lg: 0 20px 50px -12px rgba(16, 24, 40, .35);
  --sidebar: 240px;
  --tabbar: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214; --surface: #18191c; --surface-2: #212226; --surface-3: #2a2c31;
    --text: #ececef; --text-2: #b9bcc4; --muted: #8b8f99; --border: #2a2c31; --border-strong: #3a3d44;
    --primary: #5b8cff; --primary-2: #7aa2ff; --primary-soft: #1d2740; --primary-ink: #0b1020;
    --danger: #f87171; --danger-soft: #3a1d1f; --ok: #4ade80; --ok-soft: #15291d; --warn: #fbbf24; --warn-soft: #33270f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

/* base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .95rem; margin: 0 0 12px; }
h4 { font-size: .85rem; margin: 18px 0 8px; color: var(--text-2); }
p { margin: 0 0 8px; }
code, .mono, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.block { display: block; }
.grow { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.hidden, [hidden] { display: none !important; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); }
.icon { flex: 0 0 auto; display: block; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 2px 16px; }
.boot { display: grid; place-items: center; min-height: 60vh; }

/* ---------------------------------------------------------------- shell */
.content { max-width: 1120px; margin: 0 auto; padding: 20px 20px 48px; }
body.logged-in .content { margin-left: var(--sidebar); max-width: calc(1120px + var(--sidebar)); padding-left: 32px; padding-right: 32px; }
.content.loading { opacity: .6; transition: opacity .2s .15s; }
body:not(.logged-in) #shell { display: none; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
  display: flex; flex-direction: column; gap: 16px; padding: 18px 14px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); padding: 2px 8px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; }
.sidebar .btn.block kbd { margin-left: auto; opacity: .7; font-size: .72rem; border: 1px solid rgba(255,255,255,.4); border-radius: 4px; padding: 0 5px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.side-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }
.side-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.who { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.who-name { font-weight: 600; font-size: .9rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }

.tabbar { display: none; }

@media (max-width: 860px) {
  body.logged-in .content { margin-left: 0; padding: 12px 16px calc(var(--tabbar) + var(--safe-bottom) + 88px); }
  .sidebar { display: none; }
  .tabbar {
    display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font: 500 .68rem/1 inherit; background: none; border: 0; padding: 0; cursor: pointer;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--primary); }
  .tab-icon { position: relative; display: grid; place-items: center; }
  .tab-icon .nav-badge { position: absolute; top: -6px; right: -12px; height: 16px; min-width: 16px; font-size: .62rem; padding: 0 4px; }
  .tabbar .tab-primary .tab-icon {
    width: 52px; height: 52px; margin-top: -22px; border-radius: 18px; color: #fff;
    background: linear-gradient(160deg, var(--primary), var(--primary-2)); box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--primary) 70%, transparent);
  }
  .tabbar .tab-primary.active { color: var(--primary); }
  .hide-mobile { display: none !important; }
}
@media (min-width: 861px) { .only-mobile { display: none !important; } }

/* ---------------------------------------------------------------- page head */
.page-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; min-height: 44px; }
.page-title { flex: 1; min-width: 0; }
.page-title h1 { overflow: hidden; text-overflow: ellipsis; }
.page-title .sub { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; }
@media (max-width: 860px) {
  .page-head { margin-bottom: 14px; }
  h1 { font-size: 1.3rem; }
  .page-title h1 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; }
}

/* ---------------------------------------------------------------- buttons */
.btn {
  font: inherit; font-weight: 550; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .12s, border-color .12s, transform .06s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .chip-btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 2px color-mix(in srgb, var(--primary) 40%, transparent); }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 32px; padding: 0 10px; font-size: .85rem; gap: 6px; border-radius: 8px; }
.btn.lg { height: 48px; padding: 0 20px; font-size: 1rem; }
.btn.block { display: flex; width: 100%; }
.btn.icon-only { padding: 0; width: 40px; }
.btn.sm.icon-only { width: 32px; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.btn.on { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.btn.has-badge { position: relative; }
.btn.has-badge::after { content: attr(data-badge); position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--primary); color: var(--primary-ink); font-size: .7rem; display: grid; place-items: center; padding: 0 4px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }

/* ---------------------------------------------------------------- forms */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; min-height: 42px;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--primary); }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
.input-lg { font-size: 1.1rem; font-weight: 600; min-height: 48px; }
@media (max-width: 860px) { input, select, textarea { font-size: 16px; } } /* no iOS zoom */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span:first-child, .field-label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn > input { flex: 1; }
.inline-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; }
.inline-field > span { font-weight: 600; font-size: .9rem; }

/* switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; background: var(--surface-3); border-radius: 13px; transition: background .15s; }
.switch .slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: .95rem; }

/* segmented control */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { white-space: nowrap; border: 0; background: transparent; font: inherit; font-weight: 550; color: var(--text-2); padding: 6px 14px; border-radius: 8px; cursor: pointer; min-height: 34px; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.segmented.wide { display: flex; }
.segmented.wide button { flex: 1; min-width: 0; padding: 6px 4px; }
.labels-layout > * { min-width: 0; }

/* stepper */
.stepper { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; background: var(--surface); }
.stepper b, .stepper .qty-input { min-width: 36px; text-align: center; font-size: 1rem; }
.stepper .qty-input { width: 56px; border: 0; min-height: 30px; padding: 0; box-shadow: none; -moz-appearance: textfield; }
.stepper .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper .btn { border: 0; }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip-scroll { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip, .chip-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 500 .85rem/1 inherit; padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2);
}
.chip-btn { cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.chip-btn:hover { background: var(--surface-2); color: var(--text); }
.chip-btn.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-btn.lg { padding: 10px 14px; font-size: .92rem; }
.chip-btn.xs { padding: 4px 9px; font-size: .78rem; }
.chip-btn.dashed { border-style: dashed; color: var(--muted); background: transparent; }
.chip-btn.removable .icon { opacity: .7; }
.chip-count { font-size: .72rem; opacity: .65; }
.chip-ico { font-size: 1.05rem; line-height: 1; }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chips.parsed .chip { padding: 5px 10px; font-size: .8rem; }
.active-filters { margin-bottom: 10px; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); margin-left: 8px; vertical-align: middle; }
.status-pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.status-pill.ok, .status-pill.info { background: var(--ok-soft); color: var(--ok); }
.status-pill.error { background: var(--danger-soft); color: var(--danger); }
.status-pill.warning, .status-pill.blocked { background: var(--warn-soft); color: var(--warn); }

/* panels */
.panel, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 16px; }
.panel.highlight { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2 > .panel + .panel { margin-top: 0; }
.grid-2 .span-2 { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* alerts */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: .92rem; }
.alert.error { color: var(--danger); background: var(--danger-soft); }
.alert.info { background: var(--primary-soft); color: var(--text); }
.alert.ok { background: var(--ok-soft); color: var(--text); }
.alert .btn { margin-top: 8px; }
.secret { font-family: ui-monospace, monospace; padding: 10px; margin-top: 8px; background: var(--surface); border-radius: 8px; word-break: break-all; user-select: all; border: 1px solid var(--border); }
.code-block { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font: .8rem/1.5 ui-monospace, monospace; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; max-height: 320px; overflow: auto; }

/* ---------------------------------------------------------------- items list */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; color: inherit;
  padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
button.stat { cursor: pointer; }
button.stat:hover { border-color: var(--border-strong); }
.stat b { font-size: 1.4rem; line-height: 1.2; }
.stat b small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat span { color: var(--muted); font-size: .8rem; }
.stat.warn b { color: var(--warn); }
.stat .meter { margin-top: 6px; }
@media (max-width: 860px) {
  .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
  .stat { padding: 8px 10px; }
  .stat b { font-size: 1.1rem; }
  .stat span { font-size: .7rem; }
}

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; position: sticky; top: 0; z-index: 10; padding: 8px 0; background: linear-gradient(var(--bg) 80%, transparent); }
.search-input { position: relative; flex: 1; }
.search-input .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input input { padding-left: 40px; height: 44px; border-radius: 12px; background: var(--surface); }
.result-count { color: var(--muted); font-size: .8rem; margin: 0 2px 8px; min-height: 1em; }

.item-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); transition: opacity .15s; }
.item-list.dim { opacity: .5; }
.item-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .12s, box-shadow .12s, transform .06s;
}
.item-row:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.item-row:active { transform: scale(.995); }
.item-row.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.item-row .thumb { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.item-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-emoji { font-size: 28px; }
.item-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-title .qty { margin-left: 8px; font-size: .78rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 1px 6px; border-radius: 6px; }
.item-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .84rem; color: var(--text-2); min-height: 1.2em; }
.specs { color: var(--text-2); }
.item-meta { display: flex; gap: 10px; align-items: center; font-size: .76rem; color: var(--muted); overflow: hidden; white-space: nowrap; }
.item-meta .loc { display: inline-flex; align-items: center; gap: 3px; overflow: hidden; text-overflow: ellipsis; }
.item-meta .loc.none { color: var(--warn); }
.item-meta .code { font-family: ui-monospace, monospace; }
.item-meta .flag { display: inline-flex; gap: 3px; align-items: center; color: var(--warn); }
.item-row .chev { color: var(--border-strong); }
@media (max-width: 640px) {
  .item-meta .code { display: none; }
  .item-meta .loc { flex: 1 1 auto; min-width: 0; }
  .item-meta .loc, .item-meta .flag { white-space: nowrap; }
  .item-row .chev { display: none; }
  .segmented.wide button { padding: 6px 8px; }
}
.check-dot { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; color: transparent; }
.check-dot.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.ports-line { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.port-pill { font-size: .76rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.ports-line .arrow { color: var(--muted); font-size: .8rem; }
#app > .btn.block { margin-top: 12px; }

.select-bar {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: 20px;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; width: min(640px, calc(100% - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
body.logged-in .select-bar { margin-left: calc(var(--sidebar) / 2); }
.sel-count { font-weight: 650; white-space: nowrap; }
@media (max-width: 860px) {
  .select-bar { bottom: calc(var(--tabbar) + var(--safe-bottom) + 10px); padding-left: 12px; }
  body.logged-in .select-bar { margin-left: 0; }
  .select-bar .btn span { display: none; }
  .select-bar .btn.sm { width: 36px; padding: 0; }
}

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: 6px; }
.empty p { max-width: 380px; margin: 0 auto 16px; }
.onboarding { grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.onboarding h2 { font-size: 1.25rem; margin-bottom: 4px; }
.steps { padding-left: 20px; margin: 12px 0 20px; display: grid; gap: 10px; }
.steps li::marker { color: var(--primary); font-weight: 700; }

/* ---------------------------------------------------------------- item detail */
.detail { display: grid; gap: 24px; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; gap: 16px; } }
.detail-media { position: sticky; top: 16px; }
@media (max-width: 860px) { .detail-media { position: static; } }
.hero { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.hero img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; display: block; }
.hero-empty { width: 100%; height: 100%; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font: 600 .95rem inherit; cursor: pointer; }
.hero-empty:hover { color: var(--primary); }
.hero-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.hero-tools .btn { background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); border-color: transparent; box-shadow: var(--shadow-sm); }
.thumb-strip { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.thumb-btn { flex: 0 0 56px; height: 56px; padding: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; }
.thumb-btn.on { border-color: var(--primary); }
.thumb-btn.add { border: 1px dashed var(--border-strong); background: transparent; }
.thumb-btn.add:hover { color: var(--primary); border-color: var(--primary); }

.detail-info > * + * { margin-top: 16px; }
.facts { display: grid; grid-template-columns: 1fr; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fact { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 56px; border: 0; background: none; font: inherit; color: inherit; text-align: left; width: 100%; }
.fact + .fact { border-top: 1px solid var(--border); }
.fact-label { color: var(--muted); font-size: .85rem; width: 130px; flex: 0 0 auto; }
.fact b { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; flex: 1; min-width: 0; }
.fact-btn { cursor: pointer; }
.fact-btn:hover { background: var(--surface-2); }
.fact-action { color: var(--primary); font-size: .85rem; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.switch-fact { cursor: pointer; justify-content: space-between; }
.switch-fact .fact-label { flex: 1; color: var(--text); font-size: .95rem; }
.fact .stepper { margin-left: auto; }
@media (max-width: 860px) { .fact-label { width: 64px; } }

.port-diagram { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.port-node { flex: 1 1 140px; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); }
.port-node b { color: var(--primary); }
.port-node span { font-size: .8rem; color: var(--text-2); }
.port-link { display: grid; place-items: center; color: var(--muted); font-size: 1.2rem; flex: 0 0 auto; }
.spec-list { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.spec-list > div { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; }
.spec-list dt { color: var(--muted); font-size: .76rem; }
.spec-list dd { margin: 2px 0 0; font-weight: 600; word-break: break-word; }
.label-preview { background: var(--surface-2); border-radius: 10px; padding: 16px; display: grid; place-items: center; margin-bottom: 12px; overflow-x: auto; }
.label-preview img { max-width: 100%; background: #fff; box-shadow: var(--shadow); border-radius: 3px; min-height: 40px; }

.sticky-actions {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: calc(var(--tabbar) + var(--safe-bottom));
  display: flex; gap: 8px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border);
}
.sticky-actions .btn { flex: 1; }

.viewer img { max-width: 100%; max-height: 85vh; display: block; margin: 0 auto; border-radius: 10px; }

/* ---------------------------------------------------------------- item form */
.item-form { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.section-head h2 { font-size: 1rem; }
.section-head p { color: var(--muted); font-size: .84rem; margin: 2px 0 0; }
details.form-section > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
details.form-section > summary::-webkit-details-marker { display: none; }
details.form-section > summary .icon { margin-left: auto; color: var(--muted); transition: transform .15s; }
details.form-section[open] > summary .icon { transform: rotate(180deg); }
details.form-section[open] > summary { margin-bottom: 4px; }

.capture { background: linear-gradient(160deg, var(--primary-soft), var(--surface) 70%); border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border)); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.capture-actions { display: flex; gap: 10px; }
.capture-big {
  flex: 1; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left;
  padding: 14px 16px; border-radius: 14px; border: 0; cursor: pointer; font: inherit;
  background: var(--primary); color: #fff; box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--primary) 80%, transparent);
}
.capture-big .icon { grid-row: span 2; }
.capture-big b { font-size: 1.05rem; }
.capture-big span { font-size: .8rem; opacity: .85; }
.capture-big:hover { background: var(--primary-2); }
.capture-small { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 18px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; font: 500 .8rem inherit; }
.capture-small:hover { color: var(--primary); border-color: var(--primary); }
.quick-text { min-height: 64px; background: var(--surface); }
.capture-photos { display: flex; gap: 8px; flex-wrap: wrap; }
.cap-photo { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: visible; background: var(--surface-2); display: grid; place-items: center; }
.cap-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; cursor: pointer; }
.cap-remove { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); background: var(--text); color: var(--bg); display: grid; place-items: center; cursor: pointer; padding: 0; }
.ai-status { display: flex; gap: 8px; align-items: center; font-size: .88rem; padding: 10px 12px; border-radius: 10px; }
.ai-status.working { background: var(--primary-soft); color: var(--primary); }
.ai-status.done { background: var(--ok-soft); color: var(--ok); }
.ai-status.error { background: var(--danger-soft); color: var(--danger); }

.ports-edit { display: flex; flex-direction: column; gap: 8px; }
.ports-edit:empty { display: none; }
.port-edit { display: grid; grid-template-columns: 28px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.port-num { width: 26px; height: 26px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
@media (max-width: 640px) {
  .port-edit { grid-template-columns: 26px 1fr auto; }
  .port-edit .plabel { grid-column: 2; }
  .port-edit .gender { grid-column: 2; }
  .port-edit .btn { grid-row: 1; grid-column: 3; }
}
.attr-edit { display: flex; flex-direction: column; }
.attr-row { display: grid; grid-template-columns: minmax(110px, 180px) minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-top: 1px solid var(--border); }
.attr-row:first-child { border-top: 0; padding-top: 0; }
.attr-name { font-weight: 600; font-size: .9rem; padding-top: 10px; }
.attr-value { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.value-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.value-chips:empty { display: none; }
.new-flag { font-size: .65rem; font-weight: 700; color: var(--warn); background: var(--warn-soft); padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: middle; }
.unit-input { position: relative; }
.unit-input span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.unit-input input { padding-right: 56px; }
.add-attr { color: var(--primary); font-weight: 600; border-style: dashed; }
@media (max-width: 640px) {
  .attr-row { grid-template-columns: 1fr auto; gap: 6px 8px; }
  .attr-name { padding-top: 0; }
  .attr-value { grid-column: 1 / -1; grid-row: 2; }
}
.form-footer {
  position: sticky; bottom: 0; z-index: 15; display: flex; gap: 8px; align-items: center;
  padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%);
}
@media (max-width: 860px) {
  .form-footer { bottom: calc(var(--tabbar) + var(--safe-bottom)); margin: 0 -16px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
  .form-footer .btn.ghost { display: none; }
  .form-footer .btn:not(.ghost) { flex: 1; }
  .form-footer .grow { display: none; }
}

/* ---------------------------------------------------------------- dialogs */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 16, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.modal-bg.closing { animation: fade .15s ease-in reverse forwards; }
.modal { background: var(--surface); border-radius: 18px; padding: 20px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
.modal.sm { max-width: 440px; }
.modal.lg { max-width: 920px; }
.modal.full { max-width: 1200px; background: transparent; box-shadow: none; padding: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
@media (max-width: 640px) {
  .modal-bg.as-sheet, .modal-bg { place-items: end stretch; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; padding: 18px 16px calc(16px + var(--safe-bottom)); animation: slideup .22s cubic-bezier(.2, .9, .3, 1); }
  .modal.full { border-radius: 0; }
  @keyframes slideup { from { transform: translateY(40%); opacity: 0; } }
}
.dialog h2 { font-size: 1.15rem; }
.dialog > p { margin-top: 6px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px -6px 4px 0; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.dialog-actions.between { justify-content: space-between; align-items: center; }
@media (max-width: 640px) { .dialog-actions .btn { flex: 1; height: 46px; } }
.sheet-menu { display: flex; flex-direction: column; margin: -6px -4px; }
.sheet-title { font-weight: 600; color: var(--muted); font-size: .85rem; padding: 4px 12px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-item { display: flex; align-items: center; gap: 14px; padding: 13px 12px; border: 0; background: none; font: 500 1rem inherit; color: var(--text); border-radius: 12px; cursor: pointer; text-align: left; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item .icon { color: var(--text-2); }
.sheet-item.danger, .sheet-item.danger .icon { color: var(--danger); }
.sheet-item.cancel { justify-content: center; margin-top: 6px; background: var(--surface-2); font-weight: 600; }
.loc-pick-list { display: flex; flex-direction: column; max-height: 50vh; overflow: auto; margin: 0 -6px; }
.loc-pick { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; border-radius: 10px; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.loc-pick:hover, .loc-pick.active { background: var(--surface-2); }
.loc-pick .icon { color: var(--muted); }
.loc-pick .count { margin-left: auto; font-size: .78rem; color: var(--muted); }
.loc-pick.new { color: var(--primary); font-weight: 600; }
.loc-pick.new .icon { color: var(--primary); }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 200;
  display: flex; align-items: center; gap: 14px; max-width: min(92vw, 520px);
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500;
  animation: pop .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.ok::before { content: "✓"; font-weight: 800; color: var(--ok); }
.toast-action { background: none; border: 0; color: var(--primary-2); font: 700 .9rem inherit; cursor: pointer; padding: 0; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .toast-action { color: var(--primary); } }
@media (max-width: 860px) { .toast { bottom: calc(var(--tabbar) + var(--safe-bottom) + 16px); } }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; flex: 0 0 auto; }
.boot .spinner { width: 28px; height: 28px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- auth */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, var(--primary-soft), transparent); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.auth-card.card h1 { margin-bottom: 12px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand img { border-radius: 12px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-card form .row { margin-top: 16px; }

/* ---------------------------------------------------------------- locations */
.loc-tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.loc-row { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px calc(8px + var(--depth) * 22px); border-top: 1px solid var(--border); }
.loc-row:first-child { border-top: 0; }
.loc-row:hover { background: var(--surface-2); }
.twisty, .twisty-space { width: 28px; height: 28px; flex: 0 0 28px; }
.twisty { border: 0; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; display: grid; place-items: center; transition: transform .15s; }
.twisty.closed { transform: rotate(-90deg); }
.loc-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: var(--text); padding: 6px 4px; }
.loc-main:hover { text-decoration: none; }
.loc-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: 0 0 auto; }
.loc-icon.box { background: var(--primary-soft); color: var(--primary); }
.loc-name { display: flex; flex-direction: column; min-width: 0; }
.loc-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-pill { margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 2px 10px; border-radius: 999px; }
.loc-row:hover .count-pill { background: var(--surface); }
.queued { color: var(--primary); }

/* ---------------------------------------------------------------- scan */
.scan-banner { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: .9rem; display: flex; align-items: center; gap: 6px; }
.scan-banner span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.scan-banner.active { background: var(--ok-soft); color: var(--text); }
.scanner { position: relative; max-width: 560px; margin: 0 0 12px; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 28% 12%; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); border: 3px solid rgba(255,255,255,.9); }
.scan-frame::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff3b30; box-shadow: 0 0 10px #ff3b30; animation: scanline 1.8s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-36px); } 50% { transform: translateY(36px); } }
.scan-log { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.scan-entry { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: .9rem; }
.scan-entry.ok .icon { color: var(--ok); }
.scan-entry.warn .icon { color: var(--warn); }

/* ---------------------------------------------------------------- image editor */
.toolbar-row { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar-row .btn.primary { margin-left: auto; }
.editor-stage { background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 20px 20px; border-radius: 12px; padding: 12px; display: grid; place-items: center; }
.editor { position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none; cursor: crosshair; }
.editor img { max-width: 100%; max-height: 60vh; display: block; }
.editor .crop { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.5); pointer-events: none; }

/* ---------------------------------------------------------------- labels */
.labels-layout { display: grid; gap: 16px; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; }
.labels-layout > .panel + .panel { margin-top: 0; }
@media (max-width: 860px) { .labels-layout { grid-template-columns: 1fr; } }
.print-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.howto { margin-top: 16px; font-size: .86rem; color: var(--text-2); }
.howto summary { cursor: pointer; font-weight: 600; color: var(--text); }
.howto ol { padding-left: 18px; margin: 10px 0 0; display: grid; gap: 6px; }
.tape-preview { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; max-width: 100%; overflow-x: auto; padding-bottom: 4px; }
.tape-item { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.tape-item img { background: #fff; max-width: calc(100% - 40px); border-radius: 2px; box-shadow: var(--shadow); }
/* show tape labels at ~2.5x so they are readable on screen */
.tape-item.tape img { height: auto; }
.tape-item.tape-6 img { height: 36px; } .tape-item.tape-9 img { height: 54px; } .tape-item.tape-12 img { height: 72px; } .tape-item.tape-18 img { height: 110px; } .tape-item.tape-24 img { height: 126px; }
/* same scale for every tape label (never squeeze long labels – scroll instead) */
.tape-item.tape img { max-width: none; width: auto; flex: none; }
.tape-item.tape img { padding: 4px 0; border-radius: 4px; outline: 1px solid var(--border); }

/* ---------------------------------------------------------------- tables, lists, admin */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 550; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.list { display: flex; flex-direction: column; margin-bottom: 12px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: 0; }
.list-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); flex: 0 0 auto; }
.list-icon.emoji { font-size: 1.2rem; }
.con-group h4 { margin-top: 14px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.filter-row select { width: auto; }
.filter-row input { flex: 1 1 200px; width: auto; }
.table-wrap { overflow-x: auto; margin: 8px -4px 0; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.log-table td { font-size: .82rem; }
.log-debug { color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 110px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.bars .b { flex: 1; background: var(--primary); min-height: 2px; border-radius: 3px 3px 0 0; opacity: .85; }
.bars .b:hover { opacity: 1; }
.bars .b.err { background: var(--danger); }
.meter { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.meter > div { height: 100%; background: var(--primary); border-radius: 3px; }
.meter.hot > div { background: var(--danger); }

/* ---------------------------------------------------------------- printing */
#print-root { display: none; }
@media print {
  @page { margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .print-page { display: flex; align-items: center; justify-content: center; overflow: hidden; page-break-after: always; break-after: page; }
  #print-root .print-page:last-child { page-break-after: auto; break-after: auto; }
  #print-root svg { display: block; flex: 0 0 auto; }
}

/* AI model pool */
.pool-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pool-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) 76px 76px auto; gap: 12px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.pool-row:first-child { border-top: 0; }
.pool-row.off .pool-main { opacity: .55; }
.pool-order { display: flex; flex-direction: column; }
.pool-order .btn:first-child .icon { transform: rotate(180deg); }
.pool-order .btn { height: 22px; width: 28px; }
.pool-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pool-main b { overflow: hidden; text-overflow: ellipsis; }
.pool-prio { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-2); font-size: .72rem; font-weight: 700; margin-right: 8px; color: var(--text-2); }
.pool-usage { display: grid; grid-template-columns: auto 80px auto 80px; gap: 4px 8px; align-items: center; color: var(--muted); }
.pool-field { display: flex; flex-direction: column; gap: 2px; font-size: .7rem; font-weight: 700; color: var(--muted); }
.pool-num { min-height: 34px; padding: 4px 8px; text-align: right; }
.remote-list { max-height: 55vh; overflow: auto; }
.remote-model { cursor: pointer; }
@media (max-width: 640px) {
  .pool-row { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "order main main switch" "order rpm rpd del"; gap: 8px 10px; }
  .pool-order { grid-area: order; }
  .pool-main { grid-area: main; }
  .pool-switch { grid-area: switch; }
  .f-rpm { grid-area: rpm; } .f-rpd { grid-area: rpd; }
  .pool-del { grid-area: del; align-self: end; }
  .pool-usage { grid-template-columns: auto minmax(40px, 1fr); }
  .pool-main .muted.small { display: none; }
}

/* capture photos: primary star */
.cap-photo.primary img { outline: 3px solid var(--primary); outline-offset: 1px; }
.cap-star { position: absolute; left: -7px; bottom: -7px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; box-shadow: var(--shadow-sm); }
.cap-photo.primary .cap-star { background: var(--primary); color: #fff; }
.strip-hint { margin: 0; }
.ai-status.waiting { background: var(--surface); border: 1px dashed color-mix(in srgb, var(--primary) 50%, var(--border)); color: var(--text-2); }
.ai-status .btn { flex: 0 0 auto; }

/* ports: plugs → sockets */
.port-edit { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.ports-edit.with-roles .port-edit { grid-template-columns: minmax(0, 1fr) auto 110px auto; }
.ports-edit:not(.with-roles) .prole { display: none; }
.gender-seg button { padding: 6px 12px; }
.port-pill.socket { background: var(--surface-2); color: var(--text-2); border: 1px dashed var(--border-strong); }
.port-diagram.split { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
.port-col { display: flex; flex-direction: column; gap: 8px; }
.port-col-title { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.port-node.socket { background: var(--surface-2); border: 1px dashed var(--border-strong); }
.port-node.socket b { color: var(--text); }
@media (max-width: 640px) {
  .port-edit, .ports-edit.with-roles .port-edit { grid-template-columns: minmax(0, 1fr) auto; }
  .port-edit .connector { grid-column: 1 / -1; }
  .port-edit .gender-seg { grid-column: 1; justify-self: start; }
  .ports-edit.with-roles .port-edit .prole { grid-column: 1; grid-row: 3; width: auto; }
  .port-edit > .btn, .port-edit > span:last-child { grid-column: 2; grid-row: 2; }
  .port-edit { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
}
.port-col .port-node { flex: 0 0 auto; }
.port-diagram.split { align-items: start; }
.port-diagram.split .port-link { align-self: center; }

/* ports v3: modes, groups, counts */
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.port-mode button { font-size: .82rem; }
.ports-wrap { display: flex; flex-direction: column; gap: 10px; }
.port-rows { display: flex; flex-direction: column; gap: 8px; }
.port-rows:empty { display: none; }
.port-edit, .ports-edit.with-roles .port-edit { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; padding: 0; border: 0; }
.count-stepper { padding: 2px; gap: 0; }
.count-stepper .btn.sm { width: 28px; height: 28px; }
.count-stepper .cnt { min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.quick-conn { padding-bottom: 2px; }
.port-io { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: start; }
.port-group { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.port-group-head { display: flex; flex-direction: column; gap: 0; }
.port-group .port-edit { grid-template-columns: minmax(0, 1fr) auto; }
.port-group .port-edit .connector { grid-column: 1 / -1; }
.port-group .port-edit { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.port-io-arrow { align-self: center; font-size: 1.4rem; color: var(--muted); }
.port-hint { margin: 0; }
@media (max-width: 860px) {
  .port-io { grid-template-columns: 1fr; }
  .port-io-arrow { justify-self: center; transform: rotate(90deg); line-height: 1; }
}
@media (max-width: 640px) {
  .port-edit, .ports-edit.with-roles .port-edit { grid-template-columns: minmax(0, 1fr) auto auto; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .port-edit .connector { grid-column: 1 / -1; }
  .port-edit .gender-seg { grid-column: 1; }
  .port-edit > .btn { grid-column: auto; grid-row: auto; }
  .port-group .port-edit { grid-template-columns: minmax(0, 1fr) auto auto; }
}

.port-count { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 6px; background: var(--primary); color: var(--primary-ink); font-size: .8rem; }
@media (max-width: 640px) { .port-diagram.split { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; } .port-node { padding: 10px; } }
/* port rows: always a wrapping flex row → connector on its own line on small screens */
.port-edit, .ports-edit.with-roles .port-edit, .port-group .port-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.port-edit .connector { flex: 1 1 220px; min-width: 0; }
.port-group .port-edit .connector, .port-edit .connector:only-child { flex-basis: 100%; }
.port-edit .count-stepper { margin-left: auto; }
.port-edit > .btn { flex: 0 0 auto; }
@media (max-width: 640px) { .port-edit .connector { flex-basis: 100%; } }
/* remove button next to the connector field, Stecker/Buchse + count on the second line */
.port-group .port-edit .connector, .port-edit .connector { order: 0; flex: 1 1 calc(100% - 48px); }
.port-edit > .btn { order: 1; }
.port-edit .gender-seg { order: 2; }
.port-edit .count-stepper { order: 3; }
@media (min-width: 861px) { .ports-wrap > .port-rows .port-edit .connector { flex: 1 1 200px; } .ports-wrap > .port-rows .port-edit > .btn { order: 4; } }

.cable-opt { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; border-top: 1px solid var(--border); }

/* checkout / activity */
.item-meta .out-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stat.out b { color: var(--primary); }
.out-fact { flex-wrap: wrap; }
.out-fact > b { flex: 1; min-width: min-content; } /* never shrink below the longest word (was overlapped by the button on phones) */
.out-fact > .btn { margin-left: auto; }
.out-fact.is-out { background: var(--primary-soft); }
.out-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.out-info b { display: inline-flex; gap: 6px; align-items: center; color: var(--primary); }
.checkout-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding: 12px; border-radius: 12px; background: var(--primary-soft); }
.scan-banner.out { background: var(--primary-soft); }
.scan-entry.out .icon { color: var(--primary); }
.scan-entry .block { display: block; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; gap: 12px; padding: 6px 0; }
.tl-icon { position: relative; z-index: 1; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); border: 2px solid var(--surface); }
.tl-checkout .tl-icon { background: var(--primary); color: #fff; }
.tl-checkin .tl-icon { background: var(--ok-soft); color: var(--ok); }
.tl-moved .tl-icon { background: var(--primary-soft); color: var(--primary); }
.tl-body { min-width: 0; padding-top: 3px; }
.tl-note { font-style: italic; color: var(--text-2); }
@media (max-width: 860px) { .stat-row { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); } }
.scan-banner > span { display: block; }
.scan-banner .icon { display: inline-block; vertical-align: -3px; margin-right: 4px; }
@media (max-width: 860px) {
  .fact-label { width: 84px; font-size: .8rem; }
  .out-fact.is-out { align-items: flex-start; }
  .out-fact.is-out .out-info { flex-basis: calc(100% - 100px); }
  .out-fact.is-out > .row { flex-basis: 100%; justify-content: flex-end; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); }
  .stat span { font-size: .66rem; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 640px) { .segmented.wide button { font-size: .86rem; } }

/* print list: per-label layout */
.tape-entry { display: grid; gap: 4px; max-width: 100%; }
.tape-entry-bar { display: flex; align-items: center; gap: 4px; }
.label-style { font: inherit; font-size: .82rem; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); max-width: 220px; }
.label-style.set { color: var(--text); border-color: var(--primary); font-weight: 600; }

/* label state: angebracht / fehlt noch / bewusst keins */
.label-fact { justify-content: space-between; flex-wrap: wrap; }
.label-fact .fact-label { flex: 1; color: var(--text); font-size: .95rem; }
.label-fact-body { display: grid; justify-items: end; gap: 4px; }
.label-status button { padding: 6px 10px; }
.label-reason { font-size: .8rem; text-align: right; }
@media (max-width: 520px) { .label-fact-body { justify-items: stretch; width: 100%; min-width: 0; } .label-status { display: flex; min-width: 0; } .label-status button { flex: 1 1 0; min-width: 0; padding: 6px 4px; font-size: .84rem; white-space: normal; line-height: 1.15; } .label-reason { text-align: left; } }

/* box size & note */
.loc-info { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 2px; }
.size-pill { flex: none; font-size: .7rem; font-weight: 650; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.size-pill.size-xs, .size-pill.size-s { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.size-pill.size-m { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.size-pill.size-l { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.loc-note { display: inline-flex; align-items: center; gap: 4px; min-width: 0; font-size: .78rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-note .icon { flex: none; opacity: .7; }
.box-info { display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px; margin: 4px 0 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.box-info-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.box-info-main b { display: inline-flex; align-items: center; gap: 6px; }
.box-note { margin: 6px 0 0; white-space: pre-wrap; font-size: .9rem; }
.dialog textarea { width: 100%; font: inherit; }

/* USB cable tester */
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--primary); font-weight: 600; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.ct-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .85rem; color: var(--muted); padding: 2px 4px; }
.ct-hint .linkish { font-size: .85rem; }
.ct-result { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ct-class { display: inline-block; font-weight: 700; font-size: .85rem; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); }
.ct-class.ct-power { background: var(--warn-soft); color: var(--warn); }
.ct-class.ct-usb2 { background: var(--primary-soft); color: var(--primary); }
.ct-class.ct-usb3, .ct-class.ct-full { background: var(--ok-soft); color: var(--ok); }
.ct-class.ct-defect { background: var(--danger-soft); color: var(--danger); }
.ct-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.ct-chip { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }
.ct-chip.on { color: var(--text); border-color: var(--border-strong); }
.ct-chip.on .icon { color: var(--ok); }
.ct-warn { display: flex; gap: 6px; align-items: center; color: var(--danger); font-size: .85rem; margin: 8px 0 0; }
.ct-mini { display: inline-flex; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); }
.ct-board { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; padding: 12px; border-radius: 12px; background: #15171a; color: #e8e8e8; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; }
.ct-head { font-weight: 700; opacity: .7; text-align: center; margin-bottom: 4px; }
.ct-col { display: grid; gap: 3px; }
.ct-row { display: grid; align-items: center; gap: 6px; }
.ct-row.b { grid-template-columns: 1.6em 1fr auto; }
.ct-row.a { grid-template-columns: auto 1fr 1.6em; }
.ct-row.a .ct-sig { text-align: right; }
.ct-num { opacity: .55; text-align: center; }
.ct-led { width: 26px; height: 22px; border-radius: 5px; border: 1px solid #444; background: #2a2d31; cursor: pointer; padding: 0; }
.ct-led.on { background: #ff9d1c; border-color: #ffbe5c; box-shadow: 0 0 8px #ff9d1c; }
.ct-extra { grid-column: 1 / -1; display: flex; gap: 18px; justify-content: center; padding-top: 6px; }
.ct-extra label { display: inline-flex; align-items: center; gap: 6px; }
.ct-summary { display: grid; gap: 8px; }
.ct-ports, .ct-filter { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
