:root {
  --bg: #090d16;
  --bg-elev: #111827;
  --bg-card: #131c2e;
  --bg-hover: #1a2640;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(56, 189, 248, 0.35);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
code, pre { font-family: var(--mono); }

.hidden { display: none !important; }

/* Auth Screen */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 20%, rgba(56,189,248,0.12), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(129,140,248,0.12), transparent 45%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-dot {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 800; color: #090d16; font-size: 16px;
}
.brand-title { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; }
.auth-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.tabs-inline { display: flex; gap: 8px; margin-bottom: 16px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tabs-inline button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.tabs-inline button.active { background: var(--bg-card); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* App Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; flex: 1; overflow-y: auto; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 500; font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav button:hover { background: var(--bg-hover); color: var(--text); }
.nav button.active { background: rgba(56,189,248,0.14); color: var(--accent); font-weight: 600; }
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-pill {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg); padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border);
}
.user-pill .u-name { font-weight: 600; font-size: 13px; }
.user-pill .u-meta { font-size: 11.5px; color: var(--muted); }

.main { flex: 1; padding: 22px 26px; min-width: 0; overflow-x: hidden; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 20px;
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.domain-chip {
  font-family: var(--mono); font-size: 12px; padding: 6px 11px;
  background: rgba(16,185,129,0.12); color: #34d399;
  border: 1px solid rgba(16,185,129,0.28); border-radius: 999px;
}

/* Cards & Grids */
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 18px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 600; }
.kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi-val { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* Form Elements */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; font-size: 13.5px; outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row > .field { flex: 1; min-width: 140px; margin-bottom: 0; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check-row input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; background: var(--bg-hover); color: var(--text);
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--border-strong); }
.btn-primary { background: linear-gradient(135deg, #0284c7, #4f46e5); border-color: transparent; color: #fff; }
.btn-primary:hover { opacity: 0.92; }
.btn-green { background: rgba(16,185,129,0.16); border-color: rgba(16,185,129,0.35); color: #34d399; }
.btn-amber { background: rgba(245,158,11,0.16); border-color: rgba(245,158,11,0.35); color: #fbbf24; }
.btn-red { background: rgba(239,68,68,0.16); border-color: rgba(239,68,68,0.35); color: #f87171; }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid rgba(148,163,184,0.08); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: var(--mono); font-size: 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.b-ok { background: rgba(16,185,129,0.16); color: #34d399; }
.b-warn { background: rgba(245,158,11,0.16); color: #fbbf24; }
.b-err { background: rgba(239,68,68,0.16); color: #f87171; }
.b-info { background: rgba(56,189,248,0.16); color: #38bdf8; }

/* Chart Bars */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 12px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; max-width: 28px; display: flex; flex-direction: column-reverse; gap: 2px; min-height: 4px; }
.bar-ok { background: var(--green); border-radius: 3px; }
.bar-fail { background: var(--red); border-radius: 3px; }
.chart-lbl { font-size: 10px; color: var(--muted); }

/* Code Box */
.code-box {
  background: #060911;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: #cbd5e1;
  max-height: 440px;
  overflow: auto;
  white-space: pre;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.68);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100;
}
.modal {
  width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 20px 22px;
}

/* Toast */
#toast-box { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  padding: 11px 15px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  font-size: 13px; max-width: 340px;
}
.toast.err { border-color: rgba(239,68,68,0.6); color: #fca5a5; }
.toast.ok { border-color: rgba(16,185,129,0.6); color: #6ee7b7; }

.mobile-menu-btn { display: none; }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 90; transition: left 0.2s; }
  .sidebar.open { left: 0; }
  .mobile-menu-btn { display: inline-flex; }
  .main { padding: 14px; }
}
