:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface2: #1a2233;
  --border: #2a3548;
  --text: #e8edf5;
  --muted: #8b98ad;
  --primary: #5b8def;
  --primary-hover: #4a7de0;
  --success: #3ecf8e;
  --danger: #ef5b5b;
  --warning: #f0b429;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 2rem;
  padding: 0 .5rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5b8def, #8b5cf6);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand span { display: block; font-size: .75rem; color: var(--muted); }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--muted);
  padding: .75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  margin-bottom: .25rem;
  transition: .15s;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(91,141,239,.15); color: var(--primary); font-weight: 600; }

.content {
  margin-left: 260px;
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 1200px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.topbar h1 { font-size: 1.5rem; font-weight: 700; }

.tab { display: none; }
.tab.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h3 { margin-bottom: 1rem; font-size: 1rem; }

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-label { display: block; color: var(--muted); font-size: .8rem; margin-bottom: .5rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; }

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .sidebar { position: relative; width: 100%; height: auto; }
  .content { margin-left: 0; }
  .charts-row { grid-template-columns: 1fr; }
  .app { flex-direction: column; }
}

.chart-card canvas { max-height: 280px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  font-size: .85rem;
  color: var(--muted);
}

input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .75rem;
  color: var(--text);
  font-size: .9rem;
}

input:focus, select:focus { outline: 2px solid rgba(91,141,239,.4); border-color: var(--primary); }

.form-actions { display: flex; align-items: end; }

.btn {
  border: none;
  border-radius: 8px;
  padding: .65rem 1.1rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(239,91,91,.15); color: var(--danger); }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }

.hint { color: var(--muted); font-size: .8rem; margin: .5rem 0; }

.result-box {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
  background: rgba(62,207,142,.1);
  border: 1px solid rgba(62,207,142,.3);
  font-size: .9rem;
}

.result-box.error {
  background: rgba(239,91,91,.1);
  border-color: rgba(239,91,91,.3);
}

.hidden { display: none !important; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

th, td {
  text-align: left;
  padding: .65rem .5rem;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 500; }

.badge {
  display: inline-block;
  padding: .2rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-on { background: rgba(62,207,142,.15); color: var(--success); }
.badge-off { background: rgba(139,152,173,.15); color: var(--muted); }

.model-checklist {
  max-height: 300px;
  overflow-y: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem;
}

.model-check-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .5rem;
  border-radius: 6px;
}

.model-check-item:hover { background: var(--surface2); }

.provider-toggle {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

.toggle-btn {
  padding: .3rem .6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  font-size: .75rem;
}

.toggle-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(91,141,239,.1);
}

.endpoint-box {
  background: var(--surface2);
  border-radius: 8px;
  padding: 1rem;
  font-family: monospace;
  font-size: .85rem;
  line-height: 1.8;
}

.code-block {
  background: var(--surface2);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  font-size: .8rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.full-key {
  display: inline-block;
  font-family: monospace;
  font-size: .8rem;
  word-break: break-all;
  background: var(--surface2);
  padding: .25rem .5rem;
  border-radius: 4px;
  max-width: 100%;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: .75rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 1000;
  animation: slideIn .2s ease;
}

@keyframes slideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.model-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: .75rem;
}

.model-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}

.inline-edit {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.inline-edit input { width: 180px; }
