:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #5b4ce0;
  --accent-text: #ffffff;
  --accent-soft: #ecebfc;
  --ok: #1f8a4c;
  --ok-soft: #e4f4ea;
  --warn: #a15c00;
  --warn-soft: #fbefdc;
  --err: #c0362c;
  --err-soft: #fbe6e4;
  --bar: #8b80ee;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #e8eaed;
    --muted: #9aa1ab;
    --border: #2c3038;
    --accent: #8b80ee;
    --accent-text: #0f0d24;
    --accent-soft: #29254a;
    --ok: #5fc98b;
    --ok-soft: #173123;
    --warn: #f0b45a;
    --warn-soft: #3a2a12;
    --err: #ff8a80;
    --err-soft: #3b1a18;
    --bar: #7a6fe6;
    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, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 12px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }

.nav {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); }
.nav a:hover { background: var(--accent-soft); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .brand { font-weight: 700; margin-right: 12px; }
.nav .spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px;
}
.card.login { max-width: 380px; margin: 60px auto; display: flex; flex-direction: column; gap: 12px; }
.card.login h1 { margin-bottom: 4px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
input, select, button, .button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; min-height: 34px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--err); }
button.link { border: 0; background: none; color: var(--muted); padding: 6px 10px; min-height: 0; }
button.link:hover { color: var(--text); }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }

.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 10px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters select { max-width: 220px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi-v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-l { color: var(--muted); font-size: 12px; }

.chart-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px 4px; margin-bottom: 8px; }
.chart .bar { fill: var(--bar); }
.chart g:hover .bar { fill: var(--accent); }
.chart .val { font-size: 10px; fill: var(--muted); }
.chart .lbl { font-size: 10px; fill: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
td.actions { display: flex; flex-wrap: wrap; gap: 8px; }
td.actions input { width: 150px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); margin: 1px 0; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status.delivered { background: var(--ok-soft); color: var(--ok); }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.failed { background: var(--err-soft); color: var(--err); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--err-soft); color: var(--err); }

@media (max-width: 640px) {
  main { padding: 14px 16px 40px; }
  .filters label, .filters select { width: 100%; max-width: none; }
  .filters button { width: 100%; }
  .nav .brand { width: 100%; }
}
