/* Moat Watcher UI foundation. Semantic design tokens + a component kit; the dark theme
   is a single token remap (prefers-color-scheme), never a filter. Chrome (header/footer)
   stays light in both themes so the white-background logos always render (Option A).
   Contrast pairings target WCAG 2.2 AA (4.5:1 text, 3:1 large/UI). */
:root {
  color-scheme: light dark;
  /* content surfaces + text (themed) */
  --surface:#f4f6f9; --surface-2:#ffffff; --surface-3:#eef1f5;
  --text:#20262e; --text-muted:#54606f; --border:#e2e6ec;
  /* brand + semantic */
  --accent:#E8792B; --link:#2E6FB0; --focus:#2E6FB0; --heading:#16244A;
  --btn-bg:#16244A; --btn-bg-hover:#1E3A5F; --btn-text:#ffffff;
  --thead-bg:#16244A; --thead-text:#ffffff; --danger:#c0392b; --ok:#2e8b57;
  /* chrome (header/footer): light in light mode; dark in dark mode, matched to the
     dark-logo background (#00040a) so the theme-swapped logos blend seamlessly. */
  --chrome-bg:#ffffff; --chrome-text:#16244A; --chrome-border:#e2e6ec; --chrome-muted:#54606f;
  /* scale */
  --radius:6px; --maxw:60rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface:#111a2b; --surface-2:#18233a; --surface-3:#212f49;
    --text:#dce4f0; --text-muted:#98a6bd; --border:#2b3a56;
    --link:#6fa8e6; --focus:#6fa8e6; --heading:#8fb0e0; --accent:#f08a3e;
    --btn-bg:#2c4680; --btn-bg-hover:#365591; --btn-text:#ffffff;
    --thead-bg:#243a6b; --danger:#e07a6a; --ok:#5cc98a;
    --chrome-bg:#00040a; --chrome-text:#e8eef6; --chrome-border:#16223a; --chrome-muted:#93a2b8;
  }
}
* { box-sizing:border-box; }
body { font-family:system-ui,-apple-system,"Segoe UI",Arial,sans-serif; margin:0;
       background:var(--surface); color:var(--text); line-height:1.5; }
.wrap { max-width:var(--maxw); margin:0 auto; padding:0 1.25rem; }

/* header / footer (light chrome) */
.site-header { background:var(--chrome-bg); border-top:4px solid var(--accent);
               border-bottom:1px solid var(--chrome-border); }
.site-header .wrap { display:flex; align-items:center; gap:1rem; padding:.5rem 1.25rem; }
.wordmark { height:36px; display:block; }
.site-nav { margin-left:auto; display:flex; align-items:center; gap:1.1rem; }
.nav-link { color:var(--chrome-text); text-decoration:none; font-size:.92rem; }
.nav-link:hover { color:var(--link); }
.site-footer { border-top:1px solid var(--chrome-border); background:var(--chrome-bg);
               padding:.9rem 0; margin-top:2rem; }
.site-footer .wrap { display:flex; align-items:center; gap:1rem; flex-wrap:wrap; }
.cutsec { height:24px; display:block; }
.site-footer .links { margin-left:auto; display:flex; gap:1rem; font-size:.82rem; }
.site-footer span { color:var(--chrome-muted); font-size:.78rem; }
.site-footer a { color:var(--link); }

main.wrap { padding-top:1.5rem; padding-bottom:2.5rem; min-height:60vh; }
h1 { font-size:1.5rem; color:var(--heading); margin:.2rem 0 1rem; }
h2 { font-size:1.15rem; color:var(--heading); margin-top:1.6rem; }
h3 { color:var(--heading); }
a { color:var(--link); }

/* forms */
label { display:block; margin:.7rem 0 .2rem; font-size:.88rem; color:var(--text-muted); }
input[type=text],input[type=email],input[type=password],input[type=file],select {
  width:100%; max-width:26rem; padding:.5rem .6rem; font-size:1rem;
  border:1px solid var(--border); border-radius:5px; background:var(--surface-2); color:var(--text); }
input:focus,select:focus { outline:2px solid var(--focus); outline-offset:1px; }

/* buttons: one canonical style; the .btn class and <button> element share it so no
   ancestor selector can override a button's text color (the old specificity bug). */
button, .btn { display:inline-block; margin-top:.2rem; padding:.5rem 1.05rem; font-size:.95rem;
  color:var(--btn-text); background:var(--btn-bg); border:none; border-radius:5px; cursor:pointer;
  text-decoration:none; line-height:1.3; }
button:hover, .btn:hover { background:var(--btn-bg-hover); color:var(--btn-text); }
form button { margin-top:.9rem; }
.site-nav button, .site-nav .btn { margin-top:0; padding:.4rem .85rem; font-size:.9rem; }

