:root {
  --paper: #f4f1e8;
  --paper-deep: #e9e3d3;
  --ink: #18221f;
  --muted: #59635d;
  --line: #c9c6bb;
  --forest: #164c3f;
  --forest-dark: #0c332a;
  --mint: #b8e2cf;
  --coral: #e36f54;
  --gold: #d9a82e;
  --sky: #75b9c1;
  --white: #fffefa;
  --danger: #a53d32;
  --shadow: 0 18px 50px rgba(24, 34, 31, .09);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Geist, "Avenir Next", "Segoe UI", sans-serif; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #0b6670; outline-offset: 3px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; background: var(--ink); color: white; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.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; }

.topbar { position: sticky; top: 12px; z-index: 20; width: min(1180px, calc(100% - 32px)); margin: 12px auto 0; padding: 10px 12px; display: flex; align-items: center; gap: 20px; background: rgba(255,254,250,.94); border: 1px solid rgba(24,34,31,.14); box-shadow: 0 8px 30px rgba(24,34,31,.08); backdrop-filter: blur(18px); border-radius: var(--radius); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 760; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--white); background: var(--forest); border-radius: 4px; font-size: 12px; }
.topbar nav { display: flex; gap: 20px; margin-left: auto; }
.topbar nav a { color: var(--muted); font-size: 14px; text-decoration: none; }
.topbar nav a:hover { color: var(--ink); }

