:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --border: #d7e1ec;
  --border-strong: #c3d1e0;
  --text: #223042;
  --text-muted: #5b6878;
  --brand: #2f5e96;
  --brand-strong: #214977;
  --brand-soft: #e7f0fb;
  --success: #256f3a;
  --success-bg: #e9f7ee;
  --warning: #9a6700;
  --warning-bg: #fff5d6;
  --danger: #a12626;
  --danger-bg: #fdecec;
  --info: #1658a5;
  --info-bg: #e9f3ff;
  --shadow: 0 8px 24px rgba(19, 39, 68, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #eef4fa 0%, var(--bg) 180px);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

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

a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

.site-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.topbar {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(215, 225, 236, 0.9);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 20px 16px;
}

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

.topbar__eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar__title {
  width: fit-content;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
}

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

.topbar__subtitle,
.topbar__meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.topbar__meta {
  margin-top: 10px;
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
}

.topnav a:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-strong);
}

.topnav__link--logout {
  margin-left: auto;
  background: #f9fafb;
}

.content-shell {
  margin-top: 18px;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.65rem;
  color: var(--text);
  line-height: 1.2;
}

h1 {
  font-size: 1.7rem;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.08rem;
}

h4 {
  font-size: 1rem;
}

p {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
}

strong,
label {
  color: var(--text);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin: 0 0 1rem;
}

.page-actions--tight {
  margin-bottom: 0.7rem;
}

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

.card {
  margin: 1rem 0;
  padding: 1rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(19, 39, 68, 0.04);
}

.card--compact {
  padding: 0.85rem 0.95rem;
}

.card > :last-child {
  margin-bottom: 0;
}

.callout {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 14px 0 0;
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.94rem;
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout--info {
  background: var(--info-bg);
  border-color: #b9d5fb;
}

.callout--warn {
  background: var(--warning-bg);
  border-color: #f0d58b;
}

.callout--danger {
  background: var(--danger-bg);
  border-color: #f1b7b7;
}

form {
  margin: 0;
}

form.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

form.inline + form.inline,
form.inline + button,
button + form.inline {
  margin-left: 4px;
}

label {
  display: block;
  margin: 0.8rem 0 0.32rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(47, 94, 150, 0.16);
  border-color: var(--brand);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  margin: 0 0.45rem 0 0;
  padding: 0;
}

button {
  min-height: 38px;
  padding: 0.58rem 0.9rem;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

button[type="button"] {
  background: var(--surface);
  color: var(--brand);
}

button[type="button"]:hover {
  background: var(--brand-soft);
}

form.inline button,
.page-actions button,
.button-row button {
  margin: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 0.85rem;
}

.button-row a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.58rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--brand);
  font-size: 0.94rem;
  font-weight: 700;
  text-decoration: none;
}

.button-row a:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-strong);
  text-decoration: none;
}

.inline-field {
  width: auto;
  min-width: 180px;
}

.inline-field--short {
  min-width: 120px;
}

.section-block {
  margin-top: 0.8rem;
}

