/* =========================================================
   HomeWatch HQ Beta Tester — minimal, professional design
   Goals: WCAG AA contrast, dense, no decorative chrome.
   ========================================================= */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8f7;
  --bg-muted: #eef0ee;
  --bg-inset: #f3f5f3;
  --text: #111613;
  --text-muted: #4a554f;
  --text-faint: #6b746e;
  --border: #e4e7e5;
  --border-strong: #cdd3cf;

  --brand: #0c4a36;
  --brand-strong: #093928;
  --brand-soft: #e6efeb;
  --brand-fg: #ffffff;

  --pass: #15703f;
  --pass-soft: #e4f1ea;
  --fail: #a51b13;
  --fail-soft: #f8e1df;
  --blocked: #8a5a0a;
  --blocked-soft: #f7e9c8;
  --na: #57625c;
  --na-soft: #e8ebe9;

  --focus: #0c4a36;
  --shadow: 0 1px 2px rgba(15,30,25,.04);

  --radius: 6px;
  --radius-lg: 8px;

  --topbar-h: 52px;
  --sidebar-w: 260px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1310;
    --bg-soft: #131815;
    --bg-muted: #1a201c;
    --bg-inset: #161c19;
    --text: #e8efea;
    --text-muted: #b1bcb6;
    --text-faint: #889389;
    --border: #232c27;
    --border-strong: #2f3a34;
    --brand: #3fb985;
    --brand-strong: #4ec593;
    --brand-soft: #15302a;
    --brand-fg: #07140f;
    --pass: #5ac389;
    --pass-soft: #14301f;
    --fail: #ef7e76;
    --fail-soft: #361b1a;
    --blocked: #e7b25b;
    --blocked-soft: #36280f;
    --na: #b1bcb6;
    --na-soft: #1b221e;
    --focus: #5ac389;
    --shadow: 0 1px 2px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}

/* ===== reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: fixed; top: -100px; left: 8px; z-index: 200;
  background: var(--brand); color: var(--brand-fg);
  padding: 8px 12px; border-radius: 6px; font-weight: 600;
  text-decoration: none; transition: top .15s ease;
}
.skip:focus { top: 8px; }

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

/* ===== topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__nav {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; color: var(--text);
  font-size: 18px; line-height: 1;
}
.topbar__nav:hover { background: var(--bg-muted); }
.topbar__brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  font-weight: 600; font-size: 14px;
  min-width: 0; white-space: nowrap; overflow: hidden;
}
.topbar__mark {
  width: 24px; height: 24px;
  border-radius: 5px;
  background: var(--brand); color: var(--brand-fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: .03em;
  flex-shrink: 0;
}
.topbar__sub { color: var(--text-faint); font-weight: 400; margin-left: 4px; }
@media (max-width: 640px) { .topbar__sub { display: none; } }

.topbar__email {
  color: var(--text-muted); font-size: 13px;
  max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 720px) { .topbar__email { display: none; } }

.savestatus {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--border);
}
.savestatus__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pass); }
.savestatus[data-state="saving"] .savestatus__dot { background: var(--blocked); }
.savestatus[data-state="error"] .savestatus__dot { background: var(--fail); }
.savestatus[data-state="offline"] .savestatus__dot { background: var(--text-faint); }
@media (max-width: 540px) { .savestatus__text { display: none; } }

/* ===== main ===== */
main { flex: 1; width: 100%; display: flex; flex-direction: column; }

/* ===== page (centered narrow) ===== */
.page { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; width: 100%; }
.page--narrow { max-width: 480px; }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; letter-spacing: -.005em; }
.card h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.card p { margin: 0 0 16px; }

.stack { display: grid; gap: 16px; }

.eyebrow {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--brand);
  margin: 0 0 4px;
}

/* ===== forms ===== */
.field { display: grid; gap: 4px; }
.field label { font-weight: 500; font-size: 13px; color: var(--text); }
.hint { color: var(--text-faint); font-size: 12px; margin: 0; }
.error { color: var(--fail); font-size: 12px; margin: 0; font-weight: 500; }
.turnstile { min-height: 65px; display: flex; align-items: center; }

