/* Ahooy WP monitor. One stylesheet, no build step. Light and dark follow the OS. */

:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --text: #1b1f24;
  --muted: #5a636e;
  --border: #d8dce2;
  --border-strong: #b9c0c9;
  --link: #1a56a8;
  --focus: #2f6fd6;

  --red: #a4161a;
  --red-bg: #fde8e7;
  --red-solid: #b42318;
  --amber: #7a4800;
  --amber-bg: #fff0d4;
  --amber-line: #c98a12;
  --green: #1d6b35;
  --green-bg: #e3f4e8;
  --info: #1f4f8a;
  --info-bg: #e6eefa;
  --grey: #4b5563;
  --grey-bg: #eceef1;

  --dev: #5b2a86;
  --dev-bg: #f1e7fb;

  --radius: 4px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --surface: #171b20;
    --surface-2: #1d2228;
    --text: #e5e8ec;
    --muted: #9ba4af;
    --border: #2c333b;
    --border-strong: #3d4651;
    --link: #8db8ff;
    --focus: #8db8ff;

    --red: #ffa39e;
    --red-bg: #3b1517;
    --red-solid: #c42b22;
    --amber: #ffcf7d;
    --amber-bg: #392a0d;
    --amber-line: #d39a2c;
    --green: #86dca0;
    --green-bg: #13301d;
    --info: #a6c8ff;
    --info-bg: #152740;
    --grey: #c3c9d1;
    --grey-bg: #272c33;

    --dev: #e2c6ff;
    --dev-bg: #34204a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

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

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
h4 { font-size: .875rem; margin: 1rem 0 .4rem; }

.sr {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 8px; top: -40px; z-index: 10;
  background: var(--surface); color: var(--text); padding: 6px 10px; border-radius: var(--radius);
}
.skip:focus { top: 8px; }

.muted { color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: .8rem; }
.mono { font-family: var(--mono); font-size: .8125rem; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }

/* Dev banner (CONTRACT §9.4): on every page in dev mode. */
.dev-banner {
  background: var(--dev-bg); color: var(--dev);
  border-bottom: 2px solid var(--dev);
  padding: 6px 16px; font-size: .8125rem;
}
.dev-banner strong { letter-spacing: .06em; margin-right: .5rem; }

/* Header */
.top {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text); text-decoration: none; }
.top nav a { color: var(--text); text-decoration: none; padding: 4px 2px; }
.top nav a[aria-current="page"] { border-bottom: 2px solid var(--text); }
.who { margin-left: auto; display: flex; align-items: center; gap: .75rem; min-width: 0; }
.who-email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
form.inline { display: inline; margin: 0; }

button, .button-link {
  font: inherit; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 6px 12px; text-decoration: none; display: inline-block;
}
button:hover, .button-link:hover { background: var(--surface-2); }
.primary { background: var(--text); color: var(--surface); border-color: var(--text); font-weight: 600; }
.primary:hover { background: var(--text); opacity: .9; }
.link-button { border: 0; background: none; padding: 0; color: var(--link); text-decoration: underline; }
.link-button:hover { background: none; }

main { padding: 16px; max-width: 1680px; margin: 0 auto; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.5rem; margin-bottom: 12px; }
.summary { margin: 0; color: var(--muted); }
.controls { display: flex; align-items: center; gap: 1rem; }
.toggle { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; cursor: pointer; }
.toggle input { width: 16px; height: 16px; margin: 0; }
.crumb { margin: 0 0 .5rem; }

/* Data-source freshness strip */
.feeds ul { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.feed {
  display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-size: .8125rem;
}
.feed .sub { display: inline; }
.feed-name { font-weight: 600; }
.feed-ok .feed-state { color: var(--green); }
.feed-stale { border-color: var(--amber-line); background: var(--amber-bg); }
.feed-stale .feed-state { color: var(--amber); font-weight: 600; }

.warnings { margin: 0 0 12px; padding: 6px 10px; border: 1px solid var(--amber-line); background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); }
.warnings summary { cursor: pointer; font-weight: 600; }
.warnings ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; padding: 6px 10px; border-bottom: 1px solid var(--border); }
tbody tr:last-child > * { border-bottom: 0; }
thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }

table.sites { font-size: 13px; line-height: 1.3; }
table.sites thead th { position: sticky; top: 0; z-index: 1; padding: 0; font-size: 11px; }
table.sites tbody th, table.sites td { padding: 5px 8px; }
table.sites tbody th { font-weight: 600; max-width: 15rem; overflow-wrap: anywhere; }
table.sites tbody th a { color: var(--text); }
table.sites td { white-space: nowrap; }
table.sites .sub { font-size: 12px; }
table.sites td:last-child { white-space: normal; min-width: 11rem; max-width: 16rem; }
table.sites .lc-what { max-width: 15rem; }
table.sites .flags { gap: 3px; }
table.sites .chip { font-size: 11px; line-height: 1.45; }
table.sites .flags .chip { white-space: normal; }
table.sites .vulns { flex-wrap: nowrap; }
table.sites .sort { padding: 7px 8px; }
table.sites tbody tr:hover > * { background: var(--surface-2); }
.row-red > th { box-shadow: inset 4px 0 0 var(--red-solid); }
.row-amber > th { box-shadow: inset 4px 0 0 var(--amber-line); }
.row[hidden] { display: none; }

.sort {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: .3rem;
  width: 100%; padding: 8px 10px; cursor: pointer;
  font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit;
}
.sort:hover { color: var(--text); }
.sort:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.sort-ind::after { content: "↕"; opacity: .35; }
th[aria-sort="ascending"] .sort-ind::after { content: "▲"; opacity: 1; }
th[aria-sort="descending"] .sort-ind::after { content: "▼"; opacity: 1; }
th[aria-sort] { color: var(--text); }

