:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe3ef;
  --panel: #ffffff;
  --bg: #f1f5f9;
  --navy: #172554;
  --blue: #2563eb;
  --violet: #7c3aed;
  --green: #047857;
  --red: #b91c1c;
  --amber: #b45309;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { color: var(--muted); font-size: .78rem; }
.eyebrow { color: var(--blue); font-weight: 800; letter-spacing: .12em; font-size: .76rem; }

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at top left, #dbeafe, transparent 45%),
              radial-gradient(circle at bottom right, #ede9fe, transparent 45%), #f8fafc;
}
.auth-card { width: min(460px, 100%); padding: 28px; border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(15,23,42,.16); }
.brand-mark { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 20px; color: #fff; font-weight: 900; background: linear-gradient(135deg, var(--blue), var(--violet)); }
h1, h2, h3 { margin: 0 0 12px; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: #334155; font-size: .92rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #cbd5e1; border-radius: 10px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(37,99,235,.18); border-color: var(--blue); }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: 20px; min-height: auto; }

.primary, .secondary, .danger, .ghost { border: 0; border-radius: 10px; min-height: 42px; padding: 9px 14px; font-weight: 750; }
.primary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--violet)); }
.secondary { color: var(--navy); background: #dbeafe; }
.danger { color: #fff; background: var(--red); }
.ghost { color: #e2e8f0; background: rgba(255,255,255,.12); }
.primary:disabled, .secondary:disabled { opacity: .5; cursor: not-allowed; }

.app-header { position: sticky; top: 0; z-index: 20; min-height: 62px; padding: max(10px, env(safe-area-inset-top)) 18px 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #fff; background: linear-gradient(135deg, var(--navy), #312e81); box-shadow: 0 2px 16px rgba(15,23,42,.22); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status-dot { display: inline-flex; margin-left: 8px; padding: 3px 8px; border-radius: 99px; font-size: .72rem; background: #065f46; }
.status-dot.offline { background: #92400e; }

.main-nav { position: sticky; top: 62px; z-index: 15; display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.main-nav button { white-space: nowrap; border: 0; border-radius: 999px; padding: 9px 13px; color: #475569; background: #eef2f7; font-weight: 700; }
.main-nav button.active { color: #fff; background: var(--blue); }
.content { width: min(1180px, 100%); min-height: calc(100dvh - 120px); margin: 0 auto; padding: 24px 16px max(44px, env(safe-area-inset-bottom)); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 8px 22px rgba(15,23,42,.05); }
.metric strong { display: block; margin-top: 6px; font-size: clamp(1.45rem, 3vw, 2.2rem); }
.metric span { color: var(--muted); font-size: .88rem; }
.list { display: grid; gap: 10px; }
.list-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.list-item h3 { margin: 0 0 5px; font-size: 1rem; }
.list-item p { margin: 3px 0; color: var(--muted); font-size: .88rem; }
.pill { display: inline-block; padding: 4px 8px; border-radius: 99px; color: #1e3a8a; background: #dbeafe; font-size: .75rem; font-weight: 750; }
.pill.green { color: #065f46; background: #d1fae5; }
.pill.amber { color: #92400e; background: #fef3c7; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.result-box { padding: 16px; border-left: 5px solid var(--blue); border-radius: 10px; background: #eff6ff; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.result-grid div { padding: 10px; border-radius: 9px; background: #fff; }
.result-grid strong { display: block; font-size: 1.1rem; }
.volume { color: #5b21b6; border: 1px solid #ddd6fe; }
.warning { padding: 12px; color: #78350f; border: 1px solid #fbbf24; border-radius: 10px; background: #fffbeb; }
.success { padding: 12px; color: #065f46; border: 1px solid #6ee7b7; border-radius: 10px; background: #ecfdf5; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed #cbd5e1; border-radius: 14px; background: rgba(255,255,255,.7); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .83rem; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 100; transform: translate(-50%, 20px); max-width: min(520px, calc(100% - 30px)); padding: 12px 18px; color: #fff; border-radius: 999px; background: #0f172a; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: 0 12px 36px rgba(15,23,42,.28); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #991b1b; }

@media (max-width: 820px) {
  .grid.three, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-nav { top: 72px; }
}
@media (max-width: 600px) {
  .app-header { align-items: flex-start; }
  .header-actions .ghost { min-height: 36px; padding: 7px 9px; font-size: .82rem; }
  .grid.two, .grid.three, .grid.four, .form-grid, .result-grid { grid-template-columns: 1fr; }
  .page-head { display: grid; }
  .list-item { grid-template-columns: 1fr; }
  .auth-card { padding: 22px; }
  .content { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
