:root {
  --bg: #040608;
  --bg-panel: #0a0e14;
  --bg-elevated: #0f141c;
  --border: #1a2332;
  --border-bright: #243044;
  --text: #e8edf4;
  --muted: #7a8a9e;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --green: #4ade80;
  --green-dim: #14532d;
  --amber: #fbbf24;
  --red: #f87171;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --radius: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 10px 16px;
  background: #fff;
  color: #000;
  font-weight: 600;
}

.skip:focus {
  left: 12px;
  top: 12px;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 1.25rem;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1rem;
  color: var(--cyan);
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--cyan-dim), var(--green-dim));
  border: 1px solid var(--border-bright);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover {
  background: rgba(34, 211, 238, 0.08);
  color: var(--text);
}

.sidebar nav a[aria-current="page"] {
  background: rgba(34, 211, 238, 0.12);
  color: var(--cyan);
  font-weight: 600;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-bright);
}

.sidebar nav a[aria-current="page"] .nav-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.sidebar-meta {
  margin-top: auto;
  padding: 1rem 0.5rem 0;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.6;
}

.sidebar-meta strong {
  display: block;
  color: var(--text);
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}

.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--topbar-h);
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pill-live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--green);
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--green-dim);
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.06);
}

.pill-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.btn-ghost {
  appearance: none;
  border: 1px solid var(--border-bright);
  background: transparent;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
}

.btn-ghost:hover {
  border-color: var(--cyan-dim);
  color: var(--text);
}

.menu-toggle {
  display: none;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
}

main {
  flex: 1;
  padding: 1.25rem 1.5rem 2rem;
}

.demo-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.demo-footer a {
  color: var(--cyan);
}

.grid-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.metric-card label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-family: var(--mono);
}

.metric-card .value {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.metric-card .delta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.metric-card.warn .value {
  color: var(--amber);
}

.metric-card.crit .value {
  color: var(--red);
}

.metric-card.ok .value {
  color: var(--green);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 36px;
  margin-top: 0.65rem;
}

.bar-chart span {
  flex: 1;
  min-width: 4px;
  border-radius: 2px 2px 0 0;
  background: var(--border-bright);
}

.bar-chart span.on {
  background: linear-gradient(180deg, var(--cyan), var(--cyan-dim));
}

.bar-chart span.mid {
  background: linear-gradient(180deg, var(--amber), #78350f);
}

.bar-chart span.lo {
  background: linear-gradient(180deg, var(--green), var(--green-dim));
}

.layout-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.panel-head a {
  font-size: 0.78rem;
  color: var(--cyan);
}

.panel-body {
  padding: 0.5rem 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.data-table a.row-link {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.badge-p1 {
  background: #450a0a;
  color: #fca5a5;
}

.badge-p2 {
  background: #422006;
  color: #fdba74;
}

.badge-p3 {
  background: #1e3a2f;
  color: #86efac;
}

.badge-ok {
  background: var(--green-dim);
  color: var(--green);
}

.badge-warn {
  background: #422006;
  color: var(--amber);
}

.badge-down {
  background: #450a0a;
  color: var(--red);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot.ok::before {
  background: var(--green);
}

.status-dot.degraded::before {
  background: var(--amber);
}

.status-dot.down::before {
  background: var(--red);
}

.sparkline {
  height: 32px;
  margin-top: 0.5rem;
  border-radius: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--border) 0 6px,
    transparent 6px 10px
  );
  position: relative;
  overflow: hidden;
}

.sparkline::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--cyan) 15%,
    var(--cyan) 35%,
    transparent 40%,
    var(--green) 55%,
    var(--green) 75%,
    transparent 85%
  );
  opacity: 0.35;
  mask-image: linear-gradient(180deg, #000 30%, transparent);
}

.hbar-list {
  list-style: none;
  margin: 0;
  padding: 0.75rem 1rem;
}

.hbar-list li {
  display: grid;
  grid-template-columns: 100px 1fr 48px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  font-size: 0.82rem;
}

.hbar-list .track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.hbar-list .fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
}

.hbar-list .pct {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.page-toolbar select,
.page-toolbar input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
}

.page-toolbar .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding: 1rem;
}

.meta-item label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 0.2rem;
}

.meta-item span {
  font-size: 0.88rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 1rem;
}

.timeline li {
  position: relative;
  padding-left: 1.25rem;
  padding-bottom: 1rem;
  border-left: 1px solid var(--border);
  margin-left: 0.35rem;
  font-size: 0.84rem;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 0.35rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
}

.timeline time {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.service-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.service-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
}

.service-card p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.uptime-bar {
  display: flex;
  gap: 2px;
  margin-top: 0.75rem;
}

.uptime-bar i {
  flex: 1;
  height: 24px;
  border-radius: 2px;
  background: var(--green-dim);
  font-style: normal;
}

.uptime-bar i.gap {
  background: var(--amber);
  opacity: 0.7;
}

.uptime-bar i.bad {
  background: #7f1d1d;
}

.alert-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.alert-row:last-child {
  border-bottom: 0;
}

.alert-sev {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.alert-body strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
}

.alert-body p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.breadcrumb {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.breadcrumb a {
  color: var(--cyan);
}

@media (max-width: 1100px) {
  .grid-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .layout-2,
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .status-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    width: min(var(--sidebar-w), 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5);
  }
  .app.nav-open .sidebar {
    transform: translateX(0);
  }
  .menu-toggle {
    display: inline-block;
  }
  .topbar {
    padding: 0 1rem;
  }
  main {
    padding: 1rem;
  }
  .grid-metrics {
    grid-template-columns: 1fr;
  }
  .status-grid {
    grid-template-columns: 1fr;
  }
}