table.list.compact { font-size: 13px; }
table.list.compact td, table.list.compact th { padding: 4px 8px; }
table.list.compact .sub { font-size: 11px; overflow-wrap: anywhere; }
table.list td .sub { margin-top: 1px; }

/* Versions with state: shape as well as colour carries the state. */
.ver { display: inline-flex; align-items: center; gap: 2px; font-family: var(--mono); font-size: .8125rem; padding: 1px 6px; border-radius: var(--radius); border: 1px solid transparent; }
.ver-green { padding-left: 0; padding-right: 0; }
.ver-amber { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-line); }
.ver-red { color: #fff; background: var(--red-solid); font-weight: 700; }
.ver-unknown { color: var(--grey); background: var(--grey-bg); border: 1px dashed var(--border-strong); }

/* Severity */
.sev { display: inline-block; font-size: .75rem; font-weight: 600; padding: 0 6px; border-radius: 999px; line-height: 1.5; border: 1px solid transparent; }
.sev-critical { color: #fff; background: var(--red-solid); }
.sev-high { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.sev-unknown { color: var(--red); background: var(--red-bg); border-style: dashed; border-color: var(--red); }
.sev-medium { color: var(--amber); background: var(--amber-bg); }
.sev-low { color: var(--grey); background: var(--grey-bg); }

.vulns { display: inline-flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.vuln-count { font-weight: 700; }
.vuln-unknown { color: var(--red); font-weight: 600; }
.sep { color: var(--muted); }

/* Chips (flags, small labels) */
.flags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; font-size: .75rem; line-height: 1.5; padding: 0 6px; border-radius: var(--radius); border: 1px solid transparent; white-space: nowrap; }
.chip-red { color: #fff; background: var(--red-solid); font-weight: 600; }
.chip-amber { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-line); }
.chip-info { color: var(--info); background: var(--info-bg); }
.chip-grey { color: var(--grey); background: var(--grey-bg); }
.chip-ok { color: var(--green); background: var(--green-bg); }
.chip-stale { color: var(--amber); background: var(--amber-bg); border: 1px dashed var(--amber-line); }

/* Reporting */
.rep { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.rep-green { color: var(--green); }
.rep-green .dot { background: var(--green); }
.rep-red { color: var(--red); }
.rep-red .dot { background: var(--red-solid); border-radius: 1px; }
.rep-grey { color: var(--grey); font-weight: 400; }

.lc-what { display: inline-block; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.lc-by { color: var(--text); }

.empty { color: var(--muted); padding: 12px 0; margin: 0; }
.attribution { color: var(--muted); font-size: .8rem; margin-top: 12px; }

/* Notices */
.notice { padding: 8px 12px; border-radius: var(--radius); border: 1px solid; margin: 0 0 12px; }
.notice-ok { color: var(--green); background: var(--green-bg); border-color: transparent; }
.notice-amber { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-line); }
.notice-red { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.notice-grey { color: var(--grey); background: var(--grey-bg); border-color: transparent; }
.note { display: block; margin-top: .25rem; color: var(--text); white-space: pre-wrap; }

/* Site page */
.site-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 24rem); gap: 16px; align-items: start; }
@media (min-width: 1101px) { .col-side { position: sticky; top: 16px; } }
.site-grid section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.site-grid section .table-wrap { border-radius: 0; }
.col-side section { margin-bottom: 16px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 10px 16px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts.compact { grid-template-columns: 1fr; gap: 6px; }
.hash { font-size: .75rem; word-break: break-all; }
.flag-row { margin-top: 12px; }

.attribution-box { margin: 8px 0 0; padding: 8px 12px; font-size: .8rem; color: var(--muted); border-left: 3px solid var(--border-strong); background: var(--surface-2); }
.attribution-box h4 { margin: 0 0 .25rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.attribution-box p { margin: .25rem 0; }
.vuln-row-unknown td { background: var(--surface-2); }

details { margin: 0 0 6px; }
details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details > .table-wrap, details > p, details > ul, details > dl { margin-bottom: 10px; }
ul.plain { list-style: none; padding: 0; margin: 4px 0 10px; }
ul.plain li { padding: 4px 0; border-bottom: 1px solid var(--border); }
ul.paths { font-family: var(--mono); font-size: .75rem; margin: 0 0 8px; padding-left: 1.2rem; overflow-wrap: anywhere; }

.review-form { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 4px; }
.review-form fieldset { border: 0; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.review-form legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.review-form label { display: block; }
.review-form textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px 8px; margin: 4px 0 10px; resize: vertical; }

.type { font-size: .75rem; padding: 0 6px; border-radius: var(--radius); background: var(--grey-bg); color: var(--grey); }
.type-event { background: var(--info-bg); color: var(--info); }
.type-alert { background: var(--red-bg); color: var(--red); }
.type-review { background: var(--green-bg); color: var(--green); }
.hist-outside > td:first-child { box-shadow: inset 3px 0 0 var(--amber-line); }
.hist-failure > td:first-child { box-shadow: inset 3px 0 0 var(--red-solid); }

/* Login and error */
.login-card, .error-card {
  max-width: 26rem; margin: 10vh auto 0; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.login-card .primary { width: 100%; text-align: center; padding: 10px 14px; margin: 12px 0 8px; }
.login-card form { margin: 0; }
.error-card .status { font-family: var(--mono); color: var(--muted); margin: 0; }

@media (max-width: 1100px) {
  .site-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  main { padding: 12px 16px; }
  .top { flex-wrap: wrap; gap: .5rem 1rem; }
  .who-email { max-width: 12rem; }
}

@media print {
  .dev-banner, .top, .controls, .review-form { display: none; }
  .table-wrap { overflow: visible; border: 0; }
}
