:root {
  --navy: #092b35;
  --navy-soft: #17424d;
  --teal: #007e80;
  --aqua: #00bec3;
  --yellow: #ffca4b;
  --yellow-soft: #fff3cc;
  --paper: #fff;
  --wash: #f2f8f8;
  --line: #d5e3e5;
  --ink: #163943;
  --muted: #5b7077;
  --danger: #9a2f2f;
  --danger-soft: #fff0f0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
a { color: var(--teal); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #0b6fce;
  outline-offset: 2px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.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; top: -100px; left: 12px; z-index: 1000; padding: 12px 15px; background: var(--paper); border: 2px solid var(--teal); }
.skip-link:focus { top: 12px; }
.site-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px clamp(16px, 4vw, 56px); color: #fff; background: var(--navy); }
.brand-lockup, .top-nav { display: flex; align-items: center; gap: 16px; }
.brand { color: #fff; font-size: clamp(1.35rem, 2.7vw, 1.9rem); font-weight: 850; letter-spacing: -.06em; text-decoration: none; white-space: nowrap; }
.brand b { color: var(--yellow); }
.brand-context { color: #b8d1d5; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.top-nav { flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.top-nav a, .logout-form button { color: #eefafa; border: 0; background: transparent; padding: 7px 4px; text-decoration: none; font-size: .9rem; }
.top-nav a:hover, .logout-form button:hover { color: var(--yellow); }
.logout-form { margin: 0; }
.page-shell { width: min(1440px, 100%); margin: 0 auto; padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 56px) 60px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: .76rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3 { color: var(--navy); letter-spacing: -.035em; }
h1 { margin: 0 0 10px; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.08; }
h2 { margin: 0 0 9px; font-size: clamp(1.25rem, 2.4vw, 1.8rem); }
h3 { margin: 0 0 8px; font-size: 1rem; }
p { line-height: 1.55; }
.muted, .help, .fine-print { color: var(--muted); }
.fine-print { font-size: .82rem; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; padding: 9px 14px; color: var(--navy); background: var(--paper); font-weight: 700; text-decoration: none; }
.button:hover { border-color: var(--teal); }
.button-primary { border-color: var(--teal); color: #fff; background: var(--teal); }
.button-primary:hover { background: #006b6d; }
.button-yellow { border-color: #d9a51f; background: var(--yellow); }
.button-danger { border-color: #cc8989; color: var(--danger); background: var(--danger-soft); }
.button-small { min-height: 35px; padding: 6px 10px; font-size: .85rem; }
.button-wide { width: 100%; }
.text-link { font-weight: 700; }
.flash-stack { width: min(1440px, 100%); margin: 0 auto; padding: 15px clamp(16px, 4vw, 56px) 0; }
.flash { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 7px; background: #eaf7f4; }
.flash-error { border-color: #e8abab; background: var(--danger-soft); color: var(--danger); }
.flash-warning { border-color: #e4cb77; background: var(--yellow-soft); }
.auth-card { width: min(440px, 100%); margin: 7vh auto 0; padding: clamp(22px, 5vw, 40px); border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: 0 14px 40px #092b3510; }
.stack-form { display: grid; gap: 18px; }
.form-row { display: grid; gap: 7px; }
.form-row label { font-weight: 750; }
.form-row input, .form-row select, .form-row textarea, .stack-form input, .stack-form select, .stack-form textarea { width: 100%; min-height: 43px; border: 1px solid #b9ced1; border-radius: 6px; padding: 9px 11px; color: var(--ink); background: #fff; }
.form-row textarea, .stack-form textarea { min-height: 105px; resize: vertical; }
.help { margin: 0; font-size: .83rem; }
.error-summary, .field-errors { color: var(--danger); }
.error-summary { margin: 14px 0; padding: 12px 14px; border: 1px solid #e3a4a4; border-radius: 7px; background: var(--danger-soft); }
.field-errors { margin: 0; padding-left: 18px; font-size: .86rem; }
.non-field-errors { margin-bottom: 18px; }
.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 11px; margin-bottom: 26px; }
.metric-card { min-height: 110px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.metric-card strong { display: block; color: var(--navy); font-size: 1.85rem; line-height: 1.05; }
.metric-card span { display: block; margin-top: 9px; color: var(--muted); font-size: .8rem; line-height: 1.35; }
.metric-card.accent { border-color: #aedcda; background: #eaf8f6; }
.metric-card.warn { border-color: #e7d28a; background: var(--yellow-soft); }
.panel { border: 1px solid var(--line); border-radius: 11px; background: var(--paper); box-shadow: 0 5px 16px #092b3508; }
.panel + .panel { margin-top: 20px; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 20px; }
.route-table-wrap { overflow-x: auto; }
.route-table { width: 100%; min-width: 850px; border-collapse: collapse; }
.route-table th, .route-table td { padding: 13px 14px; border-bottom: 1px solid #e5edef; text-align: left; vertical-align: top; }
.route-table th { color: var(--muted); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.route-table tr:last-child td { border-bottom: 0; }
.route-ref { display: inline-flex; min-width: 45px; justify-content: center; padding: 5px 7px; border-radius: 5px; color: #fff; background: var(--navy); font-weight: 800; }
.route-name { display: block; margin-top: 5px; font-weight: 700; }
.route-meta { display: block; margin-top: 4px; color: var(--muted); font-size: .82rem; }
.status-pill { display: inline-flex; padding: 5px 8px; border: 1px solid #acd6d3; border-radius: 999px; color: #056363; background: #eaf8f6; font-size: .76rem; font-weight: 750; }
.status-pill.planned { border-color: #ccd8da; color: var(--muted); background: #f3f7f7; }
.status-pill.completed { border-color: #b9d592; color: #3e671f; background: #eff8e6; }
.status-pill.pending { border-color: #e4cc7a; color: #74550a; background: var(--yellow-soft); }
.status-pill.rejected { border-color: #dfaaaa; color: var(--danger); background: var(--danger-soft); }
.status-pill.approved, .status-pill.accepted { border-color: #b9d592; color: #3e671f; background: #eff8e6; }
.route-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 20px; align-items: start; }
.subtle-card { padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--wash); }
.subtle-card h3 { margin-bottom: 10px; }
.source-draft-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.source-card, .draft-card { padding: 16px; border-radius: 9px; }
.source-card { border: 1px solid #cbd8dc; background: #f5f8f9; }
.draft-card { border: 1px solid #a8d8d5; background: #effaf8; }
.source-card h3, .draft-card h3 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.label-tag { padding: 4px 7px; border-radius: 4px; color: var(--muted); background: #e2ebed; font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.draft-card .label-tag { color: #086666; background: #d4f1ed; }
.definition-list { display: grid; grid-template-columns: minmax(110px, .5fr) 1fr; gap: 8px 15px; margin: 0; }
.definition-list dt { color: var(--muted); font-size: .85rem; }
.definition-list dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.map-shell { min-height: 360px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #dfeff0; }
.map { min-height: 360px; }
.map-note { margin: 0; padding: 10px 13px; border-top: 1px solid var(--line); color: var(--muted); background: #f7fbfb; font-size: .82rem; }
.workspace-form { display: grid; gap: 20px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(290px, .6fr); gap: 20px; align-items: start; }
.editor-map-panel { position: sticky; top: 16px; }
.editor-map { min-height: 560px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 13px; padding: 10px 13px; border-top: 1px solid var(--line); color: var(--muted); background: #f7fbfb; font-size: .78rem; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 24px; border-top: 3px solid var(--teal); }
.legend-line.source { border-top-color: #7b9097; border-top-style: dashed; }
.legend-dot { width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: #b45113; box-shadow: 0 0 0 1px #b45113; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.place-help { padding: 11px 13px; border-left: 3px solid var(--yellow); background: var(--yellow-soft); font-size: .83rem; line-height: 1.5; }
.place-editor { min-width: 0; margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 8px; }
.place-editor legend { padding: 0 6px; color: var(--navy); font-weight: 800; }
.place-rows { display: grid; gap: 12px; margin: 12px 0; }
.place-row { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--wash); }
.place-row-grid { display: grid; grid-template-columns: 1.3fr .8fr .8fr .8fr; gap: 8px; }
.place-row-grid .wide { grid-column: 1 / -1; }
.place-row label { display: grid; gap: 4px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.place-row input { width: 100%; min-height: 37px; border: 1px solid #b9ced1; border-radius: 5px; padding: 7px 8px; background: #fff; }
.place-row-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.advanced-fields { margin-top: 16px; }
.advanced-fields summary { cursor: pointer; color: var(--teal); font-weight: 700; }
.history-list { display: grid; gap: 12px; }
.revision-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.revision-number { display: flex; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 50%; color: #fff; background: var(--navy); font-weight: 850; }
.revision-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.comparison { overflow-x: auto; }
.comparison-table { width: 100%; min-width: 650px; border-collapse: collapse; }
.comparison-table th, .comparison-table td { padding: 11px; border: 1px solid var(--line); text-align: left; vertical-align: top; white-space: pre-wrap; }
.comparison-table th { width: 20%; background: var(--wash); }
.action-card { width: min(620px, 100%); margin: 20px auto; }
.private-label { display: inline-flex; padding: 5px 8px; border-radius: 4px; color: #715205; background: var(--yellow-soft); font-size: .74rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.inbox-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .route-grid, .editor-grid { grid-template-columns: 1fr; }
  .editor-map-panel { position: static; order: -1; }
  .editor-map { min-height: 430px; }
}
@media (max-width: 680px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .brand-context { display: none; }
  .top-nav { width: 100%; justify-content: flex-start; }
  .page-heading { flex-direction: column; }
  .heading-actions { justify-content: flex-start; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-draft-grid { grid-template-columns: 1fr; }
  .panel-heading, .panel-body { padding: 15px; }
  .revision-row { grid-template-columns: auto minmax(0, 1fr); }
  .revision-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .definition-list { grid-template-columns: 1fr; gap: 2px; }
  .definition-list dd { margin-bottom: 8px; }
  .place-row-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .place-row-grid label:first-child, .place-row-grid .wide { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
