/* ============================================================================
   Vervet — the ledger.

   A compliance record, not a dashboard. Warm paper, ink type, hairline rules.
   Dense by design: an MLRO scans this, prints it, and files it in a board pack.
   Saturated colour is reserved exclusively for severity — nothing else earns it.
   ========================================================================== */

:root {
  /* Paper & ink */
  --paper:        #faf7f2;
  --paper-raised: #fffdfa;
  --paper-sunk:   #f2ede4;
  --ink:          #17150f;
  --ink-muted:    #5c574c;
  --ink-faint:    #8b8478;

  /* Hairlines — the only structure. No cards, no shadows. */
  --rule:         #e3dcd0;
  --rule-strong:  #cfc5b4;

  /* Brand: vervet grey-green. Used sparingly — nav marker, focus, links. */
  --sage:         #3f5346;
  --sage-mid:     #6e8a72;
  --sage-wash:    #eef1ea;

  /* Severity — the compliance judgment made visible */
  --critical:      #a32a17;
  --critical-wash: #f7e9e5;
  --high:          #a76a11;
  --high-wash:     #f9f0e2;
  --medium:        #47657a;
  --medium-wash:   #eaf0f4;
  --info:          #8b8478;
  --info-wash:     #f1ede6;

  --rail: 208px;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans:  "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --mono:  "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
}

/* Faint paper grain — texture without noise */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--sage); text-decoration: none; border-bottom: 1px solid var(--rule-strong); }
a:hover { border-bottom-color: var(--sage); }

/* ── Rail ─────────────────────────────────────────────────────────────── */

.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  border-right: 1px solid var(--rule);
  padding: 26px 0 20px;
  display: flex; flex-direction: column;
  background: var(--paper);
  z-index: 2;
}

.mark {
  font-family: var(--serif);
  font-size: 25px; font-weight: 500; letter-spacing: -.015em;
  padding: 0 22px 2px;
}
.mark .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--sage); margin-right: 8px; vertical-align: 4px;
}
.mark-sub {
  padding: 0 22px 24px;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
}

.nav a {
  display: block; padding: 7px 22px; border: 0;
  color: var(--ink-muted); font-size: 13.5px;
  border-left: 2px solid transparent;
}
.nav a:hover { color: var(--ink); background: var(--paper-sunk); }
.nav a.on {
  color: var(--ink); border-left-color: var(--sage);
  background: var(--sage-wash); font-weight: 500;
}
.nav .group {
  padding: 20px 22px 5px; font-size: 10px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-faint);
}

.rail-foot {
  margin-top: auto; padding: 16px 22px 0; border-top: 1px solid var(--rule);
  font-size: 11.5px; color: var(--ink-faint);
}
.rail-foot form { margin: 6px 0 0; }
.rail-foot button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--ink-muted); border-bottom: 1px solid var(--rule-strong);
}
.rail-foot button:hover { color: var(--critical); }

/* ── Main ─────────────────────────────────────────────────────────────── */

main { margin-left: var(--rail); padding: 34px 42px 90px; max-width: 1180px; position: relative; z-index: 1; }

.head { margin-bottom: 26px; }
.eyebrow {
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 5px;
}
h1 {
  font-family: var(--serif); font-weight: 500; font-size: 33px;
  letter-spacing: -.02em; margin: 0 0 4px; line-height: 1.15;
}
.lede { color: var(--ink-muted); max-width: 62ch; margin: 0; }

h2 {
  font-family: var(--serif); font-weight: 500; font-size: 19px;
  letter-spacing: -.01em; margin: 34px 0 12px;
}
h2:first-of-type { margin-top: 0; }

/* ── The watch record ─────────────────────────────────────────────────────
   The centrepiece. Every competitor shows only events; a compliance record
   must also show the nights nothing happened. Quiet nights are hairlines;
   changes break the rhythm; a missed run leaves a visible gap. */

.watch {
  border: 1px solid var(--rule); background: var(--paper-raised);
  padding: 18px 20px 14px; margin-bottom: 28px;
}
.watch-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 16px; gap: 16px; flex-wrap: wrap;
}
.watch-title { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); }
.watch-legend { font-size: 11.5px; color: var(--ink-faint); display: flex; gap: 15px; }
.watch-legend i { font-style: normal; display: inline-flex; align-items: center; gap: 5px; }
.watch-legend b { display: inline-block; width: 3px; height: 13px; }

/* Marks sit on a baseline so the strip reads as a record, not an empty box. */
.strip {
  display: flex; align-items: flex-end; gap: 3px; height: 48px;
  border-bottom: 1px solid var(--rule-strong); padding-bottom: 0;
}
.night {
  flex: 1 1 0; min-width: 3px; position: relative; cursor: default;
  display: flex; align-items: flex-end; justify-content: center; height: 100%;
}
.night span {
  display: block; width: 3px; border-radius: .5px;
  background: var(--rule-strong); height: 14px;
  transition: height .16s ease, background .16s ease;
}
.night.quiet span   { height: 14px; background: var(--sage-mid); }
.night.info span    { height: 21px; background: var(--info); }
.night.medium span  { height: 28px; background: var(--medium); }
.night.high span    { height: 36px; background: var(--high); }
.night.critical span{ height: 46px; background: var(--critical); }

