:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --border: #e3e6eb;
  --primary: #1d5fd1;
  --primary-text: #ffffff;
  --danger: #c4372b;
  --ok: #1f8a4c;
  --warn-bg: #fff4e0;
  --warn: #9a5b00;
  --row-hover: #f0f4fb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --border: #2c343f;
    --primary: #4c8dff;
    --danger: #ff6b5e;
    --ok: #4cc286;
    --warn-bg: #3a2c12;
    --warn: #f3b553;
    --row-hover: #222a35;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1em; margin: 6px 0; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 12px; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; }
nav { display: flex; gap: 4px; flex: 1; }
nav a, .me a {
  color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 6px;
}
nav a.active { color: var(--text); background: var(--bg); font-weight: 600; }
nav a:hover { color: var(--text); }
.me { display: flex; align-items: center; gap: 8px; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.spacer { flex: 1; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label { display: block; margin-bottom: 10px; }
label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label input, label select, label textarea { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }

.btn {
  font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.name { white-space: normal; min-width: 220px; }
.qty-cell { cursor: pointer; border-radius: 4px; padding: 3px 8px; display: inline-block; min-width: 44px; text-align: right; }
.qty-cell:hover { background: var(--bg); outline: 1px solid var(--border); }
.qty-zero { color: var(--muted); }
.low { background: var(--warn-bg); color: var(--warn); }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.badge {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn); margin-left: 6px;
}
.sku { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--muted); }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 28px; }

dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 22px;
  width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(10, 15, 25, .45); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; font: inherit; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--primary); color: var(--primary-text); }
.current { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

pre.sample { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; font-size: 12.5px; }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 16px; }
  .row2 { grid-template-columns: 1fr; }
}

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tag {
  font-size: 11.5px; padding: 1px 7px; border-radius: 10px;
  border: 1px solid var(--border); color: var(--muted); background: var(--bg);
}
.tag.brand { color: var(--text); font-weight: 550; }
.tag.cond-new { color: var(--ok); border-color: currentColor; background: transparent; }
.tag.cond-used, .tag.cond-open_box, .tag.cond-refurbished { color: var(--primary); border-color: currentColor; background: transparent; }
.tag.cond-for_parts { color: var(--danger); border-color: currentColor; background: transparent; }

.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.lists h2 { margin-top: 0; }
.danger-text { color: var(--danger); }
.small-note { font-size: 12.5px; margin: 2px 0 10px; }

dialog.wide { width: min(760px, calc(100vw - 32px)); }
.photo-col { width: 56px; padding-right: 0; }
.thumb {
  width: 44px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); overflow: hidden; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.none { border-style: dashed; }
.thumb.none:hover { color: var(--primary); border-color: var(--primary); }
.thumb .count {
  position: absolute; right: 2px; bottom: 2px; font-size: 10px; line-height: 1; padding: 2px 4px;
  border-radius: 6px; background: rgba(0, 0, 0, .65); color: #fff;
}
.thumb.on { outline: 2px solid var(--primary); outline-offset: 1px; }
.viewer {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; min-height: 220px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 8px;
}
.viewer img { max-width: 100%; max-height: 52vh; display: block; }
.viewer .empty { padding: 60px 20px; }
.ph-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.ph-actions .spacer { flex: 1; }
.ph-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ph-strip .thumb { width: 64px; height: 64px; }
.drop {
  display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center;
  border: 1.5px dashed var(--border); border-radius: 10px; padding: 16px; cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--row-hover); }
.ok-text { color: var(--ok); }
