:root {
  --bg: #090b10;
  --surface: #11151f;
  --surface-2: #171c29;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef2f8;
  --muted: #8b95a7;
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.14);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top center, #121827 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

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

.brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

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

.muted-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Pulse & status dots */
.pulse-dot,
.status-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.pulse-dot.operational,
.status-circle.operational {
  background: var(--green);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.65);
}

.pulse-dot.partial_outage,
.status-circle.partial_outage {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.65);
}

.pulse-dot.major_outage,
.status-circle.major_outage {
  background: var(--red);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.65);
}

/* Admin Nav Tabs */
.admin-nav {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.tab-panel.active {
  display: flex;
}

/* Overall Banner */
.overall-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.overall-banner.operational {
  border-color: rgba(16, 185, 129, 0.32);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--surface) 60%);
}

.overall-banner.partial_outage {
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.11), var(--surface) 60%);
}

.overall-banner.major_outage {
  border-color: rgba(239, 68, 68, 0.35);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.11), var(--surface) 60%);
}

.overall-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.overall-left h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.overall-stats {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-header.wrap {
  flex-wrap: wrap;
}

.card-header h3 {
  font-size: 0.98rem;
  font-weight: 600;
}

/* Monitor Groups & Items */
.monitor-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.group-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.monitor-row {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.monitor-row:first-of-type {
  border-top: none;
  padding-top: 4px;
}

.monitor-row:last-of-type {
  padding-bottom: 2px;
}

.monitor-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.monitor-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 0.95rem;
}

.monitor-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Uptime Bars */
.uptime-bars {
  display: grid;
  grid-template-columns: repeat(45, 1fr);
  gap: 3px;
  height: 24px;
}

.uptime-bar {
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.uptime-bar:hover {
  transform: scaleY(1.18);
}

.uptime-bar.up {
  background: var(--green);
}

.uptime-bar.down {
  background: var(--red);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-up {
  background: var(--green-soft);
  color: #34d399;
}

.badge-down {
  background: var(--red-soft);
  color: #f87171;
}

.badge-pending,
.badge-warn {
  background: var(--amber-soft);
  color: #fbbf24;
}

.badge-info {
  background: var(--blue-soft);
  color: #60a5fa;
}

.badge-muted {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

/* Host Bar & Metrics Grid */
.host-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 18px;
}

.host-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.metric-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.sparkline {
  height: 44px;
  margin-top: 6px;
}

.sparkline svg {
  width: 100%;
  height: 100%;
  display: block;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-fill.high {
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.net-pills {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.net-pill {
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.net-pill.rx {
  color: #34d399;
}

.net-pill.tx {
  color: #60a5fa;
}

/* Tables */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

/* Admin Monitors List */
.admin-monitors-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-monitor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.admin-monitor-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-monitor-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 600;
}

.admin-monitor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Incidents */
.incidents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.incident-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.84rem;
  flex-wrap: wrap;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--red-soft);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  outline: none;
}

.input:focus {
  border-color: var(--blue);
}

.input-sm {
  width: auto;
  padding: 6px 10px;
  font-size: 0.82rem;
}

/* Forms & Modals */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.checkbox-field {
  justify-content: flex-end;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  cursor: pointer;
  padding: 8px 0;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.full-width {
  width: 100%;
}

.error-text {
  color: #f87171;
  font-size: 0.83rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 0.88rem;
}
