:root {
  --bg: #f4f4f7;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --ok: #27ae60;
  --warn: #e67e22;
  --fail: #e74c3c;
  --mute: #8e44ad;
  --accent: #2c3e50;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  background: var(--accent);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar .brand { font-weight: 600; letter-spacing: 0.2px; }
.topbar .identity { display: flex; gap: 10px; align-items: center; color: #d1d5db; font-size: 13px; }

main {
  max-width: 1440px;
  margin: 24px auto;
  padding: 0 24px;
}

.section {
  margin-bottom: 28px;
}

/* Tab bar under the top bar */
.tabbar {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
}
.tabbar .tab {
  padding: 10px 16px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-weight: 500;
  font-size: 14px;
}
.tabbar .tab:hover { background: #f3f4f6; color: var(--text); }
.tabbar .tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  position: relative;
  top: 1px;
}
.tabbar-spacer { flex: 1; }

/* Sub-tabs inside a panel (e.g. Routes → per variant) */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}
.subtabs .subtab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.subtabs .subtab:hover { background: #f3f4f6; }
.subtabs .subtab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.subtab-count {
  display: inline-block;
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 6px;
}
.subtabs .subtab.active .subtab-count { background: rgba(255, 255, 255, 0.22); }

.subtab-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 8px;
}
/* Secondary classification chips — slightly lighter than variant chips */
.subtabs .subtab-class { font-size: 12px; }
.subtabs .subtab-class.active { background: var(--muted); border-color: var(--muted); }

/* Route groups — collapsible <details> containing route-cards */
.route-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.route-group > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(180px, auto) 1fr max-content;
  gap: 12px;
  align-items: center;
  font-size: 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.route-group > summary::-webkit-details-marker { display: none; }
.route-group:not([open]) > summary { border-bottom: none; }
.route-group > summary:hover { background: #f1f5f9; }
.route-group-name { font-weight: 700; font-size: 15px; }
.route-group-key {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.route-group-pills { display: flex; gap: 6px; }
.route-group-count { font-size: 12px; white-space: nowrap; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
}
.pill-ok { background: var(--ok); }
.pill-warn { background: var(--warn); }
.pill-fail { background: var(--fail); }
.pill-mute { background: var(--mute); }

.route-group > .route-card {
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border);
  margin: 0;
}
.route-group > .route-card:first-of-type { border-top: none; }

/* Route cards — one <details> per check */
.route-list { display: flex; flex-direction: column; gap: 8px; }
.route-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
}
.route-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 80px minmax(180px, max-content) minmax(180px, 1fr) minmax(180px, 1.5fr) auto;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}
.verdict-reason {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-card > summary::-webkit-details-marker { display: none; }
.route-card > summary:hover { background: #f9fafb; }
.route-card[open] > summary { border-bottom: 1px solid var(--border); }

.route-name { font-weight: 600; }
.route-url {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-body {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 24px;
  background: #fafafa;
}
.route-body .route-spark,
.route-body .route-actions {
  grid-column: 1 / -1;
  margin-top: 8px;
}
.route-body .route-actions { border-top: 1px solid var(--border); padding-top: 12px; }
.kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.kv-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kv-value {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0 0 10px 2px;
}

/* Health is the primary panel: full width, bigger sparkline column. */
#section-http table.checks th,
#section-http table.checks td {
  padding: 14px 14px;
}
#section-http table.checks th:first-child,
#section-http table.checks td:first-child {
  min-width: 220px;
}
#section-http table.checks td.cell-strong {
  font-weight: 600;
  font-size: 14px;
}

/* Module sync + certificates — less critical; compact, lighter. */
.section-secondary table.checks {
  background: #fafafa;
}
.section-secondary .section-title {
  color: #9ca3af;
}

.actions { white-space: nowrap; }
.actions button { margin-right: 6px; }
.actions button:last-child { margin-right: 0; }

@media (min-width: 1100px) {
  /* Put module sync and certs side by side under Health. */
  #section-module-sync,
  #section-certs {
    display: inline-block;
    width: calc(50% - 14px);
    vertical-align: top;
  }
  #section-module-sync {
    margin-right: 24px;
  }
}

.suppress-banner {
  background: #fff8e1;
  border-left: 4px solid #f1c40f;
  color: #7a5c00;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-weight: 500;
}

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

.btn, .btn-secondary {
  font: inherit;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-secondary:hover { background: #f3f4f6; }

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

table.checks {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-collapse: collapse;
  border-radius: 6px;
  overflow: hidden;
}
table.checks th, table.checks td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.checks th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
table.checks tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #fff;
}
.badge-ok { background: var(--ok); }
.badge-warn { background: var(--warn); }
.badge-fail { background: var(--fail); }
.badge-mute { background: var(--mute); }

.incidents {
  list-style: none;
  padding: 0;
  margin: 8px 0 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.incidents li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.incidents li:last-child { border-bottom: none; }

dialog {
  border: none;
  border-radius: 6px;
  padding: 20px;
  min-width: 360px;
}
dialog::backdrop { background: rgba(0,0,0,0.35); }
dialog h3 { margin: 0 0 12px; }
dialog label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
dialog input { display: block; width: 100%; padding: 6px 8px; font: inherit; margin-top: 4px; border: 1px solid var(--border); border-radius: 4px; }
.mute-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mute-actions button { flex: 1; min-width: 80px; }

.callback {
  max-width: 480px;
  margin: 80px auto;
  text-align: center;
  color: var(--muted);
}
