:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #17202a;
  --muted: #667085;
  --border: #d9e0e8;
  --blue: #2563eb;
  --green: #149268;
  --orange: #d97706;
  --teal: #0891b2;
  --violet: #7c3aed;
  --red: #dc2626;
  --shadow: 0 12px 32px rgba(18, 27, 41, 0.08);
}

* {
  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;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

.header-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.state-pill.ok {
  border-color: rgba(20, 146, 104, 0.26);
  color: var(--green);
}

.state-pill.error {
  border-color: rgba(220, 38, 38, 0.28);
  color: var(--red);
}

.timestamp {
  min-width: 158px;
  text-align: right;
}

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

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

.metric-card {
  position: relative;
  min-height: 132px;
  padding: 18px;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--blue);
}

.metric-card.accent-green::before {
  background: var(--green);
}

.metric-card.accent-orange::before {
  background: var(--orange);
}

.metric-card.accent-violet::before {
  background: var(--violet);
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-value {
  margin-top: 14px;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 800;
  white-space: nowrap;
}

.metric-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  min-height: 18px;
}

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

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented button {
  min-width: 76px;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: #17202a;
  color: #ffffff;
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

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

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

.panel.wide {
  grid-column: 1 / -1;
}

.panel.compact {
  min-height: 190px;
}

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

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.legend span,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--blue);
}

.swatch.green {
  background: var(--green);
}

.swatch.orange {
  background: var(--orange);
}

.swatch.teal {
  background: var(--teal);
}

.swatch.violet {
  background: var(--violet);
}

.swatch.red {
  background: var(--red);
}

.chart {
  width: 100%;
  height: 282px;
  min-height: 282px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

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

.axis-label {
  fill: #667085;
  font-size: 12px;
}

.grid-line {
  stroke: #dce3ec;
  stroke-width: 1;
}

.series-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-chart {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.status-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-chip {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 700;
}

.status-chip b {
  color: var(--muted);
}

.info-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.info-list div {
  min-width: 0;
}

.info-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.info-list dd {
  margin: 5px 0 0;
  min-height: 20px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

  .chart-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .app-header,
  .toolbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-status {
    justify-content: flex-start;
  }

  .timestamp {
    min-width: 0;
    text-align: left;
  }

  h1 {
    font-size: 25px;
  }

  .metrics-grid,
  .info-list {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 29px;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
  }
}
