:root {
  --ink: #233936;
  --muted: #667773;
  --paper: #f5f3ec;
  --white: #fffdf8;
  --line: #d9dfd6;
  --teal: #176b60;
  --teal-soft: #e5f0eb;
  --gold: #9a6a2f;
  --gold-soft: #f5ead8;
  --red: #9a443c;
  --red-soft: #f7e8e5;
  --blue: #365f7b;
  --blue-soft: #e7eff4;
  --slate: #53615e;
  --slate-soft: #edf0ee;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 Arial, sans-serif; }
a { color: var(--teal); }
button, select { font: inherit; }
button, a { touch-action: manipulation; }
[hidden] { display: none !important; }

.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 36px; background: var(--white); border-bottom: 1px solid var(--line); }
.wordmark { font: bold 25px Georgia, serif; letter-spacing: 2px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.wordmark span { margin-left: 18px; color: var(--muted); font: 12px Arial, sans-serif; letter-spacing: 1px; text-transform: uppercase; }
.workspace-links { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.workspace-links a, .view-tabs a { padding: 8px 11px; border: 1px solid transparent; border-radius: 6px; color: var(--teal); text-decoration: none; }
.workspace-links a:hover, .workspace-links a:focus-visible, .workspace-links a[aria-current="page"], .view-tabs a:hover, .view-tabs a:focus-visible, .view-tabs a[aria-current="page"] { border-color: #9db6a9; background: var(--teal-soft); }

.standards-shell { max-width: 1380px; margin: auto; padding: 46px 30px 70px; }
.breadcrumbs { min-height: 22px; margin-bottom: 24px; color: var(--muted); font-size: 12px; }
.breadcrumbs span { margin-left: 5px; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 32px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 11px; font-weight: bold; letter-spacing: 1.5px; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, serif; font-weight: normal; }
h1 { margin: 5px 0 10px; font-size: 46px; line-height: 1.08; }
h2 { margin: 3px 0 0; font-size: 28px; }
h3 { margin: 0; font-size: 20px; }
.lede, .section-note { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.65; }
.brand-control, .toolbar label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: bold; }
select { min-width: 190px; padding: 9px 10px; border: 1px solid #aebdb5; border-radius: 6px; background: white; color: var(--ink); }
.view-tabs { display: flex; gap: 8px; margin: 28px 0 18px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.truth-note { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.truth-note p { margin: 0; padding: 14px 16px; border-left: 3px solid var(--gold); background: var(--gold-soft); color: #57472f; }

.health-strip, .status, .toolbar, #standards-view, #comparison-view { background: var(--white); border: 1px solid var(--line); border-radius: 12px; }
.health-strip { display: grid; grid-template-columns: minmax(170px, .35fr) minmax(260px, 1fr) auto; align-items: center; gap: 20px; margin-top: 18px; padding: 15px 18px; }
.health-strip p { margin: 0; color: var(--muted); }
.health-label { display: block; color: var(--muted); font-size: 11px; font-weight: bold; text-transform: uppercase; }
.health-strip strong { display: block; margin-top: 2px; }
.health-strip.stale, .health-strip.delayed { border-left: 4px solid var(--gold); }
.health-strip.unavailable { border-left: 4px solid var(--red); }
.health-strip.healthy { border-left: 4px solid var(--teal); }
.status { margin-top: 18px; padding: 24px; }
.status.error, .status.denied { border-color: #d5aaa5; background: var(--red-soft); color: var(--red); }

#standards-view, #comparison-view { margin-top: 18px; padding: 26px; }
.toolbar { display: flex; align-items: end; gap: 14px; margin: -6px -6px 24px; padding: 15px; background: #f8f7f2; }
.toolbar-note { margin: 0 0 9px auto; color: var(--muted); font-size: 12px; }
button { padding: 10px 14px; border: 1px solid var(--teal); border-radius: 6px; background: var(--teal); color: white; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
.quiet-button, .close-button { border-color: #9db6a9; background: transparent; color: var(--teal); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.count { margin: 0; color: var(--muted); font-size: 12px; }
.section-note { margin-top: 8px; }

.standards-list { display: grid; gap: 12px; margin-top: 22px; }
.standard-card { display: grid; grid-template-columns: minmax(250px, 1.2fr) minmax(180px, .7fr) minmax(240px, 1fr) auto; align-items: start; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.standard-card p { margin: 6px 0 0; color: var(--muted); }
.standard-code { color: var(--teal); font-size: 12px; font-weight: bold; letter-spacing: .7px; }
.standard-meta { display: grid; gap: 8px; }
.meta-line { color: var(--muted); font-size: 12px; }
.meta-line strong { color: var(--ink); }
.detail-button { align-self: center; white-space: nowrap; }

.status-pill { display: inline-block; max-width: 100%; padding: 5px 9px; border-radius: 99px; font-size: 11px; font-weight: bold; }
.status-passed { background: var(--teal-soft); color: #15584e; }
.status-missing, .status-failed { background: var(--red-soft); color: #873a34; }
.status-needs_review { background: var(--gold-soft); color: #795017; }
.status-not_applicable { background: var(--slate-soft); color: var(--slate); }
.status-approved_exception { background: var(--blue-soft); color: var(--blue); }
.status-unknown { background: var(--slate-soft); color: var(--slate); }

.matrix-wrap { margin-top: 20px; overflow-x: auto; }
.matrix { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; text-align: left; }
.matrix th, .matrix td { min-width: 170px; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; }
.matrix th { background: var(--slate-soft); color: var(--muted); font-size: 11px; }
.matrix tr:first-child th { border-top: 1px solid var(--line); }
.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; z-index: 1; min-width: 205px; border-left: 1px solid var(--line); background: var(--white); }
.matrix thead th:first-child { z-index: 2; background: var(--slate-soft); }
.matrix-cell { width: 100%; min-height: 72px; padding: 9px; border: 1px solid transparent; background: transparent; color: var(--ink); text-align: left; }
.matrix-cell:hover, .matrix-cell:focus-visible { border-color: #9db6a9; background: #f8faf8; }
.matrix-cell span { display: block; }
.cell-meta { margin-top: 7px; color: var(--muted); font-size: 11px; }
.empty-state { margin-top: 20px; padding: 30px; border: 1px dashed #b8c4bd; border-radius: 9px; color: var(--muted); text-align: center; }

dialog { width: min(680px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 12px; color: var(--ink); box-shadow: 0 18px 70px #17272455; }
dialog::backdrop { background: #17272488; }
.dialog-card { padding: 26px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.detail-body { margin-top: 20px; }
.detail-row { display: grid; grid-template-columns: minmax(115px, .3fr) minmax(0, 1fr); gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.detail-row dt { color: var(--muted); font-size: 11px; font-weight: bold; text-transform: uppercase; }
.detail-row dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .standard-card { grid-template-columns: 1fr 1fr; }
  .detail-button { justify-self: start; }
}

@media (max-width: 680px) {
  .topbar { display: block; min-height: 65px; padding: 10px 18px; }
  .wordmark span { display: none; }
  .workspace-links { justify-content: flex-start; margin-top: 8px; }
  .workspace-links a { padding: 6px 8px; }
  .standards-shell { padding: 30px 16px 50px; }
  .hero { display: block; }
  h1 { font-size: 35px; }
  .brand-control { margin-top: 18px; }
  .brand-control select { width: 100%; }
  .truth-note { grid-template-columns: 1fr; }
  .health-strip { grid-template-columns: 1fr; gap: 10px; }
  #standards-view, #comparison-view { padding: 20px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar select { width: 100%; }
  .toolbar-note { margin: 0; }
  .section-heading { display: block; }
  .count { margin-top: 6px; }
  .standard-card { grid-template-columns: 1fr; }
  .detail-row { grid-template-columns: 1fr; gap: 3px; }
}