/* misc */
.error { color:var(--danger); margin:.5rem 0; }
.ok { color:var(--ok); }
.muted { color:var(--text-muted); font-size:.88rem; }
code { font-family:ui-monospace,monospace; background:var(--surface-3); color:var(--text);
       padding:0 .25rem; border-radius:3px; }
.card { background:var(--surface-2); border:1px solid var(--border); border-radius:8px; padding:1rem 1.25rem; }
table { border-collapse:collapse; width:100%; background:var(--surface-2); font-size:.92rem; }
th,td { border:1px solid var(--border); padding:.35rem .55rem; text-align:left; }
th { background:var(--thead-bg); color:var(--thead-text); font-weight:600; }
.codes { columns:2; } .codes li { font-family:ui-monospace,monospace; }
.qr { width:200px; height:200px; background:#fff; padding:6px; border-radius:6px; }

/* Batch B: scope editor - collapsible add-panels, field grids, tables, roster reveal */
.table-scroll { overflow-x:auto; margin:.4rem 0; }

details.add-panel { margin:.8rem 0 1.2rem; border:1px solid var(--border); border-radius:8px;
  background:var(--surface-2); }
details.add-panel > summary { cursor:pointer; padding:.6rem 1rem; font-weight:600;
  color:var(--heading); list-style:revert; }
details.add-panel[open] > summary { border-bottom:1px solid var(--border); }
details.add-panel > form { padding:.6rem 1rem 1rem; }

/* per-row asset editing: an Edit button reveals just that row's form via CSS :target (no JS) */
.row-actions { white-space:nowrap; }
.row-actions form { display:inline; }

/* the assets table is wide and scrolls horizontally; pin the Actions column to the right edge so
   Edit/Delete stay visible without scrolling. */
.assets-table th:last-child, .assets-table td.row-actions {
  position:sticky; right:0; z-index:2; box-shadow:-8px 0 8px -8px rgba(0,0,0,.35); }
.assets-table td.row-actions { background:var(--surface-2); }
.assets-table thead th:last-child { background:var(--thead-bg); }

/* the weekly report is a light/print-styled document (dark text on white); render it on a white
   sheet in any theme so it stays readable in dark mode. */
.report-embed { background:#ffffff; color:#20262e; border:1px solid var(--border);
  padding:12px 14px; border-radius:6px; overflow-x:auto; }
.report-embed a { color:#16244a; }
.btn-sm { margin-top:0; padding:.28rem .7rem; font-size:.82rem; }
.btn-secondary { background:var(--surface-3); color:var(--text); }
.btn-secondary:hover { background:var(--border); color:var(--text); }
tr.edit-row { display:none; }
tr.edit-row:target { display:table-row; }
tr.edit-row > td { padding:.9rem 1rem; background:var(--surface); }

/* two-column field grid inside an add-panel; .wide spans both columns */
.field-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.4rem 1.2rem; }
.field-grid > label { margin:.3rem 0 0; display:flex; flex-direction:column; }
.field-grid input { max-width:none; margin-top:.2rem; }
.field-grid .wide { grid-column:1 / -1; }
.field-grid .wide button { margin-top:.4rem; }
@media (max-width:560px) { .field-grid { grid-template-columns:1fr; } }

/* roster with blur/reveal email addresses (CSS-only, no JS - CSP blocks scripts) */
ul.roster { list-style:none; padding:0; }
ul.roster > li { border:1px solid var(--border); border-radius:8px; background:var(--surface-2);
  padding:.6rem .9rem; margin-bottom:.6rem; }
.roster-head { display:flex; align-items:center; gap:.5rem; }
.roster-head form { display:inline; }
.roster-body { margin-top:.4rem; display:flex; flex-direction:column; gap:.3rem; }

.reveal-wrap { display:inline-flex; align-items:center; gap:.4rem; }
.reveal-wrap .reveal { position:absolute; opacity:0; width:1px; height:1px; }  /* visually hidden checkbox */
.reveal-wrap .eye { display:inline-flex; align-items:center; cursor:pointer; color:var(--text-muted); }
.reveal-wrap .eye:hover { color:var(--link); }
.reveal-wrap .reveal:focus-visible + .eye { outline:2px solid var(--focus); outline-offset:2px; border-radius:3px; }
.reveal-wrap .secret { filter:blur(4.5px); transition:filter .1s; user-select:none; }
.reveal-wrap .reveal:checked ~ .secret { filter:none; user-select:text; }

/* inline set/replace key form inside the provider table */
form.inline-key { display:flex; gap:.4rem; align-items:center; margin:0; }
form.inline-key input[type=password] { max-width:16rem; margin:0; }
form.inline-key button { margin:0; }
