:root {
  color-scheme: light dark;
  --page-bg: #f7f9fb;
  --surface: #ffffff;
  --surface-muted: #f3f6f8;
  --text: #20262d;
  --text-muted: #56616d;
  --border: #d7dee5;
  --green: #2ea44f;
  --green-dark: #238636;
  --green-bg: #effaf2;
  --green-text: #116329;
  --amber: #d97706;
  --amber-dark: #92400e;
  --amber-bg: #fff8e6;
  --amber-text: #7c350b;
  --red: #dc2626;
  --red-dark: #991b1b;
  --red-bg: #fff0f0;
  --red-text: #8f1818;
  --blue: #1d5fd1;
  --focus: #2563eb;
  --chart-grid: #dfe6ec;
  --chart-1: #238636;
  --chart-2: #2563eb;
  --chart-3: #ca8a04;
  --chart-4: #ea580c;
  --chart-5: #dc2626;
  --chart-6: #b91c1c;
  --chart-7: #701a1a;
  --shadow: 0 1px 2px rgb(27 31 36 / 7%), 0 5px 18px rgb(27 31 36 / 5%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
select {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(100% - 32px, 1120px);
  margin-inline: auto;
  padding-bottom: 32px;
}

.logo-header {
  margin-bottom: 18px;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.logo-header a {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.logo-header img {
  display: block;
  width: 140px;
  height: 21px;
  transition: opacity 160ms ease;
}

.logo-header a:hover img {
  opacity: 0.82;
}

.status-hero {
  display: flex;
  min-height: 190px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  margin-bottom: 28px;
  padding: 30px 34px;
  border-radius: 14px;
  box-shadow: 0 6px 22px rgb(27 31 36 / 16%);
  color: #ffffff;
}

.status-hero.status-operational {
  background: linear-gradient(125deg, var(--green-dark), #153b29 78%);
}

.status-hero.status-degraded {
  background: linear-gradient(125deg, var(--amber-dark), #422006 78%);
}

.status-hero.status-outage {
  background: linear-gradient(125deg, var(--red-dark), #3f1010 78%);
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.status-hero .eyebrow {
  color: #ffffff;
}

.status-hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.overall-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  font-size: 1.05rem;
}

.status-symbol::before {
  display: inline-grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 50%;
  background: rgb(255 255 255 / 12%);
  font-weight: 800;
  line-height: 1;
}

.status-operational .status-symbol::before {
  content: "✓";
}

.status-degraded .status-symbol::before {
  content: "!";
}

.status-outage .status-symbol::before {
  content: "×";
}

.freshness {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0 0;
  color: #ffffff;
  font-size: 0.875rem;
}

.freshness.is-stale {
  font-weight: 650;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.refresh-button {
  min-width: 132px;
  min-height: 46px;
  padding: 10px 17px;
  border: 1px solid rgb(255 255 255 / 50%);
  border-radius: 8px;
  background: #ffffff;
  color: #1f3b2b;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
}

.refresh-button:hover {
  background: #f0fdf4;
}

.refresh-button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.service-section,
.chart-section {
  margin-bottom: 36px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 3px 13px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.section-heading > p,
.chart-description {
  max-width: 620px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.chart-description {
  margin: -5px 3px 14px;
}

.status-card,
.chart-card,
.chart-data {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-card {
  overflow: hidden;
}

.service-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.9rem;
  text-align: left;
}

.service-column {
  width: 48%;
}

.latency-column {
  width: 27%;
}

.status-column {
  width: 25%;
}

.service-table thead {
  background: var(--surface-muted);
}

.service-table thead th {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.service-table tbody th,
.service-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.service-table tbody th {
  border-left: 4px solid transparent;
  font-weight: 700;
}

.service-table tbody th span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 450;
}

.service-table tbody td:last-child {
  font-weight: 650;
}

.service-table tbody tr:last-child > * {
  border-bottom: 0;
}

.service-table tbody tr.status-operational {
  background: var(--green-bg);
}

.service-table tbody tr.status-operational th {
  border-left-color: var(--green);
}

.service-table tbody tr.status-operational td:last-child {
  color: var(--green-text);
}

.service-table tbody tr.status-degraded {
  background: var(--amber-bg);
}

.service-table tbody tr.status-degraded th {
  border-left-color: var(--amber);
}

.service-table tbody tr.status-degraded td:last-child {
  color: var(--amber-text);
}

.service-table tbody tr.status-outage {
  background: var(--red-bg);
}

.service-table tbody tr.status-outage th {
  border-left-color: var(--red);
}

.service-table tbody tr.status-outage td:last-child {
  color: var(--red-text);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-strip article {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(27 31 36 / 4%);
}

.metric-strip span,
.metric-strip small {
  display: block;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-strip span {
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.metric-strip strong {
  display: block;
  overflow: hidden;
  margin: 3px 0 1px;
  font-size: 1.18rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-card {
  position: relative;
  overflow: hidden;
}

.chart-toolbar,
.bulk-controls {
  display: flex;
  min-height: 60px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.chart-toolbar p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.chart-toolbar label,
.bulk-controls > label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
}

select {
  min-height: 44px;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.batch-selector {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 3px;
}

.batch-selector button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.batch-selector button:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.batch-selector button[aria-pressed="true"] {
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #ffffff;
}

.chart-visual {
  position: relative;
  height: 350px;
  padding: 12px 10px 4px;
}

.chart-visual canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-tooltip {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  max-width: 250px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 5px 18px rgb(27 31 36 / 18%);
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.45;
  pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  color: var(--text-muted);
}

.chart-loading,
.chart-error,
.chart-message:not([hidden]) {
  position: absolute;
  z-index: 4;
  inset: 50% auto auto 50%;
  width: min(90%, 420px);
  translate: -50% -50%;
  text-align: center;
}

.chart-loading {
  width: auto;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text-muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.chart-error .chart-message {
  position: static;
  width: auto;
  translate: none;
}

.chart-message {
  margin: 0;
  color: var(--red-text);
  font-weight: 650;
}

.retry-button,
.error-card a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 13px;
  padding: 9px 16px;
  border: 0;
  border-radius: 7px;
  background: var(--green-dark);
  color: #ffffff;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
}

.retry-button:hover,
.error-card a:hover {
  background: #1b6f2c;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 16px;
  margin: 0;
  padding: 4px 18px 17px;
  color: var(--text-muted);
  font-size: 0.75rem;
  list-style: none;
}

.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend li > span {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--chart-1);
}

.chart-legend li:nth-child(2) > span {
  background: var(--chart-2);
}

.chart-legend li:nth-child(3) > span {
  background: var(--chart-3);
}

.chart-legend li:nth-child(4) > span {
  background: var(--chart-4);
}

.chart-legend li:nth-child(5) > span {
  background: var(--chart-5);
}

.chart-legend li:nth-child(6) > span {
  background: var(--chart-6);
}

.chart-legend li:nth-child(7) > span {
  background: var(--chart-7);
}

.chart-data {
  margin-top: 10px;
  overflow: hidden;
}

.chart-data summary {
  min-height: 46px;
  padding: 11px 15px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.chart-data[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.chart-data > p {
  margin: 12px 15px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.chart-data-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.chart-data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: right;
}

.chart-data-table thead {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--surface-muted);
}

.chart-data-table th,
.chart-data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.chart-data-table th:first-child,
.chart-data-table td:first-child {
  text-align: left;
}

.chart-data-table tbody tr:last-child > * {
  border-bottom: 0;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 3px 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.page-footer p {
  margin: 0;
}

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.error-card {
  width: min(100%, 560px);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.error-card h1 {
  margin: 4px 0 8px;
  font-size: 1.6rem;
}

.error-card p {
  margin: 8px 0;
  color: var(--text-muted);
}

.error-card .error-code {
  color: var(--red);
  font-size: 2rem;
  font-weight: 700;
}

.request-id {
  overflow-wrap: anywhere;
  font-size: 0.75rem;
}

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

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

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 7px;
  }

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

  .bulk-controls > label {
    justify-content: space-between;
  }
}

@media (max-width: 600px) {
  .page-shell {
    width: min(100% - 24px, 1120px);
  }

  .logo-header {
    margin-bottom: 14px;
    padding: 12px 0 10px;
  }

  .status-hero {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 20px;
    padding: 24px 20px 20px;
  }

  .refresh-button {
    width: 100%;
  }

  .service-section,
  .chart-section {
    margin-bottom: 30px;
  }

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

  .chart-toolbar label {
    justify-content: space-between;
  }

  .chart-visual {
    height: 310px;
    padding-inline: 3px;
  }

  .chart-legend {
    justify-content: start;
    padding-inline: 14px;
  }

  .page-footer {
    align-items: start;
    flex-direction: column;
    gap: 7px;
  }
}

@media (max-width: 420px) {
  .service-table colgroup,
  .service-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .service-table,
  .service-table tbody {
    display: block;
  }

  .service-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 13px 13px 13px 0;
    border-bottom: 1px solid var(--border);
  }

  .service-table tbody tr:last-child {
    border-bottom: 0;
  }

  .service-table tbody th,
  .service-table tbody td {
    padding: 0;
    border-bottom: 0;
  }

  .service-table tbody th {
    grid-row: 1 / span 2;
    padding: 3px 12px;
  }

  .service-table tbody td {
    text-align: right;
  }

  .service-table tbody td::before {
    display: block;
    color: var(--text-muted);
    content: attr(data-label);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
  }

  .service-table tbody td:last-child {
    margin-top: 6px;
  }

  .metric-strip article {
    padding: 12px;
  }

  .metric-strip strong {
    font-size: 1.05rem;
  }

  .batch-selector button {
    min-height: 44px;
    padding-inline: 11px;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #0d1117;
    --surface: #161b22;
    --surface-muted: #20262e;
    --text: #f0f6fc;
    --text-muted: #a7b1bc;
    --border: #303842;
    --green-bg: #102b17;
    --green-text: #7ee787;
    --amber-bg: #2d2108;
    --amber-text: #f2cc60;
    --red-bg: #31151a;
    --red-text: #ff8a82;
    --blue: #70a7ff;
    --focus: #79b8ff;
    --chart-grid: #303842;
    --shadow: 0 1px 3px rgb(0 0 0 / 35%);
  }
}

@media print {
  .refresh-button,
  .chart-toolbar,
  .bulk-controls,
  .chart-tooltip {
    display: none !important;
  }

  .status-card,
  .chart-card,
  .status-hero,
  .metric-strip article {
    break-inside: avoid;
    box-shadow: none;
  }
}
