:root {
  color-scheme: light;
  --ink: #242424;
  --muted: #555751;
  --canvas: #f3f3f0;
  --surface: #fff;
  --line: #cdcec6;
  --rule: #e2e3dc;
  --strip: #f1f1ed;
  --yellow: #ffdd65;
  --selection: #fff3c6;
  --link: #235486;
  --row-height: 32px;
  font: 14px/1.4 "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: progress; opacity: .75; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid #336798;
  outline-offset: 1px;
}
h1, h2, h3, h4, p, dl, dd { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.22; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 650; }
h3 { font-size: 1rem; }
svg { flex: 0 0 auto; vertical-align: middle; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 10px;
  height: 43px;
  background: #f7e493;
  border-bottom: 1px solid #d1bc66;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 27px;
  padding: 0;
  color: #50514b;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 2px;
}
.icon-button:hover { background: #e9eae3; border-color: var(--line); }
.top-menu:hover { background: #efdb84; border-color: #d1bc66; }
.brand { display: flex; align-items: center; gap: 12px; line-height: 1.15; }
.brand-mark { color: #912b20; font-size: 1.48rem; font-weight: 800; letter-spacing: -.09em; }
.brand strong { font-weight: 650; }
.environment { margin-left: auto; color: #585037; font-size: .86rem; }
.current-role { border-left: 1px solid #caba79; padding-left: 10px; font-weight: 600; }

.app-shell { display: grid; grid-template-columns: 174px minmax(0, 1fr); min-height: calc(100vh - 43px); }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: calc(100vh - 43px);
  padding: 10px 0 8px;
  background: #f7f7f3;
  border-right: 1px solid var(--line);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 35px;
  padding: 4px 10px 4px 12px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
}
.nav-link svg { color: var(--muted); width: 16px; height: 16px; }
.nav-link:hover { background: #edede7; }
.nav-link.active { background: #f6e8a9; border-left-color: #a68122; font-weight: 650; }
.nav-link:focus-visible { outline-offset: -2px; }
.sidebar-bottom { padding-top: 5px; border-top: 1px solid var(--rule); }
.nav-overlay { display: none; }
@media (min-width: 901px) {
  .app-shell:has(.sidebar.open) { grid-template-columns: minmax(0, 1fr); }
  .sidebar.open { display: none; }
}
.workspace { min-width: 0; }
.workpath {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 3px 16px;
  background: var(--strip);
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: .86rem;
}
.page-head { padding: 13px 16px 10px; background: var(--surface); }
.page-head.subpage { border-bottom: 1px solid var(--line); }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; }
.command-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 10px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 31px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  font-weight: 600;
  line-height: 1.25;
}
.button.primary { background: var(--yellow); border-color: #bf9d30; }
.button.primary:not(:disabled):hover { background: #f6ce4c; }
.button.secondary { background: #f6f6f3; border-color: #bfc1b9; }
.button.quiet { color: var(--link); }
.button.secondary:hover, .button.quiet:hover { background: #eceee8; }
.tabs { display: flex; align-items: end; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tab {
  position: relative;
  bottom: -1px;
  min-height: 32px;
  padding: 4px 12px;
  color: #484a43;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  background: transparent;
  white-space: nowrap;
}
.tab:hover { background: #f4f4f0; }
.tab.active { background: var(--canvas); border-color: var(--line); border-bottom-color: var(--canvas); color: var(--ink); font-weight: 650; }
.tab:focus-visible { outline-offset: -3px; }

.content { padding: 12px 16px 30px; }
.overview-grid, .review-grid { display: grid; align-items: start; gap: 12px; }
.overview-grid { grid-template-columns: minmax(0, 3fr) minmax(215px, 1fr); max-width: 1200px; }
.review-grid { grid-template-columns: minmax(0, 1.7fr) minmax(330px, 1fr); gap: 10px; }
.overview-main, .review-main { min-width: 0; display: grid; gap: 12px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); }
.panel-heading, .evidence-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  min-height: var(--row-height);
  border-bottom: 1px solid var(--line);
  background: var(--strip);
}
.panel-heading p { color: var(--muted); margin-top: 1px; font-size: .9rem; }
.metadata { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metadata > div {
  display: grid;
  grid-template-columns: minmax(104px, 44%) minmax(0, 1fr);
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  padding: 6px 9px;
  border-bottom: 1px solid var(--rule);
}
.metadata > div:nth-child(odd) { border-right: 1px solid var(--rule); }
.metadata > div:nth-last-child(-n+2) { border-bottom: 0; }
.metadata dt { color: var(--muted); }
.metadata dd { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.metadata .text-link { margin-left: 7px; }

.file-table, .risk-table, .spec-table table { width: 100%; border-collapse: collapse; text-align: left; }
.file-table th, .risk-table th {
  background: #f7f7f4;
  border-bottom: 1px solid var(--line);
  color: #44463f;
  font-weight: 600;
  white-space: nowrap;
}
.file-table th, .file-table td, .risk-table th, .risk-table td {
  padding: 5px 9px;
  border-right: 1px solid var(--rule);
}
.file-table th:last-child, .file-table td:last-child, .risk-table th:last-child, .risk-table td:last-child { border-right: 0; }
.file-table td, .risk-table td { border-bottom: 1px solid var(--rule); }
.file-table tr:last-child td, .risk-table tr:last-child td { border-bottom: 0; }
.file-table td:last-child { width: 42px; padding: 2px 6px; text-align: center; }
.file-name, .text-link, .clause-link {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--link);
  text-underline-offset: 2px;
}
.file-name { display: inline-flex; align-items: baseline; gap: 6px; text-align: left; overflow-wrap: anywhere; }
.file-name svg { align-self: center; }
.file-name:hover, .text-link:hover, .clause-link:hover { text-decoration: underline; }
.check-body { padding: 9px 10px 11px; }
.check-body .button { margin-top: 8px; }
.checklist { margin: 6px 0 0; padding-left: 18px; }
.checklist li + li { margin-top: 3px; }

.badge { display: inline-block; padding: 0 4px; font-size: .91rem; font-weight: 600; line-height: 1.4; }
.badge.critical { color: #9c2028; background: #f8e5e6; }
.badge.high { color: #8a4019; background: #f7ebe1; }
.badge.medium { color: #6f500d; background: #f5eed6; }
.badge.low { color: #416135; }
.badge.neutral { color: var(--muted); }
.badge.success { color: #2d6737; }
.badge.talks { color: #235486; }
.title-row .badge { padding: 0; white-space: nowrap; }

.risk-summary {
  display: flex;
  flex-wrap: wrap;
  padding: 4px 6px;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}
.metric { min-height: 27px; padding: 2px 7px; background: var(--surface); border: 1px solid transparent; border-radius: 2px; white-space: nowrap; }
.metric span { margin-left: 1px; color: var(--muted); font-variant-numeric: tabular-nums; }
.metric:hover { background: var(--strip); }
.metric.selected { background: var(--selection); border-color: #d4bf70; font-weight: 650; }
.risk-table-wrap { overflow-x: auto; }
.risk-table td strong, .risk-table td small { display: block; }
.risk-table td strong { font-weight: 600; }
.risk-table td small { color: var(--muted); font-size: .88rem; }
.risk-table td:last-child { width: 22%; }
.risk-table tbody tr { cursor: pointer; }
.risk-table tbody tr:hover { background: #f5f5f1; }
.risk-table tbody .selected-row, .risk-table tbody .selected-row:hover { background: var(--selection); }
.selected-row td:first-child { box-shadow: inset 2px 0 #a68122; }
.clause-link { min-width: 24px; min-height: 24px; text-align: left; text-decoration: underline; }
.evidence { position: sticky; top: 8px; }
.detail-close { display: none; }
.evidence-body { padding: 9px 10px 12px; }
.evidence-title { font-size: 1.13rem; font-weight: 650; margin-bottom: 8px; }
.evidence-section + .evidence-section { margin-top: 10px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 5px 10px; }
.evidence-section p, .evidence-section blockquote { margin: 3px 0 0; }
.evidence-section blockquote { border-left: 2px solid #b9b9ad; background: #f5f5f1; padding: 6px 8px; }
mark { background: #ffe48e; color: inherit; }
.evidence-section label, .protocol-row label { font-weight: 650; }
textarea, select {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 4px 6px;
  border: 1px solid #aeb1a7;
  border-radius: 2px;
  background: var(--surface);
  line-height: 1.4;
}
textarea { resize: vertical; }
select { min-height: 30px; }
.pending { padding: 12px 10px; }
.pending p { color: var(--muted); }
.progress { height: 4px; width: min(240px, 75%); margin-top: 6px; background: var(--strip); }
.progress i { display: block; height: 4px; background: #bb921d; transform-origin: left; animation: progress .95s ease-out both; }
@keyframes progress { from { transform: scaleX(.04); } to { transform: scaleX(1); } }

.registry-summary { display: flex; flex-wrap: wrap; column-gap: 15px; row-gap: 3px; padding: 6px 9px; margin-bottom: 10px; border: 1px solid var(--line); background: var(--surface); }
.registry-summary > div { display: flex; gap: 5px; }
.registry-summary span { color: var(--muted); }
.registry-summary strong { font-variant-numeric: tabular-nums; }
.registry-panel + .conditions-panel { margin-top: 12px; }
.search { display: flex; align-items: center; gap: 4px; border: 1px solid #aeb1a7; background: var(--surface); padding: 2px 5px; }
.search input { width: min(160px, 36vw); border: 0; padding: 2px; background: transparent; }
.no-results { padding: 8px 10px; color: var(--muted); }
.library-panel details { padding: 0 10px; }
.library-panel details + details { border-top: 1px solid var(--rule); }
.library-panel summary { display: grid; grid-template-columns: 120px 1fr 17px; align-items: center; gap: 8px; list-style: none; padding: 7px 0; cursor: pointer; }
.library-panel summary::-webkit-details-marker { display: none; }
.library-panel details[open] summary svg { transform: rotate(180deg); }
.library-panel details p { margin-bottom: 10px; }
.library-preview p { margin-top: 6px; }
.library-category { color: var(--muted); }

dialog {
  width: min(520px, calc(100% - 20px));
  max-height: calc(100dvh - 20px);
  margin: auto;
  padding: 0;
  border: 1px solid #8e9087;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 16px #2223;
}
dialog[open] { display: flex; flex-direction: column; }
dialog.wide { width: min(790px, calc(100% - 20px)); }
dialog::backdrop { background: #25252555; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--strip);
}
.modal-body { overflow: auto; padding: 10px 11px; }
.modal-body > p + p { margin-top: 7px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 5px; flex-wrap: wrap; padding: 6px 8px; border-top: 1px solid var(--line); background: var(--strip); }
.paper { max-width: 670px; margin: 0 auto; padding: clamp(8px, 2vw, 18px); border: 1px solid var(--line); }
.paper > h3 { font-size: 1.25rem; }
.paper-meta { margin: 2px 0 9px; color: var(--muted); }
.paper-clause { margin-top: 6px; padding: 4px; }
.paper-clause h4 { margin-bottom: 2px; }
.paper-highlight { background: var(--selection); }
.spec-table { overflow-x: auto; margin-bottom: 6px; }
.spec-table td, .spec-table th { border: 1px solid var(--line); padding: 4px 6px; }
.spec-table th { background: var(--strip); }
.protocol-intro { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 8px; color: var(--muted); }
.count-label { font-weight: 650; }
.protocol-row { padding: 8px 0; border-top: 1px solid var(--rule); }
.protocol-row p { color: var(--muted); margin: 4px 0 5px; }
.toast {
  position: fixed;
  z-index: 10;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid #a4bd9c;
  background: #f0f6ed;
  color: #29482a;
  visibility: hidden;
  pointer-events: none;
}
.toast.visible { visibility: visible; }

@media (max-width: 1100px) {
  .review-grid { grid-template-columns: minmax(0, 1fr); }
  .evidence { display: none; }
  .evidence.mobile-visible {
    position: fixed;
    inset: 8px 8px 8px auto;
    z-index: 4;
    display: flex;
    flex-direction: column;
    width: min(420px, calc(100vw - 16px));
    box-shadow: 0 3px 18px #2224;
  }
  .evidence-body { overflow-y: auto; }
  .detail-close { display: inline-grid; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { display: none; position: fixed; z-index: 6; width: 174px; top: 43px; bottom: 0; height: auto; }
  .sidebar.open { display: flex; }
  .nav-overlay { display: block; position: fixed; inset: 43px 0 0; z-index: 5; border: 0; background: #25252533; }
}
@media (max-width: 610px) {
  .topbar { padding-inline: 5px 8px; gap: 6px; }
  .brand { gap: 6px; }
  .brand strong, .environment { font-size: .8rem; }
  .current-role { display: none; }
  .workpath, .page-head, .tabs, .content { padding-inline: 8px; }
  .tab { padding-inline: 6px; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .metadata { grid-template-columns: minmax(0, 1fr); }
  .metadata > div:nth-child(odd) { border-right: 0; }
  .metadata > div:nth-last-child(2) { border-bottom: 1px solid var(--rule); }
  .risk-table th, .risk-table td { padding-inline: 4px; }
  .risk-table td:last-child { width: auto; }
  .risk-table .badge { font-size: .82rem; }
  .risk-table { min-width: 292px; }
  .library-panel summary { grid-template-columns: 95px 1fr 17px; }
  .protocol-row .section-title { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .progress i { animation: none; }
}
