:root {
  --ink: #1a2640;
  --muted: #5d6573;
  --line: #d9dde3;
  --soft: #f4f5f7;
  --page: #ffffff;
  --header-bg: #ffffff;
  --header-ink: #1a2640;
  --header-line: #d9dde3;
  --accent: #1a2640;
  --accent-ink: #ffffff;
  --mark: #1a2640;
  --ok: #1d6b3a;
  --ok-bg: #e9f5ee;
  --error: #9b1c1c;
  --error-bg: #fbeaea;
  --radius: 6px;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
}

.theme-neutral {
  --header-bg: #1a2640;
  --header-ink: #ffffff;
  --header-line: #b0b7c3;
}

.theme-benedict {
  --ink: #1a2640;
  --header-bg: #ffffff;
  --header-ink: #1a2640;
  --header-line: #ff3854;
  --accent: #1a2640;
  --mark: #ff3854;
}

.theme-bhms {
  --ink: #172642;
  --header-bg: #172642;
  --header-ink: #ffffff;
  --header-line: #7b032a;
  --accent: #172642;
  --mark: #7b032a;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.75rem; }
.card h2:first-child { margin-top: 0; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: var(--header-bg);
  color: var(--header-ink);
  border-bottom: 3px solid var(--header-line);
}
.top a, .top .link { color: var(--header-ink); }
.top__home { display: flex; align-items: center; gap: 0.75rem 1rem; text-decoration: none; }
.top__logo { height: 28px; width: auto; display: block; }
.top__name { font-weight: 700; }
.top__app { font-weight: 600; padding-left: 0.75rem; border-left: 1px solid currentColor; }
.top__nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; font-size: 0.95rem; }

.brand-switch { display: inline-flex; border: 1px solid currentColor; border-radius: var(--radius); overflow: hidden; }
.brand-switch__item {
  font: inherit;
  padding: 0.25rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--header-ink);
  cursor: pointer;
}
.brand-switch__item[aria-pressed="true"] { background: var(--header-ink); color: var(--header-bg); }

.inline { display: inline; margin: 0; }
.link { font: inherit; background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: var(--accent); }

.page { max-width: 1100px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem; }

.hero p { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 2rem; }
.tile { border: 1px solid var(--line); border-top: 4px solid var(--mark); border-radius: var(--radius); padding: 1rem 1.25rem; }
.tile h2 { margin: 0 0 0.25rem; }
.tile p { margin: 0; color: var(--muted); }
.tile--soon { background: var(--soft); }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.card--narrow { max-width: 30rem; margin: 2rem auto; }

main form p { margin: 0 0 1rem; }
main form label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
main form .check label { display: inline; font-weight: 400; }
main input[type="text"], main input[type="email"], main input[type="password"], main select, .copy {
  width: 100%;
  max-width: 34rem;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid #9aa3b1;
  border-radius: var(--radius);
}
main img[src^="data:image"] { display: block; width: 200px; height: 200px; margin: 0 0 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; padding: 0.5rem 1rem 0.75rem; }
fieldset div, fieldset ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
main fieldset label { font-weight: 400; display: inline; }
.errorlist { color: var(--error); margin: 0 0 0.25rem; padding-left: 1.1rem; }

.button, :where(main button[type="submit"]:not(.link)) {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.button--quiet { background: transparent; color: var(--accent); }
.button--danger { background: var(--error); border-color: var(--error); }
.actions form, p.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 0 0 0.75rem; }
a.button { display: inline-block; text-decoration: none; }
.codes { font-size: 1.05rem; line-height: 1.8; background: var(--soft); border-radius: var(--radius); padding: 0.75rem 1rem; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.tabs a { padding: 0.5rem 0; text-decoration: none; color: var(--muted); }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -3px 0 var(--mark); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; background: var(--soft); }
.event--error td:nth-child(2) { color: var(--error); font-weight: 600; }

.badge { display: inline-block; font-size: 0.8rem; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); }
.badge--benedict { border-color: #ff3854; color: #1a2640; }
.badge--bhms { border-color: #7b032a; color: #7b032a; }
.badge--locked { border-color: var(--error); color: var(--error); }
.badge--ok { border-color: var(--ok); color: var(--ok); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.95rem; margin-top: 1.25rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.messages__item { padding: 0.6rem 0.9rem; border-radius: var(--radius); background: var(--soft); margin-bottom: 0.5rem; }
.messages__item--success { background: var(--ok-bg); color: var(--ok); }
.messages__item--error { background: var(--error-bg); color: var(--error); }
.notice { padding: 0.75rem 1rem; border-radius: var(--radius); margin-top: 1rem; }
.notice p { margin: 0 0 0.25rem; }
.notice--ok { background: var(--ok-bg); }
.notice--error { background: var(--error-bg); color: var(--error); }

.source h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.source__status { margin: 0 0 0.75rem; }
.source--overdue { border-color: var(--error); }
.error-text { color: var(--error); }
.counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; margin: 1rem 0 0; }
.counts div { background: var(--soft); border-radius: var(--radius); padding: 0.5rem 0.75rem; }
.counts dt { color: var(--muted); font-size: 0.85rem; }
.counts dd { margin: 0; font-size: 1.25rem; font-weight: 600; }

@media (max-width: 640px) {
  .top { padding: 0.75rem 1rem; }
  .top__nav { width: 100%; }
  h1 { font-size: 1.45rem; }
}
.nowrap { white-space: nowrap; }
