:root {
  color-scheme: dark;
  --bg: #0a0e14;
  --panel: #101722;
  --line: #263244;
  --ink: #e8eef8;
  --muted: #8d9aad;
  --cyan: #44d7e8;
  --violet: #a58bff;
  --green: #70e0a1;
  --amber: #ffc56d;
  --red: #ff7e8e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 10% -10%, #182a42 0, transparent 34rem), var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

main {
  max-width: 1440px;
  margin: auto;
  padding: 38px 28px 64px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.header-tag {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.14em;
  margin: 0;
}

.version-badge {
  background: rgba(68, 215, 232, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(68, 215, 232, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.045em;
  margin: 6px 0 0;
  font-weight: 750;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.muted { color: var(--muted); font-size: 12px; }
.muted-sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.muted-pct { color: var(--muted); font-size: 11px; font-weight: normal; }
.cyan { color: var(--cyan); }

/* Buttons */
button {
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn-sm {
  background: #19273c;
  color: var(--cyan);
  border: 1px solid #2b4263;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-sm:hover:not(:disabled) {
  background: #233754;
  border-color: var(--cyan);
  color: #fff;
}

.btn-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.15s ease;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi, .panel {
  background: linear-gradient(130deg, #121b29, #0e141e);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.kpi {
  padding: 18px;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
}

.kpi .value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-top: 8px;
}

/* Grid & Panels */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.panel {
  padding: 20px;
  min-width: 0;
}

.wide { grid-column: span 2; }

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-title h2 {
  font-size: 14px;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
}

/* Chart */
.chart {
  height: 180px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding-top: 10px;
}

.bar {
  background: linear-gradient(var(--cyan), var(--violet));
  min-width: 6px;
  flex: 1;
  border-radius: 3px 3px 0 0;
  opacity: 0.9;
  transition: opacity 0.15s;
}

.bar:hover { opacity: 1; }

/* Quota cards */
.quota-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quota-empty {
  padding: 14px 0;
  text-align: center;
}

.quota-card {
  background: rgba(16, 23, 34, 0.7);
  border: 1px solid #1c2738;
  border-radius: 8px;
  padding: 12px 14px;
}

.quota-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 8px;
}

.quota-title {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 11px;
}

.track {
  height: 7px;
  background: #1a2332;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-radius: inherit;
  transition: width 0.3s ease;
}

.fill.warning {
  background: linear-gradient(90deg, var(--amber), #ff9800);
}

.fill.critical {
  background: linear-gradient(90deg, #ff9800, var(--red));
}

.quota-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.bucket-values {
  display: grid;
  gap: 2px;
  margin: 10px 0;
  color: #c5d3e6;
  font-size: 11px;
}

.calibration {
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
}

.calibration.calibrated { color: var(--green); }

.badge-status {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-status.healthy { background: rgba(112, 224, 161, 0.15); color: var(--green); }
.badge-status.warning { background: rgba(255, 197, 109, 0.15); color: var(--amber); }
.badge-status.critical { background: rgba(255, 126, 142, 0.15); color: var(--red); }

/* Model list */
.model-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.model-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}

.model .fill {
  background: var(--amber);
}

/* Table */
.table-wrap {
  overflow-x: auto;
  max-height: 380px;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #1a2434;
  font-size: 12px;
}

th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.success { background: rgba(112, 224, 161, 0.15); color: var(--green); }
.badge.info { background: rgba(68, 215, 232, 0.15); color: var(--cyan); }
.badge.error { background: rgba(255, 126, 142, 0.15); color: var(--red); }

/* Playground */
.console-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input, textarea {
  background: #0b1018;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--cyan);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

button#run {
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  color: #050b14;
  font-weight: 700;
  padding: 10px;
  border-radius: 7px;
  font-size: 13px;
  transition: opacity 0.15s ease;
}

button#run:hover { opacity: 0.9; }

pre#console {
  margin-top: 14px;
  background: #080c12;
  border: 1px solid #192332;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  color: #9ab4d0;
}

/* Footer */
.app-footer {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

@media (max-width: 1024px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .wide { grid-column: span 1; }
}

@media (max-width: 640px) {
  main { padding: 20px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  header { flex-direction: column; }
  .app-footer { flex-direction: column; gap: 8px; text-align: center; }
}
