:root {
  --bg: #f4f6f9; --surface: #fff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #ea580c; --accent-soft: #ffedd5; --good: #15803d; --bar: #fb923c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --surface: #131c2e; --text: #e2e8f0; --muted: #94a3b8; --line: #23304a;
          --accent: #fb923c; --accent-soft: #3b2412; --good: #4ade80; --bar: #f97316; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); padding-bottom: env(safe-area-inset-bottom); }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase;
     letter-spacing: .03em; }
.card h2 + div + h2 { margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
main { padding: 0 16px 24px; max-width: 1200px; margin: 0 auto; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px;
       background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar { padding: 12px 16px 4px; max-width: 1200px; margin: 0 auto; display: grid; gap: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips button, .tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap; font: inherit; font-size: 13px; cursor: pointer; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dates { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dates input { flex: 1; min-width: 0; }
input, select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
                background: var(--surface); color: var(--text); width: 100%; }
.dates input[type=date] { width: auto; }
.active { display: flex; gap: 6px; flex-wrap: wrap; }
.active span { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 3px 10px;
               font-size: 12px; cursor: pointer; }
.active span::after { content: " ×"; color: var(--muted); }

.tabs { display: flex; gap: 6px; padding: 8px 16px; max-width: 1200px; margin: 0 auto; overflow-x: auto; }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px;
       padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn b { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 12px; }
.btn b:empty { display: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 12px; }
.chart { position: relative; height: 220px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
td.n { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
.barcell { position: relative; }
.barcell i { position: absolute; left: 0; bottom: 2px; height: 3px; background: var(--bar); border-radius: 2px; opacity: .7; }

.order { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
         margin-bottom: 8px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.order .val { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--line); margin-right: 4px; }
.tag.online { background: var(--accent-soft); color: var(--accent); }
.tag.sug { border: 1px dashed var(--muted); background: transparent; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 10px; gap: 8px; }

dialog { border: none; border-radius: 16px; padding: 0; width: min(640px, 100vw - 16px); max-height: 90vh;
         background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dlg-head, .dlg-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px;
                       position: sticky; background: var(--surface); z-index: 1; }
.dlg-head { top: 0; border-bottom: 1px solid var(--line); } .dlg-head h2 { margin: 0; }
.dlg-foot { bottom: 0; border-top: 1px solid var(--line); }
#filterBody, #odBody { padding: 8px 16px 16px; }
details { border-bottom: 1px solid var(--line); padding: 8px 0; }
summary { cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; }
summary b { color: var(--accent); font-weight: 600; }
.opts { max-height: 240px; overflow-y: auto; margin-top: 6px; }
.opts label { display: flex; gap: 8px; padding: 5px 2px; font-size: 14px; align-items: center; }
.opts input { width: auto; }
details input[type=search] { margin-top: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin-bottom: 12px; }
.kv span:nth-child(odd) { color: var(--muted); }
.ok { color: var(--good); } .err { color: #dc2626; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px;
              width: min(360px, 100%); display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
