:root {
  --bg: #070b16;
  --bg-2: #0b1326;
  --card: #131b2e;
  --card-2: #171f33;
  --line: #2d3449;
  --text: #e8eefc;
  --muted: #9aa3c2;
  --violet: #7c3aed;
  --violet-2: #6d28d9;
  --green: #4edea3;
  --red: #ffb4ab;
  --cyan: #7bd0ff;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Geist, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(124, 58, 237, 0.22), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(0, 165, 114, 0.12), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
.wrap { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.top {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(7, 11, 22, 0.78);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--violet), #00a572);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.brand b { display: block; font-size: 15px; letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav a, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; text-decoration: none; cursor: pointer;
  border-radius: 10px; padding: 9px 14px;
}
.nav a { color: var(--muted); }
.nav a:hover, .nav a.active { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-primary { background: var(--violet); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--violet-2); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(255,180,171,0.3); }

.hero, .page { padding: 28px 0 64px; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -0.03em; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 24px; max-width: 46ch; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2, .card h3 { margin: 0 0 12px; font-size: 1rem; }
.muted { color: var(--muted); }
.kicker { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.stat { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.03em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line);
}
.badge.ok { color: var(--green); border-color: rgba(78,222,163,0.35); }
.badge.warn { color: #fbbf24; border-color: rgba(251,191,36,0.35); }
.badge.bad { color: var(--red); border-color: rgba(255,180,171,0.35); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.url {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: #0b1326; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  width: 100%; background: #0b1326; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(124,58,237,0.45); border-color: var(--violet); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.alert.ok { background: rgba(78,222,163,0.1); color: var(--green); }
.alert.err { background: rgba(147,0,10,0.25); color: var(--red); }

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card { width: min(420px, 100%); }
.public {
  min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center;
}
.public .card { width: min(480px, 100%); }
.qr {
  width: 180px;
  height: 180px;
  background: transparent;
  padding: 0;
  image-rendering: pixelated;
}

.footer { color: var(--muted); font-size: 12px; padding: 0 0 32px; }

.period { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 16px; }
.period label { margin: 0; min-width: 140px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.bars span { flex: 1; min-width: 6px; background: linear-gradient(180deg, #7bd0ff, #7c3aed); border-radius: 4px 4px 0 0; }
.bar-inline { height: 6px; background: rgba(124,58,237,0.25); border-radius: 99px; overflow: hidden; min-width: 64px; }
.bar-inline i { display: block; height: 100%; background: #7c3aed; }

.analytics { margin-top: 40px; }
.analytics h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.03em; }
.analytics-head {
  display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.table-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin: 0 0 14px;
}
.table-toolbar h3 { margin: 0; font-size: 1rem; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
}
.pill:hover, .pill.is-on { color: #fff; background: var(--violet); border-color: var(--violet); }
.pill-date { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.pill-date input { width: auto; padding: 8px 10px; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { min-height: 132px; }
.kpi .stat { font-size: 2rem; }
.kpi .stat-date { font-size: 1.05rem; line-height: 1.35; font-weight: 650; }
.kpi .muted { margin: 6px 0 0; font-size: 13px; }

.peak-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.peak-card { text-align: left; position: relative; overflow: hidden; min-height: 148px; }
.peak-card .stat { font-size: 2.6rem; }
.peak-card.is-top { border-color: rgba(78,222,163,0.45); box-shadow: inset 0 0 0 1px rgba(78,222,163,0.2); }
.peak-card.is-top .kicker { color: var(--green); }
.peak-hours { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.split-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 16px; }
.split-via { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.via-panel { margin-bottom: 16px; }
.via-card .stat { font-size: 2.2rem; }
.via-track { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: #0b1326; }
.via-track i { display: block; min-width: 0; }
.via-track .nfc { background: #00a572; }
.via-track .qr { background: #7c3aed; }
.via-track .unk { background: #3d4560; }

.chart { display: flex; align-items: stretch; gap: 10px; min-height: 200px; }
.chart-y {
  display: flex; flex-direction: column; justify-content: space-between;
  color: var(--muted); font-size: 11px; width: 28px; text-align: right; padding: 18px 0 28px;
}
.chart-plot {
  flex: 1; display: flex; align-items: flex-end; gap: 6px; height: 180px;
  border-bottom: 1px solid var(--line); padding: 0 2px; overflow-x: auto; justify-content: flex-start;
}
.chart-col {
  flex: 0 0 28px; display: flex; flex-direction: column; align-items: center;
  gap: 6px; height: 100%; justify-content: flex-end;
}
.chart-col b {
  display: block; width: 16px; border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #9b7dff, #7c3aed);
}
.chart-col.is-empty b { background: #2a3348; width: 10px; }
.chart-col small { color: var(--muted); font-size: 10px; }
.chart-n { color: var(--muted); font-size: 10px; font-weight: 600; min-height: 14px; }

.week-plot { display: flex; align-items: flex-end; gap: 8px; height: 168px; padding-top: 8px; }
.week-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.week-col b {
  width: 100%; max-width: 28px; border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, #7bd0ff, #006e95);
}
.week-col.is-empty b { background: #2a3348; }
.week-col small { color: var(--muted); font-size: 11px; }

.scan-hero {
  display: grid; grid-template-columns: 1fr 1fr 196px; gap: 16px; align-items: stretch; margin-bottom: 8px;
}
.scan-frame {
  background: linear-gradient(180deg, #00a572, #006e95);
  padding: 12px 12px 10px; border-radius: 16px; text-align: center;
  display: flex; flex-direction: column; justify-content: center;
}
.scan-frame strong { display: block; color: #fff; font-size: 11px; letter-spacing: 0.16em; margin-bottom: 10px; }
.scan-frame img { width: 168px; height: 168px; display: block; margin: 0 auto; background: transparent; }
.scan-frame .btn { margin-top: 10px; width: 100%; background: rgba(0,0,0,0.22); color: #fff; border: 0; }

.rank th, .rank td { padding: 10px 8px; vertical-align: middle; }
.rank th:first-child, .rank td:first-child { width: 28px; color: var(--muted); }
.rank th:nth-child(3), .rank td:nth-child(3),
.rank th:nth-child(4), .rank td:nth-child(4) { white-space: nowrap; }

.plaque-row { display: flex; align-items: center; gap: 12px; }
.plaque-thumb {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover;
  background: #0b1326; border: 1px solid var(--line); flex: 0 0 48px;
}
.plaque-thumb.is-empty { display: inline-block; }
.plaque-block { display: grid; grid-template-columns: minmax(160px, 280px) 1fr; gap: 18px; align-items: center; }
.plaque-shot {
  width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px;
  background: #0b1326; border: 1px solid var(--line); display: block;
}

@media (max-width: 980px) {
  .kpi-row, .peak-grid, .split-2, .split-via, .scan-hero, .plaque-block { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .page table:not(.rank) thead { display: none; }
  .page table:not(.rank),
  .page table:not(.rank) tbody,
  .page table:not(.rank) tr,
  .page table:not(.rank) td { display: block; }
  .page table:not(.rank) td { border: 0; padding: 6px 0; }
  .page table:not(.rank) tr { border-bottom: 1px solid var(--line); padding: 12px 0; }
}
