:root {
  --bg: #0b0d12;
  --surface: #13161f;
  --surface-hover: #1a1e2b;
  --border: #252a3a;
  --border-light: #2e344a;
  --text: #e8eaf0;
  --text-muted: #6b7280;
  --accent: #4f6ef7;
  --accent-hover: #3d5ce0;
  --green: #22c55e;
  --green-dim: rgba(34,197,94,.12);
  --yellow: #eab308;
  --yellow-dim: rgba(234,179,8,.12);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,.12);
  --orange: #f97316;
  --orange-dim: rgba(249,115,22,.12);
  --pink: #ec4899;
  --cyan: #06b6d4;
  --radius: 8px;
  --radius-sm: 5px;
  --mono: 'JetBrains Mono','Fira Code',monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
}

#app { display: flex; height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 22px; }
.brand-title { font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active { background: rgba(79,110,247,.12); color: var(--accent); }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.live-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--green); font-weight: 600;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }
.refresh-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}
.topbar h1 { font-size: 16px; font-weight: 600; }

#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .12s; background: none; color: var(--text);
}
.btn-ghost { background: rgba(255,255,255,.05); border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { background: rgba(255,255,255,.1); color: var(--text); }
.btn-green { background: var(--green-dim); color: var(--green); border-color: rgba(34,197,94,.25); }
.btn-green:hover { background: rgba(34,197,94,.2); }
.btn-red { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,.25); }
.btn-red:hover { background: rgba(239,68,68,.2); }
.btn-blue { background: rgba(79,110,247,.12); color: var(--accent); border-color: rgba(79,110,247,.25); }
.btn-blue:hover { background: rgba(79,110,247,.2); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Cards ── */
.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-muted); margin-bottom: 6px;
}
.card-value {
  font-size: 22px; font-weight: 700; font-family: var(--mono); letter-spacing: -.5px;
}
.card-value.small { font-size: 16px; }
.card-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.card-green { border-color: rgba(34,197,94,.3); }
.card-red { border-color: rgba(239,68,68,.3); }
.card-yellow { border-color: rgba(234,179,8,.3); }
.card-blue { border-color: rgba(79,110,247,.3); }

/* ── Tables ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted); padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: rgba(0,0,0,.15);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.03); }
tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: .5px;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-blue { background: rgba(79,110,247,.12); color: var(--accent); }
.badge-gray { background: rgba(107,114,128,.12); color: var(--text-muted); }

/* ── Status dots ── */
.status-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px;
}
.status-dot.ok { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,.4); }
.status-dot.err { background: var(--red); box-shadow: 0 0 6px rgba(239,68,68,.4); }
.status-dot.warn { background: var(--yellow); }

/* ── Sections ── */
.section { margin-bottom: 28px; }
.section-title {
  font-size: 13px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}

/* ── Filter bar ── */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
  background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 7px 12px; font-size: 13px; outline: none; min-width: 160px;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--accent); }

/* ── Logs ── */
.logs-container {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-height: 70vh; overflow-y: auto; font-family: var(--mono); font-size: 12px;
}
.log-line {
  padding: 5px 14px; border-bottom: 1px solid rgba(255,255,255,.03);
  display: flex; gap: 12px; align-items: flex-start;
}
.log-line:hover { background: rgba(255,255,255,.04); }
.log-time { color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.log-container { color: var(--cyan); white-space: nowrap; flex-shrink: 0; min-width: 120px; }
.log-msg { color: #c9d1d9; word-break: break-word; }

/* ── Sites grid ── */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.site-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; transition: all .15s; cursor: pointer;
}
.site-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.site-card .site-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.site-card .site-url { font-size: 11px; color: var(--accent); word-break: break-all; margin-bottom: 10px; }
.site-card .site-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 12px; }

/* ── Command terminal ── */
.terminal {
  background: #0d1117; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
}
.terminal-head {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 14px; display: flex; align-items: center; gap: 8px;
}
.terminal-body {
  padding: 14px; white-space: pre-wrap; color: #c9d1d9;
  max-height: 500px; overflow-y: auto;
}
.terminal-body .cmd-line { color: var(--green); }
.terminal-body .err-line { color: var(--red); }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.modal-box {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; width: 92%; max-width: 860px; max-height: 85vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 14px; font-weight: 600; }
.modal-x { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; }
.modal-x:hover { color: var(--text); }
.modal-body { flex: 1; overflow: auto; padding: 16px 20px; font-size: 13px; }

/* ── Cost bars ── */
.cost-bar-wrap { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.cost-bar-bg { flex: 1; height: 8px; background: rgba(255,255,255,.06); border-radius: 4px; overflow: hidden; }
.cost-bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }
.cost-bar-label { font-size: 11px; color: var(--text-muted); min-width: 60px; text-align: right; font-family: var(--mono); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 200px; }
}
@media (max-width: 768px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { display: flex; overflow-x: auto; padding: 8px; }
  .nav-item { white-space: nowrap; margin-bottom: 0; margin-right: 4px; }
  .card-grid { grid-template-columns: 1fr; }
}

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

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .25s ease; }

/* ── Pipeline detail row ── */
.pipeline-detail { background: rgba(0,0,0,.2); padding: 14px; border-radius: var(--radius-sm); margin-top: 8px; }
.pipeline-detail pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 11px; color: #c9d1d9; }
.pipeline-detail h4 { font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin: 12px 0 6px; }
.pipeline-detail h4:first-child { margin-top: 0; }

/* ── Error card ── */
.error-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.error-card:hover { border-color: rgba(239,68,68,.3); }
.error-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 8px; font-family: var(--mono); }
.error-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }

/* ── Empty state ── */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ── Charts (simple bar) ── */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding: 10px 0; }
.bar-item { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 4px; opacity: .8; transition: opacity .2s; position: relative; }
.bar-item:hover { opacity: 1; }
.bar-item .bar-tip { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); padding: 4px 8px; border-radius: 4px; font-size: 10px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; margin-bottom: 4px; }
.bar-item:hover .bar-tip { opacity: 1; }

/* ── Model color coding ── */
.model-claude { color: var(--orange); }
.model-gpt { color: var(--green); }
.model-deepseek { color: var(--cyan); }
.model-kimi { color: var(--pink); }
.model-gemini { color: var(--yellow); }
