/* ComplianceHub dashboard.
   Self-contained: no CDN, no build step, no JS. The app runs on hosts whose
   egress is deliberately restricted, so a stylesheet that needs the internet to
   render would be a bad dependency for a compliance tool to carry. */

:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #14181b;
  --muted: #5b6670;
  --line: #dfe3e6;
  --accent: #0e5966;
  --accent-ink: #ffffff;
  --ok: #16653f;
  --ok-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf1dc;
  --bad: #9b2226;
  --bad-bg: #fbe9e9;
  --idle: #56606a;
  --idle-bg: #eceff1;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181b;
    --panel: #1c2226;
    --ink: #e8ecef;
    --muted: #9aa5ae;
    --line: #2d353b;
    --accent: #3d9aab;
    --accent-ink: #0b1416;
    --ok: #6ed49f;
    --ok-bg: #14301f;
    --warn: #e8b866;
    --warn-bg: #33270e;
    --bad: #f08f92;
    --bad-bg: #3a1a1b;
    --idle: #9aa5ae;
    --idle-bg: #262d33;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ── chrome ─────────────────────────────────────────────────────────────── */

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .wrap { display: flex; align-items: center; gap: 28px; height: 56px; }
.brand { font-size: 16px; font-weight: 500; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand b { font-weight: 700; color: var(--accent); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  color: var(--muted); text-decoration: none; font-size: 14px;
  padding: 6px 11px; border-radius: 6px;
}
.topbar nav a:hover { background: var(--idle-bg); color: var(--ink); }
.topbar nav a.on { color: var(--accent); background: var(--idle-bg); font-weight: 600; }

main.wrap { padding-top: 28px; padding-bottom: 48px; }
.foot { color: var(--muted); font-size: 12.5px; padding-bottom: 32px; border-top: 1px solid var(--line); padding-top: 16px; }

/* ── type ───────────────────────────────────────────────────────────────── */

h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 650; margin: 30px 0 12px; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.mono { font-family: var(--mono); font-size: 13px; }
a { color: var(--accent); }

/* ── tiles ──────────────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
}
.tile .n { font-size: 26px; font-weight: 660; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.tile .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.tile.bad .n { color: var(--bad); }
.tile.warn .n { color: var(--warn); }
.tile.ok .n { color: var(--ok); }

/* ── panels + tables ────────────────────────────────────────────────────── */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
}
.panel + .panel { margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--idle-bg); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
td.key a { font-family: var(--mono); font-size: 13px; text-decoration: none; font-weight: 600; }
td.key a:hover { text-decoration: underline; }
td.desc { color: var(--muted); }
.scroll { overflow-x: auto; }

/* ── pills ──────────────────────────────────────────────────────────────── */

.pill {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; white-space: nowrap; letter-spacing: 0.01em;
}
.pill.current      { color: var(--ok);   background: var(--ok-bg); }
.pill.overdue      { color: var(--bad);  background: var(--bad-bg); }
.pill.never_collected { color: var(--warn); background: var(--warn-bg); }
.pill.not_scheduled { color: var(--idle); background: var(--idle-bg); }
.pill.tsc { color: var(--muted); background: var(--idle-bg); font-family: var(--mono); font-weight: 500; margin-right: 3px; }
.pill.manual { color: var(--warn); background: var(--warn-bg); }

/* ── filters ────────────────────────────────────────────────────────────── */

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters .lab { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 4px; }
.chip {
  font-size: 13px; padding: 5px 11px; border-radius: 7px; text-decoration: none;
  color: var(--muted); border: 1px solid var(--line); background: var(--panel);
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ── detail pages ───────────────────────────────────────────────────────── */

.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; }
/* min-width:0 is load-bearing: grid items default to min-content width, so a long
   unbroken value like an evidence-folder name overflows its cell and lands on top
   of the next field instead of wrapping. */
.meta > div {
  padding: 13px 16px; min-width: 0;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.meta .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 3px; }
.meta .v { font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }

pre.rendered, pre.payload {
  margin: 0; padding: 16px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  background: var(--panel); color: var(--ink);
}
pre.payload { color: var(--muted); border-top: 1px solid var(--line); }

.callout {
  border-left: 3px solid var(--accent); background: var(--panel);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 13px 16px; font-size: 13.5px; color: var(--muted);
  margin-bottom: 18px;
}
.callout b { color: var(--ink); }

.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.hashline { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }

/* ── forms (the manual-evidence workflow is the only write path) ─────────── */

.field { margin-bottom: 16px; max-width: 640px; }
.field label {
  display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600; margin-bottom: 5px;
}
.field input[type="file"], .field textarea, .field input[type="text"], .field input[type="password"] {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px;
}
.field textarea { resize: vertical; font-family: var(--sans); }
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.field ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 18px; }
.field ul label { display: inline; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
.help { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.err { font-size: 12.5px; color: var(--bad); margin-top: 5px; font-weight: 600; }

.btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 9px 18px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
}
.btn:hover { filter: brightness(1.1); }

.who { margin-left: auto; font-size: 13px; color: var(--muted); }
.who a { text-decoration: none; }
.linkbtn {
  font: inherit; font-size: 13px; color: var(--accent);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
}

/* ── finding triage ─────────────────────────────────────────────────────────
   The P-level pills are the one place colour carries meaning rather than
   decoration: IS-11 §6.2 assigns a remediation clock per level, so P0 and P4
   are different obligations and should not look alike. */

.pill.p0 { color: var(--bad);  background: var(--bad-bg); }
.pill.p1 { color: var(--bad);  background: var(--bad-bg); }
.pill.p2 { color: var(--warn); background: var(--warn-bg); }
.pill.p3 { color: var(--warn); background: var(--warn-bg); }
.pill.p4 { color: var(--idle); background: var(--idle-bg); }
.pill.p5 { color: var(--idle); background: var(--idle-bg); }
.pill.jira { color: var(--accent); background: var(--idle-bg); font-family: var(--mono); font-weight: 500; }
.pill.dry  { color: var(--warn); background: var(--warn-bg); }

.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

/* Sticks to the bottom of the viewport so a selection made 200 rows down does
   not require scrolling back up to act on it. */
.bulkbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; margin-top: -1px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 8px 8px;
  font-size: 13.5px; color: var(--muted);
}
.bulkbar .count { font-weight: 700; color: var(--ink); }
.bulkbar .spacer { margin-left: auto; }

td.pick { width: 34px; text-align: center; }
td.pick input, th.pick input { cursor: pointer; }

.trail { list-style: none; margin: 0; padding: 0; }
.trail li { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.trail li:last-child { border-bottom: 0; }
.trail .when { color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.trail .who { margin-left: 0; font-weight: 600; color: var(--ink); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

pre.ticket {
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  background: var(--idle-bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px 14px; margin: 0; max-height: 420px; overflow: auto;
}
