:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #262b36;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --pos: #3ddc97;
  --neg: #ff6b6b;
  --warn: #ffc857;
  --accent: #6aa3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 4px; }
h3.sub { font-size: 13px; margin: 20px 0 6px; color: var(--muted); font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.error { color: var(--neg); }

/* ---------------------------------------------------------------- login -- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
}
.login-card label {
  display: block;
  margin: 18px 0 6px;
  font-size: 12px;
  color: var(--muted);
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0d0f14;
  color: var(--text);
  font-size: 14px;
}
.login-card button {
  width: 100%;
  margin-top: 18px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #0b0d12;
  font-weight: 600;
  cursor: pointer;
}
.login-card .error { margin: 12px 0 0; font-size: 13px; }

/* --------------------------------------------------------------- topbar -- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
/* The sign-out button is wrapped in a form, so without this the form's own line
   box (complete with descender space) becomes the flex item and the button sits
   a pixel or two below the chip and timestamp beside it. */
.topbar-right > form { display: flex; align-items: center; margin: 0; }
/* A shared line-height keeps the three items' text on one optical line even
   though the chip is the only one with padding and a border. */
.topbar-right > * { line-height: 18px; }

.badge {
  font-size: 11px;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok { color: var(--pos); border-color: rgba(61, 220, 151, .4); }
.badge.neg { color: var(--neg); border-color: rgba(255, 107, 107, .4); }
.badge.live { color: var(--warn); border-color: rgba(255, 200, 87, .5); }
.badge.warn { color: var(--warn); border-color: rgba(255, 200, 87, .5); }

button.link {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
button.link:hover { color: var(--text); }

main { padding: 20px; }

/* ---------------------------------------------------------------- tiles -- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tile-value { font-size: 22px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 11px; color: var(--muted); }

/* ----------------------------------------------------------------- tabs -- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tab, .chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.tab.active, .chip.active { color: var(--text); border-color: var(--accent); }
.controls { display: flex; gap: 6px; margin: 10px 0; }
/* The stop button carries real consequence, so it reads as an action rather
   than as another filter chip. */
.chip.danger { color: var(--neg); border-color: rgba(255, 107, 107, .5); font-weight: 600; }
.chip:disabled { opacity: .5; cursor: not-allowed; }

.panel { display: none; }
.panel.active { display: block; }

/* ---------------------------------------------------------------- table -- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  margin-top: 10px;
}
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }
td.empty { color: var(--muted); text-align: center; padding: 22px; }

footer { padding: 16px 20px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------- settings -- */
/* One card per tunable group (Control, Sizing, Filters, Discovery, Loop). */
#settings-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.setting-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.setting-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
}
.setting-card-title {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.setting-card-desc { flex: 1 1 auto; }
.setting-card-count { margin-left: auto; white-space: nowrap; }
.setting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px 18px;
  padding: 14px 16px 16px;
}
.setting { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.setting-head { min-width: 0; }
.setting-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}
/* Under the input, so an overridden field does not push its own input out of
   line with its neighbours in the grid. */
.setting-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.setting-tags:empty { display: none; }
.setting-tags .badge { white-space: nowrap; }
.badge.link {
  cursor: pointer;
  font: inherit;
  color: var(--muted);
  background: none;
}
.badge.link:hover { color: var(--text); border-color: currentColor; }
.setting input, .setting select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line, #2a2f3a);
  border-radius: 4px;
  background: var(--panel, #12151c);
  color: inherit;
  font: inherit;
}
.setting input:disabled, .setting select:disabled { opacity: 0.55; }
/* A value that differs from the deployed env is worth spotting at a glance. */
.setting.overridden input, .setting.overridden select { border-color: #d2a24c; }
/* Sticky, so "Save changes" stays reachable while scrolling a long form. */
.settings-actions {
  position: sticky;
  bottom: 0;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 10px 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.chip.primary { font-weight: 600; }

/* ⓘ toggle on skip reasons; expands an explanation row under the reason. */
.info-toggle {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0 2px;
  margin-left: 6px;
}
.info-toggle:hover, .info-toggle[aria-expanded="true"] { color: var(--fg, inherit); }
td.reason-detail {
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
  max-width: 0; /* with colspan, keeps long text wrapping instead of widening the table */
}
