:root {
  --navy: #102f3c;
  --navy-2: #173f4f;
  --ink: #17262d;
  --muted: #68777d;
  --paper: #f5f1e9;
  --surface: #fffefd;
  --line: #ddd8ce;
  --terracotta: #b34f36;
  --terracotta-dark: #8f3824;
  --sea: #287a87;
  --sage: #587b68;
  --amber: #a76716;
  --danger: #a63d35;
  --shadow: 0 8px 30px rgba(27, 45, 51, .07);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 15px/1.5 var(--sans); }
a { color: var(--sea); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #e7a047; outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: -.018em; }
h1 { color: var(--navy); font-size: clamp(2rem, 3.5vw, 3.15rem); line-height: 1.08; margin-bottom: .55rem; }
h2 { color: var(--navy); font-size: 1.45rem; line-height: 1.2; }
small { display: block; color: var(--muted); }
.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; }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 100; background: white; padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 244px; background: var(--navy); color: white; z-index: 20; display: flex; flex-direction: column; }
.brand { display: flex; gap: .8rem; align-items: center; min-height: 78px; padding: 0 1.35rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.45); color: white; font: 600 14px var(--serif); }
.brand strong, .login-brand > span:last-child { display: block; font-family: var(--serif); font-size: 18px; font-weight: 500; }
.brand small, .login-brand small { display: block; color: rgba(255,255,255,.65); font: 10px var(--sans); letter-spacing: .08em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: .2rem; padding: 1.25rem .75rem; }
.sidebar nav a { display: flex; align-items: center; gap: .75rem; color: rgba(255,255,255,.72); padding: .68rem .8rem; border-radius: 4px; font-size: 14px; }
.sidebar nav a span { width: 18px; text-align: center; font: 17px var(--serif); }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255,255,255,.1); text-decoration: none; }
.sidebar nav a.active { box-shadow: inset 3px 0 var(--terracotta); }
.sidebar-foot { margin-top: auto; padding: 1rem 1.4rem 1.25rem; border-top: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: 12px; }
.sidebar-foot a, .link-button { color: rgba(255,255,255,.8); }
.link-button { background: none; border: 0; cursor: pointer; padding: 0; font-size: 12px; }
.app-shell { margin-left: 244px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 15; min-height: 72px; padding: .85rem clamp(1rem, 3vw, 2.4rem); background: rgba(255,254,253,.96); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 1rem; backdrop-filter: blur(10px); }
.global-search { flex: 1; max-width: 680px; }
.global-search input, .search-field input { width: 100%; padding: .7rem .85rem; background-color: #f8f6f1; border: 1px solid var(--line); border-radius: 3px; }
.menu-button { display: none; border: 0; background: none; font-size: 1.4rem; color: var(--navy); }
.main-content { padding: clamp(1.5rem, 3vw, 2.75rem); max-width: 1600px; margin: auto; }
.page-heading, .detail-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; margin-bottom: 1.7rem; }
.page-heading > div { max-width: 800px; }
.page-heading p:not(.eyebrow), .detail-heading p { color: var(--muted); margin-bottom: 0; }
.eyebrow { margin-bottom: .35rem; color: var(--terracotta); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.eyebrow.light { color: #e8b499; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: .58rem 1rem; border: 1px solid transparent; border-radius: 3px; cursor: pointer; font-weight: 700; font-size: 13px; text-decoration: none; transition: background .15s, border-color .15s; }
.button:hover { text-decoration: none; }
.button.primary { background: var(--terracotta); color: white; }
.button.primary:hover { background: var(--terracotta-dark); }
.button.secondary { background: var(--surface); color: var(--navy); border-color: #bfc7c8; }
.button.secondary:hover { background: #f4f6f5; border-color: var(--navy); }
.button.ghost { color: var(--navy); background: transparent; }
.button.danger { background: var(--danger); color: white; }
.button.compact { min-height: 38px; padding: .48rem .8rem; }
.button.tiny { min-height: 32px; padding: .3rem .65rem; font-size: 12px; }
.button.full { width: 100%; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.35rem; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.panel-heading .eyebrow { margin-bottom: .25rem; }
.panel-heading > span { color: var(--muted); font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.stat-card { min-height: 138px; padding: 1.2rem; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--sea); color: var(--ink); box-shadow: var(--shadow); text-decoration: none; }
a.stat-card:hover { border-color: #aab5b5; text-decoration: none; transform: translateY(-1px); }
.stat-card.accent { border-top-color: var(--terracotta); }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat-card strong { display: block; margin: .2rem 0 0; color: var(--navy); font: 500 2.8rem var(--serif); line-height: 1; }
.content-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1.2rem; }
.distribution-list { list-style: none; margin: 0; padding: 1rem 1.35rem; }
.distribution-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .68rem 0; border-bottom: 1px solid var(--line); }
.distribution-list strong { color: var(--navy); }
.health-block { margin: .2rem 1.35rem 1.35rem; padding: 1rem; background: #f4f7f5; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .7rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sage); }
.status-dot.warn { background: var(--amber); }
.health-block strong { display: block; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: .72rem 1rem; background: #f2f0eb; color: #57666c; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; text-align: left; white-space: nowrap; }
td { padding: .9rem 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfaf7; }
td small { margin-top: .18rem; }
.title-link { color: var(--ink); font-weight: 650; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--sea); }
.break { word-break: break-all; }
.badge { display: inline-flex; align-items: center; width: max-content; padding: .22rem .48rem; border-radius: 2px; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: #e8ecec; color: #45565d; white-space: nowrap; }
.badge.success { background: #dfece4; color: #285943; }
.badge.warning { background: #f4e8cf; color: #70460d; }
.badge.danger { background: #f1deda; color: #7b2f29; }
.badge.neutral { background: #e8ecec; color: #45565d; }
.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(4, auto) auto auto; gap: .65rem; align-items: center; margin-bottom: 1rem; }
.filter-bar input, .filter-bar select, .inline-edit input, .inline-edit select, .source-actions select { min-height: 40px; border: 1px solid var(--line); background: var(--surface); padding: .5rem .7rem; border-radius: 3px; color: var(--ink); }
.check { display: flex; align-items: center; gap: .35rem; font-size: 12px; white-space: nowrap; }
.check input { min-height: 0; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1.5rem; padding: 1rem; border-top: 1px solid var(--line); font-size: 13px; }
.breadcrumbs { display: flex; gap: .5rem; margin-bottom: 1rem; color: var(--muted); font-size: 12px; }
.detail-heading h1 { max-width: 1000px; font-size: clamp(1.8rem, 3vw, 2.65rem); }
.heading-badges { display: flex; gap: .4rem; margin-bottom: .7rem; }
.heading-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.section-tabs { position: sticky; top: 72px; z-index: 10; display: flex; gap: 1.6rem; margin: 0 0 1.2rem; padding: 0 1.1rem; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); }
.section-tabs a { color: #536269; padding: .85rem 0; border-bottom: 2px solid transparent; font-size: 12px; font-weight: 700; white-space: nowrap; }
.section-tabs a:hover { color: var(--navy); border-bottom-color: var(--terracotta); text-decoration: none; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.2rem; align-items: start; }
.detail-main { display: grid; gap: 1.2rem; min-width: 0; }
.detail-aside { display: grid; gap: 1.2rem; position: sticky; top: 138px; }
.detail-section { scroll-margin-top: 150px; overflow: hidden; }
.preview-frame { display: block; margin: 1.25rem; max-height: 520px; overflow: hidden; border: 1px solid #cfc9bf; background: #e9e5de; }
.preview-frame img { display: block; width: 100%; height: auto; }
.empty-preview { margin: 1.25rem; padding: 5rem 1rem; text-align: center; color: var(--muted); background: #efede8; }
.summary-block { padding: 0 1.35rem 1.35rem; }
.summary-block h3, .tag-groups h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.file-list { padding: .35rem 1.35rem 1rem; }
.file-row { display: grid; grid-template-columns: 42px 1fr auto; gap: .8rem; align-items: center; padding: .72rem 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.file-row:hover { text-decoration: none; }
.file-icon { width: 36px; height: 36px; display: grid; place-items: center; background: #e8efef; color: var(--navy); font-size: 10px; font-weight: 800; }
.file-meta { text-align: right; font-size: 12px; }
.file-meta small { font-family: ui-monospace, monospace; font-size: 9px; }
.tag-groups { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; padding: 1.3rem; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tags span { padding: .3rem .55rem; background: #e9f0ef; color: #315962; border: 1px solid #d0dfdc; border-radius: 2px; font-size: 11px; }
.callout { margin-bottom: 1rem; padding: .9rem 1rem; border-left: 3px solid var(--sea); background: #e9f1f1; color: #385860; font-size: 13px; }
.detail-section > .callout { margin: 1.2rem 1.35rem; }
.wide-callout { max-width: 950px; }
.legal-link { margin: 0 1.35rem 1.2rem; padding: 1rem; border: 1px solid var(--line); border-left: 3px solid var(--terracotta); }
.legal-link h3 { margin: .5rem 0 .35rem; font: 500 1.1rem var(--serif); color: var(--navy); }
.inspector { padding: 1.25rem; }
.inspector h2 { margin-bottom: 1rem; }
.inspector dl { margin: 0; }
.inspector dl > div { display: grid; grid-template-columns: 100px 1fr; gap: .5rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
dd { margin: 0; font-size: 13px; }
.warning-box { margin-top: 1rem; padding: .8rem; background: #f8edda; border-left: 3px solid var(--amber); font-size: 12px; }
.warning-box p { margin: .3rem 0 0; }
.danger-zone { padding: 1.2rem; border-color: #e1c6c0; }
.danger-zone h2 { font-size: 1.2rem; }
.danger-zone p { color: var(--muted); font-size: 12px; }
.danger-zone textarea { width: 100%; min-height: 75px; margin-bottom: .6rem; border: 1px solid var(--line); padding: .6rem; }
.timeline { list-style: none; margin: 0; padding: 1.2rem 1.35rem; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: .7rem; padding-bottom: 1rem; }
.timeline li > span { width: 9px; height: 9px; margin-top: .35rem; border: 2px solid var(--sea); border-radius: 50%; }
.timeline strong { font-size: 13px; }
.timeline p { margin: .15rem 0 0; color: var(--muted); font-size: 11px; }
.form-panel { padding: 1.4rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
.field { display: grid; gap: .32rem; align-content: start; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 750; color: #3e5057; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: .62rem .7rem; color: var(--ink); background: #fff; border: 1px solid #cfc9bf; border-radius: 3px; }
.field textarea { min-height: 90px; resize: vertical; }
.field small { font-size: 10px; }
.errorlist, .form-errors { color: var(--danger); margin: .2rem 0 0; padding-left: 1.2rem; font-size: 12px; }
.form-errors { padding: .7rem 1rem; background: #f5e6e3; margin-bottom: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.3rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.narrow-page { max-width: 940px; margin: auto; }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.count-chip { padding: .42rem .7rem; background: var(--surface); border: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.count-chip strong { color: var(--navy); margin-right: .2rem; }
.error-text { color: var(--danger); max-width: 700px; }
.source-grid, .legal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.source-card { padding: 1.15rem; }
.source-top { display: flex; justify-content: space-between; gap: 1rem; }
.source-top h2 { margin: .7rem 0 .25rem; font-size: 1.25rem; }
.source-top p { color: var(--muted); font-size: 12px; }
.source-count { color: var(--navy); text-align: right; font: 500 2rem var(--serif); }
.source-count small { font: 10px var(--sans); text-transform: uppercase; }
.source-card dl { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); padding: .7rem 0; }
.source-card dl div { padding: 0 .45rem; border-right: 1px solid var(--line); }
.source-card dl div:first-child { padding-left: 0; }
.source-card dl div:last-child { border: 0; }
.source-card dd { margin-top: .25rem; }
.source-actions { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .8rem; font-size: 12px; }
.source-actions form { display: flex; gap: .35rem; }
.review-list, .incident-list { display: grid; gap: .75rem; }
.review-card { display: grid; grid-template-columns: 130px 1fr auto; gap: 1rem; align-items: center; padding: 1rem 1.2rem; color: var(--ink); }
.review-card:hover { text-decoration: none; border-color: #aeb9b9; }
.review-card h2 { margin: 0 0 .25rem; font: 650 1rem var(--sans); }
.review-card p { margin: 0; color: var(--muted); font-size: 12px; }
.review-card > div:last-child { display: flex; gap: 1rem; align-items: center; }
.incident-card { padding: 1.1rem 1.25rem; }
.incident-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.incident-card h2 { margin: .8rem 0 .25rem; font-size: 1.2rem; }
.incident-card pre { white-space: pre-wrap; word-break: break-word; padding: .7rem; background: #f2f0eb; color: #633d38; font-size: 11px; }
.inline-edit { display: grid; grid-template-columns: 180px 1fr auto; gap: .5rem; }
.legal-card { display: flex; flex-direction: column; min-height: 220px; padding: 1.25rem; color: var(--ink); }
.legal-card:hover { text-decoration: none; border-color: #aeb9b9; }
.legal-card h2 { margin: .5rem 0; }
.legal-card p { color: var(--muted); font-size: 12px; }
.legal-card > div { display: flex; justify-content: space-between; gap: 1rem; margin-top: auto; padding-top: .8rem; border-top: 1px solid var(--line); font-size: 11px; }
.legal-detail-grid { grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); }
.legal-detail-grid aside { display: grid; gap: 1rem; }
.provision { padding: 1.2rem 1.35rem; border-bottom: 1px solid var(--line); }
.provision h3 { color: var(--navy); font: 500 1.2rem var(--serif); }
.provision blockquote { margin: .7rem 0; padding-left: 1rem; border-left: 2px solid var(--line); color: #45565d; }
.compact-form h2 { font-size: 1.2rem; }
.compact-form form { display: grid; gap: .75rem; }
.empty, .empty-state { padding: 2rem; color: var(--muted); text-align: center; }
.messages { display: grid; gap: .5rem; margin-bottom: 1rem; }
.message { padding: .8rem 1rem; background: #e7efec; border-left: 3px solid var(--sage); }
.message.error { background: #f3e2df; border-color: var(--danger); }
.message.info { background: #e7eff0; border-color: var(--sea); }
.auth-body { background: var(--surface); }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, .85fr) minmax(520px, 1.15fr); }
.login-panel { width: min(460px, calc(100% - 3rem)); margin: auto; padding: 3rem 0; }
.login-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 5rem; color: var(--navy); }
.login-brand .brand-mark { background: var(--navy); }
.login-brand small { color: var(--muted); }
.login-panel h1 { font-size: 2.5rem; }
.login-panel .muted { color: var(--muted); margin-bottom: 1.8rem; }
.stacked-form { display: grid; gap: 1rem; }
.security-note { margin-top: 1rem; color: var(--muted); text-align: center; font-size: 10px; }
.login-context { display: flex; align-items: flex-end; padding: 6vw; color: white; background: var(--navy); position: relative; overflow: hidden; }
.login-context::before, .login-context::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.login-context::before { width: 70vw; height: 70vw; top: -35vw; right: -20vw; }
.login-context::after { width: 42vw; height: 42vw; top: -15vw; right: -6vw; }
.login-context > div { position: relative; z-index: 1; max-width: 640px; }
.login-context h2 { color: white; font-size: clamp(2.2rem, 4vw, 4.3rem); line-height: 1.05; }
.login-context p:last-child { color: rgba(255,255,255,.72); max-width: 510px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .source-grid, .legal-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr) 285px; }
  .filter-bar { grid-template-columns: 1fr 1fr 1fr; }
  .search-field { grid-column: span 2; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 12px 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .app-shell { margin-left: 0; }
  .menu-button { display: block; }
  .topbar { min-height: 64px; }
  .detail-grid, .content-grid, .legal-detail-grid { grid-template-columns: 1fr; }
  .detail-aside { position: static; grid-row: 1; grid-template-columns: repeat(2, 1fr); }
  .section-tabs { top: 64px; }
  .login-page { grid-template-columns: 1fr; }
  .login-context { display: none; }
  .login-brand { margin-bottom: 3rem; }
}
@media (max-width: 620px) {
  .main-content { padding: 1.15rem .85rem 3rem; }
  .topbar { padding: .65rem .8rem; }
  .topbar .button { width: 40px; overflow: hidden; white-space: nowrap; padding: 0; font-size: 0; }
  .topbar .button::before { content: "+"; font-size: 20px; }
  .page-heading, .detail-heading { display: grid; gap: 1rem; }
  .page-heading .button, .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat-card { min-height: 118px; padding: .9rem; }
  .stat-card strong { font-size: 2.25rem; }
  .stat-card small { font-size: 10px; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filter-bar select { min-width: 0; width: 100%; }
  .material-panel table, .dashboard-grid table { display: block; }
  .material-panel thead, .dashboard-grid thead { display: none; }
  .material-panel tbody, .dashboard-grid tbody { display: grid; }
  .material-panel tr, .dashboard-grid tr { display: grid; grid-template-columns: 1fr auto; padding: .9rem; border-top: 1px solid var(--line); }
  .material-panel td, .dashboard-grid td { display: block; border: 0; padding: .18rem 0; }
  .material-panel td:nth-child(2), .dashboard-grid td:nth-child(2) { grid-column: 1 / -1; grid-row: 1; padding-bottom: .55rem; }
  .material-panel td:last-child, .dashboard-grid td:last-child { grid-column: 2; grid-row: 2; }
  .material-panel td:nth-child(3), .dashboard-grid td:nth-child(3) { color: var(--muted); }
  .material-panel td:nth-child(4), .material-panel td:nth-child(5) { display: none; }
  .detail-aside { grid-template-columns: 1fr; }
  .tag-groups, .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .file-row { grid-template-columns: 38px 1fr; }
  .file-meta { grid-column: 2; text-align: left; }
  .source-grid, .legal-grid { grid-template-columns: 1fr; }
  .review-card { grid-template-columns: 1fr auto; }
  .review-card > .mono { grid-column: 1 / -1; }
  .inline-edit { grid-template-columns: 1fr; }
}
