/* 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-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.875rem;
  --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: 0 16px; 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: 22px; width: auto; display: block; }
.sr-header__projects { position: relative; flex: none; }
.sr-header__projects > 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__projects > summary::-webkit-details-marker { display: none; }
.sr-header__projects > summary .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-header__projects[open] > summary { border-color: var(--sr-white); }
.sr-header__projects ul {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 1001;
  min-width: 16rem; 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__projects 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 { background: #f2f2f2; }
.sr-header__projects ul a[aria-current="true"] { font-weight: 700; }
.sr-header__projects 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; }
}

/* ── 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; }
.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: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--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; }

/* ── 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; }
}
