:root {
  --bg-0: #071018;
  --bg-1: #0c1824;
  --bg-2: #122536;
  --panel: rgba(14, 28, 42, 0.78);
  --panel-border: rgba(120, 180, 210, 0.12);
  --text: #e7f1f7;
  --muted: #8aa3b5;
  --accent: #2ec4b6;
  --accent-2: #4cc9f0;
  --warn: #e9c46a;
  --danger: #f07167;
  --ok: #2a9d8f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: "Sora", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  line-height: 1.45;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.9em; }

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(46, 196, 182, 0.18), transparent 55%),
    radial-gradient(700px 420px at 90% 8%, rgba(76, 201, 240, 0.14), transparent 50%),
    radial-gradient(600px 400px at 70% 100%, rgba(20, 80, 110, 0.25), transparent 45%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1) 45%, #09141e);
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(140, 190, 210, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 190, 210, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  animation: gridDrift 28s linear infinite;
}

@keyframes gridDrift {
  from { transform: translateY(0); }
  to { transform: translateY(48px); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(46, 196, 182, 0.45); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(46, 196, 182, 0); }
}

.reveal { animation: fadeUp 0.55s ease both; }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.4rem 1rem;
  border-right: 1px solid var(--panel-border);
  background: rgba(6, 14, 22, 0.72);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand, .login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, var(--accent), transparent 60%),
    linear-gradient(225deg, var(--accent-2), #0b2a3a 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.brand-mark.lg { width: 48px; height: 48px; border-radius: 14px; }
.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em; }

.nav { display: flex; flex-direction: column; gap: 0.35rem; }
.nav-link {
  color: var(--muted);
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.04); text-decoration: none; }
.nav-link.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(46,196,182,0.16), rgba(76,201,240,0.06));
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-foot { margin-top: auto; display: grid; gap: 0.6rem; }
.user-chip {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.main { padding: 1.4rem 1.6rem 2.5rem; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.page-title { margin: 0; font-size: 1.55rem; font-weight: 650; letter-spacing: -0.02em; }
.page-sub { margin: 0.25rem 0 0; color: var(--muted); }
.topbar-meta { display: flex; align-items: center; gap: 0.55rem; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.2s ease infinite;
}

.panel, .gauge-card, .stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.panel { padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.panel-head h2, .gauge-meta h2, .stat-card h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.gauge-card, .stat-card {
  padding: 1rem;
  display: flex;
  gap: 0.9rem;
  align-items: center;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.gauge-card:hover, .stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(46, 196, 182, 0.28);
}
.stat-card { flex-direction: column; align-items: flex-start; }

.gauge {
  --p: 0;
  width: 72px;
  height: 72px;
  position: relative;
  flex: 0 0 auto;
}
.gauge-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255,255,255,0.08) 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
}
.gauge-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.tiny { font-size: 0.78rem; }
.label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.25rem; }
.stat-xl { font-size: 1.7rem; font-weight: 600; margin: 0.2rem 0; }
.stat-lg { font-size: 1.25rem; font-weight: 600; margin: 0.15rem 0; }
.net-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.site-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.site-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.025);
  border: 1px solid transparent;
}
.site-list.dense li { padding: 0.45rem 0.55rem; }
.site-name { font-weight: 550; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.45rem; border-bottom: 1px solid rgba(255,255,255,0.06); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }

.tag, .pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  background: rgba(255,255,255,0.03);
}
.tag.ok, .pill { color: #b8f2e6; border-color: rgba(46,196,182,0.35); background: rgba(46,196,182,0.12); }
.tag.warn { color: #ffe2a8; border-color: rgba(233,196,106,0.35); background: rgba(233,196,106,0.12); }
.tag.err { color: #ffc4bf; border-color: rgba(240,113,103,0.35); background: rgba(240,113,103,0.12); }

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(46,196,182,0.35); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, rgba(46,196,182,0.95), rgba(36,150,170,0.95));
  border-color: transparent;
  color: #042028;
}
.btn-ghost { background: transparent; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

.field { display: grid; gap: 0.35rem; }
.field span { color: var(--muted); font-size: 0.8rem; }
.field input, .field select, .field textarea {
  width: 100%;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: rgba(46,196,182,0.55);
  box-shadow: 0 0 0 3px rgba(46,196,182,0.12);
}
.form-row { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; }
.form-row .grow { flex: 1 1 160px; }
.stack-form { display: grid; gap: 0.75rem; }
.check { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); padding-bottom: 0.55rem; }
.at { color: var(--muted); padding-bottom: 0.65rem; }
.help { color: var(--muted); font-size: 0.85rem; margin: 0.75rem 0 0; }
.kv { display: grid; gap: 0.55rem; }
.kv > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }

.toast {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 0.9rem;
  border: 1px solid var(--panel-border);
}
.toast.ok { background: rgba(42,157,143,0.15); border-color: rgba(42,157,143,0.35); }
.toast.err { background: rgba(240,113,103,0.12); border-color: rgba(240,113,103,0.35); }

.codeblock {
  margin: 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--panel-border);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  color: #c6d8e4;
}

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-stage { width: min(420px, 100%); }
.login-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.login-title { margin: 1.2rem 0 0.35rem; font-size: 1.45rem; letter-spacing: -0.02em; }
.login-lead { margin: 0 0 1.1rem; color: var(--muted); }
.login-form { display: grid; gap: 0.85rem; }

.empty-hero .lead { color: var(--muted); max-width: 52ch; }
.steps { color: var(--muted); padding-left: 1.2rem; }
.steps li { margin: 0.35rem 0; }

@media (max-width: 1100px) {
  .gauge-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0.5rem; grid-template-columns: 1fr auto; align-items: center; }
  .split-grid, .gauge-grid { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}

.pipeline { color: var(--muted); padding-left: 1.2rem; margin: 0 0 1rem; }
.pipeline li { margin: 0.4rem 0; }
.pipeline strong { color: var(--text); }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.log-list li {
  display: flex; gap: 0.55rem; align-items: flex-start;
  padding: 0.45rem 0.55rem; border-radius: 8px;
  background: rgba(255,255,255,0.025);
  font-size: 0.9rem;
}
.handoff .secret { color: #b8f2e6; }
.toast.warn { background: rgba(233,196,106,0.12); border-color: rgba(233,196,106,0.35); }
.subhead { font-size: 0.95rem; margin: 1rem 0 0.4rem; }
.perm-list { color: var(--muted); margin: 0 0 1rem; padding-left: 1.2rem; }
.perm-list li { margin: 0.3rem 0; }
.wizard .btn-primary { min-width: 160px; }
