/*
 * Styles the shared app shell and the views rendered by the UI modules.
 * The visual system presents immutable packet evidence and ledger-derived workpaper state.
 * It contains presentation rules only; application behavior stays in the JavaScript modules.
 */
:root {
  --paper: #f4f3ed;
  --surface: #fffefa;
  --ink: #202b27;
  --graphite: #59645e;
  --faint: #818a84;
  --rule: #d9ddd5;
  --rule2: #e8eae4;
  --verify: #32644e;
  --verify-bg: #e5efe8;
  --flag: #94631e;
  --flag-bg: #f4eedc;
  --block: #a34237;
  --block-bg: #f5e8e4;
  --review: #3b6255;
  --review-bg: #e7eeea;
  --hl: #f2e2a4;
  --sel: #eef1eb;
  --doc-paper: #fffefa;
  --doc-ink: #252c28;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --paper: #171d1a;
  --surface: #202823;
  --ink: #e8ece6;
  --graphite: #b0bab1;
  --faint: #89958b;
  --rule: #354139;
  --rule2: #2b352e;
  --verify: #78aa88;
  --verify-bg: #253b2c;
  --flag: #d8b36d;
  --flag-bg: #40351f;
  --block: #e18a7a;
  --block-bg: #402925;
  --review: #9ab5a6;
  --review-bg: #293832;
  --hl: #62552d;
  --sel: #2a352e;
  --doc-paper: #242d27;
  --doc-ink: #e4e8e1;
  color-scheme: dark;
}
:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
  height: 100%;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}
