/* ── Reset & Root ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

:root {
  --bg:           #0b0e14;
  --surface:      #111520;
  --surface2:     #161b27;
  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);
  --accent:       #3b7ef8;
  --accent-dim:   rgba(59,126,248,0.15);
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.15);
  --amber:        #f59e0b;
  --amber-dim:    rgba(245,158,11,0.15);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.15);
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --text-faint:   #334155;
  --mono:         'IBM Plex Mono', monospace;
  --sans:         'Syne', system-ui, sans-serif;
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --sidebar-w:    192px;
  --topbar-h:     52px;
}

/* ── Base ─────────────────────────────────────────────── */
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.6; }

/* ── Shell ────────────────────────────────────────────── */
.shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  position: relative;
  overflow: hidden;
}
.logo-icon::before {
  content: '';
  position: absolute;
  width: 14px; height: 8px;
  border-radius: 4px 4px 0 0;
  background: rgba(255,255,255,0.9);
  top: 6px; left: 7px;
}
.logo-icon::after {
  content: '';
  position: absolute;
  width: 20px; height: 5px;
  border-radius: 2px;
  background: rgba(255,255,255,0.4);
  bottom: 5px; left: 4px;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.5} }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
}

/* ── Main Layout ──────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section { margin-bottom: 20px; }

.nav-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  width: 15px; height: 15px;
  flex-shrink: 0;
  stroke: currentColor;
}

.badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--mono);
}

/* ── Content ──────────────────────────────────────────── */
.content {
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

.page { display: none; animation: fade-in 0.2s ease; }
.page.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

/* ── Stat Grid ────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--border-hover); }

.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--text); letter-spacing: -0.03em; line-height: 1.1; }
.stat-sub { font-size: 11px; margin-top: 4px; font-family: var(--mono); }
.stat-sub.positive { color: var(--green); }
.stat-sub.warn { color: var(--amber); }

/* ── Cards ────────────────────────────────────────────── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

/* ── Pills ────────────────────────────────────────────── */
.pill {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  font-family: var(--mono);
}
.pill-green  { background: var(--green-dim); color: var(--green); }
.pill-blue   { background: var(--accent-dim); color: var(--accent); }
.pill-amber  { background: var(--amber-dim); color: var(--amber); }
.pill-red    { background: var(--red-dim); color: var(--red); }
.pill-gray   { background: var(--surface2); color: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  font-size: 12px;
  font-family: var(--sans);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hover);
  background: transparent;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border-hover); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #2d6de0; border-color: #2d6de0; color: #fff; }

/* ── Repo List ────────────────────────────────────────── */
.repo-list {}
.repo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background 0.12s;
}
.repo-row:last-child { border-bottom: none; }
.repo-row:hover { background: var(--surface2); }

.commit-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: var(--green); box-shadow: 0 0 4px var(--green); }
.dot-blue   { background: var(--accent); box-shadow: 0 0 4px var(--accent); }
.dot-amber  { background: var(--amber); box-shadow: 0 0 4px var(--amber); }

.repo-name { color: var(--accent); font-weight: 500; flex: 1; }
.repo-branch {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.repo-time { color: var(--text-muted); font-size: 11px; margin-left: auto; font-family: var(--mono); }

/* ── Edge Map ─────────────────────────────────────────── */
.edge-map {
  height: 120px;
  background: var(--surface2);
  margin: 0;
  position: relative;
  overflow: hidden;
}
.edge-map::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 30px, rgba(255,255,255,0.02) 30px, rgba(255,255,255,0.02) 31px),
    repeating-linear-gradient(90deg, transparent, transparent 30px, rgba(255,255,255,0.02) 30px, rgba(255,255,255,0.02) 31px);
}
.edge-node {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%,-50%);
}
.edge-node::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  transform: translate(-50%,-50%);
  opacity: 0.2;
  animation: edge-pulse 2.5s ease-in-out infinite;
}
@keyframes edge-pulse { 0%,100%{transform:translate(-50%,-50%) scale(1);opacity:0.2} 50%{transform:translate(-50%,-50%) scale(1.5);opacity:0.05} }

