:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f0f3f7; --line: #dfe4eb; --text: #142033; --muted: #5d6b7e;
  --brand: #0f4c81; --brand-2: #1767ad; --brand-ink: #ffffff; --accent: #e8710a;
  --ok: #18794e; --ok-bg: #e5f5ec; --warn: #9a5b00; --warn-bg: #fff3dc; --bad: #b42318; --bad-bg: #fde8e7; --info-bg: #e6f0fb;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171e27; --surface-2: #1d2631; --line: #2a3542; --text: #e6ebf2; --muted: #93a1b3;
    --brand: #4a9be0; --brand-2: #69aee8; --brand-ink: #0b1220; --accent: #f59e42;
    --ok: #4cc38a; --ok-bg: #12291f; --warn: #f0b456; --warn-bg: #2d2412; --bad: #f47067; --bad-bg: #331a19; --info-bg: #142336;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171e27; --surface-2: #1d2631; --line: #2a3542; --text: #e6ebf2; --muted: #93a1b3;
  --brand: #4a9be0; --brand-2: #69aee8; --brand-ink: #0b1220; --accent: #f59e42;
  --ok: #4cc38a; --ok-bg: #12291f; --warn: #f0b456; --warn-bg: #2d2412; --bad: #f47067; --bad-bg: #331a19; --info-bg: #142336;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; } .b { font-weight: 600; }
.r { text-align: right; } .nowrap { white-space: nowrap; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.hide { display: none !important; }

/* layout */
.shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.logo .mark { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; }
.logo .nm { font-weight: 800; letter-spacing: .02em; line-height: 1.1; } .logo .nm small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 9px; color: var(--text); margin: 1px 0; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--info-bg); color: var(--brand); font-weight: 600; }
.nav .ic { width: 20px; text-align: center; }
.nav .cnt { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.main { min-width: 0; padding: 18px 22px 90px; max-width: 1180px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.top .who { font-size: 13px; color: var(--muted); }
.bottom { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 12px 16px 92px; }
  .bottom { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface);
    border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom a { display: flex; flex-direction: column; align-items: center; padding: 7px 2px 6px; font-size: 11px; color: var(--muted); gap: 2px; position: relative; }
  .bottom a .ic { font-size: 19px; line-height: 1; }
  .bottom a.on { color: var(--brand); font-weight: 600; }
  .bottom .cnt { position: absolute; top: 3px; right: 18%; background: var(--accent); color: #fff; border-radius: 99px; font-size: 10px; padding: 0 5px; }
}

/* components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.flat { box-shadow: none; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .g2.stack, .g3.stack { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .row.nw { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; min-height: 40px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.pri:hover { background: var(--brand-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { border-color: transparent; background: transparent; }
label.f { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 4px; }
.in, select.in, textarea.in { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 11px; min-height: 42px; outline: none; }
.in:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea.in { min-height: 64px; resize: vertical; }
.fld { margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.info { background: var(--info-bg); color: var(--brand); border-color: transparent; }
.chip.zero { opacity: .5; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.kpi .v { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; color: var(--text); box-shadow: var(--shadow); }
.tile .ic { font-size: 24px; } .tile .t { font-weight: 700; } .tile .s { font-size: 12px; color: var(--muted); }
.tile:hover { border-color: var(--brand); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
.tw { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
.list .it { display: block; padding: 11px 2px; border-bottom: 1px solid var(--line); color: var(--text); }
.list .it:last-child { border-bottom: 0; }
.list .it .nm { font-weight: 600; }
.locs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.banner { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); } .banner.info { background: var(--info-bg); } .banner.bad { background: var(--bad-bg); color: var(--bad); } .banner.ok { background: var(--ok-bg); color: var(--ok); }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.qtybig { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.qtybig > div { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.qtybig .n { font-size: 24px; font-weight: 750; } .qtybig .l { font-size: 12px; color: var(--muted); }
.qtybig .unm { background: var(--warn-bg); color: var(--warn); }
.line { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: var(--surface); }
.sum { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 14px; }
.sum .tot { font-size: 20px; font-weight: 800; border-top: 1px solid var(--line); padding-top: 6px; }
.dd { position: relative; }
.dd .menu { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 320px; overflow-y: auto; margin-top: 4px; }
.dd .menu div { padding: 9px 11px; cursor: pointer; border-bottom: 1px solid var(--line); }
.dd .menu div:hover, .dd .menu div.act { background: var(--surface-2); }
.bars { display: flex; gap: 4px; align-items: flex-end; height: 120px; padding-top: 8px; }
.bars .b { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars .b:hover { opacity: 1; }
.barlbl { display: flex; gap: 4px; font-size: 10px; color: var(--muted); } .barlbl span { flex: 1; text-align: center; overflow: hidden; }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 25, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 16px; } }
.modal .x { float: right; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; }
#toast div { background: #182233; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 92vw; }
#toast div.err { background: #b42318; }
video.scan { width: 100%; border-radius: 10px; background: #000; max-height: 50vh; object-fit: cover; }
.photo-prev { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); }
.login { max-width: 380px; margin: 9vh auto; padding: 0 16px; }
.login .logo { justify-content: center; padding-bottom: 22px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }
.st-ok { color: var(--ok); } .st-bad { color: var(--bad); } .st-warn { color: var(--warn); }
details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
pre.xml { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 10px; border-radius: 8px; max-height: 300px; overflow: auto; font-size: 11px; }
@media print { .side, .bottom, .top .acts { display: none !important; } .main { padding: 0; } }
.savebar { position: sticky; bottom: 10px; z-index: 5; }
@media (max-width: 860px) { .savebar { bottom: 70px; } }
