:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --ink: #1c2321;
  --muted: #5b6a63;
  --accent: #1f7a5c;
  --accent-soft: #e3f1ea;
  --accent-ink: #ffffff;
  --border: #dce3df;
  --warn: #b5484b;
  --warn-soft: #fbeaea;
  --row-alt: #f4f6f4;
  --shadow: 0 1px 2px rgba(28, 35, 33, 0.06), 0 8px 24px rgba(28, 35, 33, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917;
    --surface: #1b2220;
    --ink: #eef2f0;
    --muted: #93a39b;
    --accent: #3ea27c;
    --accent-soft: #1f2e28;
    --accent-ink: #06120d;
    --border: #2a3532;
    --warn: #e08083;
    --warn-soft: #2e1f20;
    --row-alt: #1f2725;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Segoe UI Variable", -apple-system, system-ui, sans-serif;
  line-height: 1.5;
}

.page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 24px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: filter 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { filter: brightness(1.05); background: var(--accent-soft); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.status.ok { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.status.error { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status.ok .status-dot { background: var(--accent); }
.status.error .status-dot { background: var(--warn); }

/* Empty state: full-bleed, this is the first thing the user sees */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.empty-state.hidden { display: none; }

.empty-icon {
  font-family: "Cascadia Code", "Consolas", ui-monospace, monospace;
  font-size: 28px;
  font-weight: 600;
  color: var(--accent);
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--accent-soft);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 44ch;
  text-align: center;
}

/* Table view: takes over the page like a zoomed-in canvas */
.table-section {
  flex: 1;
  display: none;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.table-section.visible { display: flex; }

.table-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-family: "Cascadia Code", "Consolas", ui-monospace, monospace;
  flex-shrink: 0;
}

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--accent-soft);
  color: var(--ink);
  text-align: left;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
}

thead th:hover { filter: brightness(1.08); }

.sort-arrow {
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.8;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  right: 5px;
  width: 2px;
  height: 100%;
  background: transparent;
}

.col-resize-handle:hover::after,
.col-resize-handle:active::after {
  background: rgba(255, 255, 255, 0.6);
}

tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:nth-child(even) td { background: var(--row-alt); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--accent-soft); }

@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; }
}

/* Diagnostic page */
.diag-intro {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 72ch;
}

.diag-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.diag-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.diag-table th {
  position: sticky;
  top: 0;
  background: var(--accent-soft);
  color: var(--ink);
  text-align: left;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.diag-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.diag-table tr:nth-child(even) td { background: var(--row-alt); }

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

.diag-desc {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.diag-time {
  font-family: "Cascadia Code", "Consolas", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.diag-detail {
  font-family: "Cascadia Code", "Consolas", ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
  max-width: 340px;
  overflow-wrap: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-fail { background: var(--warn-soft); color: var(--warn); }
.badge-pending { background: var(--row-alt); color: var(--muted); }

.diag-run-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.diag-run-btn:hover { background: var(--accent-soft); }
.diag-run-btn:disabled { opacity: 0.4; cursor: default; }
