:root {
  color-scheme: light;
  --ink: #18231f;
  --muted: #68756f;
  --paper: #f4f6f2;
  --card: #ffffff;
  --line: #dce3de;
  --green: #286148;
  --green-soft: #e7f1eb;
  --amber: #9b6217;
  --amber-soft: #fff3dc;
  --shadow: 0 18px 55px rgba(24, 35, 31, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.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; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: #f7f8f6; }
.login-shell { width: min(88vw, 330px); }
.login-form { display: grid; gap: 12px; }
.login-form input { width: 100%; height: 48px; padding: 0 16px; border: 1px solid #cfd8d2; border-radius: 10px; background: #fff; outline: none; }
.login-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(40,97,72,.12); }
.login-form button { height: 48px; border: 0; border-radius: 10px; color: #fff; background: var(--green); cursor: pointer; font-weight: 650; }
.login-error { min-height: 20px; margin: 0; text-align: center; color: #a33d31; font-size: 13px; }

.topbar { height: 58px; padding: 0 max(24px, calc((100vw - 1480px)/2)); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.brand { font-weight: 750; letter-spacing: -.02em; }
.quiet-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px 10px; }
.workspace { max-width: 1480px; margin: 0 auto; padding: 24px; }
.dashboard { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.metric-card { min-height: 116px; padding: 18px 20px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; gap: 6px 18px; text-align: left; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); cursor: pointer; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.metric-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(24,35,31,.08); }
.metric-card.active { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.metric-card strong { grid-row: 1 / 3; grid-column: 2; font-size: 36px; line-height: 1; align-self: center; }
.metric-card span:last-child { color: var(--muted); font-size: 13px; align-self: end; }
.metric-card.success strong { color: var(--green); }
.metric-card.review strong { color: var(--amber); }
.metric-label { font-weight: 700; }
.project-section { margin-top: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list-heading { display: flex; align-items: baseline; gap: 12px; padding: 20px 22px 14px; }
.list-heading h1 { margin: 0; font-size: 21px; }
.list-heading span { color: var(--muted); font-size: 13px; }
.table-shell { min-height: 220px; overflow: auto; border-top: 1px solid var(--line); }
.project-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.project-table th { position: sticky; top: 0; z-index: 2; background: #f8faf8; color: var(--muted); font-size: 12px; font-weight: 650; text-align: left; white-space: nowrap; }
.project-table th, .project-table td { padding: 12px 14px; border-bottom: 1px solid #edf0ee; vertical-align: middle; }
.project-table tr:hover td { background: #fafcfb; }
.number-cell { width: 80px; color: var(--muted); }
.name-cell { min-width: 300px; font-weight: 600; }
.region-cell { min-width: 190px; }
.numeric-cell { text-align: right; white-space: nowrap; }
.actions-cell { width: 120px; white-space: nowrap; text-align: right; }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: #edf1ee; color: #506058; font-size: 12px; white-space: nowrap; }
.view-button, .download-button { border: 0; color: var(--green); background: var(--green-soft); border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-grid; place-items: center; height: 32px; }
.view-button { padding: 0 11px; font-weight: 650; }
.download-button { width: 32px; margin-left: 5px; font-size: 18px; }
.loading, .empty { min-height: 220px; display: grid; place-items: center; color: var(--muted); }

.passport-modal { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; border: 0; background: var(--paper); }
.passport-modal::backdrop { background: rgba(14,25,20,.5); }
.reader-shell { height: 100vh; display: grid; grid-template-columns: 272px minmax(0,1fr); transition: grid-template-columns .18s ease; }
.reader-shell.nav-collapsed { grid-template-columns: 48px minmax(0,1fr); }
.reader-nav { position: relative; padding: 24px 18px; background: #eef2ef; border-right: 1px solid var(--line); overflow: auto; }
.reader-shell.nav-collapsed .reader-nav { overflow: hidden; padding-inline: 8px; }
.reader-shell.nav-collapsed .reader-nav nav, .reader-shell.nav-collapsed .nav-title { display: none; }
.nav-toggle { position: sticky; top: 0; float: right; width: 30px; height: 30px; border: 1px solid #cad5ce; border-radius: 8px; background: #fff; color: var(--green); cursor: pointer; z-index: 3; }
.reader-shell.nav-collapsed .nav-toggle { transform: rotate(180deg); float: none; }
.nav-title { padding: 5px 38px 18px 2px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.reader-nav a { display: block; padding: 6px 8px; border-radius: 7px; color: #4f5d56; text-decoration: none; font-size: 13px; line-height: 1.35; }
.reader-nav a:hover { color: var(--green); background: #fff; }
.reader-nav a.level-1 { font-weight: 750; color: var(--ink); }
.reader-nav a.level-3 { padding-left: 18px; font-size: 12px; }
.reader-nav a.level-4 { padding-left: 28px; font-size: 11px; }
.reader-main { min-width: 0; height: 100vh; overflow: auto; scroll-behavior: smooth; }
.reader-header { height: 66px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.reader-header h2 { margin: 0; max-width: calc(100% - 110px); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-actions { display: flex; gap: 8px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; font-size: 20px; }
.passport-content { width: min(100%, 1080px); margin: 0 auto; padding: 42px 52px 100px; line-height: 1.65; }
.passport-content h1 { margin: 0 0 34px; font-size: clamp(28px,3vw,43px); line-height: 1.12; letter-spacing: -.035em; }
.passport-content h2 { margin: 48px 0 18px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 24px; }
.passport-content h3 { margin: 34px 0 13px; font-size: 19px; }
.passport-content h4 { margin: 26px 0 10px; font-size: 15px; }
.passport-content p { margin: 0 0 15px; }
.passport-content li { margin: 5px 0; }
.passport-content a { color: #236c50; text-underline-offset: 3px; }
.passport-content code { padding: 2px 5px; border-radius: 4px; background: #edf1ee; font-size: .88em; }
.table-scroll { overflow-x: auto; margin: 18px 0 28px; border: 1px solid var(--line); border-radius: 10px; }
.passport-content table { width: 100%; border-collapse: collapse; font-size: 13px; }
.passport-content th { background: #f1f5f2; text-align: left; }
.passport-content th, .passport-content td { padding: 9px 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; }
.citation { padding: 0; border: 0; background: transparent; color: #236c50; font-weight: 750; cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.source-popover { position: fixed; z-index: 1000; width: min(440px, calc(100vw - 24px)); max-height: min(520px, calc(100vh - 24px)); overflow: auto; padding: 16px; border: 1px solid #cbd6cf; border-radius: 12px; background: #fff; box-shadow: var(--shadow); font-size: 13px; line-height: 1.45; }
.source-popover h3 { margin: 0 0 7px; font-size: 15px; }
.source-meta { margin-bottom: 12px; color: var(--muted); }
.source-evidence { padding: 10px 0; border-top: 1px solid var(--line); }
.source-evidence p { margin: 0 0 5px; }
.source-place { color: var(--muted); font-size: 12px; }
.source-link { display: inline-block; margin-top: 9px; color: var(--green); }

@media (max-width: 820px) {
  .dashboard { grid-template-columns: 1fr; }
  .metric-card { min-height: 92px; }
  .workspace { padding: 14px; }
  .reader-shell { grid-template-columns: 48px minmax(0,1fr); }
  .reader-nav { overflow: hidden; padding-inline: 8px; }
  .reader-nav nav, .nav-title { display: none; }
  .reader-shell:not(.nav-collapsed) { grid-template-columns: min(82vw,280px) minmax(0,1fr); }
  .reader-shell:not(.nav-collapsed) .reader-nav { overflow: auto; padding: 20px 14px; }
  .reader-shell:not(.nav-collapsed) .reader-nav nav, .reader-shell:not(.nav-collapsed) .nav-title { display: block; }
  .passport-content { padding: 30px 22px 80px; }
}
