:root {
  --bg: #0b1120;
  --bg-elev: #111827;
  --card: #151e31;
  --card-border: rgba(148, 163, 184, 0.14);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.1), transparent 45%),
              radial-gradient(circle at bottom left, rgba(59, 130, 246, 0.08), transparent 45%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.25);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 16.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.kpi-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-active { background: rgba(34, 197, 94, 0.16); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-exhausted { background: rgba(245, 158, 11, 0.16); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-blocked, .badge-disabled { background: rgba(239, 68, 68, 0.16); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-muted { background: rgba(148, 163, 184, 0.14); color: var(--muted); border: 1px solid rgba(148, 163, 184, 0.25); }

.progress-wrap {
  width: 100%;
  height: 10px;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.15);
  margin: 12px 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #3b82f6);
  transition: width 0.3s ease;
}

.progress-bar.warn { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--card-border);
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}

.btn:hover:not(:disabled) { background: rgba(51, 65, 85, 0.95); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-color: rgba(56, 189, 248, 0.4);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #0284c7, #1d4ed8); }

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.3); }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.input, textarea, select {
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.24);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
}

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

.mono { font-family: var(--mono); word-break: break-all; }

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.code-box {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
  color: #bae6fd;
}

.alert {
  padding: 13px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.alert-warn {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.alert-info {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #bae6fd;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}

.qr-wrap {
  background: #fff;
  padding: 10px;
  border-radius: 12px;
  width: 170px;
  height: 170px;
  display: grid;
  place-items: center;
}

.qr-wrap svg {
  width: 100%;
  height: 100%;
}

.center-card {
  max-width: 460px;
  margin: 64px auto;
  text-align: center;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--card-border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.45);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 9999;
}

.muted { color: var(--muted); font-size: 12.5px; }
.hidden { display: none !important; }
label.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 12px; }
