:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #141820;
  --surface-2: #181e26;
  --line: #2a313b;
  --muted: #8e9ba8;
  --text: #eef4f6;
  --in: #39d98a;
  --out: #54b7ff;
  --cpu: #c7f464;
  --warn: #f2c94c;
  --alert: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar,
.panel-heading,
.status-strip,
.legend,
.metric-card,
.server-row,
.server-values,
.spark-title {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.08;
  font-weight: 720;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-strip {
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.pill {
  min-width: 88px;
  padding: 7px 10px;
  border: 1px solid rgba(57, 217, 138, 0.35);
  border-radius: 999px;
  background: rgba(57, 217, 138, 0.11);
  color: var(--in);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.pill.demo,
.pill.demo-fallback {
  border-color: rgba(242, 201, 76, 0.38);
  background: rgba(242, 201, 76, 0.12);
  color: var(--warn);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric-card,
.panel,
.spark-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card {
  justify-content: space-between;
  min-height: 84px;
  padding: 18px;
  gap: 12px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric-card strong {
  font-size: 26px;
  line-height: 1;
  white-space: nowrap;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.38fr);
  gap: 12px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.legend {
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 999px;
}

.legend-in {
  background: var(--in);
}

.legend-out {
  background: var(--out);
}

canvas {
  display: block;
  width: 100%;
}

#aggregateChart {
  height: 360px;
}

.server-list {
  display: grid;
  gap: 10px;
}

.server-row {
  min-height: 104px;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  background: var(--surface-2);
}

.server-row.warning {
  border-color: rgba(242, 201, 76, 0.42);
}

.server-row.critical {
  border-color: rgba(255, 107, 107, 0.52);
}

.server-head,
.bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.server-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 750;
}

.server-values {
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.bar-stack {
  display: grid;
  gap: 6px;
}

.bar-line {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.bar-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 820;
  white-space: nowrap;
}

.bar {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--width);
  border-radius: inherit;
}

.bar.in span {
  background: var(--in);
}

.bar.out span {
  background: var(--out);
}

.bar.cpu span {
  background: var(--cpu);
}

.spark-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.spark-card {
  min-width: 0;
  padding: 14px;
}

.spark-title,
.checkmk-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.spark-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.spark-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.spark-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.checkmk-card {
  padding: 0;
  overflow: hidden;
  background: #202932;
}

.checkmk-title {
  display: block;
  margin: 0;
  padding: 7px 10px;
  overflow: hidden;
  background: #252f39;
  color: #f5f7f8;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 820;
}

.checkmk-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 10px 8px;
  color: #dce7ec;
  font-size: 10px;
  font-weight: 760;
  white-space: nowrap;
}

.checkmk-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.spark-canvas {
  height: 92px;
}

.error-banner {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 107, 0.4);
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.12);
  color: #ffd1d1;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

@media (min-width: 1200px) and (min-height: 800px) {
  body {
    overflow: hidden;
  }

  .shell {
    width: 100%;
    height: 100vh;
    padding: 18px 22px;
    display: grid;
    grid-template-rows: 48px 72px minmax(300px, 36vh) minmax(0, 1fr);
    gap: 10px;
  }

  .topbar,
  .summary-grid,
  .spark-grid {
    margin: 0;
  }

  h1 {
    font-size: 27px;
  }

  h2 {
    font-size: 16px;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 11px;
  }

  .status-strip {
    font-size: 13px;
  }

  .metric-card {
    min-height: 0;
    padding: 12px 14px;
  }

  .metric-card strong {
    font-size: 23px;
  }

  .main-grid {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) 440px;
  }

  .panel {
    padding: 14px;
  }

  .chart-panel,
  .server-panel {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .panel-heading {
    margin-bottom: 10px;
  }

  #aggregateChart {
    height: 100%;
    min-height: 0;
  }

  .server-list {
    min-height: 0;
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .server-row {
    min-height: 0;
    padding: 9px 10px;
    gap: 7px;
  }

  .server-values {
    gap: 8px;
    font-size: 10px;
  }

  .bar-stack {
    gap: 5px;
  }

  .bar {
    height: 7px;
  }

  .spark-grid {
    min-height: 0;
  }

  .spark-card {
    padding: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: 32px minmax(0, 1fr) 28px;
  }

  .spark-title {
    margin-bottom: 6px;
  }

  .spark-canvas {
    height: 100%;
    min-height: 0;
  }

  .checkmk-title {
    padding: 7px 9px;
    font-size: 13px;
  }

  .checkmk-meta {
    padding: 6px 9px;
    font-size: 10px;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .metric-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .spark-grid {
    grid-template-columns: 1fr;
  }

  .metric-card strong {
    font-size: 23px;
  }

  #aggregateChart {
    height: 300px;
  }
}
