:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface2: #eef0f4; --text: #17181c; --muted: #676b76;
  --border: #e2e4ea; --accent: #3a5bd9; --accent-ink: #fff; --ok: #138a4c; --warn: #b26a00; --bad: #c62828;
  --acc-hermes: #d62976; --acc-retro: #1f8a70; --acc-other: #7a5af8;
  --radius: 12px; --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 8px 24px rgb(0 0 0 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111215; --surface: #1a1b20; --surface2: #24262d; --text: #ececf1; --muted: #9a9ca8;
    --border: #2d2f37; --accent: #7b96ff; --accent-ink: #0d0f17; --ok: #3ccf82; --warn: #f0a640; --bad: #ff6b6b;
    --acc-hermes: #f05c9c; --acc-retro: #3cc49c; --acc-other: #a48bff;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h2 { font-size: 1.15rem; margin: 0; } h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .45rem .85rem; border-radius: 9px;
  font: inherit; font-weight: 560; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: .28rem .6rem; font-size: .85rem; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: progress; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; flex-wrap: wrap;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; display: flex; align-items: center; gap: .4rem; }
.logo { color: var(--accent); font-size: 1.2rem; }
.tabs { display: flex; gap: .2rem; overflow-x: auto; }
.tabs a { color: var(--muted); text-decoration: none; padding: .38rem .7rem; border-radius: 8px; font-weight: 560; white-space: nowrap; }
.tabs a.on { color: var(--text); background: var(--surface2); }
.top-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; }

main { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.4rem 0 .7rem; flex-wrap: wrap; }
.section-head:first-child { margin-top: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.grid { display: grid; gap: .8rem; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi .label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 1.55rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .split { display: flex; gap: .8rem; margin-top: .35rem; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }
.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }

.acc { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 650; padding: .08rem .45rem; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); white-space: nowrap; }
.acc::before { content: ""; width: .5rem; height: .5rem; border-radius: 99px; background: var(--c); }
.acc.hermes { --c: var(--acc-hermes); } .acc.retro { --c: var(--acc-retro); } .acc.other { --c: var(--acc-other); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 99px; background: var(--c); margin-right: .3rem; }

.pill { font-size: .74rem; font-weight: 600; padding: .08rem .45rem; border-radius: 6px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.pill.info { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .42rem .6rem; }
input[type=search] { min-width: 240px; }
input.qty { width: 5.5rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .65rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 650; background: var(--surface2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.thumb { width: 42px; height: 42px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--border); }
.title-cell { max-width: 420px; }
.title-cell a { color: var(--text); text-decoration: none; font-weight: 550; }
.title-cell a:hover { text-decoration: underline; }
.sub { font-size: .78rem; color: var(--muted); }

.chart { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); margin-top: .3rem; }
.bars .bar { fill: var(--c); } .bars .bar:hover { opacity: .8; }

.group { padding: .8rem 1rem; }
.group + .group { margin-top: .7rem; }
.group-head { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.group-head .name { font-weight: 650; flex: 1; min-width: 200px; }
.group-items { margin-top: .6rem; display: grid; gap: .35rem; }
.gi { display: flex; align-items: center; gap: .6rem; font-size: .88rem; }
.gi .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mismatch { color: var(--warn); font-weight: 650; }
.sugg { display: grid; grid-template-columns: 1fr 1fr auto; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.sugg:last-child { border-bottom: 0; }
@media (max-width: 760px) { .sugg { grid-template-columns: 1fr; } }

.selbar { position: sticky; bottom: 1rem; margin-top: .8rem; display: flex; gap: .6rem; align-items: center; justify-content: center; }
.selbar .card { display: flex; gap: .7rem; align-items: center; padding: .55rem .9rem; }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: .55rem .95rem; border-radius: 10px; font-weight: 550; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.order-items { display: grid; gap: .2rem; }
.log-row { font-size: .85rem; }
.lvl-error { color: var(--bad); } .lvl-warn { color: var(--warn); }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .6rem; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 1.6rem;
  width: min(340px, 100%); display: grid; gap: .9rem; }
.login-card label { display: grid; gap: .3rem; font-weight: 560; font-size: .9rem; }
.login-card .err { color: var(--bad); margin: 0; min-height: 1.2em; font-size: .9rem; }