main { overflow-x: hidden; width: 100%; max-width: 100%; }
.hero { width: min(1180px, calc(100% - 32px)); min-height: 720px; margin: 0 auto; padding: 110px 0 76px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 70px; align-items: center; }
.hero-copy { max-width: 820px; }
.eyebrow { margin: 0 0 14px; color: var(--forest); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 1180px; margin-bottom: 28px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.4rem, 6vw, 5.4rem); line-height: .98; font-weight: 500; letter-spacing: 0; }
h2 { margin-bottom: 10px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.65rem, 3vw, 2.7rem); line-height: 1.05; font-weight: 500; letter-spacing: 0; }
.hero-lede { max-width: 760px; color: var(--muted); font-size: clamp(1.04rem, 1.7vw, 1.25rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.privacy-note { position: relative; padding: 28px; background: var(--forest-dark); color: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.privacy-note::after { content: ""; position: absolute; width: 180px; height: 180px; right: -80px; bottom: -90px; border: 28px solid rgba(184,226,207,.15); border-radius: 50%; }
.privacy-title { font-size: 1.14rem; font-weight: 800; }
.privacy-note p:last-child { margin-bottom: 0; color: #d6e6df; }

.button { min-height: 44px; padding: 11px 16px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 5px; font-weight: 760; text-decoration: none; transition: transform .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--forest); color: white; }
.button-primary:hover { background: var(--forest-dark); }
.button-secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.button-secondary:hover { background: #ece9df; }
.button-danger { background: #fff7f5; color: var(--danger); border-color: #d8a09a; }
.button-full { width: 100%; }
.text-button { border: 0; padding: 6px; color: var(--forest); background: transparent; font-weight: 750; text-decoration: underline; }

.metrics-band { width: 100%; padding: 0 max(16px, calc((100vw - 1180px) / 2)); display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); background: var(--ink); color: var(--white); }
.metric { min-height: 186px; padding: 30px; border-right: 1px solid rgba(255,255,255,.14); display: flex; flex-direction: column; justify-content: center; }
.metric:last-child { border-right: 0; }
.metric-label { color: #c8d0cb; font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin: 8px 0; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1; }
.metric small { color: #adb8b2; }
.meter { height: 7px; margin: 2px 0 12px; background: #38443f; overflow: hidden; }
.meter span { display: block; width: 0; height: 100%; background: var(--mint); transition: width .45s ease; }

.dashboard, .preservation-grid { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 150px 0; display: grid; grid-template-columns: repeat(12, 1fr); grid-auto-flow: dense; gap: 16px; }
.panel { padding: 28px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(24,34,31,.04); }
.coverage-panel { grid-column: span 8; min-height: 500px; }
.readiness-panel { grid-column: span 4; min-height: 500px; background: #dcebe2; }
.mini-panel { grid-column: span 4; min-height: 190px; }
.alert-panel { background: #f5dfd7; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.panel-heading select { min-width: 180px; }
.coverage-chart { min-height: 290px; margin-top: 28px; display: grid; gap: 16px; align-content: center; }
.bar-row { display: grid; grid-template-columns: 145px minmax(0, 1fr) 64px; align-items: center; gap: 12px; }
.bar-label { font-size: 13px; font-weight: 750; }
.bar-track { height: 18px; background: #e1ded5; overflow: hidden; }
.bar-fill { height: 100%; background: var(--forest); transition: width .35s ease; }
.bar-value { color: var(--muted); font-size: 13px; text-align: right; }
.chart-note { margin: 24px 0 0; color: var(--muted); }
.signal-list { display: grid; gap: 12px; margin: 26px 0; }
.signal { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; }
.signal-dot { width: 34px; height: 34px; display: grid; place-items: center; color: var(--forest-dark); background: rgba(255,255,255,.65); border-radius: 50%; font-size: 12px; font-weight: 850; }
.signal p { margin: 0; font-size: 14px; }
.signal small { display: block; color: var(--muted); }
.audit-result { min-height: 66px; margin-top: 14px; padding: 13px; background: rgba(255,255,255,.6); border-left: 3px solid var(--forest); font-size: 14px; }
.mini-kicker { color: var(--muted); font-size: 13px; font-weight: 750; }
.mini-panel strong { display: block; margin: 12px 0; font-size: 3rem; line-height: 1; }
.mini-panel p { margin: 0; color: var(--muted); }

.catalog-section { padding: 150px max(16px, calc((100vw - 1180px) / 2)); background: var(--white); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; margin-bottom: 38px; }
.section-heading > div { max-width: 760px; }
.section-heading p:not(.eyebrow) { color: var(--muted); }
.toolbar { padding: 18px; display: grid; grid-template-columns: minmax(230px, 1.4fr) repeat(3, minmax(150px, .7fr)) auto; gap: 12px; align-items: end; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
label span, legend { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 760; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 11px; color: var(--ink); background: var(--white); border: 1px solid #aead9f; border-radius: 4px; }
textarea { resize: vertical; }
.toggle-field { min-height: 44px; padding: 10px; display: flex; align-items: center; gap: 8px; }
.toggle-field input { width: 18px; min-height: 18px; }
.toggle-field span { margin: 0; white-space: nowrap; }
.table-wrap { min-height: 360px; border: 1px solid var(--line); border-top: 0; overflow-x: auto; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 17px 16px; text-align: left; border-bottom: 1px solid #dedbd1; vertical-align: top; }
th { color: var(--muted); background: #f6f4ed; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.record-title { display: block; font-weight: 780; }
.record-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.record-archived { opacity: .58; }
.status-chip { display: inline-flex; width: fit-content; padding: 5px 9px; color: var(--forest-dark); background: var(--mint); border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-review { background: #f5dfad; }
.status-restricted { color: #742c26; background: #f4cbc6; }
.completeness { min-width: 120px; }
.completeness small { display: block; color: var(--muted); }
.mini-meter { width: 100%; height: 5px; margin-top: 7px; background: #dfddd4; }
.mini-meter span { display: block; height: 100%; background: var(--forest); }
.row-actions { display: flex; gap: 6px; }
.row-button { min-width: 44px; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); color: var(--ink); background: var(--white); border-radius: 4px; }
.empty-state { padding: 70px 20px; text-align: center; }

.preservation-grid { padding-bottom: 120px; }
.backup-planner { grid-column: span 8; }
.checklist-panel { grid-column: span 4; background: var(--forest-dark); color: var(--white); }
.checklist-panel .eyebrow { color: var(--mint); }
.backup-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 28px; }
.backup-rule { margin: 24px 0; padding: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; background: var(--paper); }
.rule-part { padding: 12px; border-left: 3px solid var(--coral); }
.rule-part.met { border-left-color: var(--forest); }
.rule-part strong { display: block; font-size: 1.4rem; }
.rule-part span { color: var(--muted); font-size: 12px; }
.location-builder { display: grid; grid-template-columns: 1.2fr .8fr auto; gap: 12px; align-items: end; }
.location-list { margin: 20px 0 0; padding: 0; display: grid; gap: 8px; list-style: none; }
.location-list li { padding: 10px 12px; display: flex; justify-content: space-between; gap: 12px; background: #efede6; }
.location-list button { border: 0; background: transparent; color: var(--danger); font-weight: 750; }
.checklist { display: grid; gap: 12px; margin: 28px 0; }
.check-item { padding: 11px 0; display: flex; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.16); }
.check-item input { width: 20px; min-height: 20px; accent-color: var(--mint); }
.check-item span { margin: 0; color: var(--white); font-size: 14px; }
.checklist-footer { display: flex; justify-content: space-between; align-items: center; color: #c8d6d0; font-size: 13px; }
.checklist-footer .text-button { color: var(--mint); }

.manifest-section { padding: 78px max(16px, calc((100vw - 1180px) / 2)); display: grid; grid-template-columns: 1fr auto; gap: 60px; align-items: center; background: var(--gold); }
.manifest-section > div:first-child { max-width: 700px; }
.manifest-actions { display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 8px; }
.file-button { position: relative; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.status-message { grid-column: 1 / -1; min-height: 20px; margin: 0; }
.guidance { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 150px 0; }
.guidance-heading { align-items: start; }
.guidance-heading > p { max-width: 430px; color: var(--muted); }
.guidance-list { border-top: 1px solid var(--line); }
details { padding: 22px 0; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-family: Georgia, serif; font-size: 1.35rem; }
details p { max-width: 850px; margin: 14px 0 0; color: var(--muted); }
footer { padding: 54px max(16px, calc((100vw - 1180px) / 2)); display: flex; justify-content: space-between; gap: 40px; background: var(--ink); color: white; }
footer p { max-width: 520px; margin: 6px 0 0; color: #b8c2bd; }

dialog { width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 30px 90px rgba(0,0,0,.32); }
dialog::backdrop { background: rgba(10,25,21,.7); backdrop-filter: blur(4px); }
dialog form { padding: 28px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.close-button { min-height: 40px; border: 0; background: transparent; color: var(--muted); font-weight: 750; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
fieldset { margin: 0; padding: 12px; border: 1px solid var(--line); }
.backup-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.backup-options label { display: flex; gap: 8px; align-items: center; }
.backup-options input { width: 18px; min-height: 18px; }
.backup-options span { margin: 0; }
.duplicate-warning { margin-top: 14px; padding: 12px; background: #f7e6ba; border-left: 3px solid var(--gold); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.form-error { min-height: 22px; color: var(--danger); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: 360px; padding: 13px 16px; color: white; background: var(--forest-dark); border-radius: 5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(16px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 940px) {
  .topbar nav { display: none; }
  .topbar .button { margin-left: auto; }
  .hero { min-height: auto; grid-template-columns: 1fr; gap: 38px; padding: 90px 0 70px; }
  .privacy-note { max-width: 620px; }
  .metrics-band { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.14); }
  .coverage-panel, .readiness-panel, .backup-planner, .checklist-panel { grid-column: span 12; }
  .toolbar { grid-template-columns: repeat(2, 1fr); }
  .search-field { grid-column: span 2; }
  .backup-controls { grid-template-columns: repeat(2, 1fr); }
  .manifest-section { grid-template-columns: 1fr; gap: 30px; }
}

@media (max-width: 640px) {
  .topbar { width: calc(100% - 20px); top: 6px; margin-top: 6px; }
  .brand span:last-child { display: none; }
  .hero, .dashboard, .preservation-grid, .guidance { width: calc(100% - 24px); }
  .hero { padding-top: 70px; }
  h1 { font-size: clamp(2.65rem, 13vw, 4rem); }
  .hero-actions { display: grid; }
  .metrics-band { grid-template-columns: 1fr; padding: 0; }
  .metric { min-height: 145px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.14); }
  .dashboard, .preservation-grid { padding: 92px 0; }
  .mini-panel { grid-column: span 12; }
  .panel { padding: 20px; }
  .panel-heading, .section-heading, .guidance-heading { display: grid; gap: 18px; }
  .panel-heading select { width: 100%; min-width: 0; }
  .bar-row { grid-template-columns: 95px minmax(0, 1fr) 44px; gap: 8px; }
  .catalog-section { padding-top: 92px; padding-bottom: 92px; }
  .toolbar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .backup-controls, .backup-rule, .location-builder, .manifest-actions, .form-grid, .backup-options { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  footer { display: grid; }
  dialog form { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
