:root {
  --bg: #0b1118;
  --bg-2: #121a24;
  --bg-3: #182331;
  --line: #243044;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #2aabee;
  --gold: #f5c542;
  --green: #3dd68c;
  --red: #ff6b6b;
  --purple: #a78bfa;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 20% -10%, #1a3a5c 0%, transparent 50%), var(--bg);
}
.login-card {
  width: 360px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card input, .field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.field textarea { min-height: 120px; resize: vertical; }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}
.brand { font-weight: 700; font-size: 18px; padding: 8px 12px 18px; }
.brand span { color: var(--gold); }
.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.nav button.active, .nav button:hover { background: var(--bg-3); color: var(--text); }
.main { padding: 22px 26px 40px; overflow: auto; }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.top h2 { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
}
.btn.gold { background: var(--gold); color: #1a1404; }
.btn.ghost { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); }
.btn.red { background: var(--red); }
.btn.green { background: var(--green); color: #062214; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: default; }

.pills { display: flex; gap: 8px; margin-bottom: 16px; }
.pill {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.pill.active { color: #fff; border-color: var(--accent); background: #16324a; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 24px; font-weight: 700; margin-top: 6px; }
.card .s { color: var(--gold); font-size: 12px; margin-top: 4px; }

.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { margin-bottom: 10px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar button { background: var(--bg-3); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 8px; cursor: pointer; }
.preview {
  background: #1d2b3a;
  border-radius: 14px;
  padding: 12px;
  min-height: 80px;
  white-space: pre-wrap;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.ok { color: var(--green); }
.warn { color: var(--gold); }
.err { color: var(--red); }
.link { color: var(--accent); word-break: break-all; }
.funnel { display: flex; gap: 8px; flex-wrap: wrap; }
.funnel div { flex: 1; min-width: 110px; background: var(--bg-3); border-radius: 12px; padding: 10px; }
.funnel .k { color: var(--muted); font-size: 12px; }
.color-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; vertical-align: middle; margin-right: 6px; }
html.webapp body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
html.webapp .app { grid-template-columns: 1fr; min-height: 100dvh; }
html.webapp .side {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  border-right: 0;
  border-bottom: 1px solid var(--line);
  padding-top: 10px;
}
html.webapp .nav { display: flex; }
html.webapp .nav button { white-space: nowrap; width: auto; }
html.webapp .main { padding: 14px 12px 28px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: flex; overflow: auto; gap: 8px; }
  .nav { display: flex; }
  .grid2 { grid-template-columns: 1fr; }
}