body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  font-feature-settings: 'tnum' 1;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: var(--review);
}
:focus-visible {
  outline: 2px solid var(--review);
  outline-offset: 2px;
}
.app {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  height: 100%;
}
header.top {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 22px;
  background: var(--surface);
  border-top: 3px solid var(--verify);
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.brand {
  font-weight: 680;
  letter-spacing: -0.025em;
  font-size: 15px;
}
.brand small {
  display: block;
  font-weight: 400;
  color: var(--graphite);
  font-size: 11px;
  letter-spacing: 0.01em;
}
.top .spacer {
  flex: 1;
}
.ctl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--graphite);
}
.ctl select {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12.5px;
  color: var(--ink);
  max-width: 260px;
}
.gate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
}
.gate.blocked {
  background: var(--block-bg);
  color: var(--block);
}
.gate.ready {
  background: var(--verify-bg);
  color: var(--verify);
}
.gate.frozen {
  background: var(--review-bg);
  color: var(--review);
}
nav.rail {
  overflow: auto;
  border-right: 1px solid var(--rule);
  background: #f0f0e9;
  padding: 16px 12px 40px;
}
nav.rail .grp {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 15px 10px 5px;
}
nav.rail a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-left: 2px solid transparent;
  border-radius: 4px;
  color: var(--graphite);
  text-decoration: none;
  font-size: 12.5px;
  transition:
    background-color 0.12s,
    color 0.12s;
}
nav.rail a:hover {
  background: #e6eae2;
  color: var(--ink);
}
nav.rail a.on {
  background: #dde8df;
  border-left-color: var(--verify);
  color: #254a39;
  font-weight: 650;
}
nav.rail a .ct {
  font-size: 11.5px;
  min-width: 20px;
  text-align: center;
  border-radius: 9px;
  padding: 0 6px;
  background: var(--rule2);
  color: var(--graphite);
}
nav.rail a.on .ct {
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
}
nav.rail a .ct.r {
  background: var(--block-bg);
  color: var(--block);
}
main {
  overflow: auto;
  padding: 30px clamp(20px, 3vw, 46px) 80px;
  min-width: 0;
  width: 100%;
  max-width: 1650px;
  margin-inline: auto;
}
h1 {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
  font-weight: 600;
}
h2 {
  font-size: 16px;
  margin: 28px 0 9px;
  letter-spacing: -0.01em;
  font-weight: 680;
}
h3 {
  font-size: 14px;
  margin: 18px 0 6px;
  font-weight: 680;
}
.lede {
  color: var(--graphite);
  max-width: 74ch;
  margin: 0 0 20px;
  font-size: 13.5px;
  line-height: 1.65;
}
.muted {
  color: var(--graphite);
}
.faint {
  color: var(--faint);
}
.small {
  font-size: 12.5px;
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 18px;
  margin: 12px 0;
  box-shadow: 0 1px 2px rgba(32, 43, 39, 0.035);
}
.panel.tight {
  padding: 8px 10px;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.tbl-wrap {
  overflow-x: auto;
  max-width: 100%;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th {
  font-weight: 650;
  text-align: left;
  color: var(--graphite);
  font-size: 11px;
  letter-spacing: 0.035em;
  border-bottom: 1px solid var(--rule);
  padding: 8px 9px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface);
}
td {
  border-bottom: 1px solid var(--rule2);
  padding: 8px 9px;
  vertical-align: top;
}
td.n,
th.n {
  text-align: right;
  white-space: nowrap;
}
tr.click {
  cursor: pointer;
}
tr.click:hover td {
  background: var(--sel);
}
tr.sub td {
  color: var(--graphite);
}
tr.tot td {
  font-weight: 700;
  border-top: 1px solid var(--ink);
}
.num {
  cursor: pointer;
  border-bottom: 1px dotted var(--faint);
  white-space: nowrap;
}
.num:hover {
  background: var(--hl);
  color: var(--ink);
}
.chg {
  color: var(--flag);
  font-weight: 600;
}
.btn {
  border: 1px solid #cdd3cb;
  background: var(--surface);
  border-radius: 5px;
  padding: 6px 11px;
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  transition:
    background-color 0.12s,
    border-color 0.12s,
    transform 0.12s;
}
.btn:hover {
  border-color: var(--verify);
  background: var(--verify-bg);
}
.btn.pri {
  background: var(--verify);
  color: #fff;
  border-color: var(--verify);
}
.btn.pri:hover {
  background: #284f3d;
}
.btn.ok {
  background: var(--verify);
  color: #fff;
  border-color: var(--verify);
}
.btn.bad {
  color: var(--block);
  border-color: var(--block);
}
.btn.sm {
  padding: 2px 8px;
  font-size: 12px;
}
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  border-radius: 999px;
  padding: 1px 8px;
  background: var(--rule2);
  color: var(--graphite);
  white-space: nowrap;
  font-weight: 600;
}
.pill.red {
  background: var(--block-bg);
  color: var(--block);
}
.pill.amb {
  background: var(--flag-bg);
  color: var(--flag);
}
.pill.grn {
  background: var(--verify-bg);
  color: var(--verify);
}
.pill.ind {
  background: var(--review-bg);
  color: var(--review);
}
/* tick marks: the visual language of proof */
.tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  vertical-align: -3px;
  margin-left: 4px;
  cursor: help;
  border: 1.5px solid currentColor;
}
.tick.src {
  color: var(--verify);
}
.tick.calc {
  color: var(--review);
}
.tick.cli {
  color: #8a4fb0;
}
.tick.py {
  color: #2b7a8c;
}
.tick.tp {
  color: #6b6b1e;
}
.tick.none {
  color: var(--faint);
  border-style: dashed;
}
.tick.fail {
  color: var(--block);
  background: var(--block-bg);
}
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--graphite);
}
.finding {
  border-left: 3px solid var(--rule);
  background: var(--surface);
  border-radius: 0 5px 5px 0;
  padding: 14px 16px;
  margin: 10px 0;
  border-top: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.finding.error {
  border-left-color: var(--block);
}
.finding.judgment {
  border-left-color: var(--flag);
}
.finding.info {
  border-left-color: var(--review);
}
.finding.pass {
  border-left-color: var(--verify);
}
.finding h4 {
  margin: 0 0 4px;
  font-size: 14.5px;
}
.finding .vs {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  font-size: 13px;
  margin: 8px 0;
}
.finding .vs b {
  font-weight: 600;
  color: var(--graphite);
}
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 14px;
  font-size: 13px;
}
.kv b {
  color: var(--graphite);
  font-weight: 500;
}
/* trace drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(760px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--rule);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12);
  transform: translateX(102%);
  transition: transform 0.18s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.drawer.open {
  transform: none;
}
.drawer .dh {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.drawer .db {
  overflow: auto;
  padding: 14px 18px 60px;
}
.tree {
  list-style: none;
  margin: 0;
  padding-left: 16px;
  border-left: 1px solid var(--rule);
}
.tree li {
  margin: 3px 0;
}
.tree .node {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.tree .node .k {
  font-size: 12px;
  color: var(--faint);
  min-width: 96px;
}
.srcchip {
  display: inline-block;
  font-size: 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1px 6px;
  margin: 2px 4px 2px 0;
  cursor: pointer;
  background: var(--paper);
}
.srcchip:hover {
  border-color: var(--verify);
}
/* simulated source document */
.docview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.page {
  position: relative;
  background: var(--doc-paper);
  color: var(--doc-ink);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 var(--rule);
  padding: 28px 30px 34px;
  font: 14.5px/1.65 var(--serif);
  min-height: 220px;
  max-width: 70ch;
}
.page .ph {
  display: flex;
  justify-content: space-between;
  font: 12px var(--sans);
  color: var(--faint);
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rule2);
  padding-bottom: 6px;
}
.page mark {
  background: var(--hl);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  outline: 2px solid var(--flag);
}
.page .bbox {
  position: absolute;
  border: 2px dashed var(--flag);
  border-radius: 3px;
  pointer-events: none;
  opacity: 0.55;
}
.pages-thumbs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pages-thumbs button {
  min-width: 30px;
}
.evlist td {
  font-size: 12.5px;
}
.conf {
  font-size: 11.5px;
}
.conf.low {
  color: var(--block);
  font-weight: 700;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 9px 14px;
  border-radius: 8px;
  z-index: 40;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.toast button {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: inherit;
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
}
.sumgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.sumgrid > div {
  background: var(--surface);
  padding: 10px 12px;
}
.sumgrid .l {
  font-size: 12px;
  color: var(--graphite);
}
.sumgrid .v {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.sumgrid .d {
  font-size: 12px;
}
.bar {
  height: 8px;
  background: var(--rule2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--verify);
}
.bar i.over {
  background: var(--block);
}
.steps li {
  margin: 4px 0;
}
.ok {
  color: var(--verify);
}
.bad {
  color: var(--block);
}
.amb {
  color: var(--flag);
}
textarea,
input[type='text'],
input[type='number'] {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 7px 9px;
  width: 100%;
}
.form-row {
  display: flex;
  gap: 8px;
  margin: 6px 0;
  flex-wrap: wrap;
  align-items: center;
}
.form-row > * {
  flex: 1;
}
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 20, 0.4);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  max-width: 620px;
  width: 100%;
  padding: 18px 20px;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 16px 50px rgba(20, 32, 26, 0.18);
}
.who {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.av {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.presence {
  display: flex;
  gap: -4px;
}
.tl {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--rule);
  margin-left: 6px;
}
.tl li {
  padding: 4px 0 8px 14px;
  position: relative;
}
.tl li:before {
  content: '';
  position: absolute;
  left: -6px;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--graphite);
}
.tl li.now:before {
  background: var(--review);
  border-color: var(--review);
}
.tl li.future {
  opacity: 0.5;
}
.mask {
  letter-spacing: 0.05em;
}
.reveal {
  font-size: 11px;
  margin-left: 4px;
}
.searchbox {
  width: 240px;
}
.chipset {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chipset button {
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 12.5px;
}
.chipset button.on {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.diffpos {
  color: var(--block);
}
.diffneg {
  color: var(--verify);
}
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  nav.rail {
    display: none;
  }
  nav.rail.show {
    display: block;
    position: fixed;
    inset: 0;
    top: 52px;
    z-index: 25;
    box-shadow: 8px 12px 24px rgba(32, 43, 39, 0.12);
  }
  main {
    padding: 24px 18px 72px;
  }
  .menu-btn {
    display: inline-flex !important;
  }
  header.top {
    padding: 8px 14px;
    gap: 8px 10px;
  }
  header.top .brand small,
  .top .spacer {
    display: none;
  }
  header.top input.searchbox {
    width: auto;
    flex: 1 1 190px;
    max-width: none;
  }
  header.top .ctl {
    flex: 1 1 210px;
  }
  header.top .ctl select {
    min-width: 0;
    max-width: none;
  }
  .gate {
    flex: 1 1 auto;
    justify-content: center;
  }
}
@media (max-width: 520px) {
  h1 {
    font-size: 28px;
  }
  main {
    padding: 20px 14px 64px;
  }
  header.top .brand {
    font-size: 13px;
  }
  header.top .ctl {
    flex-basis: 100%;
    justify-content: space-between;
  }
  header.top .ctl select {
    flex: 1;
  }
  .panel {
    padding: 12px;
  }
}
.menu-btn {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  .drawer {
    transition: none;
  }
}
@media print {
  header.top,
  nav.rail,
  .noprint {
    display: none !important;
  }
  .app {
    display: block;
  }
  main {
    overflow: visible;
  }
}
header.top input.searchbox {
  width: 230px;
  flex: 0 1 230px;
}
.toast[hidden] {
  display: none;
}
.finding > .row > div:first-child {
  flex: 1;
  min-width: 240px;
}
.pagewrap {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.pagemap {
  position: relative;
  flex: 0 0 64px;
  height: 84px;
  border: 1px solid var(--rule);
  background: var(--doc-paper);
  border-radius: 2px;
  margin-top: 4px;
}
.pagemap .bbox {
  position: absolute;
  background: var(--hl);
  border: 1.5px solid var(--flag);
  border-radius: 1px;
  opacity: 1;
}
