:root {
  --ink: #11242a;
  --muted: #5f6f73;
  --paper: #f5f6f2;
  --white: #fff;
  --line: #dce3dd;
  --river: #087e72;
  --river-dark: #075c56;
  --river-soft: #e7f2ee;
  --navy: #122f3a;
  --gold: #c29342;
  --red: #9f3f42;
  --shadow: 0 18px 44px rgba(17, 36, 42, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: linear-gradient(180deg, #f8faf7 0, var(--paper) 380px); }
a { color: var(--river-dark); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(8, 126, 114, .28); outline-offset: 2px; }

.topbar { min-height: 78px; padding: 14px clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--white); background: var(--navy); border-bottom: 3px solid var(--river); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 1.02rem; letter-spacing: .1em; }
.brand small { display: block; margin-top: 2px; color: #a9bdc2; font-size: .73rem; letter-spacing: .08em; text-transform: uppercase; }
.river { color: #24aa99; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; position: relative; border: 1px solid rgba(255,255,255,.3); border-radius: 50% 50% 46% 54%; transform: rotate(-8deg); }
.brand-mark::after { content: ""; position: absolute; width: 20px; height: 1px; background: var(--gold); transform: rotate(-40deg) translate(12px, 10px); }
.brand-mark span { transform: rotate(8deg); font-family: Georgia, serif; font-size: 1.3rem; }
.admin-identity { display: flex; align-items: center; gap: 14px; color: #c9d5d7; font-size: .86rem; }
.admin-identity form { margin: 0; }

.page-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.page-heading h1 { margin: 4px 0 10px; max-width: 900px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.02; font-weight: 500; letter-spacing: -.035em; }
.page-heading p:not(.eyebrow) { margin: 0; max-width: 760px; color: var(--muted); line-height: 1.65; }
.eyebrow { margin: 0 0 7px; color: var(--river-dark); font-size: .73rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.breadcrumbs { display: flex; gap: 8px; margin-bottom: 24px; color: var(--muted); font-size: .86rem; }
.breadcrumbs a { color: var(--river-dark); font-weight: 700; }
.heading-badges { display: flex; align-items: center; gap: 8px; }

.button { min-height: 42px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 5px; font-weight: 750; font-size: .88rem; line-height: 1; text-decoration: none; cursor: pointer; transition: background .18s ease, border .18s ease, transform .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--river-dark); border-color: var(--river-dark); }
.button-primary:hover { background: #064b47; }
.button-secondary { color: var(--river-dark); background: var(--river-soft); border-color: #bcd8cf; }
.button-quiet { color: inherit; background: transparent; border-color: currentColor; }
.button-danger { color: var(--red); background: #fff7f6; border-color: #e7c9c7; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stats-grid article { padding: 20px; background: var(--white); border: 1px solid var(--line); border-top: 3px solid var(--river); box-shadow: 0 7px 18px rgba(17,36,42,.04); }
.stats-grid span, .stats-grid small { display: block; color: var(--muted); }
.stats-grid span { font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.stats-grid strong { display: block; margin: 7px 0 2px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.stats-grid small { font-size: .78rem; }

.panel { padding: clamp(20px, 3vw, 32px); background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.filter-panel { margin-bottom: 20px; padding-block: 20px; }
.filters { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(150px, .7fr) minmax(150px, .7fr) auto auto; align-items: end; gap: 12px; }
label { display: grid; gap: 7px; color: #31464b; font-size: .78rem; font-weight: 750; letter-spacing: .025em; }
input, textarea, select { width: 100%; color: var(--ink); background: #fbfcfa; border: 1px solid #cdd8d3; border-radius: 4px; }
input, select { min-height: 43px; padding: 9px 11px; }
textarea { padding: 11px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--river); box-shadow: 0 0 0 3px rgba(8,126,114,.11); outline: 0; }
.section-heading { margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-heading h2, .detail-sidebar h2 { margin: 0; font-family: Georgia, serif; font-weight: 500; font-size: 1.65rem; }
.privacy-chip, .reference { padding: 7px 10px; color: var(--river-dark); background: var(--river-soft); border: 1px solid #c4ddd6; border-radius: 100px; font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.reference { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { padding: 12px 13px; color: var(--muted); background: #f3f6f3; border-block: 1px solid var(--line); text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 16px 13px; border-bottom: 1px solid #e7ece8; vertical-align: top; }
td strong, td small { display: block; }
td small { margin-top: 4px; max-width: 270px; color: var(--muted); line-height: 1.35; }
.record-link { color: var(--river-dark); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; }
.status, .priority, .draft-state { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px; border-radius: 100px; font-size: .68rem; font-weight: 800; letter-spacing: .035em; white-space: nowrap; }
.status { color: #315961; background: #e8f0f0; }
.status-new, .status-follow_up { color: #075c56; background: #daf0e9; }
.status-closed { color: #5b6465; background: #edf0ed; }
.priority { color: #4d5a5c; background: #edf0ed; }
.priority-high { color: #7c5203; background: #fff0cf; }
.priority-urgent { color: #8c3034; background: #fee8e6; }
.empty-state { padding: 58px 24px; color: var(--muted); text-align: center; border: 1px dashed #ccd8d2; background: #fafbf9; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-family: Georgia, serif; font-size: 1.35rem; font-weight: 500; }
.empty-state p { margin: 0; }
.empty-state.compact { padding: 30px 20px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; gap: 20px; }
.detail-main { display: grid; gap: 20px; }
.sticky-panel { position: sticky; top: 20px; }
.record-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--line); }
.record-grid div { padding: 17px 4px; border-bottom: 1px solid var(--line); }
.record-grid div:nth-child(odd) { margin-right: 24px; }
dt { margin-bottom: 5px; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
.context-block { margin-top: 24px; padding: 20px; background: #f6f8f5; border-left: 3px solid var(--river); }
.context-block h3 { margin: 0 0 8px; font-family: Georgia, serif; font-weight: 500; }
.context-block p { margin: 0; white-space: pre-wrap; line-height: 1.65; }
.form-stack { display: grid; gap: 15px; }
.archive-control { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.archive-control .button { width: 100%; }
.archive-control p { margin: 10px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.45; }

.draft-form { margin-bottom: 26px; padding: 20px; background: #f4f8f6; border: 1px solid #d6e3dc; }
.action-row { margin-top: 13px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.action-row p { margin: 0; max-width: 620px; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.draft-list { display: grid; gap: 16px; }
.draft-card { padding: 20px; border: 1px solid var(--line); background: #fdfefc; }
.draft-card label + label { margin-top: 13px; }
.draft-meta { margin-bottom: 16px; display: flex; justify-content: space-between; gap: 20px; }
.draft-meta > div { display: flex; align-items: center; gap: 8px; }
.draft-meta small { color: var(--muted); }
.draft-state-prepared { color: #795410; background: #fff0cd; }
.draft-state-approved { color: #075c56; background: #dff1eb; }
.draft-state-superseded { color: #616a6b; background: #ecefed; }
.approval-row, .approved-actions { margin-top: 16px; padding-top: 16px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--line); }
.approval-row p { margin: 0 auto 0 0; color: var(--muted); font-size: .76rem; }
.approved-actions > div { margin-right: auto; }
.approved-actions strong, .approved-actions small { display: block; }
.approved-actions small { margin-top: 3px; color: var(--muted); font-size: .73rem; }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { min-height: 68px; display: grid; grid-template-columns: 18px 1fr; gap: 12px; position: relative; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 13px; bottom: -3px; width: 1px; background: #cbd9d3; }
.timeline-dot { width: 11px; height: 11px; margin-top: 4px; z-index: 1; border: 2px solid var(--white); border-radius: 50%; background: var(--river); box-shadow: 0 0 0 1px var(--river); }
.timeline p, .timeline small { margin: 3px 0 0; color: var(--muted); font-size: .77rem; }

.alert { margin: 0 0 20px; padding: 13px 15px; border: 1px solid; border-radius: 4px; font-size: .86rem; }
.alert-success { color: #075c56; background: #e4f3ed; border-color: #b9dacc; }
.alert-error { color: #842f35; background: #fff0ef; border-color: #e9c2c2; }
.alert-warning { color: #76520f; background: #fff5dc; border-color: #ead39e; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, .85fr); background: var(--navy); }
.login-intro { padding: clamp(48px, 9vw, 140px); display: flex; flex-direction: column; justify-content: center; color: #fff; background: radial-gradient(circle at 5% 15%, rgba(30,160,143,.19), transparent 34%), linear-gradient(145deg, #0d2832, #153642); }
.login-wordmark { margin-bottom: clamp(54px, 10vh, 110px); font-size: 1.05rem; font-weight: 850; letter-spacing: .17em; }
.login-intro .eyebrow { color: #69cab9; }
.login-intro h1 { margin: 7px 0 20px; max-width: 680px; font-family: Georgia, serif; font-size: clamp(2.6rem, 5.3vw, 5.1rem); line-height: .98; font-weight: 400; letter-spacing: -.04em; }
.login-intro > p:not(.eyebrow) { max-width: 620px; color: #b9c9cd; line-height: 1.7; }
.boundary-list { margin: 34px 0 0; padding: 0; display: grid; gap: 12px; list-style: none; color: #d4dfe1; }
.boundary-list li::before { content: "—"; margin-right: 10px; color: #45b7a6; }
.login-card { align-self: center; margin: 40px; padding: clamp(28px, 5vw, 54px); background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
.login-card h2 { margin: 4px 0 26px; font-family: Georgia, serif; font-size: 2.4rem; font-weight: 500; }
.login-card .button { width: 100%; margin-top: 4px; }
.fine-print { margin: 22px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.55; }

.error-shell { width: min(620px, calc(100% - 40px)); min-height: 100vh; margin: auto; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.error-code { color: #c9d9d4; font-family: Georgia, serif; font-size: 8rem; line-height: .8; }
.error-shell h1 { margin: 4px 0 10px; font-family: Georgia, serif; font-size: 2.6rem; font-weight: 500; }
.error-shell > p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.footer { min-height: 70px; padding: 20px clamp(20px, 4vw, 64px); display: flex; justify-content: space-between; gap: 20px; color: #94a9ad; background: var(--navy); font-size: .76rem; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 50vh; }
  .login-card { width: min(620px, calc(100% - 40px)); margin: 40px auto; }
}

@media (max-width: 700px) {
  .topbar { align-items: flex-start; }
  .admin-identity { align-items: flex-end; flex-direction: column; }
  .admin-identity > span { display: none; }
  .page-shell { width: min(100% - 24px, 1440px); padding-top: 26px; }
  .page-heading, .section-heading, .action-row, .approved-actions, .approval-row, .draft-meta { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .record-grid { grid-template-columns: 1fr; }
  .record-grid div:nth-child(odd) { margin-right: 0; }
  .approved-actions > div { margin-right: 0; }
  .approved-actions .button { width: 100%; }
  .login-intro { padding: 44px 24px; }
  .login-card { margin-block: 20px; }
  .footer { flex-direction: column; }
}
