:root {
  --bg: #0b1120;
  --panel: #111827;
  --panel-alt: #0f172a;
  --border: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --teal: #2dd4bf;
  --sky: #38bdf8;
  --rose: #fb7185;
  --amber: #fbbf24;
  --emerald: #34d399;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
code, pre { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.mono-sm { font-family: var(--mono); font-size: 16px !important; }

.auth-gate {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 480px at 15% 0%, rgba(45, 212, 191, 0.12), transparent 60%),
    radial-gradient(700px 420px at 85% 15%, rgba(56, 189, 248, 0.09), transparent 60%),
    #070c17;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
  z-index: 100;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.brand-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--teal);
  margin-bottom: 10px;
}
.auth-card h1, .auth-card h3 { margin: 0 0 8px; color: #fff; }
.auth-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.auth-card input,
.form-stack input,
.form-stack select,
.card input[type="text"],
.card input[type="email"],
.card input[type="password"],
.card input[type="number"],
.card select,
#apiKeyForm input,
.select {
  width: 100%;
  background: #090e1a;
  color: #fff;
  border: 1px solid #293548;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
}
.auth-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  background: #090e1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.err-msg {
  margin-top: 10px;
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.14);
  border: 1px solid rgba(251, 113, 133, 0.4);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}

.app-shell { display: grid; grid-template-columns: 245px 1fr; min-height: 100vh; }
.sidebar {
  background: #080d19;
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.logo-row { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; letter-spacing: 0.12em; color: #fff; }
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.tag { font-family: var(--mono); font-size: 10px; padding: 2px 6px; border-radius: 4px; background: rgba(56, 189, 248, 0.16); color: var(--sky); }
.org-pill { margin-top: 10px; font-size: 12px; color: var(--muted); background: #0f172a; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); }

.side-nav { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; flex: 1; }
.nav-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.nav-btn:hover { background: #0f172a; color: #fff; }
.nav-btn.active { background: rgba(45, 212, 191, 0.12); border-color: rgba(45, 212, 191, 0.35); color: var(--teal); }

.side-foot { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.engine-pill { font-family: var(--mono); font-size: 11px; color: #cbd5e1; background: #0f172a; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; }
.user-badge { font-size: 12px; color: var(--muted); }

.main { padding: 22px 28px; max-width: 1420px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h2 { margin: 0 0 2px; font-size: 20px; color: #fff; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.top-actions .select { width: 250px; }

.view { display: none; }
.view.active { display: block; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .kpi-grid, .grid-2 { grid-template-columns: 1fr; }
}

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: #fff; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.kpi-lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.kpi-val { font-size: 26px; font-weight: 800; color: #fff; margin: 4px 0; }
.kpi-sub { font-size: 12px; color: var(--muted); }

canvas { width: 100%; background: #070c17; border: 1px solid #1e293b; border-radius: 10px; display: block; }
.legend-row { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot.teal { background: var(--teal); }
.dot.rose { background: var(--rose); }
.dot.amber { background: var(--amber); }

.btn {
  border: 1px solid #334155;
  background: #1e293b;
  color: #fff;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.primary { background: var(--teal); color: #04201c; border-color: var(--teal); }
.btn.secondary { background: #1e293b; color: #e2e8f0; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: rgba(251, 113, 133, 0.16); color: #fecdd3; border-color: rgba(251, 113, 133, 0.45); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.full { width: 100%; margin-top: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; font-family: var(--mono); }
.badge.PASS { background: rgba(52, 211, 153, 0.16); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.4); }
.badge.WARN { background: rgba(251, 191, 36, 0.16); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.4); }
.badge.FAIL { background: rgba(251, 113, 133, 0.16); color: #fda4af; border: 1px solid rgba(251, 113, 133, 0.4); }
.badge.neutral { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border: 1px solid #334155; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; background: #0d1424; }
.tbl td.num { font-family: var(--mono); }

.form-stack { display: flex; flex-direction: column; gap: 10px; }
.drop-zone {
  border: 1.5px dashed #334155;
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  background: #090e1a;
  position: relative;
  cursor: pointer;
}
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.status-box, .notice-box {
  background: #090e1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 12.5px;
  color: #cbd5e1;
}
.notice-box ul { margin: 6px 0 0; padding-left: 18px; }
.code-block {
  background: #070b14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px;
  font-size: 12px;
  color: #cbd5e1;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.tabs-inline { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tab-btn { background: #0f172a; color: var(--muted); border: 1px solid var(--border); border-radius: 7px; padding: 6px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tab-btn.active { background: rgba(56, 189, 248, 0.16); border-color: var(--sky); color: #fff; }
.insp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.live-controls { display: grid; grid-template-columns: 280px auto 1fr; gap: 14px; align-items: end; flex-wrap: wrap; }
.check-row { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: #cbd5e1; }
.check-row label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.btn-strip { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.live-banner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.live-state-txt { font-family: var(--mono); font-size: 17px; font-weight: 800; color: #fff; margin-top: 2px; }
.pill-strip { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 1100px) { .live-controls { grid-template-columns: 1fr; } .btn-strip { justify-content: flex-start; } }

/* Public Landing & Sign-In Screen */
.landing-nav {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.landing-nav-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-pill {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #6ee7b7;
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 999px;
  padding: 5px 11px;
}
.landing-wrap {
  width: 100%;
  max-width: 1220px;
  margin: auto;
  padding: 18px 28px 34px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.landing-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 34px;
  align-items: center;
}
.landing-hero h1 {
  margin: 0 0 14px;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #fff;
}
.landing-sub {
  margin: 0 0 22px;
  font-size: 15px;
  color: #cbd5e1;
  line-height: 1.6;
}
.landing-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.landing-kpi {
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px;
}
.landing-kpi .kpi-val {
  font-size: 23px;
  color: var(--teal);
  margin: 0 0 4px;
}
.landing-kpi .kpi-lbl {
  font-size: 11px;
  color: #fff;
  margin-bottom: 4px;
}
.landing-kpi .kpi-sub {
  font-size: 11.5px;
  line-height: 1.38;
}
.landing-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.auth-card h2 { margin: 0 0 6px; font-size: 21px; color: #fff; }
.landing-foot {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid rgba(30, 41, 59, 0.8);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 920px) {
  .landing-grid, .landing-metrics { grid-template-columns: 1fr; }
  .landing-hero h1 { font-size: 28px; }
  .auth-card { max-width: 100%; }
}
