:root {
  --bg:#f5f6f8; --surface:#ffffff; --surface-2:#f0f2f5; --border:#e2e5ea; --text:#1b1f27; --muted:#667085;
  --accent:#4f46e5; --accent-bg:#eef0ff; --good:#15803d; --good-bg:#e7f6ec; --bad:#b42318; --bad-bg:#fdecea; --warn:#b45309; --warn-bg:#fff4dd;
  --bar:#4f46e5; --bar2:#94a3b8; color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg:#0f1218; --surface:#181c25; --surface-2:#202531; --border:#2b3140; --text:#e8eaf0; --muted:#98a2b3;
  --accent:#8b8cf8; --accent-bg:#252a4a; --good:#4ade80; --good-bg:#12301e; --bad:#f87171; --bad-bg:#3a1b1b; --warn:#fbbf24; --warn-bg:#3a2e12; --bar:#8b8cf8; --bar2:#64748b; color-scheme: dark; } }
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--text); font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; }
[hidden] { display:none !important; }
.muted { color:var(--muted); } .err { color:var(--bad); min-height:1.2em; }
.login { min-height:100vh; display:grid; place-items:center; padding:16px; }
.login-card { width:100%; max-width:340px; display:grid; gap:12px; padding:28px; }
.login-card h1 { margin:0; font-size:22px; }
#app { display:grid; grid-template-columns:200px 1fr; min-height:100vh; }
.side { background:var(--surface); border-right:1px solid var(--border); padding:18px 12px; display:flex; flex-direction:column; gap:14px; position:sticky; top:0; height:100vh; }
.brand { font-weight:800; font-size:17px; line-height:1.1; padding:0 8px; } .brand span { color:var(--accent); }
nav { display:grid; gap:2px; flex:1; align-content:start; }
nav button { text-align:left; border:0; background:none; color:var(--text); padding:9px 10px; border-radius:8px; cursor:pointer; font:inherit; }
nav button:hover { background:var(--surface-2); } nav button.on { background:var(--accent-bg); color:var(--accent); font-weight:700; }
main { padding:0 22px 40px; min-width:0; }
.bar { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; padding:18px 0 12px; position:sticky; top:0; background:var(--bg); z-index:5; }
.bar h2 { margin:0; font-size:20px; } .filters { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
select, input[type=date], input[type=text], input[type=number], input[type=password], input[type=search] {
  background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:8px; padding:7px 10px; font:inherit; min-width:0; }
.btn { border:1px solid var(--border); background:var(--surface); color:var(--text); padding:7px 14px; border-radius:8px; cursor:pointer; font:inherit; font-weight:600; }
.btn:hover { background:var(--surface-2); } .btn.primary { background:var(--accent); color:#fff; border-color:var(--accent); } .btn.small { padding:5px 10px; font-size:13px; } .btn.ghost { background:none; }
.card { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:16px; }
.banner { background:var(--warn-bg); color:var(--warn); border:1px solid var(--border); border-radius:10px; padding:10px 14px; margin-bottom:12px; }
.banner.bad { background:var(--bad-bg); color:var(--bad); }
.grid { display:grid; gap:12px; } .kpis { grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); }
.kpi .l { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.04em; } .kpi .v { font-size:24px; font-weight:800; margin-top:2px; } .kpi .s { color:var(--muted); font-size:12px; margin-top:2px; }
.cols2 { grid-template-columns:repeat(auto-fit,minmax(340px,1fr)); }
h3 { margin:0 0 10px; font-size:14px; }
.tablewrap { overflow-x:auto; } table { width:100%; border-collapse:collapse; font-size:13px; }
th { text-align:left; color:var(--muted); font-weight:600; font-size:11px; text-transform:uppercase; letter-spacing:.04em; padding:6px 10px; border-bottom:1px solid var(--border); white-space:nowrap; }
td { padding:7px 10px; border-bottom:1px solid var(--border); white-space:nowrap; } tr:last-child td { border-bottom:0; } td.n, th.n { text-align:right; font-variant-numeric:tabular-nums; }
.pill { display:inline-block; padding:1px 8px; border-radius:99px; font-size:12px; font-weight:600; background:var(--surface-2); }
.pill.delivered { background:var(--good-bg); color:var(--good); } .pill.cancelled,.pill.rto,.pill.returned { background:var(--bad-bg); color:var(--bad); }
.pill.shipped,.pill.ready_to_ship,.pill.pending { background:var(--warn-bg); color:var(--warn); }
.bars { display:grid; gap:6px; } .barrow { display:grid; grid-template-columns:110px 1fr 70px; gap:8px; align-items:center; font-size:12px; }
.barrow .t { height:10px; background:var(--surface-2); border-radius:6px; overflow:hidden; display:flex; } .barrow .t i { display:block; height:100%; }
.legend { display:flex; gap:12px; flex-wrap:wrap; font-size:12px; color:var(--muted); margin:6px 0 0; } .legend b { display:inline-block; width:10px; height:10px; border-radius:2px; margin-right:4px; vertical-align:-1px; }
.drop { border:2px dashed var(--border); border-radius:12px; padding:26px; text-align:center; color:var(--muted); cursor:pointer; }
.drop.over { border-color:var(--accent); background:var(--accent-bg); }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; } .field { display:grid; gap:4px; font-size:12px; color:var(--muted); }
code, pre { background:var(--surface-2); border-radius:6px; font-size:12px; } code { padding:1px 5px; } pre { padding:10px; overflow:auto; }
.ok { color:var(--good); } .bad { color:var(--bad); }
@media (max-width: 820px) { #app { grid-template-columns:1fr; } .side { position:static; height:auto; flex-direction:row; flex-wrap:wrap; align-items:center; }
  nav { display:flex; flex-wrap:wrap; } main { padding:0 14px 30px; } .brand br { display:none; } }

@media print { header, nav, #nav, .btn, #logout, #refresh, .filters, .toolbar { display:none !important } .card { box-shadow:none; border:1px solid #ccc; page-break-inside:avoid } body { background:#fff } }