/* Before we started watching — a fact about the world, drawn as absence. */
.night.pre span { height: 3px; width: 3px; background: var(--rule); }
/* Not yet arrived. Distinct from a gap: we have not missed a night that is
   still to come, so it must not borrow the gap's accusing mark. */
.night.future span { height: 3px; width: 3px; background: transparent;
  border-bottom: 1px dotted var(--rule-strong); }
/* A night we owed and missed — our failure, and it must be conspicuous. */
.night.gap span {
  height: 14px; width: 3px; background: repeating-linear-gradient(
    to bottom, var(--critical) 0 2px, transparent 2px 4px);
}
.night:hover span { background: var(--ink); }

.night::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-family: var(--mono);
  font-size: 10.5px; line-height: 1.45; letter-spacing: -.01em;
  padding: 5px 8px; border-radius: 2px; white-space: pre; z-index: 5;
  opacity: 0; pointer-events: none; transition: opacity .13s ease;
}
.night:hover::after { opacity: 1; }

/* ── Figures ──────────────────────────────────────────────────────────── */

.figures { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--rule); background: var(--paper-raised); margin-bottom: 30px; }
.fig { padding: 15px 18px; border-right: 1px solid var(--rule); }
.fig:last-child { border-right: 0; }
.fig .n { font-family: var(--serif); font-size: 30px; line-height: 1; letter-spacing: -.02em; }
.fig .n.zero { color: var(--ink-faint); }
.fig .k { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint); margin-top: 6px; }
.fig .sub { font-size: 11.5px; color: var(--ink-muted); margin-top: 3px; font-family: var(--mono); }

/* ── Tables — the ledger proper ───────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 500; font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 0 12px 7px 0; border-bottom: 1px solid var(--rule-strong); white-space: nowrap;
}
tbody td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:hover { background: var(--paper-raised); }
tbody tr:last-child td { border-bottom: 1px solid var(--rule-strong); }
td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.tight { width: 1%; white-space: nowrap; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.mono  { font-family: var(--mono); font-size: 12px; }

/* Staggered reveal — one calm page-load gesture, not scattered fidgets */
tbody tr { animation: rise .34s cubic-bezier(.2,.7,.3,1) backwards; }
tbody tr:nth-child(1){animation-delay:.02s} tbody tr:nth-child(2){animation-delay:.04s}
tbody tr:nth-child(3){animation-delay:.06s} tbody tr:nth-child(4){animation-delay:.08s}
tbody tr:nth-child(5){animation-delay:.10s} tbody tr:nth-child(6){animation-delay:.12s}
tbody tr:nth-child(7){animation-delay:.14s} tbody tr:nth-child(8){animation-delay:.16s}
tbody tr:nth-child(n+9){animation-delay:.18s}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { tbody tr { animation: none; } }

/* ── Severity ─────────────────────────────────────────────────────────── */

.sev {
  display: inline-block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 7px; border: 1px solid; white-space: nowrap; font-weight: 500;
}
.sev-critical { color: var(--critical); border-color: var(--critical); background: var(--critical-wash); }
.sev-high     { color: var(--high);     border-color: var(--high);     background: var(--high-wash); }
.sev-medium   { color: var(--medium);   border-color: var(--medium);   background: var(--medium-wash); }
.sev-info     { color: var(--info);     border-color: var(--rule-strong); background: var(--info-wash); }
.sev-none     { color: var(--ink-faint);border-color: var(--rule-strong); background: transparent; }

/* ── Empty states — silence, stated plainly ───────────────────────────── */

.quiet-state {
  border: 1px solid var(--rule); border-left: 2px solid var(--sage-mid);
  background: var(--paper-raised); padding: 20px 22px; margin: 4px 0 8px;
}
.quiet-state h3 { font-family: var(--serif); font-weight: 500; font-size: 17px; margin: 0 0 5px; }
.quiet-state p { margin: 0; color: var(--ink-muted); max-width: 64ch; }

/* ── Filters ──────────────────────────────────────────────────────────── */

.filters { display: flex; gap: 7px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 11.5px; padding: 3px 10px; border: 1px solid var(--rule-strong);
  color: var(--ink-muted); background: var(--paper-raised);
}
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ── Forms ────────────────────────────────────────────────────────────── */

label { display: block; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 5px; }
input[type=text], input[type=password], textarea, select {
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: var(--paper-raised); border: 1px solid var(--rule-strong);
  padding: 8px 10px; width: 100%; border-radius: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--sage-mid); outline-offset: -1px; border-color: var(--sage-mid); }
textarea { min-height: 116px; resize: vertical; line-height: 1.6; }

