[hidden] { display: none !important; }
:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --text: #1d2420;
  --muted: #66706a;
  --line: #e2e6e2;
  --brand: #2f5d3a;
  --brand-2: #c2185b;
  --brand-soft: #e8f0ea;
  --ok: #2e7d32;
  --warn: #b26a00;
  --err: #c62828;
  --radius: 10px;
  --series-prev: #b9c2bc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614; --panel: #1b201d; --text: #e6ebe7; --muted: #9aa49e; --line: #2c332e;
    --brand: #6fbf7f; --brand-2: #f06292; --brand-soft: #1f2d23; --series-prev: #4f5a53;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 800; font-size: 19px; padding: 4px 10px 2px; color: var(--brand); }
.brand span { color: var(--brand-2); }
.company { padding: 0 10px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--brand-soft); }
.nav a.active { background: var(--brand); color: #fff; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 4px; }
.main { padding: 24px; max-width: 1200px; width: 100%; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .main { padding: 16px; }
}

/* Components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
textarea { min-height: 90px; }
.field { margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.check input { width: auto; }

button, .btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--brand); }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover { filter: brightness(1.08); }
.danger { color: var(--err); }
.sm { padding: 5px 9px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--brand-soft); }

.badge { display: inline-block; white-space: nowrap; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: #fff3e0; color: var(--warn); }
.badge.err { background: #ffebee; color: var(--err); }
.badge.gray { background: var(--line); color: var(--muted); }
.badge.pink { background: #fce4ec; color: var(--brand-2); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--brand); }

/* Scanner */
.scan-input { font-size: 22px; padding: 14px; font-family: ui-monospace, monospace; letter-spacing: 1px; }
.scan-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.scan-modes button { justify-content: center; padding: 12px 8px; white-space: normal; text-align: center; line-height: 1.2; }
.scan-modes button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
#reader { max-width: 420px; margin-top: 10px; }
.scan-log .item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.scan-log .ok { color: var(--ok); }
.scan-log .err { color: var(--err); }
.flash-ok { animation: fo .6s; }
.flash-err { animation: fe .6s; }
@keyframes fo { from { background: #c8e6c9; } }
@keyframes fe { from { background: #ffcdd2; } }

pre.dispo { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 14px; max-height: 420px; overflow: auto; }

/* Toast & modal */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; max-width: 90vw; }
.toast.err { background: var(--err); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal-card { background: var(--panel); border-radius: 12px; padding: 20px; width: 100%; max-width: 620px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; }
.login .brand { font-size: 28px; text-align: center; padding: 0 0 4px; }

.lines-table input, .lines-table select { padding: 6px 8px; }
.empty { text-align: center; padding: 30px; color: var(--muted); }

/* Charts */
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.bars { display: flex; align-items: stretch; gap: 4px; height: 240px; overflow-x: auto; padding-top: 8px; }
.bar-col { flex: 1 0 22px; display: flex; flex-direction: column; cursor: default; }
.bar-col:hover .bar { filter: brightness(1.1); }
.bar-stack { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--line); }
.bar { flex: 1; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 0; }
.bar-label { font-size: 11px; color: var(--muted); text-align: center; padding-top: 4px; white-space: nowrap; height: 20px; }
.chart-tip { position: absolute; z-index: 60; background: #1d2420; color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12px; white-space: pre-line; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.nowrap { white-space: nowrap; }
