:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2129;
  --muted: #667085;
  --accent: #2557d6;
  --row-hover: #f8f9fb;
  --ok: #157f3b;
  --ok-bg: #e3f5e9;
  --warn: #9a5b00;
  --warn-bg: #fff2d6;
  --bad: #b42318;
  --bad-bg: #fde8e7;
  --neutral-bg: #eef0f3;
  --cell-up: #34a853;
  --cell-partial: #f0a429;
  --cell-down: #d93025;
  --cell-none: #dfe3e8;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --border: #2a3039;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --accent: #7aa2ff;
    --row-hover: #1c2129;
    --ok: #5fd38a;
    --ok-bg: #133222;
    --warn: #f5b84b;
    --warn-bg: #3a2a0c;
    --bad: #ff8a80;
    --bad-bg: #3d1614;
    --neutral-bg: #232932;
    --cell-up: #3fb465;
    --cell-partial: #e9a23b;
    --cell-down: #f2564b;
    --cell-none: #2c333d;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

h3 {
  font-size: 0.95rem;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.1rem;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

main.wrap {
  padding-top: 24px;
  padding-bottom: 48px;
}

/* Top bar */

.main-site-bar {
  background: var(--neutral-bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}

/* The padding sits on the link so the whole strip height is the tap target. */
.main-site-link {
  display: inline-block;
  padding: 4px 0;
  color: var(--muted);
  font-weight: 500;
}

.main-site-link:hover {
  color: var(--text);
  text-decoration: none;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 20px;
  white-space: nowrap;
}

.topnav form {
  margin: 0;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

/* Layout blocks */

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-head p {
  margin: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Tables */

.table-scroll {
  overflow-x: auto;
}

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

th,
td {
  padding: 10px 20px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--row-hover);
}

tbody tr.row-overdue,
tbody tr.row-overdue:hover {
  background: var(--bad-bg);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
  font-size: 0.875rem;
}

/* Badges and text states */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.row-overdue .badge-bad {
  background: var(--surface);
}

.kind {
  color: var(--muted);
  font-size: 0.8rem;
  margin-right: 4px;
}

.muted {
  color: var(--muted);
}

.text-bad-soft {
  color: var(--bad);
}

.cell-sub {
  display: block;
  margin-top: 2px;
}

.app-name {
  font-weight: 600;
}

.cell-sub .mono {
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.small {
  font-size: 0.85rem;
}

.text-bad {
  color: var(--bad);
  font-weight: 600;
}

.text-warn {
  color: var(--warn);
  font-weight: 600;
}

.text-ok {
  color: var(--ok);
  font-weight: 600;
}

.empty {
  margin: 0;
  padding: 20px;
  color: var(--muted);
}

/* Banners and alerts */

.banner {
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.banner-bad {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--text);
}

.banner-bad strong {
  color: var(--bad);
}

.banner-info {
  background: var(--neutral-bg);
  border-color: var(--border);
}

.card-note {
  margin: 0;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bad-bg);
  font-size: 0.9rem;
}

.card-subhead {
  padding: 14px 20px 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.alert-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.alert-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}

.alert-item:last-child {
  border-bottom: 0;
}

.alert-item .badge {
  flex: none;
  min-width: 68px;
  text-align: center;
}

.alert-title {
  flex: 1 1 320px;
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.alert-critical .alert-title {
  font-weight: 600;
}

.all-clear {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.dot-ok {
  background: var(--cell-up);
}

/* Uptime strips: one cell per hour */

.strip {
  display: inline-flex;
  gap: 2px;
  vertical-align: middle;
}

a.strip:hover {
  text-decoration: none;
  opacity: 0.85;
}

.cell {
  display: inline-block;
  width: 6px;
  height: 20px;
  border-radius: 2px;
  background: var(--cell-none);
}

.cell-up {
  background: var(--cell-up);
}

.cell-partial {
  background: var(--cell-partial);
}

.cell-down {
  background: var(--cell-down);
}

.cell-future {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--border);
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  padding: 10px 20px 14px;
  border-top: 1px solid var(--border);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend .cell {
  width: 10px;
  height: 10px;
}

.week {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px;
}

.week-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.week-day {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.strip-wide {
  display: flex;
  width: 100%;
  min-width: 0;
}

.strip-wide .cell {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  height: 22px;
}

.week-head .cell-label {
  height: auto;
  background: none;
  overflow: visible;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.75rem;
}

.breadcrumb {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-url {
  margin: -12px 0 20px;
  overflow-wrap: anywhere;
}

/* Login */

.login-card {
  max-width: 380px;
  margin: 48px auto;
  padding: 28px;
}

.login-card h1 {
  margin-bottom: 20px;
}

.login-card form {
  display: flex;
  flex-direction: column;
}

.login-card label {
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.button {
  margin-top: 4px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .button {
    color: #0f1216;
  }
}

.form-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bad-bg);
  color: var(--bad);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  main.wrap {
    padding-top: 16px;
  }

  th,
  td {
    padding: 10px 12px;
  }

  .card-head,
  .card-subhead {
    padding: 14px 12px;
  }

  .alert-item,
  .legend,
  .card-note {
    padding-left: 12px;
    padding-right: 12px;
  }

  .week {
    padding: 12px;
  }

  .week-row {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
  }

  .strip-wide {
    gap: 1px;
  }

  .topnav {
    gap: 14px;
    font-size: 0.9rem;
  }
}