input[type="text"], input[type="email"], input[type="url"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-height: 36px;
  font-size: 14px;
  line-height: 1.4;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}
textarea { min-height: 72px; resize: vertical; padding-top: 8px; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
                    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* disclosure */
.disc { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
.disc > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 500; font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  color: var(--text);
}
.disc > summary::-webkit-details-marker { display: none; }
.disc > summary::before {
  content: "▸"; color: var(--text-faint); display: inline-block; width: 12px; transition: transform .15s ease;
}
.disc[open] > summary::before { transform: rotate(90deg); }
.disc__body { padding: 0 12px 12px; }

/* ===== buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  min-height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-muted); border-color: var(--text-faint); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--bg-muted); }
.btn--sm { padding: 5px 10px; min-height: 28px; font-size: 12px; }

.link {
  background: none; border: 0; padding: 0;
  color: var(--brand); cursor: pointer; font: inherit;
  text-decoration: underline; text-underline-offset: 2px;
}
.link:hover { color: var(--brand-strong); }

/* ===== workspace layout ===== */
.workspace {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
}
@media (min-width: 980px) {
  .workspace { grid-template-columns: var(--sidebar-w) 1fr; }
}

/* sidebar */
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 12px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
@media (max-width: 979px) {
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0;
    width: min(300px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
  }
  .sidebar.is-open { transform: translateX(0); }
}
.scrim {
  position: fixed; inset: var(--topbar-h) 0 0 0;
  background: rgba(0,0,0,.35); border: 0; padding: 0; z-index: 35; cursor: pointer;
}

.sidebar__progress {
  display: grid; gap: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sidebar__progress-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--text-muted); }
.sidebar__progress-top strong { color: var(--text); font-size: 13px; font-weight: 600; }
.bar { width: 100%; height: 4px; background: var(--bg-muted); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); width: 0%; transition: width .2s ease; border-radius: 999px; }
.sidebar__counts { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--text-muted); }

