/* =============================================================================
   Orange County Roadway Prioritization Tool, Stylesheet
   Identity: civil engineering ranking ledger on the HNTB brand system.
   Type: Overpass (open Interstate) for UI/headlines, Overpass Mono for figures.
   Color: HNTB Pantone 433 primary #1B242A, 646 blue #5482AB, 172 orange spark only.
   ============================================================================= */

:root {
  /* HNTB brand palette: Pantone 433 primary, 646 blue secondary, 172 orange spark */
  --ink:        #1B242A;   /* Pantone 433 — primary structure + text */
  --ink-2:      #33414B;
  --ink-soft:   #51626F;   /* Pantone 7545 — muted text */
  --paper:      #F2F4F5;   /* cool page ground */
  --surface:    #FFFFFF;
  --rule:       #E2E5E4;   /* hairline */
  --rule-2:     #C9CAC8;   /* Cool Gray 3 — stronger rule */
  --blue:       #5482AB;   /* Pantone 646 — secondary accent */
  --blue-light: #93B1CC;   /* Pantone 644 */
  --green:      #3F9C35;   /* highlight green — status only */
  --gold:       #DFAA25;   /* highlight gold */
  --gray:       #8996A0;   /* Pantone 7544 */
  --bg-soft:    #ECEFEF;
  --accent:     #F9461C;   /* Pantone 172 — SPARK ONLY: stripe, active tick */
  --accent-2:   #C9381A;
  --accent-soft:#FBEDE6;
  --danger:     #9B2C2C;

  --display: 'Overpass', 'Arial Narrow', Arial, sans-serif;
  --sans:    'Overpass', Arial, sans-serif;
  --mono:    'Overpass Mono', ui-monospace, Consolas, monospace;

  --radius: 3px;
  --t: 0.16s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink-2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

/* ----------------------------------------------------------------------------
   Header — plan-sheet title block
   ---------------------------------------------------------------------------- */
.oc-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-top: 3px solid var(--ink);
  display: flex; align-items: center; gap: 18px;
  padding: 13px 26px 15px;
}
/* HNTB spark-to-rule: orange spark (Pantone 172) igniting into the secondary blue */
.oc-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg,
    var(--accent) 0, var(--accent) 60px, var(--blue) 150px,
    var(--blue-light) 55%, var(--rule) 100%);
}
.header-brand { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.header-seal { height: 46px; width: 46px; object-fit: contain; flex-shrink: 0; }
.header-text { min-width: 0; padding-left: 16px; border-left: 1px solid var(--rule-2); }
.header-county {
  font-family: var(--sans); font-weight: 700;
  font-size: .62rem; text-transform: uppercase; letter-spacing: .2em; color: var(--blue);
}
.header-title {
  font-family: var(--display); font-size: 1.34rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .005em; line-height: 1.04; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ----------------------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--radius);
  font-family: var(--sans); font-size: .78rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap;
  text-decoration: none; transition: background var(--t), border-color var(--t), color var(--t);
}
.btn-primary   { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #06182f; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--rule-2); }
.btn-secondary:hover { border-color: var(--ink); }
.btn-outline   { background: var(--surface); color: var(--ink); border-color: var(--rule-2); }
.btn-outline:hover { border-color: var(--ink); }
.btn-ghost     { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { color: var(--ink); background: var(--paper); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #7f2222; }
.btn-sm { padding: 5px 11px; font-size: .76rem; }
.btn-lg { padding: 10px 20px; font-size: .9rem; }

/* Cloud-save status — quiet mono indicator, not a pill */
.storage-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .02em;
  padding: 5px 10px; border-radius: var(--radius);
  border: 1px solid var(--rule-2); background: var(--surface);
  color: var(--ink-soft); white-space: nowrap;
}
.storage-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-soft); flex-shrink: 0;
}
.storage-badge.connected { color: var(--ink); border-color: var(--rule-2); }
.storage-badge.connected::before { background: var(--green); }
.storage-badge.disconnected { color: var(--ink-soft); border-color: var(--rule-2); }
.storage-badge.disconnected::before { background: var(--gray); }

.btn-icon {
  background: none; border: 1px solid transparent; cursor: pointer;
  color: var(--ink-soft); padding: 5px 9px; border-radius: var(--radius);
  font-family: var(--sans); font-size: .76rem; font-weight: 600;
  transition: color var(--t), background var(--t);
}
.btn-icon:hover { color: var(--ink); background: var(--paper); }