button.act, .act {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink);
  padding: 8px 18px; cursor: pointer; border-radius: 0;
}
button.act:hover { background: var(--sage); border-color: var(--sage); }
button.ghost {
  background: none; color: var(--ink-muted); border: 1px solid var(--rule-strong);
  font-size: 12px; padding: 4px 10px; cursor: pointer; font-family: var(--sans);
}
button.ghost:hover { color: var(--critical); border-color: var(--critical); }

.note { font-size: 12px; color: var(--ink-muted); margin-top: 7px; }

.flash { border: 1px solid; padding: 11px 15px; margin-bottom: 20px; font-size: 13px; }
.flash.ok  { border-color: var(--sage-mid); background: var(--sage-wash); color: var(--sage); }
.flash.bad { border-color: var(--critical); background: var(--critical-wash); color: var(--critical); }
/* "We could not check" is not "the firm is not there". A retryable failure of
   ours must never wear the same colour as a verdict about a firm. */
.flash.retry { border-color: var(--high); background: var(--high-wash); color: var(--high); }

/* ── Detail blocks ────────────────────────────────────────────────────── */

.panel { border: 1px solid var(--rule); background: var(--paper-raised); padding: 16px 18px; margin-bottom: 16px; }
.panel h3 { font-family: var(--serif); font-weight: 500; font-size: 16px; margin: 0 0 3px; }
.stamp { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); }

details.svc { border-bottom: 1px solid var(--rule); }
details.svc summary {
  cursor: pointer; padding: 9px 0; list-style: none;
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
}
details.svc summary::-webkit-details-marker { display: none; }
details.svc summary:hover { color: var(--sage); }
details.svc .svc-name { font-weight: 500; }
details.svc pre {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  background: var(--paper-sunk); border: 1px solid var(--rule);
  padding: 12px; overflow-x: auto; margin: 2px 0 14px; max-height: 380px;
}

.kv { display: grid; grid-template-columns: 152px 1fr; gap: 5px 16px; font-size: 13px; }
.kv dt { color: var(--ink-faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding-top: 3px; }
.kv dd { margin: 0; }

.diff-old { color: var(--critical); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff-new { color: var(--sage); }

/* ── Login ────────────────────────────────────────────────────────────── */

.gate { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; position: relative; z-index: 1; }
.gate-inner { width: 100%; max-width: 392px; }
.gate .mark { padding: 0 0 2px; font-size: 34px; }
.gate .mark-sub { padding: 0 0 26px; }
.gate form { border: 1px solid var(--rule); background: var(--paper-raised); padding: 22px; }
.gate .act { width: 100%; margin-top: 14px; }
.gate-note { font-size: 12px; color: var(--ink-faint); margin-top: 18px; line-height: 1.6; }

/* ── Print: this ends up in a board pack ──────────────────────────────── */

/* ── The compliance record (print-native report) ──────────────────────── */

.report-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 26px; padding-bottom: 14px; border-bottom: 1px solid var(--rule);
}
.report-actions .periods { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.report-actions .periods a { color: var(--ink-muted); border-bottom-color: transparent; font-family: var(--mono); }
.report-actions .periods a.on { color: var(--sage); border-bottom-color: var(--sage); }
.report-actions button {
  font: 500 12px/1 var(--sans); color: var(--sage); background: none;
  border: 1px solid var(--rule-strong); border-radius: 3px; padding: 8px 14px; cursor: pointer;
}
.report-actions button:hover { border-color: var(--sage); }

.report-meta { font-size: 12px; color: var(--ink-faint); max-width: 62ch; margin-top: 10px; }

.signoff { margin-top: 44px; padding-top: 6px; border-top: 2px solid var(--rule-strong); }
.signoff p { font-size: 12.5px; color: var(--ink-muted); max-width: 72ch; }
.signoff p.mono { font-size: 11px; }

@media print {
  @page { size: A4; margin: 16mm 14mm; }
  body::before, .rail, .report-actions { display: none; }
  body { background: #fff; font-size: 12px; }
  main { margin: 0; padding: 0; max-width: none; }
  tbody tr { animation: none; }
  .watch, .figures, .panel { break-inside: avoid; }
  h2 { break-after: avoid; }
  tr, .quiet-state, .signoff { break-inside: avoid; }
  a { color: var(--ink); border: 0; }
  .night[data-tip]:hover::after { display: none; }
  .sev, .night span, .strip .night, .watch-legend b {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

@media (max-width: 860px) {
  :root { --rail: 0px; }
  .rail { position: static; width: auto; inset: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .nav { display: flex; flex-wrap: wrap; }
  .nav .group { display: none; }
  .rail-foot { margin-top: 12px; }
  main { padding: 22px 18px 60px; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .fig:nth-child(2) { border-right: 0; }
  .fig:nth-child(1), .fig:nth-child(2) { border-bottom: 1px solid var(--rule); }
}
