:root {
  --page-bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --border: #d9dee7;
  --border-soft: #e8ebf1;
  --text: #202633;
  --muted: #667085;
  --muted-strong: #4b5565;
  --brand: #5865f2;
  --operational: #2fb344;
  --degraded: #f59f00;
  --partial: #f76707;
  --major: #e03131;
  --maintenance: #228be6;
  --nodata: #c7ccd6;
  --chart-grid: #edf0f5;
  --shadow: 0 10px 28px rgba(32, 38, 51, 0.07);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

.page-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  display: block;
  border-radius: 8px;
}

.last-updated {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.status-main {
  padding: 34px 0 56px;
}

.overall-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 116px;
  margin-bottom: 26px;
  padding: 28px 30px;
  border: 1px solid var(--border);
  border-left: 8px solid var(--nodata);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.overall-panel.status-operational {
  border-left-color: var(--operational);
}

.overall-panel.status-degraded_performance {
  border-left-color: var(--degraded);
}

.overall-panel.status-partial_outage {
  border-left-color: var(--partial);
}

.overall-panel.status-major_outage {
  border-left-color: var(--major);
}

.overall-panel.status-maintenance {
  border-left-color: var(--maintenance);
}

.overall-label {
  margin: 0 0 8px;
  color: var(--text);
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 700;
  line-height: 1.15;
}

.overall-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.overall-percent {
  flex: 0 0 auto;
  color: var(--muted-strong);
  font-size: 26px;
  font-weight: 700;
  white-space: nowrap;
}

.status-section {
  margin-top: 24px;
  padding: 26px 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.section-header h1,
.section-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}

.section-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.monitor-groups {
  display: grid;
  gap: 22px;
}

.monitor-group {
  display: grid;
  gap: 12px;
}

.group-title {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.monitor-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(360px, 2.2fr) minmax(104px, auto);
  align-items: center;
  gap: 18px;
  padding: 15px 0;
  border-top: 1px solid var(--border-soft);
}

.monitor-row:first-of-type {
  border-top: 0;
}

.monitor-main {
  min-width: 0;
}

.monitor-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.monitor-name {
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  color: var(--muted-strong);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--nodata);
}

.status-dot.status-operational,
.legend-swatch.status-operational,
.history-day.status-operational {
  background: var(--operational);
}

.status-dot.status-degraded_performance,
.legend-swatch.status-degraded_performance,
.history-day.status-degraded_performance {
  background: var(--degraded);
}

.status-dot.status-partial_outage,
.legend-swatch.status-partial_outage,
.history-day.status-partial_outage {
  background: var(--partial);
}

.status-dot.status-major_outage,
.legend-swatch.status-major_outage,
.history-day.status-major_outage {
  background: var(--major);
}

.status-dot.status-maintenance,
.legend-swatch.status-maintenance,
.history-day.status-maintenance {
  background: var(--maintenance);
}

.status-dot.status-no_data,
.legend-swatch.status-no_data,
.history-day.status-no_data {
  background: var(--nodata);
}

.history-wrap {
  position: relative;
  min-width: 0;
}

.history-bar {
  display: grid;
  grid-template-columns: repeat(90, minmax(2px, 1fr));
  gap: 2px;
  width: 100%;
  min-height: 34px;
  align-items: stretch;
}

.history-day {
  display: block;
  min-width: 2px;
  height: 34px;
  border-radius: 2px;
  outline: 0;
}

.history-day:focus-visible {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--brand);
}

.history-tooltip {
  position: absolute;
  z-index: 10;
  width: min(280px, calc(100vw - 40px));
  padding: 12px 13px;
  border: 1px solid rgba(32, 38, 51, 0.18);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(32, 38, 51, 0.16);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  transform: translateX(-50%);
}

.history-tooltip[hidden] {
  display: none;
}

.history-tooltip-title {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
}

.history-tooltip-line {
  color: var(--muted-strong);
  font-weight: 650;
}

.history-tooltip-muted {
  margin-top: 4px;
  color: var(--muted);
}

.history-tooltip-section {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  color: var(--text);
  font-weight: 700;
}

.history-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.uptime-value {
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 13px;
}

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

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.metrics-header {
  align-items: center;
}

.metrics-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.monitor-select {
  min-width: 150px;
  height: 38px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.range-tabs {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.range-tab {
  min-width: 64px;
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
}

.range-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(32, 38, 51, 0.12);
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fafbfc);
}

#latency-chart {
  display: block;
  width: 100%;
  height: 320px;
}

.chart-tooltip {
  position: absolute;
  z-index: 12;
  min-width: 150px;
  padding: 10px 11px;
  border: 1px solid rgba(32, 38, 51, 0.18);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(32, 38, 51, 0.16);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  transform: translateX(-50%);
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip-title {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
}

.chart-tooltip-line {
  color: var(--muted-strong);
  font-weight: 650;
}

.chart-tooltip-muted {
  margin-top: 3px;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 20px, 1040px);
  }

  .header-inner {
    min-height: 64px;
  }

  .last-updated {
    font-size: 12px;
  }

  .status-main {
    padding-top: 20px;
  }

  .overall-panel,
  .status-section {
    padding: 20px;
  }

  .overall-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .overall-percent {
    font-size: 22px;
  }

  .section-header,
  .metrics-header,
  .metrics-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .monitor-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .uptime-value {
    text-align: left;
  }

  .history-bar {
    min-width: 100%;
  }

  .history-day {
    height: 30px;
  }
}

@media (max-width: 520px) {
  .brand span {
    font-size: 16px;
  }

  .brand img {
    width: 32px;
    height: 32px;
  }

  .last-updated {
    white-space: normal;
    text-align: right;
  }

  .overall-label {
    font-size: 25px;
  }

  .range-tabs {
    width: 100%;
  }

  .range-tab {
    flex: 1;
    min-width: 0;
  }
}
