:root {
  --ink: #17202a;
  --muted: #617080;
  --line: #d9e0e6;
  --panel: #ffffff;
  --canvas: #f4f6f8;
  --teal: #067a73;
  --teal-dark: #075e59;
  --blue: #2357a5;
  --amber: #a45f00;
  --amber-bg: #fff5df;
  --red: #aa2635;
  --red-bg: #fff0f1;
  --green: #087449;
  --green-bg: #e9f7f0;
  --shadow: 0 8px 24px rgba(23, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  background: var(--canvas);
}

button, textarea { font: inherit; }

.appbar {
  min-height: 64px;
  padding: 10px clamp(16px, 3vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #fff;
  background: #17202a;
  border-bottom: 4px solid var(--teal);
}

.brand-block, .appbar-status, .command-row, .asset-caption {
  display: flex;
  align-items: center;
}

.brand-block { gap: 11px; }

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #72d2ca;
  border-radius: 4px;
  color: #a9eee8;
  font: 700 13px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.brand-name, .brand-meta { margin: 0; }
.brand-name { font-weight: 700; }
.brand-meta { margin-top: 2px; color: #b7c5d0; font-size: 12px; }
.appbar-status { gap: 8px; font-size: 13px; color: #d6e0e7; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a6b1bb;
}

.status-dot.pass { background: #50d39a; }
.status-dot.fail { background: #ff7a89; }
.status-dot.open { background: #ffc35a; }

main { padding: 0 clamp(16px, 3vw, 36px) 44px; }

.command-band {
  min-height: 102px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 24px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 15px; line-height: 1.3; letter-spacing: 0; }
.command-band p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.command-row { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #aeb9c2;
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 650;
}

button:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
button:focus-visible, textarea:focus-visible { outline: 3px solid rgba(35, 87, 165, 0.25); outline-offset: 2px; }
button.primary { color: #fff; border-color: var(--teal-dark); background: var(--teal); }
button.primary:hover:not(:disabled) { color: #fff; border-color: #044b47; background: var(--teal-dark); }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 0;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 78px;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}
.metric:last-child { border-right: 0; }
.metric-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.metric strong { display: block; overflow-wrap: anywhere; font-size: 18px; }
.decision-metric strong { color: var(--amber); }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
  margin-top: 18px;
}

.editor-pane, .preview-pane, .results-section, .event-log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.editor-pane { min-width: 0; padding: 16px; }
.preview-pane { min-width: 0; overflow: hidden; }

.section-heading {
  min-height: 34px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.section-heading span { color: var(--muted); font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; text-align: right; }

textarea {
  display: block;
  width: 100%;
  height: 444px;
  resize: vertical;
  padding: 14px;
  border: 1px solid #c7d0d8;
  border-radius: 4px;
  color: #dce7ef;
  background: #111820;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  tab-size: 2;
}

.asset-frame {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #edf1f4;
  border-bottom: 1px solid var(--line);
}
.asset-frame img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }
.evidence-purpose {
  min-height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 12px;
  padding: 30px;
  background: linear-gradient(145deg, #edf4ff, #ffffff 58%, #e8eef8);
}
.evidence-purpose .purpose-kicker {
  color: #34537d;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.evidence-purpose strong {
  color: #0c1c32;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.12;
}
.evidence-purpose p, .purpose-note p { color: #40536d; line-height: 1.65; }
.purpose-note a { color: #123f78; font-weight: 750; }
.asset-caption { min-height: 54px; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.asset-caption span { color: var(--blue); font-size: 12px; font-weight: 800; }
.asset-caption strong { font-size: 13px; }
.boundary-block { padding: 16px; }
.boundary-block h2 { margin-bottom: 9px; }
.boundary-block p { margin-bottom: 0; color: #485764; font-size: 13px; line-height: 1.55; }

.results-section, .event-log { margin-top: 18px; padding: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 12px; overflow-wrap: anywhere; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; }
th:nth-child(1) { width: 23%; }
th:nth-child(2) { width: 25%; }
th:nth-child(3) { width: 38%; }
th:nth-child(4) { width: 14%; }
td code { font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.empty-cell { padding: 24px; color: var(--muted); text-align: center; }

.pill {
  display: inline-block;
  min-width: 58px;
  padding: 4px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}
.pill.pass { color: var(--green); background: var(--green-bg); }
.pill.fail { color: var(--red); background: var(--red-bg); }
.pill.open { color: var(--amber); background: var(--amber-bg); }

.gate-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.gate-row { min-height: 112px; padding: 13px; background: #fff; }
.gate-row header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gate-row h3 { margin: 0; font-size: 13px; letter-spacing: 0; }
.gate-row p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.gate-row .gate-authority { color: #45606a; font-size: 10px; font-weight: 700; overflow-wrap: anywhere; text-transform: uppercase; }

pre {
  min-height: 76px;
  max-height: 220px;
  margin: 0;
  overflow: auto;
  padding: 13px;
  color: #dce7ef;
  background: #111820;
  border-radius: 4px;
  white-space: pre-wrap;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

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

@media (max-width: 900px) {
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace-grid { grid-template-columns: 1fr; }
  .gate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .appbar, .command-band { align-items: flex-start; flex-direction: column; }
  .appbar { padding-top: 12px; padding-bottom: 12px; }
  .appbar-status { align-self: flex-start; }
  .command-band { padding: 20px 0; }
  .command-row { width: 100%; justify-content: stretch; }
  .command-row button { flex: 1 1 120px; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .gate-grid { grid-template-columns: 1fr; }
  textarea { height: 390px; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  table { table-layout: auto; }
  tbody { display: grid; gap: 10px; }
  tbody tr { padding: 4px 12px; border: 1px solid var(--line); border-radius: 4px; }
  tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 0.38fr) minmax(0, 0.62fr);
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
  }
  tbody td:last-child { border-bottom: 0; }
  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }
  tbody td code { min-width: 0; overflow-wrap: anywhere; }
  tbody .empty-cell { display: block; padding: 20px 0; }
}
