:root {
  --bg: #0a0e17;
  --surface: #111827;
  --surface-2: #172033;
  --border: #243047;
  --text: #e6eaf2;
  --muted: #93a0b5;
  --brand: #7c8cff;
  --brand-strong: #5b6cff;
  --brand-soft: rgba(124, 140, 255, 0.14);
  --up: #22c55e;
  --up-soft: rgba(34, 197, 94, 0.14);
  --down: #f05252;
  --down-soft: rgba(240, 82, 82, 0.14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
[hidden] { display: none !important; }

.container { width: min(1140px, 100% - 40px); margin-inline: auto; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.85rem; }
.up { color: var(--up); }
.down { color: var(--down); }
.accent { color: var(--brand); }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 14px/1.2 var(--font); cursor: pointer; text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand-strong); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: #fff; }
.btn-danger { background: var(--down-soft); border-color: rgba(240, 82, 82, 0.4); color: #ffb4b4; }
.btn-danger:hover:not(:disabled) { background: var(--down); color: #fff; }
.btn-ok { background: var(--up-soft); border-color: rgba(34, 197, 94, 0.4); color: #a7f3c0; }
.btn-ok:hover:not(:disabled) { background: var(--up); color: #04210f; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- Cards, badges, tables ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.card h3 { font-size: 1.05rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-ok { background: var(--up-soft); color: var(--up); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-err { background: var(--down-soft); color: var(--down); border-color: transparent; }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 260px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.notice {
  border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 14px;
}
.notice.warn { border-color: rgba(245, 165, 36, 0.4); background: var(--warn-soft); color: #fcd9a0; }
.notice.err { border-color: rgba(240, 82, 82, 0.4); background: var(--down-soft); color: #ffc4c4; }
.notice.ok { border-color: rgba(34, 197, 94, 0.35); background: var(--up-soft); color: #b9f5cf; }
.notice.brand { border-color: rgba(124, 140, 255, 0.35); background: var(--brand-soft); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span, .field > label { font-weight: 600; font-size: 13.5px; }
.field small { color: var(--muted); font-size: 12.5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font: 14px var(--font); outline: none; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--brand-strong); }
input[type="checkbox"] { accent-color: var(--brand-strong); width: 16px; height: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; flex: none; }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row output { min-width: 72px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: background 0.2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + .track { background: var(--up); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Toast & dialog ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 100; }
.toast {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--up);
  padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); max-width: 380px; font-size: 14px;
  animation: toast-in 0.2s ease-out;
}
.toast.err { border-left-color: var(--down); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0; width: min(560px, 100% - 32px); box-shadow: var(--shadow);
}
dialog.wide { width: min(980px, 100% - 32px); }
dialog::backdrop { background: rgba(3, 6, 12, 0.7); }
.dialog-body { padding: 24px; max-height: 80vh; overflow-y: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); font-size: 17px; text-decoration: none !important; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--brand-strong), #22c5b4);
  position: relative;
}
.logo-mark::after {
  content: ""; position: absolute; inset: 8px 6px; border-radius: 2px;
  border-top: 3px solid rgba(255, 255, 255, 0.9); border-bottom: 3px solid rgba(255, 255, 255, 0.55);
}

/* ---------- Landing ---------- */
.nav { position: sticky; top: 0; z-index: 20; background: rgba(10, 14, 23, 0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; gap: 20px; }
.nav-links { display: flex; gap: 24px; }
.nav-links a { color: var(--muted); font-weight: 500; font-size: 14.5px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-cta { display: flex; gap: 10px; }

.hero { padding: 84px 0 64px; background: radial-gradient(900px 400px at 15% -10%, rgba(91, 108, 255, 0.22), transparent 60%), radial-gradient(700px 360px at 100% 10%, rgba(34, 197, 180, 0.12), transparent 60%); }
.hero-inner { display: grid; grid-template-columns: 1.25fr 1fr; gap: 56px; align-items: center; }
.eyebrow { color: var(--brand); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.1rem); font-weight: 800; }
.lead { font-size: 1.12rem; color: #c4cbda; max-width: 60ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 26px 0 12px; }

.signal-card { box-shadow: var(--shadow); }
.signal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.signal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 18px; }
.signal-grid div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.signal-grid dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.signal-grid dd { margin: 2px 0 0; font-weight: 700; font-size: 1.1rem; }
.checklist { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.checklist li { padding-left: 26px; position: relative; }
.checklist li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%; background: var(--up-soft); color: var(--up); font-size: 12px; font-weight: 800; display: grid; place-items: center; margin-top: 3px; }

.band { border-block: 1px solid var(--border); background: var(--surface); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; padding: 26px 0; }
.stats div { display: grid; }
.stats strong { font-size: 1.7rem; font-weight: 800; }
.stats span { color: var(--muted); font-size: 14px; }

.section { padding: 84px 0; }
.section.alt { background: var(--surface); border-block: 1px solid var(--border); }
.section-head { max-width: 680px; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; }
.section-head.center { margin-inline: auto; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; counter-reset: step; }
.step { position: relative; padding-top: 56px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 20px; left: 22px; width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand); font-weight: 800; display: grid; place-items: center;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature h3 { font-size: 1rem; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }
.feature .icon { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; margin-bottom: 12px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; align-items: stretch; }
.plan { display: flex; flex-direction: column; gap: 14px; position: relative; }
.plan.highlight { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.plan .tag { position: absolute; top: -12px; right: 18px; }
.plan-price { font-size: 2.3rem; font-weight: 800; line-height: 1; }
.plan-price small { font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; flex: 1; }
.plan li { padding-left: 24px; position: relative; font-size: 14.5px; }
.plan li::before { content: "✓"; position: absolute; left: 0; color: var(--up); font-weight: 800; }

.faq { max-width: 820px; margin-inline: auto; display: grid; gap: 12px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::after { content: "+"; color: var(--brand); font-weight: 800; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 12px 0 0; color: #c4cbda; }

.risk-box { border: 1px solid rgba(245, 165, 36, 0.4); background: var(--warn-soft); border-radius: var(--radius); padding: 24px 28px; }
.risk-box h3 { color: var(--warn); }
.risk-box p { color: #f3dcb4; font-size: 14.5px; margin: 0; }

.footer { border-top: 1px solid var(--border); padding: 34px 0; color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer a { color: var(--muted); }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; background: radial-gradient(700px 360px at 50% -10%, rgba(91, 108, 255, 0.2), transparent 60%); }
.auth-card { width: min(440px, 100%); }
.auth-card .logo { margin-bottom: 22px; }
.auth-card h1 { font-size: 1.5rem; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 22px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { color: var(--muted); padding: 9px 12px; border-radius: var(--radius-sm); font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.side-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.side-nav a.active { color: #fff; background: var(--brand-soft); }
.side-nav .count { background: var(--warn); color: #1a1200; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px; }
.side-foot { margin-top: auto; display: grid; gap: 10px; font-size: 13px; color: var(--muted); word-break: break-all; }
.main { padding: 30px 34px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head p { margin: 4px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 1.55rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.status-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.status-title { display: flex; align-items: center; gap: 12px; font-size: 1.15rem; font-weight: 800; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--up); box-shadow: 0 0 0 5px var(--up-soft); }
.dot.off { background: var(--warn); box-shadow: 0 0 0 5px var(--warn-soft); }
.dot.blocked { background: var(--down); box-shadow: 0 0 0 5px var(--down-soft); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart { width: 100%; height: 220px; display: block; }
.chart-empty { height: 220px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius-sm); text-align: center; padding: 20px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; font: 600 13px var(--font); cursor: pointer; }
.seg button.active { background: var(--brand-soft); color: #fff; }

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; background: var(--surface-2); display: grid; gap: 6px; }
.mode-card input { position: absolute; opacity: 0; }
.mode-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.mode-card.disabled { opacity: 0.55; cursor: not-allowed; }
.mode-card strong { font-size: 1.05rem; }

.token-box { font-family: var(--mono); background: var(--bg); border: 1px dashed var(--brand); padding: 12px 14px; border-radius: var(--radius-sm); word-break: break-all; }
.code-block { font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--border); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; white-space: pre; }
ol.guide { padding-left: 20px; display: grid; gap: 8px; margin: 0; }
.event-list { display: grid; gap: 0; }
.event { display: grid; grid-template-columns: 150px 90px 1fr; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14px; align-items: start; }
.event:last-child { border-bottom: 0; }
.event time { color: var(--muted); font-variant-numeric: tabular-nums; }

.plan-editor { display: grid; gap: 14px; }
.plan-editor .card { background: var(--surface-2); }
.symbols { display: flex; flex-wrap: wrap; gap: 10px 18px; }

@media (max-width: 960px) {
  .hero-inner, .two-col, .grid-2, .mode-cards { grid-template-columns: 1fr; }
  .steps, .features { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .side-nav { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .main { padding: 22px 16px 50px; }
  .event { grid-template-columns: 1fr; gap: 4px; }
}