/* ----------------------------------------------------------------------------
   Page
   ---------------------------------------------------------------------------- */
.page-content { max-width: 1080px; margin: 0 auto; padding: 30px 22px 72px; }

/* ----------------------------------------------------------------------------
   Filters — tabs with an accent underline, not pills
   ---------------------------------------------------------------------------- */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  margin-bottom: 22px; padding: 0 0 0 2px;
  border-bottom: 1px solid var(--rule);
}
.filter-label {
  font-family: var(--mono); font-size: .64rem; text-transform: uppercase;
  letter-spacing: .16em; color: var(--ink-soft); margin-right: 12px;
}
.filter-btn {
  padding: 9px 13px; border: none; background: none; cursor: pointer;
  font-family: var(--sans); font-size: .82rem; font-weight: 600; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t);
}
.filter-btn:hover { color: var(--ink); }
.filter-btn.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ----------------------------------------------------------------------------
   Summary legend (replaces stat chips)
   ---------------------------------------------------------------------------- */
.stats-bar {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px;
  margin-bottom: 18px;
}
.ls-total { font-size: .92rem; color: var(--ink); }
.ls-total strong { font-family: var(--mono); font-weight: 600; font-size: 1.05rem; }
.ls-type { font-size: .78rem; color: var(--ink-soft); }
.ls-type strong { font-family: var(--mono); font-weight: 600; color: var(--ink); }

/* ----------------------------------------------------------------------------
   Ranked ledger
   ---------------------------------------------------------------------------- */
.ledger-head, .project-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 52px 200px 188px;
  align-items: center; gap: 18px;
}
.ledger-head {
  padding: 0 14px 7px; border-bottom: 1px solid var(--rule-2);
  font-family: var(--mono); font-size: .62rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--ink-soft);
}
.ledger-head .lh-actions { text-align: right; }