.seclist { list-style: none; padding: 0; margin: 0; display: grid; gap: 1px; }
.seclist a {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
}
.seclist a:hover { background: var(--bg-muted); }
.seclist a[aria-current="true"] {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.seclist .sn { font-variant-numeric: tabular-nums; color: var(--text-faint); font-size: 12px; }
.seclist a[aria-current="true"] .sn { color: var(--brand); }
.seclist .st { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.seclist .ss {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.seclist .ss[data-state="done"] { color: var(--pass); }
.seclist .ss[data-state="fail"] { color: var(--fail); }
.seclist .ss[data-state="partial"] { color: var(--blocked); }

.sidebar__review { margin-top: auto; width: 100%; justify-content: center; }

/* content */
.content {
  padding: 20px 16px 80px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 980px) { .content { padding: 24px 28px 60px; } }

.content__head { display: grid; gap: 8px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.crumbs { margin: 0; color: var(--text-faint); font-size: 12px; font-weight: 500; }
.crumbs > span + span { margin-left: 6px; }
.content__title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.003em; }
.content__intro { margin: 0; }

.filters {
  display: inline-flex;
  background: var(--bg-muted);
  border-radius: var(--radius);
  padding: 2px;
  width: fit-content;
}
.filter {
  background: transparent; border: 0;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.filter:hover { color: var(--text); }
.filter.is-on { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }

.empty { color: var(--text-muted); padding: 24px 0; text-align: center; font-size: 13px; }

/* rows */
.rows { list-style: none; padding: 0; margin: 0; }
.row {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  display: grid;
  gap: 8px;
}
.row:first-child { padding-top: 4px; }
.row:last-child { border-bottom: 0; }

.row__head {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: baseline;
}
.row__id {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.row__check { margin: 0; font-weight: 500; font-size: 14px; line-height: 1.45; color: var(--text); }
.row__pass { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.row__pass b { color: var(--text); font-weight: 600; }

.results {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 60px;
}
@media (max-width: 540px) { .results { margin-left: 0; } }

.rb {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  padding: 5px 12px;
  min-height: 30px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px; font-weight: 500;
}
.rb:hover { border-color: var(--text-faint); color: var(--text); background: var(--bg-muted); }
.rb::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid var(--text-faint);
  background: var(--bg);
  flex-shrink: 0;
}
.rb[aria-pressed="true"]::before {
  background: currentColor;
  border-color: currentColor;
  box-shadow: inset 0 0 0 2px var(--bg);
}
.rb[aria-pressed="true"][data-result="Pass"]    { color: var(--pass);    background: var(--pass-soft);    border-color: var(--pass); }
.rb[aria-pressed="true"][data-result="Fail"]    { color: var(--fail);    background: var(--fail-soft);    border-color: var(--fail); }
.rb[aria-pressed="true"][data-result="Blocked"] { color: var(--blocked); background: var(--blocked-soft); border-color: var(--blocked); }
.rb[aria-pressed="true"][data-result="N/A"]     { color: var(--na);      background: var(--na-soft);      border-color: var(--na); }

.rowerr {
  margin: 0 0 0 60px;
  color: var(--fail);
  font-size: 12px;
  font-weight: 500;
}
@media (max-width: 540px) { .rowerr { margin-left: 0; } }

.comment {
  margin-left: 60px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
@media (max-width: 540px) { .comment { margin-left: 0; } }
.comment > summary {
  list-style: none;
  cursor: pointer;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.comment > summary::-webkit-details-marker { display: none; }
.comment > summary::before {
  content: "▸";
  display: inline-block;
  width: 12px;
  color: var(--text-faint);
  transition: transform .15s ease;
}
.comment[open] > summary::before { transform: rotate(90deg); }
.comment__body { padding: 0 10px 10px; }
.comment textarea { min-height: 56px; }

.fail {
  margin-left: 60px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--fail);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 10px;
}
@media (max-width: 540px) { .fail { margin-left: 0; } }
.fail__title { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fail); }

.evidence { display: grid; gap: 6px; }
.evidence__label { font-size: 12px; color: var(--text-muted); }
.evidence__list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.evidence__list li {
  background: var(--bg); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 4px;
  font-size: 12px; color: var(--text-muted);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fail input[type="file"] { font-size: 12px; }

/* pager */
.pager {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== review ===== */
.stats {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  margin: 16px 0;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.stat__n { font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.stat__l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

.block { margin-top: 24px; }
.block h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }

.rlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.rlist li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.rlist .rid {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--text-muted);
}
.rlist .rt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--text); }
.rlist .rs {
  font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 3px;
  text-transform: uppercase;
  background: var(--bg-muted); color: var(--text-muted);
}
.rlist .rs[data-sev="P0"], .rlist .rs[data-sev="P1"] { background: var(--fail-soft); color: var(--fail); }
.rlist .rs[data-sev="P2"], .rlist .rs[data-sev="P3"] { background: var(--blocked-soft); color: var(--blocked); }
.rlist .go { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; padding: 0; }
.rlist .go:hover { text-decoration: underline; }

.qs { padding-left: 18px; margin: 0 0 16px; color: var(--text-muted); display: grid; gap: 4px; }

/* completed */
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.meta dt { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.meta dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; }
.meta code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-muted); padding: 2px 6px; border-radius: 4px; }

/* footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  background: var(--bg);
}

/* toast */
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  z-index: 60;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  max-width: 90vw;
}
.toast[hidden] { display: none; }

/* hide nav toggle on desktop, show on mobile */
@media (max-width: 979px) {
  .topbar__nav:not([hidden]) { display: inline-flex; }
}

/* reduced motion + forced colors */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
@media (forced-colors: active) {
  .btn, .rb, .filter, .seclist a, .stat, .rlist li, .card, .fail, .sidebar__progress { border: 1px solid CanvasText; }
  .btn--primary { background: Highlight; color: HighlightText; }
}
