/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-root: #0a0a0f;
  --bg-surface: #12131a;
  --bg-card: #181a24;
  --bg-input: #1e2030;
  --border: #2a2d3e;
  --border-hover: #3d4160;
  --text-primary: #e6e6f0;
  --text-secondary: #8b8da0;
  --text-muted: #5c5e72;
  --accent: #6c8aff;
  --accent-hover: #8ba3ff;
  --green: #3dd68c;
  --green-bg: rgba(61, 214, 140, 0.12);
  --yellow: #f0c040;
  --yellow-bg: rgba(240, 192, 64, 0.12);
  --red: #f06060;
  --red-bg: rgba(240, 96, 96, 0.12);
  --radius: 8px;
  --radius-sm: 4px;
  --font: 'Inter', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
}

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  color: var(--accent);
  font-size: 18px;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.topbar-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-link.active { color: var(--accent); background: rgba(108, 138, 255, 0.1); }

/* === Main === */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* === Stats Row === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.5px;
}

/* === Section === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
}

/* === Budget Cards Grid === */
.budget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.budget-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.budget-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.budget-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.budget-name {
  font-weight: 600;
  font-size: 15px;
}

.budget-period {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
}

.progress-wrap {
  margin-bottom: 12px;
}

.progress-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-fill.green { background: var(--green); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.red { background: var(--red); }

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-family: var(--mono);
}

.progress-spent { color: var(--text-primary); }
.progress-limit { color: var(--text-muted); }

.budget-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.budget-meta span { display: flex; align-items: center; gap: 4px; }

/* === Table === */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

td {
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(108, 138, 255, 0.03); }

.td-mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* === Badge pills === */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.pill-green { background: var(--green-bg); color: var(--green); }
.pill-yellow { background: var(--yellow-bg); color: var(--yellow); }
.pill-red { background: var(--red-bg); color: var(--red); }

/* === Forms === */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder { color: var(--text-muted); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

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

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(240, 96, 96, 0.2);
}

.btn-danger:hover { background: rgba(240, 96, 96, 0.2); }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* === Detail View === */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.detail-actions { display: flex; gap: 8px; }

.gauge-container {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

/* === Gauge SVG === */
.gauge-wrap {
  text-align: center;
}

/* === Model Breakdown Bar === */
.model-bar {
  display: flex;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
}

.model-bar-segment {
  transition: width 0.4s ease;
  min-width: 2px;
}

.model-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.model-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.model-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* === Code Block === */
.code-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-secondary);
  margin-bottom: 16px;
  white-space: pre;
}

.code-block .kw { color: var(--accent); }
.code-block .str { color: var(--green); }
.code-block .cmt { color: var(--text-muted); }

/* === Badge Embed === */
.badge-embed {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.badge-embed input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 20px;
  font-size: 14px;
}

/* === Alerts table === */
.webhook-ok { color: var(--green); }
.webhook-fail { color: var(--red); }
.webhook-none { color: var(--text-muted); }

/* === Pricing table === */
.pricing-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  width: 90px;
  text-align: right;
}

.pricing-input:focus { outline: none; border-color: var(--accent); }

/* === Responsive === */
@media (max-width: 768px) {
  .stats-row { grid-template-columns: 1fr; }
  .budget-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  #app { padding: 16px 12px; }
}

/* === Misc === */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