/* ── Repo Cards ───────────────────────────────────────── */
.repo-card-inner {
  padding: 14px 18px;
}
.repo-card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.repo-commit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.repo-actions { margin-left: auto; display: flex; gap: 6px; }

/* ── Workers ──────────────────────────────────────────── */
.worker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}
.worker-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: border-color 0.15s;
}
.worker-card:hover { border-color: var(--border-hover); }
.worker-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.worker-name { font-size: 13px; font-weight: 500; color: var(--text); }
.worker-route { font-family: var(--mono); font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
.worker-stats { display: flex; gap: 16px; }
.worker-stat-v { font-size: 15px; font-weight: 600; color: var(--text); font-family: var(--mono); }
.worker-stat-l { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── CF List ──────────────────────────────────────────── */
.cf-list {}
.cf-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background 0.12s;
}
.cf-row:last-child { border-bottom: none; }
.cf-row:hover { background: var(--surface2); }
.cf-domain { font-weight: 500; flex: 1; color: var(--text); }
.cf-meta { color: var(--text-muted); font-size: 11px; font-family: var(--mono); }

/* ── Analytics Chart ──────────────────────────────────── */
.chart-wrap { padding: 16px 18px; }
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 100px;
}
.chart-bar {
  flex: 1;
  background: var(--accent-dim);
  border: 1px solid rgba(59,126,248,0.2);
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: background 0.15s;
  cursor: default;
}
.chart-bar:hover { background: rgba(59,126,248,0.4); }
.chart-bar-val {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-family: var(--mono);
  color: var(--text-muted);
  padding-bottom: 3px;
  white-space: nowrap;
}
.chart-labels {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}
.chart-label {
  flex: 1;
  text-align: center;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
}

/* ── Two Col ──────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Cache Panel ──────────────────────────────────────── */
.cache-panel { padding: 16px 18px; }
.cache-value { font-size: 42px; font-weight: 600; color: var(--text); font-family: var(--mono); letter-spacing: -0.04em; line-height: 1; margin-bottom: 4px; }
.cache-unit { font-size: 24px; }
.progress-track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; width: 0; transition: width 1s ease; }
.progress-labels { display: flex; justify-content: space-between; font-size: 10px; font-family: var(--mono); color: var(--text-muted); }

/* ── Deployments ──────────────────────────────────────── */
.deploy-list {}
.deploy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  transition: background 0.12s;
}
.deploy-row:last-child { border-bottom: none; }
.deploy-row:hover { background: var(--surface2); }
.deploy-sha { font-family: var(--mono); color: var(--accent); font-size: 11px; flex-shrink: 0; }
.deploy-msg { flex: 1; color: var(--text); }
.deploy-time { color: var(--text-muted); font-family: var(--mono); font-size: 11px; }

/* ── Logs ─────────────────────────────────────────────── */
.log-panel {
  background: #060a0f;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.8;
  padding: 14px 18px;
  min-height: 240px;
  max-height: 360px;
  overflow-y: auto;
  color: #64748b;
}
.log-line { display: flex; gap: 12px; }
.log-time { color: #334155; flex-shrink: 0; }
.log-level-info { color: #38bdf8; }
.log-level-ok   { color: #4ade80; }
.log-level-warn { color: #fb923c; }
.log-level-err  { color: #f87171; }
.log-msg { color: #94a3b8; }
.log-cursor {
  display: inline-block;
  width: 7px; height: 13px;
  background: #64748b;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.log-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
}

/* ── Settings ─────────────────────────────────────────── */
.settings-group { padding: 4px 0; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.settings-row:last-child { border-bottom: none; }
.settings-key { color: var(--text); }
.settings-val { color: var(--text-muted); font-family: var(--mono); font-size: 11px; }

.toggle {
  width: 34px; height: 20px;
  background: var(--green);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px; right: 3px;
  transition: right 0.2s;
}
.toggle.off { background: var(--text-faint); }
.toggle.off::after { right: 17px; }

/* ── Toast ────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}
.toast.success .toast-dot { background: var(--green); }
.toast.error   .toast-dot { background: var(--red); }
.toast.info    .toast-dot { background: var(--accent); }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
