:root {
  --bg: #0b1220;
  --surface: #121b2e;
  --border: #23304c;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --danger: #ef4444;
  --online: #10b981;
  --unknown: #f59e0b;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { margin: 0; font-size: 1.25rem; }
.topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.container { max-width: 1380px; margin: 1.25rem auto; padding: 0 1rem; display: grid; gap: 1rem; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.card h2 { margin: 0 0 0.75rem 0; font-size: 1.05rem; }
.metric-card { display: grid; gap: 0.4rem; }
.metric-label { font-size: 0.85rem; color: var(--muted); }
.metric-value { font-size: 1.65rem; font-weight: 700; }

.bar {
  width: 100%;
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--primary); transition: width 0.25s ease; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.section-head h2 { margin: 0; }

.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.inline-form input, .inline-form select, .field input {
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
}
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.btn {
  border: 0;
  border-radius: 6px;
  padding: 0.48rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}
.btn-primary { background: var(--primary); }
.btn-secondary { background: #334155; }
.btn-danger { background: var(--danger); }
.btn-xs { padding: 0.25rem 0.55rem; font-size: 0.78rem; }

.table-wrap { overflow-x: auto; }
.scroll-table { max-height: 420px; overflow-y: auto; }
.scroll-table-sm { max-height: 290px; overflow-y: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.5rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; position: sticky; top: 0; background: var(--surface); }

.row-anomaly { background: rgba(239, 68, 68, 0.08); }
.text-danger { color: #f87171; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; word-break: break-all; }
.sql-preview { display: inline-block; max-width: 520px; color: #cbd5e1; }

.badge {
  display: inline-block;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-online { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.badge-offline { background: rgba(239, 68, 68, 0.18); color: #f87171; }
.badge-unknown { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-info { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }

.status-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill { font-size: 0.82rem; padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); }
.muted { color: var(--muted); }
.center { text-align: center; }

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; }
.auth-header h1 { margin: 0.5rem 0 0.2rem 0; font-size: 1.35rem; }
.stack { display: grid; gap: 0.9rem; margin-top: 1rem; }
.field { display: grid; gap: 0.35rem; font-size: 0.88rem; }
.alert { padding: 0.65rem 0.8rem; border-radius: 6px; margin-top: 0.75rem; font-size: 0.88rem; }
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5; }
