/* Sentinel dashboard styles.
   Self-hosted only: no remote fonts, no CDN, nothing the CSP would have to
   allow from another origin. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #16191d;
  --text-2: #5a6472;
  --text-3: #8b94a1;
  --accent: #1f4ed8;
  --accent-soft: #eaeffc;
  --good: #0f7b4f;
  --good-soft: #e6f4ec;
  --warn: #92610a;
  --warn-soft: #fdf3e0;
  --bad: #b4231f;
  --bad-soft: #fdecec;
  --critical: #8c1113;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --surface-2: #1b212a;
    --border: #262d38;
    --border-strong: #38414f;
    --text: #e6edf3;
    --text-2: #9aa5b1;
    --text-3: #6e7781;
    --accent: #6c93f7;
    --accent-soft: #182440;
    --good: #43c08a;
    --good-soft: #10261d;
    --warn: #e0a84a;
    --warn-soft: #2a2113;
    --bad: #f2716c;
    --bad-soft: #2d1616;
    --critical: #ff8b86;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

code, .secret, .mono { font-family: var(--mono); font-size: .92em; }

.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;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem;
}
.skip:focus { left: .5rem; top: .5rem; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0 1.25rem; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: .5rem; color: var(--accent); }
.brand-mark { width: 22px; height: 22px; }
.brand-name { font-weight: 650; font-size: 15px; color: var(--text); letter-spacing: -.01em; }

.nav { display: flex; gap: .15rem; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: .4rem .65rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.badge {
  display: inline-block; margin-left: .35rem; padding: 0 .35rem;
  border-radius: 9px; font-size: 11px; font-weight: 700; line-height: 17px;
}
.badge-critical { background: var(--bad); color: #fff; }

.account { display: flex; align-items: center; gap: .6rem; }
.account-link { display: flex; align-items: center; gap: .45rem; color: var(--text); }
.account-name { font-weight: 550; }

.role-chip {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: .1rem .4rem; border-radius: 4px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.role-admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.role-analyst { background: var(--good-soft); color: var(--good); border-color: transparent; }

.main { max-width: 1680px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.footer {
  display: flex; justify-content: space-between; max-width: 1680px;
  margin: 0 auto; padding: 0 1.25rem 2rem;
  color: var(--text-3); font-size: 12px;
}

/* ---------- Page heads ---------- */

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.page-sub { margin: .3rem 0 0; color: var(--text-2); max-width: 78ch; }
.head-actions { display: flex; gap: .5rem; }

.crumbs { font-size: 12px; color: var(--text-3); margin-bottom: .2rem; }
.crumbs span { margin: 0 .3rem; }

/* ---------- KPI tiles ---------- */

.kpis {
  display: grid; gap: .75rem; margin-bottom: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem .95rem;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .15rem;
  border-left: 3px solid var(--border-strong);
}
.kpi-good { border-left-color: var(--good); }
.kpi-warn { border-left-color: var(--warn); }
.kpi-bad { border-left-color: var(--bad); }

.kpi-label {
  font-size: 11px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3);
}
.kpi-value {
  font-size: 26px; font-weight: 640; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi-unit { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: .25rem; }
.kpi-foot { font-size: 11.5px; color: var(--text-2); }

/* ---------- Cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1.25rem; padding: 1rem 1.1rem;
}
.card-flush { padding: 0; overflow: hidden; }
.card-flush .table { margin: 0; }

.card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap;
}
.card-flush .card-head { padding: 1rem 1.1rem 0; }
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.card-note { font-size: 12px; color: var(--text-3); }
.card-action { font-size: 12.5px; font-weight: 550; }

.card-revealed { border-color: var(--warn); border-width: 2px; }

.grid-2 {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table caption { text-align: left; }
.table th, .table td {
  padding: .55rem .7rem; text-align: left;
  border-bottom: 1px solid var(--border); vertical-align: top;
}
.table thead th {
  font-size: 11px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3);
  background: var(--surface-2); white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table-compact th, .table-compact td { padding: .4rem .6rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-sticky thead th { position: sticky; top: 56px; z-index: 5; }

.row-disabled { opacity: .55; }
.row-unread { background: var(--accent-soft); }
.row-unread:hover { background: var(--accent-soft); }
.row-actions { display: flex; gap: .3rem; flex-wrap: wrap; }

.site-link { font-weight: 550; }
.subtle { display: block; font-size: 11px; color: var(--text-3); }
.muted { color: var(--text-3); }
.unit { font-size: 10.5px; color: var(--text-3); margin-left: 1px; }
.warn-text { color: var(--warn); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 650; }
.error-cell, .detail-cell { max-width: 36ch; overflow-wrap: anywhere; }

/* ---------- Pills, tags, chips ---------- */

.pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: 11px; font-weight: 650; white-space: nowrap;
}
.pill-up { background: var(--good-soft); color: var(--good); }
.pill-down { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-unknown { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }

.tag {
  display: inline-block; padding: .05rem .4rem; border-radius: 4px;
  font-size: 11px; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); white-space: nowrap;
}

