/* SLED Reviewer: shared look (tokens, header, buttons, tables, forms, modals,
   tabs, badges, icons). Matches sled.design: black on white, square, system
   type. Pages keep only their own layout rules inline. */

:root {
  --sr-black: #000;
  --sr-white: #fff;
  --sr-red: #b91c1c;
  --sr-brand-red: #FF4B4B;
  --sr-green: #15803d;
  --sr-grey: #6b7280;
  --sr-hairline: #e5e5e5;
  --sr-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sr-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sr-fs-small: 0.85rem;
  --sr-fs-medium: 1.0625rem;
  --sr-fs-large: 1.375rem;
  --sr-fs-xlarge: 2rem;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }

body {
  margin: 0;
  background: var(--sr-white);
  color: var(--sr-black);
  font: var(--sr-fs-medium)/1.5 var(--sr-font);
}

a { color: inherit; text-decoration: underline; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--sr-black); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd, .mono { font-family: var(--sr-mono); font-size: 0.9em; }
h1 { font-size: var(--sr-fs-xlarge); line-height: 1.15; margin: 0 0 1rem; }
h2 { font-size: var(--sr-fs-large); line-height: 1.2; margin: 2rem 0 0.75rem; }
h3 { font-size: var(--sr-fs-medium); margin: 1.5rem 0 0.5rem; }
.muted { color: var(--sr-grey); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.small { font-size: var(--sr-fs-small); }

/* Page wrapper for admin and client pages (the header sits outside it). */
.page { max-width: 1100px; margin: 0 auto; padding: 2rem 16px 4rem; }
.page--narrow { max-width: 640px; }

/* ── The black header ─────────────────────────────────────────────── */
.sr-header {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: flex-start; gap: 1rem;
  min-height: 52px; margin: 0; padding: 18px; border: 0;
  background: var(--sr-black); color: var(--sr-white);
  font-size: var(--sr-fs-small); line-height: 1.2;
}
.sr-header a, .sr-header button { color: var(--sr-white); }
.sr-header :focus-visible { outline-color: var(--sr-white); }
.sr-header__logo { display: inline-flex; align-items: center; flex: none; text-decoration: none; }
.sr-header__logo svg { height: 31px; /* the project selector's height */ width: auto; display: block; }
.sr-header__env {
  flex: none; color: var(--sr-brand-red); font-size: 0.7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.sr-header__new, .sr-header__projects, .sr-header__menu-group, .sr-header__account { position: relative; flex: none; }
.sr-header__new > summary, .sr-header__projects > summary, .sr-header__menu-group > summary, .sr-header__account > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.6rem; border: 1px solid rgba(255,255,255,.45); max-width: 16rem;
}
.sr-header__new > summary::-webkit-details-marker, .sr-header__projects > summary::-webkit-details-marker, .sr-header__menu-group > summary::-webkit-details-marker, .sr-header__account > summary::-webkit-details-marker { display: none; }
.sr-header__projects > summary .label, .sr-header__menu-group > summary .label, .sr-header__account > summary .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-header__new[open] > summary, .sr-header__projects[open] > summary, .sr-header__menu-group[open] > summary, .sr-header__account[open] > summary { border-color: var(--sr-white); }
.sr-header__menu-group > summary, .sr-header__account > summary { border-color: transparent; }
.sr-header__menu-group > summary[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }
.sr-header__new ul, .sr-header__projects ul, .sr-header__menu-group ul, .sr-header__account ul {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 1001;
  min-width: 12rem; max-width: min(24rem, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto;
  margin: 0; padding: 0.25rem 0; list-style: none;
  background: var(--sr-white); color: var(--sr-black); border: 1px solid var(--sr-black);
}
.sr-header__account ul { left: auto; right: 0; }
.sr-header__projects ul a, .sr-header__menu-group ul a, .sr-header__account ul a {
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
  padding: 0.5rem 0.75rem; color: var(--sr-black); text-decoration: none;
}
.sr-header__projects ul a:hover, .sr-header__menu-group ul a:hover, .sr-header__account ul a:hover { background: #f2f2f2; }
/* New + items are buttons (they open the Upload PDF / Add site windows). */
.sr-header__new ul button {
  display: block; width: 100%; text-align: left; padding: 0.5rem 0.75rem; background: none; border: 0;
  color: var(--sr-black); font: inherit; cursor: pointer;
}
.sr-header__new ul button:hover { background: #f2f2f2; }
.sr-header__projects ul a[aria-current="true"], .sr-header__menu-group ul a[aria-current="page"], .sr-header__account ul a[aria-current="page"] { font-weight: 700; }
.sr-header__nav > a, .sr-header__nav > details > summary { opacity: .8; }
.sr-header__nav details[open] > summary, .sr-header__nav summary:hover, .sr-header__nav summary[aria-current="page"] { opacity: 1; }
.sr-header__projects ul li.sep, .sr-header__account ul li.sep { border-top: 1px solid var(--sr-hairline); margin: 0.25rem 0; }
.sr-header__projects .count {
  flex: none; min-width: 1.5rem; padding: 0 0.35rem; text-align: center;
  background: var(--sr-black); color: var(--sr-white); font-size: 0.75rem; line-height: 1.5;
}
.sr-header__projects .count.zero { background: transparent; color: var(--sr-grey); }
.sr-header__collapse { display: flex; align-items: center; gap: 1rem; flex: 1; min-width: 0; }
.sr-header__nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.sr-header__nav > a { text-decoration: none; opacity: .8; padding: 0.25rem 0; }
.sr-header__nav > a:hover, .sr-header__nav > a[aria-current="page"] { opacity: 1; }
.sr-header__nav > a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }
.sr-header__actions { display: flex; align-items: center; gap: 1rem; margin-left: auto; flex-wrap: wrap; }
.sr-header__actions a { text-decoration: none; }
.sr-header__actions > a:hover { text-decoration: underline; }
.sr-header__actions button {
  background: none; border: 0; padding: 0; cursor: pointer; font-size: inherit;
}
.sr-header__actions button:hover { text-decoration: underline; }
.sr-header__menu {
  display: none; margin-left: auto; padding: 0; background: none; border: 1px solid rgba(255,255,255,.45);
  width: 36px; height: 36px; align-items: center; justify-content: center; cursor: pointer;
}
@media (max-width: 720px) {
  .sr-header { flex-wrap: wrap; gap: 0.75rem; }
  .sr-header__menu { display: inline-flex; }
  .sr-header__projects > summary { max-width: 10rem; }
  .sr-header__collapse {
    display: none; flex-basis: 100%; flex-direction: column; align-items: flex-start;
    gap: 0.75rem; padding: 0.5rem 0 1rem; border-top: 1px solid rgba(255,255,255,.25);
  }
  .sr-header.is-open .sr-header__collapse { display: flex; }
  .sr-header__nav, .sr-header__actions { flex-direction: column; align-items: flex-start; margin-left: 0; gap: 0.75rem; }
  /* System and name menus read as plain open lists inside the phone menu. */
  .sr-header__collapse details > summary { pointer-events: none; padding: 0.25rem 0; border: 0; opacity: .8; }
  .sr-header__collapse details > summary svg { display: none; }
  .sr-header__collapse details > ul {
    position: static; min-width: 0; max-width: none; max-height: none; overflow: visible;
    background: none; color: inherit; border: 0; padding: 0 0 0 0.75rem;
  }
  .sr-header__collapse details > ul a, .sr-header__collapse details > ul button { color: var(--sr-white); padding: 0.25rem 0; }
  .sr-header__collapse details > ul a:hover, .sr-header__collapse details > ul button:hover { background: none; text-decoration: underline; }
  .sr-header__collapse details > ul li.sep { display: none; }
  .sr-header__collapse details::details-content { content-visibility: visible; display: block; }
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border: 1px solid var(--sr-black);
  background: var(--sr-black); color: var(--sr-white);
  font-size: var(--sr-fs-small); font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #222; text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn--secondary { background: var(--sr-white); color: var(--sr-black); }
.btn--secondary:hover { background: #f2f2f2; }
.btn--danger { background: var(--sr-white); color: var(--sr-red); border-color: var(--sr-red); }
.btn--danger:hover { background: var(--sr-red); color: var(--sr-white); }
.btn--small { padding: 0.3rem 0.6rem; font-size: 0.8125rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; flex: none;
  background: var(--sr-white); color: var(--sr-black); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; vertical-align: middle;
}
.icon-btn:hover { border-color: var(--sr-black); }
.icon-btn--danger { color: var(--sr-red); }
.icon-btn--danger:hover { border-color: var(--sr-red); }
.icon { display: block; flex: none; }

/* ── Tables ───────────────────────────────────────────────────────── */
.table-wrap { position: relative; overflow-x: auto; }
/* The ⋯ menu on the last rows must not be clipped; phones keep the horizontal scroll */
@media (min-width: 721px) { .table-wrap:has(.users-table) { overflow: visible; } }
.table { width: 100%; border-collapse: collapse; font-size: var(--sr-fs-small); }
.table th {
  text-align: left; font-weight: 600; padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--sr-black); white-space: nowrap;
}
.table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--sr-hairline); vertical-align: middle; }

/* ── Forms ────────────────────────────────────────────────────────── */
.field { display: block; margin: 0 0 1rem; }
.field > span, .field > label { display: block; font-size: var(--sr-fs-small); font-weight: 600; margin-bottom: 0.3rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
input[type=search], input[type=date], input:not([type]), select, textarea {
  padding: 0.5rem 0.6rem; border: 1px solid var(--sr-black); background: var(--sr-white);
  font-size: var(--sr-fs-small); max-width: 100%;
}
input[type=checkbox], input[type=radio] { accent-color: var(--sr-black); }
.status-ok { color: var(--sr-green); font-size: var(--sr-fs-small); }
.status-bad { color: var(--sr-red); font-size: var(--sr-fs-small); }
.notice { border: 1px solid var(--sr-black); padding: 0.75rem 1rem; margin: 0 0 1rem; font-size: var(--sr-fs-small); }
.notice--bad { border-color: var(--sr-red); color: var(--sr-red); }

/* ── Tabs ─────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--sr-black); margin: 0 0 1.5rem; overflow-x: auto; }
.tabs a {
  padding: 0.6rem 1rem; text-decoration: none; font-size: var(--sr-fs-small); font-weight: 600;
  border: 1px solid transparent; border-bottom: 0; white-space: nowrap;
}
.tabs a:hover { text-decoration: underline; }
.tabs a[aria-current="page"] { background: var(--sr-black); color: var(--sr-white); }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 0.05rem 0.45rem; border: 1px solid var(--sr-black);
  font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--sr-white); color: var(--sr-black);
}
.badge--filled { background: var(--sr-black); color: var(--sr-white); }
.badge--muted { border-color: #9ca3af; color: var(--sr-grey); }
.badge + a { margin-left: .4rem; }
.badge--urgent { border-color: var(--sr-red); background: var(--sr-red); color: var(--sr-white); }

/* ── Modals ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5); padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--sr-white); color: var(--sr-black); border: 1px solid var(--sr-black);
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 1.5rem;
}
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ── Connection window (assets/js/net.js) ─────────────────────────── */
.sr-net-dialog {
  background: var(--sr-white); color: var(--sr-black); border: 1px solid var(--sr-black); border-radius: 0;
  width: min(440px, calc(100vw - 32px)); padding: 1.5rem; margin: auto;
  font: var(--sr-fs-small)/1.5 var(--sr-font);
}
.sr-net-dialog::backdrop { background: rgba(0,0,0,.5); }
.sr-net-dialog h2 { font-size: var(--sr-fs-medium); line-height: 1.3; margin: 0 0 0.5rem; }
.sr-net-dialog p { margin: 0 0 0.5rem; }
.sr-net-dialog__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* Quick hover labels (assets/js/tips.js) */
.sr-tip { position: fixed; z-index: 1000; background: var(--sr-black); color: var(--sr-white); font-size: .75rem; line-height: 1; padding: 6px 8px; white-space: nowrap; pointer-events: none; }
.sr-tip--wrap { white-space: normal; max-width: calc(100vw - 8px); }
.sr-tip[hidden] { display: none; }

/* ── New + windows: Upload PDF, Add site (admin/_new_modals.php) ──── */
.sr-new label { display: block; font-size: var(--sr-fs-small); font-weight: 600; margin: .75rem 0 .25rem; }
.sr-new input, .sr-new select { width: 100%; }
.sr-new select[multiple] { height: 100px; }
.sr-new .modal-error { color: var(--sr-red); font-size: var(--sr-fs-small); margin-top: .5rem; }
.sr-new .modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.sr-new .pl-base { color: var(--sr-grey); }
.sr-new .pl-status { display: block; margin: .2rem 0 0; min-height: 1em; font-size: .75rem; }
.sr-new .pl-status.ok { color: var(--sr-green); } .sr-new .pl-status.bad { color: var(--sr-red); }
.sr-new .pl-field { display: flex; align-items: center; gap: .15rem; font-size: .8rem; }
.sr-new .pl-field .pl-base { white-space: nowrap; }
.sr-new .pl-field input { flex: 1; min-width: 0; }
.sr-new .copied { margin-left: .25rem; }

/* ── Add-a-site window (assets/js/add-site.js) ────────────────────── */
.add-site [hidden] { display: none !important; }
.add-site h3 { font-size: var(--sr-fs-medium); margin: 0 0 .5rem; }
.as-block { margin: 0 0 .75rem; }
.as-code { display: flex; align-items: flex-start; gap: .25rem; }
.as-code textarea { flex: 1; font: 0.8125rem/1.4 ui-monospace, Menlo, monospace; resize: none; }
.as-toggle { background: none; border: 0; padding: 0; color: var(--sr-black); text-decoration: underline; cursor: pointer; font: inherit; font-size: var(--sr-fs-small); }
.as-bar { margin-top: 1rem; }
.as-bar__label { font-size: var(--sr-fs-small); margin-bottom: .35rem; }
.as-bar__track { height: 3px; background: #e5e5e5; }
.as-bar__fill { height: 100%; width: 0; background: var(--sr-black); transition-property: width; transition-timing-function: ease-out; }
@media (prefers-reduced-motion: reduce) {
  .as-bar__fill { transition-timing-function: steps(4, end) !important; }
}

/* Footer on signed-in pages (not the viewer) */
.sr-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .35rem 1.5rem;
  padding: 18px; margin-top: 3rem; border: 0;
  background: var(--sr-black); color: var(--sr-white); font-size: var(--sr-fs-small);
}
.sr-footer__left, .sr-footer__right { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.25rem; }
.sr-footer a { color: inherit; }
.sr-footer :focus-visible { outline-color: var(--sr-white); }
.sr-footer__logo { display: inline-flex; color: var(--sr-white); }
.sr-footer__logo svg { display: block; height: 16px; width: auto; }
.sr-footer__bad { color: var(--sr-brand-red); font-weight: 600; }
@media (max-width: 480px) {
  .sr-footer, .sr-footer__left, .sr-footer__right { flex-direction: column; align-items: flex-start; }
}

/* Shared list pattern: filter bar, segmented counts, project chips, load more */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 0 0 1rem; }
.filters label { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--sr-fs-small); font-weight: 600; }
.filters label select, .filters label input { font-weight: 400; }
.segmented { display: inline-flex; }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.75rem;
  border: 1px solid var(--sr-black); background: var(--sr-white); color: var(--sr-black);
  font: inherit; font-size: var(--sr-fs-small); text-decoration: none; cursor: pointer; border-radius: 0;
}
.segmented > * + * { margin-left: -1px; }
.segmented [aria-current], .segmented [aria-pressed="true"] { background: var(--sr-black); color: var(--sr-white); }
.segmented .count { color: var(--sr-grey); }
.segmented [aria-current] .count, .segmented [aria-pressed="true"] .count { color: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* Notes: Open / Done / All beside the heading; one search field holding tags. */
.notes-head { display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.notes-head h1 { margin: 0; }
.notes-filters { align-items: center; }
.notes-filters [data-no-js][hidden] { display: none; }
.tag-search {
  position: relative; flex: 1 1 22rem; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.4rem; border: 1px solid var(--sr-black); background: var(--sr-white); cursor: text;
}
.tag-search:focus-within { box-shadow: 0 0 0 1px var(--sr-black); }
.tag-list { display: contents; }
.tag {
  display: inline-flex; align-items: center; gap: 0.3rem; max-width: 100%;
  padding: 0.15rem 0.2rem 0.15rem 0.45rem; background: var(--sr-black); color: var(--sr-white);
  font-size: var(--sr-fs-small); line-height: 1.3; overflow-wrap: anywhere;
}
.tag__kind { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; }
.tag--q { background: var(--sr-white); color: var(--sr-black); outline: 1px solid var(--sr-black); outline-offset: -1px; }
.tag__x { border: 0; background: none; color: inherit; font: inherit; font-size: 1rem; line-height: 1; padding: 0 0.2rem; cursor: pointer; }
.tag-search input.tag-search__input {
  flex: 1 1 10rem; min-width: 8rem; border: 0; outline: 0; box-shadow: none; border-radius: 0;
  padding: 0.3rem 0.2rem; font: inherit; background: transparent; -webkit-appearance: none; appearance: none;
}
.tag-search input.tag-search__input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.tag-suggest {
  position: absolute; top: calc(100% + 2px); left: -1px; right: -1px; z-index: 20;
  margin: 0; padding: 0; list-style: none; background: var(--sr-white); border: 1px solid var(--sr-black);
}
.tag-suggest li { padding: 0.45rem 0.6rem; cursor: pointer; }
.tag-suggest li .tag__kind { opacity: 1; color: var(--sr-grey); margin-right: 0.3rem; }
.tag-suggest li[aria-selected="true"], .tag-suggest li:hover { background: var(--sr-black); color: var(--sr-white); }
.tag-suggest li[aria-selected="true"] .tag__kind, .tag-suggest li:hover .tag__kind { color: inherit; }
.notes-filters[aria-busy="true"] + script + [data-swap="results"] { opacity: 0.6; }
.chip {
  display: inline-block; padding: 0.2rem 0.6rem; border: 1px solid var(--sr-black);
  background: var(--sr-white); color: var(--sr-black); font-size: var(--sr-fs-small); text-decoration: none; border-radius: 0;
}
.chip[aria-current] { background: var(--sr-black); color: var(--sr-white); }
.list-count { margin: 1rem 0; color: var(--sr-grey); font-size: var(--sr-fs-small); }
.list-count a { color: var(--sr-black); font-weight: 600; }
.list-count a[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.bulk-bar {
  position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; background: var(--sr-black); color: var(--sr-white); font-size: var(--sr-fs-small);
}
.bulk-bar[hidden] { display: none; }
.bulk-bar a, .bulk-bar button { color: var(--sr-white); }
.bulk-bar button {
  background: none; border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 0;
  padding: 0.3rem 0.7rem; font: inherit; cursor: pointer;
}
.bulk-bar button:hover { border-color: var(--sr-white); }
.bulk-bar :focus-visible { outline-color: var(--sr-white); }
.row-menu { position: relative; display: inline-block; }
.row-menu > summary { list-style: none; cursor: pointer; padding: 0.1rem 0.5rem; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { outline: 1px solid var(--sr-black); }
.row-menu > :not(summary) {
  position: absolute; right: 0; z-index: 30; min-width: 10rem; margin-top: 0.25rem; padding: 0.25rem 0;
  background: var(--sr-white); color: var(--sr-black); border: 1px solid var(--sr-black); border-radius: 0;
}
.row-menu a, .row-menu button {
  display: block; width: 100%; padding: 0.4rem 0.9rem; border: 0; background: none; color: inherit;
  font: inherit; font-size: var(--sr-fs-small); text-align: left; text-decoration: none; cursor: pointer;
}
.row-menu a:hover, .row-menu button:hover { background: var(--sr-hairline); }
.table tr.is-done td { color: var(--sr-grey); }
.table tr.is-done td:first-child, .table tr.is-done td:last-child { color: inherit; }

/* Footer sits at the bottom on short pages (pages that have a footer; the viewer has none) */
body:has(> .sr-footer) { min-height: 100vh; display: flex; flex-direction: column; }
body:has(> .sr-footer) > .page { flex: 1 0 auto; width: 100%; }
/* Centred page containers (margin: auto) would shrink to their content in the flex column; fixed overlays stay untouched */
body:has(> .sr-footer) > :is(.page, .wrap, main, .empty) { width: 100%; box-sizing: border-box; }

/* Comments list: text first, small grey meta on the same line */
.comment-meta { color: var(--sr-grey); font-size: var(--sr-fs-small); margin-left: 0.4rem; white-space: nowrap; }
.comment-meta > * { margin-right: 0.5rem; }
.comment-meta .icon { display: inline-block; vertical-align: middle; width: 14px; height: 14px; }
.comment-meta a { color: inherit; }
.mark-done-btn { border-color: var(--sr-hairline); color: var(--sr-grey); }
.mark-done-btn:hover { border-color: var(--sr-black); color: var(--sr-black); }
.mark-done-btn[aria-pressed="true"] { background: var(--sr-black); border-color: var(--sr-black); color: var(--sr-white); }
.mark-done-btn[aria-pressed="true"]:hover { background: #222; }
@media (max-width: 720px) {
  .comments-table thead { display: none; }
  .comments-table, .comments-table tbody { display: block; }
  .comments-table tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0;
    padding: 0.75rem 0; border-bottom: 1px solid var(--sr-hairline);
  }
  .comments-table td { display: block; border: 0; padding: 0; }
  .comments-table .cell-check { flex: 0 0 1.75rem; align-self: flex-start; padding-top: 0.15rem; }
  .comments-table .cell-comment { flex: 1 1 calc(100% - 1.75rem); min-width: 0; overflow-wrap: anywhere; }
  .comments-table .cell-comment .comment-meta { white-space: normal; }
  .comments-table .cell-project, .comments-table .cell-author, .comments-table .cell-when {
    color: var(--sr-grey); font-size: var(--sr-fs-small);
  }
  .comments-table .cell-project { margin-left: 1.75rem; }
  .comments-table .cell-author::before, .comments-table .cell-when::before { content: "\00b7"; margin: 0 0.4rem; }
  .comments-table .cell-done { margin-left: auto; }
}

/* The message after a background save (admin pages), and hours in the red */
.flash { color: var(--sr-green); border: 1px solid var(--sr-green); padding: .6rem .9rem; margin-bottom: 1rem; font-size: var(--sr-fs-small); }
.flash.error { color: var(--sr-red); border-color: var(--sr-red); }
.over { color: var(--sr-red); font-weight: 600; }

/* ── Billing (admin/billing.php: the overview and a person's page) ── */
.billing-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap; margin: 0 0 1.25rem; }
.billing-head h1 { margin: 0; }
.billing-period { display: flex; align-items: center; gap: 0.5rem; }
.billing-period [data-no-js][hidden] { display: none; }
.billing-recap {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.75rem 1rem;
  padding: 1rem 0; border-top: 1px solid var(--sr-black); border-bottom: 1px solid var(--sr-hairline);
}
.billing-fig strong { display: block; font-size: var(--sr-fs-xlarge); font-weight: 700; line-height: 1.1; }
.billing-fig span { display: block; max-width: 8rem; margin-top: 0.2rem; color: var(--sr-grey); font-size: var(--sr-fs-small); line-height: 1.3; }
.billing-fig--red strong { color: var(--sr-red); }
.billing-section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; flex-wrap: wrap;
  margin: 2rem 0 0; padding-bottom: 0.4rem; border-bottom: 1px solid var(--sr-black);
}
.billing-section-head h2 { margin: 0; font-size: var(--sr-fs-medium); }
.billing-list, .billing-rows { list-style: none; margin: 0 0 1rem; padding: 0; }
.billing-list > li, .billing-rows > li { padding: 0.65rem 0; border-bottom: 1px solid var(--sr-hairline); font-size: var(--sr-fs-small); min-width: 0; }
.billing-list a, .billing-rows a { color: inherit; }
.round-waiting__what { overflow-wrap: anywhere; }
.round-waiting__note { margin: 0.3rem 0 0; padding-left: 0.6rem; border-left: 2px solid var(--sr-hairline); color: var(--sr-grey); overflow-wrap: anywhere; }
.round-waiting__fix { margin: 0.4rem 0 0; font-weight: 600; }
.round-waiting .billing-line { margin: 0.5rem 0 0; }
.billing-client__line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; }
.billing-client__line > a { font-weight: 700; overflow-wrap: anywhere; }
.billing-client__fig { white-space: nowrap; }
.billing-client__project { padding-left: 1rem; color: var(--sr-grey); overflow-wrap: anywhere; }
.billing-row { display: grid; grid-template-columns: 6.5rem 4.5rem minmax(0, 1fr); gap: 0.75rem; align-items: baseline; }
.billing-row__date { color: var(--sr-grey); }
.billing-row__amount { font-weight: 600; white-space: nowrap; }
.billing-row__what { overflow-wrap: anywhere; }
.billing-person-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; flex-wrap: wrap; }
.billing-person-head h1 { margin: 0; overflow-wrap: anywhere; }
.billing-balance { font-size: var(--sr-fs-large); font-weight: 700; white-space: nowrap; }
.billing-totals { margin: 0.25rem 0 1rem; }
.billing-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; margin: 0 0 0.5rem; }
.billing-line input[name="note"] { flex: 1 1 12rem; min-width: 0; }
.billing-add { margin: 1rem 0; }
.billing-history > li { display: flex; align-items: center; gap: 0.5rem; }
.billing-history > li > .billing-line { flex: 1 1 auto; min-width: 0; margin: 0; }
.billing-history .what { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.billing-history input[type=date], .billing-history__date { flex: none; width: 9.5rem; }
.billing-history__date { color: var(--sr-grey); }
.billing-history__hours { white-space: nowrap; }
/* A round has no note: the spacer keeps its hours and Save under the entries' */
.billing-history input[name="note"], .billing-history__spacer { flex: 0 1 20rem; }
.billing-history form.inline { margin: 0; flex: none; }
@media (max-width: 720px) {
  .billing-history__spacer { display: none; }
  .billing-history input[name="note"] { flex: 1 1 12rem; }
}
@media (max-width: 480px) {
  /* Phones: date and hours on the first line, what it was under them at full width */
  .billing-row { grid-template-columns: auto minmax(0, 1fr); gap: 0.15rem 0.75rem; }
  .billing-row__what { grid-column: 1 / -1; }
}

/* ── Dashboard cards (admin/dashboard.php) ────────────────────────── */
/* 3 columns from 1000px, 2 from 720px, 1 below. One grid: the fixed cards (Needs
   attention, gate) first, then the cards. With JS (masonry.js adds .is-masonry)
   the rows are 4px and each card spans its height, plus a bottom margin equal to
   the column gap, so cards pack up under shorter neighbours. Without JS: plain rows. */
.dash-title { margin-bottom: 1.25rem; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.dash-grid.is-masonry { grid-auto-rows: 4px; row-gap: 0; }
.dash-grid.is-masonry > * { margin-bottom: 1rem; }
@media (min-width: 720px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .dash-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 720px) and (max-width: 999px) {
  /* Two columns: the strip takes the row, the gate card sits under it at half width */
  .dash-card--alert { grid-column: 1 / -1; }
}
@media (min-width: 1000px) { .dash-card--alert { grid-column: span 2; } }
.dash-card {
  min-width: 0; padding: 0.75rem 1rem 0.9rem;
  border: 1px solid var(--sr-hairline); border-left: 3px solid var(--sr-black);
  background: var(--sr-white); font-size: var(--sr-fs-small);
}
.dash-card--alert { border-left-color: var(--sr-brand-red); }
.dash-card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 32px; margin: 0 0 0.4rem; }
.dash-card__head h2 { margin: 0; font-size: var(--sr-fs-medium); line-height: 1.3; min-width: 0; }
.dash-card__head h2 a { text-decoration: none; }
.dash-card__head h2 a:hover { text-decoration: underline; }
.dash-card__head form { margin: 0; }
.dash-card__tools { display: inline-flex; flex: none; margin-right: -0.4rem; }
.dash-card__tools .icon-btn { width: 28px; height: 28px; color: var(--sr-grey); }
.dash-card__tools .icon-btn:hover { color: var(--sr-black); }
.dash-handle { cursor: grab; }
@media (pointer: coarse) { .dash-handle { display: none; } }
/* Arrows: reachable by keyboard everywhere; visible at once on touch, on focus elsewhere */
@media (hover: hover) and (pointer: fine) {
  .dash-card__tools [data-move]:not(:focus-visible) { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
}
.dash-card.is-dragging { opacity: 0.45; }
.dash-card.drop-before { box-shadow: 0 -3px 0 var(--sr-black); }
.dash-card.drop-after { box-shadow: 0 3px 0 var(--sr-black); }
.dash-rows { list-style: none; margin: 0; padding: 0; }
.dash-rows > li { padding: 0.45rem 0; border-top: 1px solid var(--sr-hairline); overflow-wrap: anywhere; }
.dash-rows > li:first-child { border-top: 0; }
.dash-row__main { display: block; }
.dash-row__meta { display: flex; align-items: center; gap: 0.25rem; min-width: 0; color: var(--sr-grey); }
.dash-row__meta .badge { margin: 0 0.1rem; }
.dash-row__meta .icon-btn { width: 28px; height: 28px; }
.dash-link {
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--sr-mono); font-size: 0.8rem; text-decoration: none;
}
.dash-link:hover { text-decoration: underline; }
.dash-red, .dash-red a { color: var(--sr-red); }
.dash-rows--buttons > li { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dash-card__all { display: inline-block; margin-top: 0.4rem; font-weight: 600; }
/* Needs attention: each row has its own ✕ (form.ack-row) on the right. */
.dash-card--alert .dash-rows > li { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.dash-card--alert .dash-row__main { flex: 1 1 auto; min-width: 0; }
.ack-row { flex: none; margin: 0 -0.4rem 0 0; }
.ack-row .icon-btn { width: 28px; height: 28px; color: var(--sr-grey); }
.ack-row .icon-btn:hover { color: var(--sr-black); }
.dash-gate { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dash-gate input { flex: 1 1 160px; min-width: 0; font-family: var(--sr-mono); }
.dash-hint { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--sr-grey); }
.gate-password-status { display: block; min-height: 1.2em; margin-top: 0.3rem; font-size: 0.8rem; }

/* ── Sites page (admin/sites.php) ─────────────────────────────────── */
/* Star toggle: both icons are in the button, aria-pressed picks one. */
.star-form { margin: 0; display: inline; }
.star-btn { color: var(--sr-grey); }
.star-btn:hover { color: var(--sr-black); }
.star-btn[aria-pressed="true"] { color: var(--sr-black); }
.star-btn .star-on, .star-btn[aria-pressed="true"] .star-off { display: none; }
.star-btn[aria-pressed="true"] .star-on { display: block; }
.star-btn.is-saving { opacity: 0.5; }
.sites-table .cell-star { width: 32px; padding-right: 0; }
.sites-table .cell-edit { width: 72px; text-align: right; } /* room for WordPress + Edit, so Edit lines up on every row */
.site-actions { display: inline-flex; justify-content: flex-end; align-items: center; gap: 0.25rem; }
.site-actions .wp-admin[hidden] { display: none; }
.sites-table .cell-php { white-space: nowrap; font-family: var(--sr-mono); font-size: 0.8rem; }
.site-name { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; min-width: 0; }
.site-name:hover .site-title { text-decoration: underline; }
.site-title { overflow-wrap: anywhere; }
.site-icon-box { display: inline-flex; flex: none; width: 16px; height: 16px; }
.site-icon { display: block; width: 16px; height: 16px; object-fit: contain; }
.site-icon[hidden], .site-letter[hidden] { display: none; }
.site-letter {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  background: var(--sr-black); color: var(--sr-white); font-size: 10px; font-weight: 700; line-height: 1;
}
.sites-table .cell-pins { white-space: nowrap; }
.sites-table .cell-link { white-space: nowrap; }
.sites-table .pl-link { font-family: var(--sr-mono); font-size: 0.8rem; text-decoration: none; }
.sites-table .pl-link:hover { text-decoration: underline; }
.link-tools { display: inline-flex; align-items: center; margin-left: 0.1rem; vertical-align: middle; }
.link-tools .copied { margin-left: 0.25rem; }
.pill {
  display: inline-block; margin: 0.1rem 0.25rem 0.1rem 0; padding: 0.1rem 0.5rem;
  border: 1px solid var(--sr-black); font-size: 0.8125rem; line-height: 1.4; text-decoration: none; white-space: nowrap;
}
.pill:hover { background: var(--sr-black); color: var(--sr-white); }
@media (max-width: 720px) {
  /* Phones: each row is a block; cells show their caption (data-label). No sideways scroll. */
  .sites-table thead { display: none; }
  .sites-table, .sites-table tbody { display: block; }
  .sites-table tr {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 0.3rem 0.5rem; align-items: center;
    padding: 0.75rem 0; border-bottom: 1px solid var(--sr-hairline);
  }
  .sites-table td { display: block; border: 0; padding: 0; min-width: 0; }
  .sites-table td.cell-star { grid-column: 1; grid-row: 1; width: auto; }
  .sites-table td.cell-site { grid-column: 2; grid-row: 1; }
  .sites-table td.cell-edit { grid-column: 3; grid-row: 1; width: auto; }
  /* The caption hangs in a 5.5rem gutter, so wrapped values (link tools, pills) line up under the value. */
  .sites-table td[data-label]:not(.cell-site) { grid-column: 2 / -1; white-space: normal; position: relative; padding-left: 5.5rem; }
  .sites-table td[data-label]:not(.cell-site)::before {
    content: attr(data-label); position: absolute; left: 0; top: 0; color: var(--sr-grey);
  }
  .sites-table .pl-link { overflow-wrap: anywhere; }
  .sites-table .pill { white-space: normal; overflow-wrap: anywhere; }
  .sites-table .sites-empty td { grid-column: 1 / -1; }
}

/* Edit page: Delete at the bottom of the Link tab */
.danger-zone { border-top: 1px solid var(--sr-hairline); padding-top: 1.25rem; margin-top: 0.5rem; }
.danger-zone h2 { color: var(--sr-red); }
.danger-zone form { margin: 0; }
