:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #192235;
  --border: #243047;
  --text: #e6edf7;
  --muted: #8ea0bc;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 1.1rem; margin: 0; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.badge-env {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.topbar-actions { display: flex; gap: 8px; }

.container { max-width: 1400px; margin: 24px auto; padding: 0 20px 48px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; }
.text-green { color: var(--green); }
.text-blue { color: #60a5fa; }
.text-amber { color: var(--amber); }
.text-muted { color: var(--muted); }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 { font-size: 0.95rem; margin: 0 0 14px; font-weight: 600; color: #cbd5e1; }

.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar-meta { display: flex; justify-content: space-between; font-size: 0.82rem; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #60a5fa); border-radius: 999px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pill {
  background: var(--amber);
  color: #111;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.panel-header h2 { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.78rem; }
.subtext { font-size: 0.75rem; color: var(--muted); display: block; margin-top: 2px; }

.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.status-active { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-revoked { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.status-warn { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-info { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }

.btn {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
}
.btn:hover { filter: brightness(1.12); }
.btn-sm { padding: 4px 8px; font-size: 0.76rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-warning { background: #b45309; border-color: #b45309; color: #fff; }
.btn-danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-ghost { background: transparent; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

.input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 0.85rem;
  min-width: 240px;
}
.input:focus { outline: none; border-color: var(--primary); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: min(480px, 92vw);
}
.modal h3 { margin: 0 0 14px; font-size: 1rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.82rem; color: var(--muted); }
.field .input { width: 100%; min-width: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--surface-2);
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 100;
}
.hidden { display: none !important; }