.chip {
  display: inline-block; min-width: 20px; padding: .05rem .35rem;
  border-radius: 4px; font-size: 11.5px; font-weight: 700; text-align: center;
}
.chip-critical { background: var(--bad); color: #fff; }
.chip-high { background: var(--warn-soft); color: var(--warn); }
.chip-low { background: var(--surface-2); color: var(--text-2); }

.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score-good { color: var(--good); }
.score-warn { color: var(--warn); }
.score-bad { color: var(--bad); }

/* ---------- Findings ---------- */

.finding-list { list-style: none; margin: 0; padding: 0; }
.finding-list-full > .finding { padding: .85rem 1.1rem; }
.finding {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.finding:last-child { border-bottom: 0; }
.finding-resolved { opacity: .6; }

.sev {
  flex: 0 0 auto; min-width: 62px; text-align: center;
  padding: .12rem .4rem; border-radius: 4px;
  font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em;
}
.sev-critical { background: var(--critical); color: #fff; }
.sev-high { background: var(--bad-soft); color: var(--bad); }
.sev-medium { background: var(--warn-soft); color: var(--warn); }
.sev-low { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.sev-info { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }

.finding-body { flex: 1; min-width: 0; }
.finding-title { display: block; font-weight: 600; }
.finding-meta {
  display: block; font-size: 11.5px; color: var(--text-3);
  margin-top: .1rem; overflow-wrap: anywhere;
}
.finding-detail {
  margin: .35rem 0 0; color: var(--text-2); font-size: 12.5px; max-width: 110ch;
}
.finding-side { flex: 0 0 auto; display: flex; flex-direction: column; gap: .35rem; align-items: flex-end; }
.finding-age { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* ---------- Submissions ---------- */

.sub-list { list-style: none; margin: 0; padding: 0; }
.sub {
  display: flex; gap: .75rem; justify-content: space-between;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.sub:last-child { border-bottom: 0; }
.sub-body { min-width: 0; }
.sub-title { display: block; font-weight: 600; }
.sub-preview {
  display: block; font-family: var(--mono); font-size: 11.5px;
  color: var(--text-2); margin-top: .15rem; overflow-wrap: anywhere;
}
.sub-meta { display: block; font-size: 11px; color: var(--text-3); margin-top: .1rem; }
.sub-age { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

.masked { font-family: var(--mono); font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.masked-large { font-size: 13px; padding: .6rem .75rem; background: var(--surface-2);
  border-radius: var(--radius-sm); border: 1px solid var(--border); }

.privacy-note {
  margin: .7rem 0 0; font-size: 11.5px; color: var(--text-3);
  padding-top: .6rem; border-top: 1px dashed var(--border);
}

.reveal-gate { max-width: 80ch; }
.reveal-gate p { color: var(--text-2); }

.facts { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: .4rem 1rem; margin: 0; }
.facts dt { font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-values dd .value {
  font-family: var(--mono); background: var(--warn-soft);
  padding: .1rem .3rem; border-radius: 3px;
}

/* ---------- Charts ---------- */

.chart {
  width: 100%; height: 84px; display: block;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: .75rem;
}
.chart-line {
  fill: none; stroke: var(--accent); stroke-width: 1.2;
  stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.probe-strip { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: .75rem; }
.probe { width: 7px; height: 22px; border-radius: 2px; background: var(--good); }
.probe-down { background: var(--bad); }

.host-strip {
  display: flex; gap: 1.25rem; flex-wrap: wrap; margin-top: .75rem;
  padding-top: .75rem; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-2);
}

/* ---------- Forms ---------- */

.filters {
  display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: .2rem; }
.field label, .auth-form label {
  font-size: 11.5px; font-weight: 650; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .03em;
}
.field-checks { display: flex; gap: .85rem; flex-wrap: wrap; align-items: center; }
.field-checks label {
  text-transform: none; letter-spacing: 0; font-size: 13px;
  font-weight: 450; color: var(--text); display: flex; gap: .3rem; align-items: center;
}
.field-hint { margin: .2rem 0 0; font-size: 11.5px; color: var(--text-3); max-width: 46ch; }
.field-submit { justify-content: flex-end; }

.form-grid {
  display: grid; gap: 1rem; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

input[type="text"], input[type="password"], input[type="search"], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: .4rem .55rem; min-width: 150px;
}
input[type="search"] { min-width: 200px; }

.btn {
  display: inline-block; font: inherit; font-weight: 550; cursor: pointer;
  padding: .42rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); text-align: center; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-quiet { background: transparent; }
.btn-small { padding: .2rem .5rem; font-size: 12px; }
.btn-block { display: block; width: 100%; }

.inline-form { display: inline; }
.stack { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

.pager {
  display: flex; gap: .75rem; align-items: center; justify-content: center;
  margin: 1rem 0;
}
.pager-state { font-size: 12.5px; color: var(--text-2); }

/* ---------- Alerts and empty states ---------- */

.alert {
  padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: 1rem;
  border: 1px solid var(--border); font-size: 13px; overflow-wrap: anywhere;
}
.alert-error { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert-info { background: var(--accent-soft); border-color: transparent; color: var(--text); }

.empty { padding: 1.5rem 1rem; text-align: center; color: var(--text-2); }
.empty p { margin: .25rem 0; }
.empty p:first-child { color: var(--text); }

.integrity {
  display: flex; gap: .75rem; align-items: center;
  padding: .75rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 1.25rem;
}
.integrity p { margin: 0; }
.integrity-mark {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; color: #fff;
}
.integrity-ok { background: var(--good-soft); border-color: var(--good); }
.integrity-ok .integrity-mark { background: var(--good); }
.integrity-bad { background: var(--bad-soft); border-color: var(--bad); }
.integrity-bad .integrity-mark { background: var(--bad); }

.rights { list-style: none; margin: 0; padding: 0; }
.rights li { padding: .3rem 0 .3rem 1.6rem; position: relative; }
.rights li::before { position: absolute; left: 0; font-weight: 800; }
.right-yes::before { content: "✓"; color: var(--good); }
.right-no::before { content: "✕"; color: var(--text-3); }
.right-no { color: var(--text-3); }

/* ---------- Auth pages ---------- */

.auth-body { background: var(--bg); }
.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  padding: 2rem 1rem; align-content: center; gap: 1rem;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.75rem; box-shadow: var(--shadow);
}
.auth-brand {
  display: flex; align-items: center; gap: .5rem; justify-content: center;
  color: var(--accent); font-weight: 650; margin-bottom: 1.25rem;
}
.auth-brand span { color: var(--text); font-size: 16px; }
.auth-title { margin: 0 0 .4rem; font-size: 19px; font-weight: 650; text-align: center; }
.auth-sub { margin: 0 0 1.1rem; color: var(--text-2); font-size: 13px; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: .3rem; }
.auth-form label { margin-top: .6rem; }
.auth-form input { width: 100%; }
.auth-form .btn { margin-top: 1.1rem; }
.auth-alt { margin-top: .85rem; text-align: center; font-size: 12.5px; }
.auth-foot { color: var(--text-3); font-size: 11.5px; text-align: center; margin: 0; }

.enrol-steps { color: var(--text-2); font-size: 13px; padding-left: 1.2rem; margin: 0 0 1rem; }
.enrol-steps li { margin-bottom: .3rem; }

.qr-wrap { display: grid; place-items: center; margin-bottom: 1rem; }
.qr {
  width: 200px; height: 200px; background: #fff; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: grid; place-items: center;
}
.qr svg { width: 100%; height: 100%; display: block; }

.secret-box {
  display: flex; flex-direction: column; gap: .2rem; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem; margin-bottom: 1rem;
}
.secret-label {
  font-size: 10.5px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3);
}
.secret { font-size: 13px; letter-spacing: .06em; overflow-wrap: anywhere; text-align: center; }

.codes {
  list-style: none; margin: 0 0 1.25rem; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: .4rem;
}
.codes li {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .45rem; text-align: center;
}
.codes code { font-size: 12.5px; letter-spacing: .04em; }

.action { font-size: 11.5px; }

/* ---------- Narrow screens ---------- */

@media (max-width: 860px) {
  .topbar { height: auto; padding: .6rem 1rem; }
  .nav { order: 3; width: 100%; }
  .main { padding: 1rem .75rem 2rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .table-sticky thead th { position: static; }
  .facts { grid-template-columns: 1fr; gap: .1rem .5rem; }
  .facts dd { margin-bottom: .5rem; }
  .codes { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .footer, .filters, .btn, .pager { display: none; }
  .card { break-inside: avoid; box-shadow: none; }
}
