:root {
  --bg: #0d0f12; --panel: #161a1f; --panel2: #1d2228; --line: #2a3139; --text: #e8ecf0; --muted: #8b95a1;
  --accent: #30C7B5; --accent2: #25a393; --red: #e5614f; --yellow: #e0b341; --green: #4cc16f; --blue: #4aa3ff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3 { font-family: Oswald, Inter, system-ui, sans-serif; letter-spacing: .02em; margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #04211d; font-weight: 600; }
button.danger { border-color: var(--red); color: var(--red); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.login { max-width: 360px; margin: 14vh auto; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.login button { width: 100%; margin-top: 6px; }
.err { color: var(--red); margin-top: 10px; min-height: 20px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px; }
.side .brand { font-family: Oswald, Inter, sans-serif; font-size: 20px; padding: 0 10px; }
.side .brand span { color: var(--accent); }
.menu { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.menu button { border: none; background: none; color: var(--muted); padding: 9px 10px; border-radius: 8px; text-align: left; display: flex; gap: 10px; align-items: center; }
.menu button:hover { color: var(--text); background: var(--panel2); }
.menu button.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.menu .ic { width: 20px; text-align: center; }
.who { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 6px; font-size: 13px; }
main { padding: 22px; max-width: 1180px; width: 100%; min-width: 0; }
.addrow { display: flex; gap: 8px; flex-wrap: wrap; }
.addrow input { flex: 1; min-width: 180px; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; flex-direction: row; align-items: center; padding: 10px; gap: 10px; border-right: none; border-bottom: 1px solid var(--line); z-index: 5; overflow-x: auto; }
  .side .brand { display: none; }
  .menu { flex-direction: row; }
  .menu button { white-space: nowrap; padding: 7px 9px; }
  .menu button.on { box-shadow: inset 0 -2px 0 var(--accent); }
  .who .muted { display: none; }
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.card .v { font-family: Oswald, Inter, sans-serif; font-size: 30px; margin-top: 4px; }
.card .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.box h2 { font-size: 18px; margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .row2 { grid-template-columns: 1fr; } main { padding: 14px; } }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars { display: flex; align-items: flex-end; gap: 2px; width: 100%; justify-content: center; flex: 1; }
.bar { width: 30%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 2px; }
.col .m { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #0b0d10; white-space: nowrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters button.on { border-color: var(--accent); background: var(--panel2); }
.filters input { max-width: 240px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 22px; text-align: center; }

.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; justify-content: flex-end; }
.drawer { width: min(520px, 100%); background: var(--panel); border-left: 1px solid var(--line); padding: 20px; overflow-y: auto; }
.drawer h2 { font-size: 20px; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; margin: 14px 0; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.set label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
code.copy { display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; font-size: 13px; }
.ok { color: var(--green); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent); padding: 10px 18px; border-radius: 10px; z-index: 40; }