.project-card {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 13px 14px;
  transition: background var(--t);
}
.project-card:hover { background: #FAFBFC; }

.card-rank {
  font-family: var(--mono); font-size: .95rem; font-weight: 600;
  color: var(--ink-soft); text-align: right;
}
.project-card:first-child .card-rank { color: var(--ink); }

.card-body { min-width: 0; }
.card-name {
  font-size: .96rem; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-segment {
  font-size: .76rem; color: var(--ink-soft); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Two-letter engineering type tag */
.type-tag {
  display: inline-block; font-family: var(--mono); font-size: .72rem; font-weight: 600;
  letter-spacing: .04em; color: var(--ink); border: 1px solid var(--rule-2);
  border-radius: 2px; padding: 1px 6px; background: var(--surface);
}
.project-card[data-type="safety-corridor"] .type-tag,
.project-card[data-type="safety-signalized"] .type-tag,
.project-card[data-type="safety-unsignalized"] .type-tag {
  color: var(--blue); border-color: var(--blue-light);
}

/* Score meter — the signature. Mono value + survey-scale bar; lead rank in amber. */
.card-score { display: flex; align-items: center; gap: 12px; }
.score-num {
  font-family: var(--mono); font-size: 1.05rem; font-weight: 600; color: var(--ink);
  min-width: 30px; text-align: right;
}
.score-meter {
  position: relative; flex: 1; height: 6px; background: var(--rule);
  border-radius: 1px; overflow: hidden;
}
.score-fill { position: absolute; inset: 0 auto 0 0; height: 100%; background: var(--blue); }
.score-fill--lead { background: var(--ink); }

.card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

/* Legacy hooks kept harmless (no longer emitted, but referenced by older code) */
.type-badge { display: inline-block; font-family: var(--mono); font-size: .72rem;
  font-weight: 600; color: var(--ink); border: 1px solid var(--rule-2);
  border-radius: 2px; padding: 1px 6px; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.score-value { font-family: var(--mono); font-weight: 600; }
.score-label { font-size: .7rem; color: var(--ink-soft); }
.score-high, .score-mid, .score-low { color: var(--ink); }

/* ----------------------------------------------------------------------------
   Empty state
   ---------------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 84px 20px; color: var(--ink-soft); }
.empty-state .empty-icon {
  width: 34px; height: 34px; margin: 0 auto 16px; border: 1px solid var(--rule-2);
  position: relative;
}
.empty-state .empty-icon::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 1px;
  background: var(--accent); transform: translate(-50%, -50%);
}
.empty-state h3 { font-family: var(--display); font-size: 1.05rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.empty-state p { font-size: .86rem; }

/* ----------------------------------------------------------------------------
   Modal
   ---------------------------------------------------------------------------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(11, 37, 69, .45);
  z-index: 200; padding: 24px; overflow-y: auto;
}
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-container {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--rule-2); box-shadow: 0 24px 60px rgba(11, 37, 69, .26);
  width: 100%; max-width: 880px; margin: auto;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--ink); color: #fff;
}
.modal-header h2 { font-family: var(--display); font-size: 1.05rem; font-weight: 600; }
.modal-close {
  background: none; border: none; color: rgba(255,255,255,.75);
  font-size: 1.25rem; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 3px;
}
.modal-close:hover { background: rgba(255,255,255,.16); color: #fff; }
.modal-body { padding: 24px; overflow-y: auto; max-height: calc(100vh - 200px); }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 24px; border-top: 1px solid var(--rule);
}

/* ----------------------------------------------------------------------------
   Form sections
   ---------------------------------------------------------------------------- */
.form-section {
  margin-bottom: 20px; padding: 0 0 18px; border-bottom: 1px solid var(--rule);
}
.form-section:last-child { border-bottom: none; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h3 {
  font-family: var(--display); font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.weight-chip {
  font-family: var(--mono); font-size: .68rem; font-weight: 500; letter-spacing: .04em;
  color: var(--ink-soft); border: none; background: none; padding: 0;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-group.half { grid-column: span 2; }

label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
label .required { color: var(--accent-2); margin-left: 2px; }

input[type="text"], input[type="number"], select, textarea {
  padding: 8px 10px; border: 1px solid var(--rule-2); border-radius: var(--radius);
  font-family: var(--sans); font-size: .86rem; color: var(--ink); background: var(--surface);
  width: 100%; transition: border-color var(--t), box-shadow var(--t);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(11, 37, 69, .10);
}
input[type="number"] { -moz-appearance: textfield; font-family: var(--mono); }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.hint { font-size: .74rem; color: var(--ink-soft); margin-top: 2px; }
.hint a { color: var(--ink); font-weight: 600; }
.hint strong { color: var(--ink-2); }

.radio-group, .checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.radio-group label, .checkbox-group label { display: flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }

.info-box { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 10px 14px; font-size: .8rem; color: var(--ink-2); margin-top: 8px; }
.calc-box { background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--radius);
  padding: 10px 14px; font-size: .8rem; margin-top: 8px; display: flex; align-items: center; gap: 10px; }
.calc-box .calc-result { font-family: var(--mono); font-weight: 600; font-size: .95rem; color: var(--ink); }

/* LOS rating chips — A-F is a standard engineering color scale, kept but flattened */
.los-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 2px; font-family: var(--mono);
  font-weight: 600; font-size: .95rem; color: #fff; flex-shrink: 0;
}
.los-A { background: #2F7D4F; } .los-B { background: #5B9A3E; }
.los-C { background: #C9A227; color: #1a1a1a; } .los-D { background: #C77D1A; }
.los-E { background: #B85416; } .los-F { background: #9B2C2C; }

/* Live score preview — consistent with the ledger meter, not a navy KPI card */
.score-preview {
  display: flex; align-items: center; gap: 16px;
  background: var(--paper); border: 1px solid var(--rule-2); border-left: 3px solid var(--blue);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 22px;
}
.score-preview .preview-label {
  font-family: var(--mono); font-size: .64rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-soft);
}
.score-preview .preview-value { font-family: var(--mono); font-size: 2rem; font-weight: 600; color: var(--ink); line-height: 1; margin-left: auto; }
.score-preview .preview-max { font-family: var(--mono); font-size: .72rem; color: var(--ink-soft); }

.relative-note { background: var(--bg-soft); border: 1px solid var(--rule-2); border-radius: var(--radius);
  padding: 8px 12px; font-size: .76rem; color: var(--ink-2); margin-top: 8px; }

.map-panel { display: none; border: 1px solid var(--rule-2); border-radius: var(--radius); overflow: hidden; margin-top: 10px; }
.map-panel.open { display: block; }
.map-panel iframe { display: block; width: 100%; height: 420px; border: none; }
.map-panel-header { background: var(--paper); border-bottom: 1px solid var(--rule); padding: 8px 14px;
  font-size: .8rem; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; align-items: center; }

.breakdown-table { width: 100%; border-collapse: collapse; font-size: .84rem; margin-top: 12px; }
.breakdown-table th { background: var(--ink); color: #fff; text-align: left; padding: 8px 12px;
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.breakdown-table td { padding: 8px 12px; border-bottom: 1px solid var(--rule); }
.breakdown-table tr:last-child td { border-bottom: none; }
.breakdown-table .weighted-col { font-family: var(--mono); font-weight: 600; color: var(--ink); text-align: right; }

/* Program-type selection cards (first step of add) */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 22px; }
.type-card { border: 1px solid var(--rule-2); border-radius: var(--radius); padding: 16px 14px;
  cursor: pointer; display: flex; align-items: center; gap: 12px; transition: border-color var(--t), background var(--t); }
.type-card:hover { border-color: var(--ink); }
.type-card.selected { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--blue); }
.type-card .type-icon {
  font-family: var(--mono); font-size: .82rem; font-weight: 600; color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: 2px; padding: 3px 7px; flex-shrink: 0;
}
.type-card .type-name { font-size: .84rem; font-weight: 600; color: var(--ink-2); }

/* Confirm dialog */
.dialog-overlay { display: none; position: fixed; inset: 0; background: rgba(11, 37, 69, .45);
  z-index: 300; align-items: center; justify-content: center; padding: 20px; }
.dialog-overlay.open { display: flex; }
.dialog-box { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--rule-2);
  padding: 26px 30px; max-width: 420px; width: 100%; box-shadow: 0 24px 60px rgba(11,37,69,.26); }
.dialog-box h3 { font-family: var(--display); font-size: 1rem; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.dialog-box p { color: var(--ink-soft); font-size: .86rem; margin-bottom: 20px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* LOS auto-calculator panel */
.los-calc-panel { background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--radius); padding: 16px 18px; margin-top: 14px; }
.los-calc-header { font-family: var(--mono); font-size: .68rem; font-weight: 600; color: var(--ink);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 14px; }
.method-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.method-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px;
  border: 1px solid var(--rule-2); border-radius: var(--radius); font-size: .8rem; font-weight: 600;
  cursor: pointer; background: var(--surface); color: var(--ink-soft); transition: all var(--t); user-select: none; }
.method-pill input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.method-pill:hover { border-color: var(--ink); color: var(--ink); }
.method-pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ----------------------------------------------------------------------------
   Archived dropdown
   ---------------------------------------------------------------------------- */
.archive-wrap { position: relative; display: inline-block; }
.archive-panel { position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 90vw;
  max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--rule-2);
  border-radius: var(--radius); box-shadow: 0 18px 44px rgba(11,37,69,.22); padding: 8px; z-index: 200; display: none; }
.archive-panel.open { display: block; }
.archive-panel-head { font-family: var(--mono); font-size: .64rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-soft); margin: 4px 6px 8px; }
.archive-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid var(--rule); }
.archive-item:last-child { border-bottom: 0; }
.archive-item-name { font-size: .84rem; font-weight: 600; color: var(--ink); }
.archive-item-type { font-family: var(--mono); font-size: .68rem; color: var(--ink-soft); margin-top: 2px; }
.archive-item-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.archive-empty { font-size: .8rem; color: var(--ink-soft); padding: 14px; text-align: center; }

/* ----------------------------------------------------------------------------
   Print
   ---------------------------------------------------------------------------- */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .oc-header { position: relative !important; border-top: none !important; }
  .header-actions, .card-actions, .filter-bar, .stats-bar, .ledger-head,
  .modal-overlay, .dialog-overlay { display: none !important; }
  body { background: #fff; }
  .page-content { padding: 0; max-width: 100%; }
  .project-card { break-inside: avoid; page-break-inside: avoid; }
}

/* ----------------------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .oc-header { flex-wrap: wrap; padding: 12px 16px; }
  .ledger-head { display: none; }
  .project-card { grid-template-columns: 32px 1fr; grid-auto-rows: auto; gap: 4px 12px; padding: 14px; }
  .card-type { grid-column: 2; }
  .card-score { grid-column: 1 / -1; }
  .card-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 6px; }
  .type-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