.section-block > :last-child {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 0.9rem 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

th,
td {
  padding: 0.72rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  background: #f7f9fc;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:nth-child(even) td {
  background: #fbfcfe;
}

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

code {
  padding: 0.12rem 0.38rem;
  border-radius: 6px;
  background: #edf2f8;
  color: var(--brand-strong);
  font-size: 0.88em;
}

ul {
  margin: 0.25rem 0 0.8rem 1.1rem;
  padding: 0;
}

li + li {
  margin-top: 0.22rem;
}

.error {
  color: var(--danger);
  font-weight: 600;
}

.status-pending,
.status-approved,
.status-rejected,
.status-completed,
.status-failed,
.status-running,
.status-none {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pending {
  color: var(--warning);
  background: var(--warning-bg);
}

.status-approved,
.status-completed {
  color: var(--success);
  background: var(--success-bg);
}

.status-rejected,
.status-failed {
  color: var(--danger);
  background: var(--danger-bg);
}

.status-running {
  color: var(--info);
  background: var(--info-bg);
}

.status-none {
  color: #66758a;
  background: #eef2f7;
}

.login-panel {
  max-width: 520px;
  margin: 32px auto 0;
}

.field-note {
  margin-top: 0.4rem;
  font-size: 0.86rem;
}

@media (max-width: 900px) {
  .site-shell {
    width: min(100%, calc(100% - 24px));
    margin: 16px auto 28px;
  }

  .topnav__link--logout {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  body {
    background: var(--bg);
  }

  .topbar {
    padding: 16px;
    border-radius: 16px;
  }

  .topnav {
    gap: 8px;
  }

  .topnav a {
    width: 100%;
    justify-content: center;
  }

  .card {
    padding: 0.9rem;
    border-radius: 14px;
  }

  form.inline {
    display: flex;
    flex-wrap: wrap;
  }

  form.inline + form.inline,
  form.inline + button,
  button + form.inline {
    margin-left: 0;
  }

  .inline-field,
  .inline-field--short {
    width: 100%;
    min-width: 0;
  }

  .callout {
    padding: 0.75rem 0.85rem;
  }

  th,
  td {
    padding: 0.64rem 0.68rem;
  }
}

/* --- Admin sub-navigation, health strip and diagnostic pills -------------
   Added 2026-08-02 alongside the admin-panel audit. The admin area had grown
   to eight pages reachable only through a flat card grid on /admin, with no
   way to move sideways and no visual distinction between a settings page and
   a diagnostics page. */

.adminnav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.adminnav__group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.adminnav__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-right: 0.15rem;
}
.adminnav__item {
  font-size: 0.86rem;
  text-decoration: none;
  color: var(--text);
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  border: 1px solid transparent;
}
.adminnav__item:hover {
  background: var(--brand-soft);
  border-color: var(--border);
}
.adminnav__item.is-active {
  background: var(--brand);
  border-color: var(--brand-strong);
  color: #fff;
  font-weight: 600;
}

.health-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 1.1rem;
}
.health-tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 190px;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
}
.health-tile__n {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}
.health-tile__label { font-size: 0.79rem; line-height: 1.25; }
.health-tile--good { border-left-color: var(--success); }
.health-tile--good .health-tile__n { color: var(--success); }
.health-tile--warn { border-left-color: var(--warning); background: var(--warning-bg); }
.health-tile--warn .health-tile__n { color: var(--warning); }
.health-tile--bad  { border-left-color: var(--danger); background: var(--danger-bg); }
.health-tile--bad .health-tile__n { color: var(--danger); }
.health-tile--none { border-left-color: var(--border-strong); }
.health-tile--none .health-tile__n { color: var(--text-muted); }

/* Status pills. Deliberately distinct from .status-* badges: those describe a
   record's state, these describe our *interpretation* of it — "wrote nothing"
   is a judgement drawn from the log, not a value any table stores. */
.pill {
  display: inline-block;
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill--ok   { background: var(--success-bg); color: var(--success); }
.pill--bad  { background: var(--danger-bg);  color: var(--danger); }
.pill--run  { background: var(--info-bg);    color: var(--info); }
.pill--noop { background: var(--warning-bg); color: var(--warning); }

.row--flagged > td { background: rgba(154, 103, 0, 0.055); }

.log-headline {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--text-muted);
  word-break: break-word;
}
.log-headline--bad { color: var(--danger); }

.log-tail {
  white-space: pre-wrap;
  font-size: 0.78rem;
  max-height: 280px;
  overflow: auto;
  background: var(--surface-2);
  padding: 8px;
  border-radius: 4px;
  margin: 0.35rem 0 0;
}

/* The admin nav and health strip both wrap by default; below the existing
   breakpoints they need to stack rather than wrap into ragged rows. Matches
   the 900/640 breakpoints already used above rather than inventing new ones. */
@media (max-width: 900px) {
  .adminnav { gap: 0.75rem 1.1rem; }
  .health-tile { min-width: 160px; flex: 1 1 160px; }
}

@media (max-width: 640px) {
  .adminnav {
    flex-direction: column;
    gap: 0.6rem;
    align-items: stretch;
  }
  .adminnav__group {
    align-items: baseline;
  }
  .health-strip { gap: 8px; }
  .health-tile {
    /* Two per row rather than one tall column - four single-file tiles push
       the failing-rows table below the fold, which defeats the point. */
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 0.6rem 0.7rem;
  }
  .health-tile__n { font-size: 1.15rem; }
  .health-tile__label { font-size: 0.74rem; }
}
