:root {
  --bg: #f1f1f1;
  --card: #ffffff;
  --ink: #303030;
  --muted: #616161;
  --line: #e3e3e3;
  --focus: #005bd3;
  --success: #0c5132; --success-bg: #cdfee1;
  --warning: #5e4200; --warning-bg: #ffef9d;
  --attention: #5e4200; --attention-bg: #ffd6a4;
  --critical: #8e0b21; --critical-bg: #fedad9;
  --info: #00527c; --info-bg: #e0f0ff;
  --neutral-bg: #e3e3e3;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; line-height: 1.3; margin: 0 0 2px; font-weight: 650; }
h2 { font-size: 14px; line-height: 1.35; margin: 0; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
p { margin: 0; }
.muted { color: var(--muted); }
.light { font-weight: 450; }
.small { font-size: 12px; }
.danger-text { color: var(--critical); }
[hidden] { display: none !important; }

.page { max-width: 1180px; margin: 0 auto; padding: 16px 20px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 6px 0 16px; }
.back { display: inline-block; margin: 4px 0 8px; color: var(--muted); font-weight: 550; }
.loading { display: flex; align-items: center; gap: 10px; padding: 48px; justify-content: center; color: var(--muted); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #c9c9c9; border-top-color: #303030; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 0 rgba(26,26,26,.07), 0 0 0 1px rgba(26,26,26,.06) inset;
  margin-bottom: 16px;
}
.card-head { margin-bottom: 12px; }
.card-head p { margin-top: 4px; }
.count { background: var(--neutral-bg); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 550; }
.empty { color: var(--muted); padding: 6px 0 2px; }
.rows { margin: 0 -16px -16px; border-top: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.row:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.row:hover { background: #f7f7f7; text-decoration: none; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 12px; }
.row-side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.badge { display: inline-flex; align-items: center; border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 550; line-height: 18px; white-space: nowrap; background: var(--neutral-bg); color: var(--ink); }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.attention { background: var(--attention-bg); color: var(--attention); }
.badge.critical { background: var(--critical-bg); color: var(--critical); }
.badge.info { background: var(--info-bg); color: var(--info); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px;
  padding: 5px 12px; border-radius: 8px; border: 0; cursor: pointer; font: inherit; font-weight: 550;
  background: #fff; color: var(--ink); box-shadow: 0 0 0 1px #d4d4d4 inset, 0 1px 0 rgba(0,0,0,.05); white-space: nowrap;
}
.btn:hover { background: #f7f7f7; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: #303030; color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.12); }
.btn.primary:hover:not(:disabled) { background: #1a1a1a; }
.btn.critical { background: #c70a24; color: #fff; box-shadow: none; }
.btn.critical:hover { background: #a3091d; }
.btn.plain { background: none; box-shadow: none; color: var(--focus); padding-left: 6px; padding-right: 6px; }
.btn.plain:hover { text-decoration: underline; background: none; }
.link-btn { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.actions.right { justify-content: flex-end; margin-top: 8px; }

.callout { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; line-height: 1.5; }
.callout.critical { background: var(--critical-bg); color: var(--critical); }
.callout.attention { background: var(--attention-bg); color: var(--attention); }
.callout a { color: inherit; text-decoration: underline; font-weight: 600; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }

.layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 920px) { .layout { grid-template-columns: 1fr; } .page { padding: 12px; } }

/* Verdict card */
.verdict { border-top: 4px solid #8a8a8a; }
.verdict.success { border-top-color: #29845a; }
.verdict.warning { border-top-color: #e8a400; }
.verdict.critical { border-top-color: #c70a24; }
.verdict-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.verdict-head h2 { font-size: 17px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.score { text-align: center; min-width: 54px; }
.score span { display: block; font-size: 26px; font-weight: 700; line-height: 1; }
.score small { color: var(--muted); font-size: 11px; }
.summary { margin: 8px 0 12px; }
.meter { position: relative; height: 6px; background: #ececec; border-radius: 6px; }
.meter span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: #303030; }
.verdict.success .meter span { background: #29845a; }
.verdict.warning .meter span { background: #e8a400; }
.verdict.critical .meter span { background: #c70a24; }
.meter i { position: absolute; top: -3px; width: 2px; height: 12px; background: #8a8a8a; }
.meter i.hold { background: #c70a24; }
.meter-legend { display: flex; justify-content: space-between; margin: 4px 0 6px; }
.sigs { list-style: none; margin: 10px 0 0; padding: 0; }
.sig { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.sig:first-child { border-top: 0; }
.sig-icon { width: 14px; flex: 0 0 14px; font-size: 10px; padding-top: 3px; }
.sig.risk .sig-icon { color: #c70a24; }
.sig.trust .sig-icon { color: #29845a; }
.sig.info .sig-icon { color: #8a8a8a; }
.pts { margin-left: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ctx { margin-top: 6px; }
.ctx summary { cursor: pointer; color: var(--muted); font-weight: 550; padding: 4px 0; }
.gaps { margin-top: 8px; }
.protect { margin-top: 14px; border-radius: 10px; padding: 10px 12px; background: #f7f7f7; }
.protect.covered, .protect.lender { background: var(--success-bg); color: var(--success); }
.protect.coverable { background: var(--info-bg); color: var(--info); }
.protect.not_covered { background: var(--attention-bg); color: var(--attention); }

/* Details */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.sub-head { font-weight: 650; margin: 14px 0 6px; }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 3px 0; }

/* Documents */
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 16px; }
@media (max-width: 720px) { .review-grid { grid-template-columns: 1fr; } }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.doc { margin: 0; }
.doc-img { aspect-ratio: 4 / 3; background: #f3f3f3; border-radius: 10px; display: grid; place-items: center; overflow: hidden; cursor: zoom-in; box-shadow: 0 0 0 1px var(--line) inset; }
.doc-img img { width: 100%; height: 100%; object-fit: contain; }
.doc figcaption { margin-top: 6px; font-weight: 550; }
.expect { background: #f7f7f7; border-radius: 10px; padding: 12px; }
.expect-title { font-weight: 650; margin-bottom: 6px; }
.expect ul { margin: 0; padding-left: 16px; }
.expect li { margin: 4px 0; }
.note { margin-top: 8px; padding: 8px 10px; background: #f7f7f7; border-radius: 8px; font-style: italic; }
.checklist { display: grid; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.checklist label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
textarea { width: 100%; margin-top: 12px; border: 1px solid #8a8a8a; border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }
textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 4px 0 10px 10px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: #b5b5b5; }

/* Insights */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .stats { grid-template-columns: 1fr; } }
.stat { background: #f7f7f7; border-radius: 10px; padding: 12px; }
.stat-label { font-weight: 600; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; margin: 2px 0; }
.stat.critical .stat-value { color: var(--critical); }
.stat.success .stat-value { color: var(--success); }
.insights .callout { margin: 12px 0 0; }

/* Overlays */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: grid; place-items: center; padding: 20px; }
.sheet { background: #fff; border-radius: 14px; padding: 18px; width: min(760px, 100%); max-height: 90vh; overflow: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet textarea { min-height: 240px; font-size: 13px; line-height: 1.5; }
.ev-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .ev-cols { grid-template-columns: 1fr; } }
.viewer { width: min(1100px, 100%); height: min(88vh, 900px); display: flex; flex-direction: column; background: #111; border-radius: 12px; overflow: hidden; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; color: #fff; font-weight: 600; gap: 8px; }
.viewer-stage { flex: 1; overflow: auto; display: grid; place-items: center; }
.viewer-stage img { transition: transform .2s; }
.viewer-stage img.fit { max-width: 100%; max-height: 100%; object-fit: contain; }

.standalone { max-width: 420px; margin: 80px auto; text-align: center; padding: 0 20px; }
.standalone p { color: var(--muted); margin-top: 8px; }

.hold-status { margin-top: 12px; border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.hold-status.held { background: #f1f1f1; }
.hold-status.failed { background: var(--critical-bg); color: var(--critical); }
.hold-status.open { background: var(--attention-bg); color: var(--attention); }
