:root {
  --navy: #102640;
  --navy-2: #17365d;
  --blue: #205f8c;
  --blue-dark: #174866;
  --gold: #c99a3d;
  --canvas: #f5f6f7;
  --card: #ffffff;
  --ink: #172331;
  --muted: #667384;
  --line: #d9dee5;
  --soft-blue: #e8f0f7;
  --green: #176b45;
  --green-bg: #e5f4eb;
  --amber: #8a5704;
  --amber-bg: #fff1d6;
  --red: #9b2f2b;
  --red-bg: #fbe9e7;
  --slate-bg: #eef1f4;
  --shadow: 0 10px 30px rgba(16, 38, 64, .08);
  --radius: 10px;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.5 var(--sans); }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); }
.shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }
.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; }

.site-header { background: var(--navy); color: #fff; border-bottom: 3px solid var(--gold); }
.header-inner { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 13px; color: #fff; text-decoration: none; }
.brand img { width: 54px; height: 54px; object-fit: contain; }
.brand strong { display: block; font-family: var(--serif); font-size: 20px; letter-spacing: .15px; }
.brand small { display: block; margin-top: 2px; color: #b9c7d5; font-size: 13px; letter-spacing: .3px; }
.header-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.quiet-link, .quiet-button { border: 1px solid rgba(255,255,255,.24); border-radius: 7px; background: transparent; color: #fff; padding: 8px 11px; text-decoration: none; cursor: pointer; }
.quiet-link:hover, .quiet-button:hover { background: rgba(255,255,255,.1); }

.app-nav { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 9px rgba(16,38,64,.05); }
.nav-inner { display: flex; gap: 2px; overflow-x: auto; }
.nav-tab { flex: 0 0 auto; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); padding: 14px 17px 12px; font-weight: 700; cursor: pointer; }
.nav-tab:hover { color: var(--navy-2); background: #f7f9fb; }
.nav-tab.active { color: var(--navy-2); border-bottom-color: var(--gold); }

.app-main { padding: 32px 0 70px; }
.view[hidden] { display: none !important; }
.page-heading { margin: 0 0 22px; max-width: 900px; }
.page-heading h1 { margin: 2px 0 7px; color: var(--navy-2); font: 700 clamp(28px, 3vw, 40px)/1.15 var(--serif); }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow, .section-number { margin: 0 !important; color: var(--blue); font: 800 11px/1.3 var(--mono); letter-spacing: 1.25px; text-transform: uppercase; }
.split-heading { max-width: none; display: flex; align-items: end; justify-content: space-between; gap: 24px; }

.button { min-height: 40px; border: 1px solid var(--blue); border-radius: 7px; padding: 9px 14px; background: #fff; color: var(--blue-dark); font-weight: 750; cursor: pointer; }
.button:hover { background: var(--soft-blue); }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); }
.button.ghost { border-color: var(--line); color: var(--ink); }
.button.danger-ghost { border-color: #e4b5b1; color: var(--red); }
.button.danger-ghost:hover { background: var(--red-bg); }
.button.small { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--slate-bg); color: var(--navy); font-size: 26px; line-height: 1; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.summary-grid { display: grid; gap: 12px; }
.dashboard-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.cost-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.summary-card { min-height: 105px; padding: 17px 18px; background: #fff; border: 1px solid var(--line); border-top: 4px solid #8093a6; border-radius: var(--radius); box-shadow: var(--shadow); }
.summary-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .55px; text-transform: uppercase; }
.summary-card strong { display: block; margin-top: 7px; color: var(--navy-2); font-size: 25px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary-card small { display: block; margin-top: 7px; color: var(--muted); }
.summary-card small span { display: inline; font-size: inherit; font-weight: inherit; letter-spacing: 0; text-transform: none; }
.summary-card.emphasis { border-top-color: var(--blue); background: linear-gradient(145deg, #fff, #eff5fa); }
.summary-card.eligible { border-top-color: var(--green); }
.summary-card.review { border-top-color: var(--gold); background: #fffbf2; }
.summary-card.local { border-top-color: #6d7782; }

.filter-card { display: flex; align-items: end; gap: 14px; margin-bottom: 18px; padding: 15px; box-shadow: none; }
.field { display: block; min-width: 0; }
.field.grow { flex: 1 1 360px; }
.field > span { display: block; margin-bottom: 6px; color: #3e4b59; font-size: 12px; font-weight: 800; }
.field em { color: var(--red); font-style: normal; font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #aeb8c3; border-radius: 7px; background: #fff; color: var(--ink); padding: 10px 11px; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid rgba(32,95,140,.18); border-color: var(--blue); }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: #f0f2f4; color: #68727d; }
.check-field { display: flex; align-items: center; gap: 8px; min-height: 42px; white-space: nowrap; color: #3e4b59; font-weight: 700; }
.check-field input { width: 17px; height: 17px; accent-color: var(--blue); }
.field-help { position: relative; display: inline-flex; align-items: center; margin-left: 6px; vertical-align: middle; }
.field-help-trigger { width: 21px; height: 21px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--blue); border-radius: 50%; background: var(--soft-blue); color: var(--blue-dark); font: 850 12px/1 var(--sans); cursor: help; }
.field-help-trigger:hover, .field-help-trigger:focus-visible, .field-help.open .field-help-trigger { outline: 0; background: var(--blue); color: #fff; box-shadow: 0 0 0 3px rgba(32,95,140,.18); }
.field-tooltip { position: fixed; z-index: 190; max-width: calc(100vw - 32px); padding: 10px 12px; border: 1px solid #37516c; border-radius: 7px; background: var(--navy); color: #fff; box-shadow: 0 12px 32px rgba(7,18,31,.28); font: 500 12px/1.45 var(--sans); letter-spacing: 0; text-align: left; text-transform: none; white-space: normal; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-3px); transition: opacity .14s ease, transform .14s ease, visibility .14s ease; }
.field-help:hover .field-tooltip, .field-help:focus-within .field-tooltip, .field-help.open .field-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }

.table-card { overflow: hidden; }
.table-scroll { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 920px; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 11px 12px; background: #edf1f5; color: #435264; border-bottom: 1px solid #cdd4dc; text-align: left; font-size: 11px; letter-spacing: .45px; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid #e5e9ee; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr[data-id] { cursor: pointer; }
.data-table tbody tr[data-id]:hover { background: #f6f9fb; }
.data-table .number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-title { display: block; color: var(--navy-2); font-weight: 800; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.table-action { border: 0; background: transparent; color: var(--blue); font-weight: 750; cursor: pointer; padding: 4px; }
.table-action + .table-action { margin-left: 5px; }
.table-action.danger-text { color: var(--red); }
.line-actions { white-space: nowrap; }
.empty-state, .line-empty { padding: 34px; text-align: center; color: var(--muted); }
.empty-state h2 { margin: 0 0 4px; color: var(--navy-2); font: 700 22px var(--serif); }
.empty-state p { margin: 0; }
.line-empty { padding: 22px; border-top: 1px dashed var(--line); }

.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; background: var(--slate-bg); color: #4c5866; font-size: 11px; font-weight: 850; letter-spacing: .45px; text-transform: uppercase; }
.status-pill.active { background: var(--green-bg); color: var(--green); }
.status-pill.draft { background: var(--slate-bg); }
.status-pill.submitted { background: var(--amber-bg); color: var(--amber); }
.status-pill.approved { background: var(--green-bg); color: var(--green); }
.status-pill.archived { background: #ece7e6; color: #665552; }

.editor-toolbar { position: sticky; top: 49px; z-index: 20; display: flex; align-items: center; gap: 12px; margin: -12px 0 24px; padding: 10px; background: rgba(245,246,247,.95); border: 1px solid var(--line); border-radius: 9px; backdrop-filter: blur(8px); }
.toolbar-title { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 750; }
.toolbar-actions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; justify-content: end; gap: 7px; }
.editor-heading { margin-bottom: 18px; }

.warning-panel { margin-bottom: 18px; border: 1px solid #e7c477; border-radius: var(--radius); background: var(--amber-bg); color: #5c430f; padding: 15px 18px; }
.warning-heading { display: flex; justify-content: space-between; gap: 12px; }
.warning-heading span { min-width: 28px; padding: 2px 8px; border-radius: 999px; background: #fff; text-align: center; font-weight: 850; }
.warning-panel ul { margin: 10px 0 0; padding-left: 20px; }
.warning-panel li + li { margin-top: 6px; }

.form-section { margin-bottom: 18px; padding: 22px; }
.form-section.compact { padding-bottom: 24px; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.section-heading h2 { margin: 3px 0 3px; color: var(--navy-2); font: 700 24px/1.2 var(--serif); }
.section-heading p:not(.section-number) { margin: 0; color: var(--muted); }
.action-heading { align-items: center; }
.form-grid { display: grid; gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.deployment-print-details { display: none; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.callout, .privacy-note { margin: -3px 0 16px; padding: 12px 14px; border-left: 4px solid var(--gold); background: #fff9ed; color: #5f4b21; }
.privacy-note { margin: 0 0 18px; border: 1px solid #b8cadb; border-left: 4px solid var(--blue); border-radius: 8px; background: var(--soft-blue); color: #294762; }
.line-table { min-width: 980px; box-shadow: none; }
.line-table th { top: 0; }
.classification-stack { display: grid; gap: 3px; min-width: 170px; font-size: 12px; }
.classification-stack span { display: flex; justify-content: space-between; gap: 8px; }

.guidance-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.guidance-card { padding: 18px; }
.guidance-card h2 { margin: 0 0 7px; color: var(--navy-2); font: 700 20px var(--serif); }
.guidance-card p { margin: 0 0 13px; color: var(--muted); }
.guidance-note { margin-top: 16px; padding: 20px; }
.guidance-note h2 { margin: 0 0 7px; color: var(--navy-2); }
.guidance-note p { margin: 0; }

.toast { position: fixed; right: 22px; top: 22px; z-index: 1000; max-width: min(420px, calc(100% - 44px)); padding: 12px 15px; border-radius: 8px; background: var(--navy); color: #fff; box-shadow: 0 16px 40px rgba(0,0,0,.22); }
.toast.error { background: var(--red); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(7,18,31,.65); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(900px, 100%); max-height: min(92vh, 960px); display: flex; flex-direction: column; background: #fff; border-radius: 12px; box-shadow: 0 30px 90px rgba(0,0,0,.32); overflow: hidden; }
.modal > header { display: flex; justify-content: space-between; align-items: start; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal h2 { margin: 3px 0 0; color: var(--navy-2); font: 700 26px var(--serif); }
.modal form { min-height: 0; display: flex; flex-direction: column; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal footer { display: flex; justify-content: end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); background: #f8f9fa; }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.modal-grid .full { grid-column: span 2; }
.modal-subheading { grid-column: span 2; margin: 5px 0 -2px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--navy-2); font-size: 12px; font-weight: 850; letter-spacing: .65px; text-transform: uppercase; }
.rate-preview { grid-column: span 2; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; padding: 12px; background: var(--soft-blue); border-radius: 8px; }
.rate-preview span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.rate-preview strong { display: block; margin-top: 2px; color: var(--navy-2); font-size: 17px; }
.modal-help { margin: 0; padding: 11px 13px; border-radius: 7px; background: #f4f6f8; color: var(--muted); }
.modal-help.full { grid-column: span 2; }

.loading-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; background: rgba(245,246,247,.94); }
.loading-overlay[hidden] { display: none; }
.loading-card { width: min(460px, 100%); display: grid; justify-items: center; text-align: center; gap: 8px; padding: 32px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.loading-card strong { color: var(--navy-2); font-size: 18px; }
.loading-card small { color: var(--muted); }
.spinner { width: 30px; height: 30px; border: 3px solid #d9e2ea; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .cost-summary { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-3 { grid-column: span 2; }
  .editor-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .toolbar-actions { width: 100%; margin-left: 0; justify-content: flex-start; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 1440px); }
  .header-inner { padding: 12px 0; align-items: flex-start; }
  .brand strong { font-size: 17px; }
  .brand small { font-size: 12px; }
  .brand img { width: 44px; height: 44px; }
  .header-actions { justify-content: end; }
  .quiet-link, .quiet-button { padding: 6px 8px; font-size: 12px; }
  .app-main { padding-top: 22px; }
  .split-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-summary, .cost-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .filter-card { align-items: stretch; flex-direction: column; }
  .form-grid.three, .modal-grid { grid-template-columns: 1fr; }
  .span-2, .span-3, .modal-grid .full, .modal-subheading, .rate-preview { grid-column: 1; }
  .action-heading { align-items: flex-start; flex-direction: column; }
  .guidance-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 10px; }
  .modal { max-height: 96vh; }
  .rate-preview { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .editor-toolbar { top: 49px; }
}

@media (max-width: 470px) {
  .header-inner { display: block; }
  .header-actions { margin-top: 10px; justify-content: flex-start; }
  .dashboard-summary, .cost-summary { grid-template-columns: 1fr; }
  .summary-card { min-height: 90px; }
  .form-section { padding: 17px; }
  .toolbar-actions .button { flex: 1 1 auto; }
}

@media print {
  @page { margin: .55in; }
  body { background: #fff; color: #000; font-size: 11px; }
  .site-header, .app-nav, .editor-toolbar, .button, .field-help, .loading-overlay, .toast, .modal-backdrop, #view-dashboard, #view-rates, #view-guidance { display: none !important; }
  .shell { width: 100%; }
  .app-main { padding: 0; }
  #view-editor { display: block !important; }
  .card, .summary-card { box-shadow: none; break-inside: avoid; }
  .cost-summary { grid-template-columns: repeat(4, 1fr); }
  .summary-card { min-height: 72px; padding: 10px; }
  .summary-card strong { font-size: 18px; }
  .form-section { padding: 12px; margin-bottom: 10px; }
  .form-grid { display: none; }
  .deployment-print-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
  .deployment-print-detail { min-width: 0; }
  .deployment-print-detail.wide { grid-column: 1 / -1; }
  .deployment-print-detail dt { margin: 0 0 2px; color: #334155; font-size: 8px; font-weight: 850; letter-spacing: .45px; text-transform: uppercase; }
  .deployment-print-detail dd { margin: 0; color: #000; font-size: 10px; line-height: 1.35; overflow-wrap: anywhere; white-space: pre-wrap; }
  .table-scroll { overflow: visible; }
  .data-table { min-width: 0; font-size: 9px; }
  .data-table th, .data-table td { padding: 5px; }
  .line-empty { display: none !important; }
}
