:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #151d36;
  --panel-soft: #1a2443;
  --border: #2d3a63;
  --text: #ecf2ff;
  --muted: #a6b4d8;
  --accent: #76bcff;
  --danger: #ff7676;
  --ok: #49d59a;
  --warn: #f6c760;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #1b2b58 0%, var(--bg) 42%, #080d1d 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: rgba(10, 15, 31, 0.96);
  border-right: 1px solid #222f54;
  padding: 1.15rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  display: grid;
  place-content: center;
  font-weight: 900;
  color: #04132d;
  background: linear-gradient(145deg, #7fc5ff, #5a80ff);
}

.brand-block h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
}

.brand-block p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.73rem;
}

.primary-action {
  border: 0;
  border-radius: 0.7rem;
  background: linear-gradient(120deg, #2f74c9, #4458d9);
  color: #fff;
  padding: 0.67rem 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.menu {
  display: grid;
  gap: 0.25rem;
}

.menu a,
.sidebar-footer a {
  padding: 0.62rem 0.68rem;
  border-radius: 0.55rem;
  color: #d0dbf8;
  font-size: 0.92rem;
}

.menu a.active,
.menu a:hover,
.sidebar-footer a:hover {
  background: rgba(118, 188, 255, 0.12);
  color: #9ad3ff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 0.25rem;
  border-top: 1px solid #243258;
  padding-top: 0.8rem;
}

.main-panel {
  padding: 1.1rem 1.2rem 1.4rem;
}

.topbar {
  border: 1px solid var(--border);
  background: rgba(17, 25, 48, 0.86);
  padding: 0.9rem 1rem;
  border-radius: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.topbar h2 {
  margin: 0;
  font-size: 1.05rem;
}

.topbar p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar-actions {
  display: flex;
  gap: 0.55rem;
}

input,
button {
  font: inherit;
}

#search-input {
  width: min(350px, 52vw);
  border: 1px solid #40548b;
  border-radius: 0.6rem;
  padding: 0.5rem 0.68rem;
  color: var(--text);
  background: #0e1733;
}

#refresh-btn,
.command-item button {
  border: 1px solid #365395;
  border-radius: 0.6rem;
  padding: 0.5rem 0.72rem;
  background: #183671;
  color: #ebf1ff;
  cursor: pointer;
}

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

.kpi-card {
  background: linear-gradient(160deg, rgba(29, 39, 68, 0.95), rgba(20, 28, 53, 0.95));
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.85rem;
}

.kpi-card h3 {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: #bfd0f7;
}

.kpi-value {
  margin: 0.35rem 0 0.3rem;
  font-size: 1.68rem;
  font-weight: 750;
}

.kpi-value.danger {
  color: var(--danger);
}

.kpi-card small {
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 0.75rem;
}

.panel {
  background: rgba(22, 31, 58, 0.92);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.9rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.legend {
  display: flex;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.77rem;
}

.legend-dot {
  width: 0.6rem;
  height: 0.6rem;
  display: inline-block;
  border-radius: 999px;
  background: #6ec2ff;
}

.legend-dot.muted {
  background: #355783;
}

.chart-bars {
  height: 220px;
  border-radius: 0.6rem;
  border: 1px solid #304678;
  padding: 0.6rem;
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  align-items: end;
  gap: 0.22rem;
  background: linear-gradient(180deg, #0f1936 0%, #0d1630 100%);
}

.chart-bar {
  border-radius: 0.3rem 0.3rem 0 0;
  background: linear-gradient(180deg, #4a8fdf 0%, #2b4c91 100%);
  opacity: 0.75;
}

.chart-bar.is-current {
  background: linear-gradient(180deg, #6dd2ff 0%, #2b6de3 100%);
  opacity: 1;
}

.chart-labels {
  margin-top: 0.45rem;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
}

.pill {
  margin: 0;
  border: 1px solid #36507f;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  color: #b8cdf7;
  font-size: 0.77rem;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #2a3d66;
  padding: 0.58rem 0.35rem;
  text-align: left;
  font-size: 0.85rem;
}

th {
  color: #bed0f6;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td code {
  color: #9bcfff;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
}

.status-running {
  color: #dafbe9;
  background: rgba(73, 213, 154, 0.26);
}

.status-completed {
  color: #d3f1ff;
  background: rgba(102, 174, 247, 0.24);
}

.status-failed {
  color: #ffd8d8;
  background: rgba(255, 118, 118, 0.27);
}

.status-queued {
  color: #ffebc0;
  background: rgba(246, 199, 96, 0.24);
}

.panel-chart {
  grid-column: 1;
}

.panel-table {
  grid-column: 1;
}

.panel-alerts,
.panel-docs {
  grid-column: 2;
}

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.alert-card {
  border: 1px solid #355086;
  border-left-width: 5px;
  border-radius: 0.65rem;
  padding: 0.6rem 0.65rem;
  background: #122246;
}

.alert-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.alert-head span,
.alert-card p,
.alert-card small {
  color: var(--muted);
  font-size: 0.78rem;
}

.alert-critical {
  border-left-color: var(--danger);
}

.alert-warning {
  border-left-color: var(--warn);
}

.alert-info {
  border-left-color: var(--accent);
}

.docs-layout {
  display: grid;
  gap: 0.6rem;
}

.meta-block {
  border: 1px solid #385082;
  border-radius: 0.65rem;
  padding: 0.6rem;
  background: var(--panel-soft);
}

.meta-block p {
  margin: 0.2rem 0;
  font-size: 0.84rem;
}

.command-list {
  display: grid;
  gap: 0.42rem;
}

.command-item {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem;
  align-items: center;
  background: #0f1c3c;
  border: 1px solid #36548a;
  border-radius: 0.6rem;
  padding: 0.42rem 0.5rem;
}

.command-item code {
  color: #b8dbff;
  font-size: 0.77rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}

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

  .panel-alerts,
  .panel-docs {
    grid-column: auto;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
  }

  #search-input {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
