:root {
  --bg-primary: #090d14;
  --bg-surface: #0f1520;
  --bg-surface-elevated: #151d2c;
  --border-subtle: #1e293b;
  --border-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #ea580c;
  --accent-hover: #f97316;
  --accent-subtle: rgba(234, 88, 12, 0.12);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-primary); color: var(--text-primary);
  font-family: var(--font-sans); width: 100vw; height: 100vh;
  overflow: hidden; display: flex; flex-direction: column;
}

header {
  height: 52px; background: rgba(9, 13, 20, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 20;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo { height: 26px; width: auto; display: block; }
.header-badge {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px; background: var(--accent-subtle);
  color: var(--accent); border: 1px solid rgba(234, 88, 12, 0.3);
}

.header-actions { display: flex; align-items: center; }
.header-portal-btn { height: 32px; font-size: 11px; padding: 0 12px; width: auto; }
.mobile-text { display: none; }

.gis-container { flex: 1; display: flex; position: relative; overflow: hidden; }
#map { flex: 1; height: 100%; width: 100%; background: #06090e; }

.floating-screening-btn { display: none; }
.modal-backdrop { display: none; }

.side-panel {
  width: 420px; background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; z-index: 10;
  overflow-y: auto;
}
.sheet-handle-zone { display: none; }
.btn-icon-close { display: none; }
.panel-head {
  padding: 16px; border-bottom: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: center;
}
.panel-kicker {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.panel-title { font-size: 16px; font-weight: 700; margin-top: 4px; }

.panel-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 11px; font-weight: 500; color: var(--text-secondary); }
.form-select, .form-input {
  background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle);
  border-radius: 6px; color: var(--text-primary); font-size: 12px;
  padding: 8px 10px; font-family: var(--font-sans); outline: none;
}
.form-select:focus, .form-input:focus { border-color: var(--accent); }
.form-grid-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn {
  height: 42px; padding: 0 16px; font-size: 13px; font-weight: 600;
  border-radius: 6px; border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 150ms ease; text-decoration: none; width: 100%;
}
.btn-icon { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary svg { stroke: #ffffff !important; }
.btn-secondary { background: var(--bg-surface-elevated); color: var(--text-primary); border-color: var(--border-subtle); }
.btn-secondary:hover { border-color: var(--border-hover); }

.results-card {
  background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle);
  border-radius: 6px; padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.result-head { display: flex; justify-content: space-between; align-items: center; }
.res-category-text { font-weight: 700; font-size: 14px; color: var(--accent); }
.score-badge {
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  color: var(--accent); background: var(--accent-subtle);
  padding: 4px 8px; border-radius: 4px; border: 1px solid rgba(234, 88, 12, 0.3);
}

.criteria-list { display: flex; flex-direction: column; gap: 8px; }
.crit-row { display: flex; justify-content: space-between; font-size: 11px; }
.crit-name { color: var(--text-secondary); }
.crit-val { font-family: var(--font-mono); font-weight: 600; }
.crit-bar { height: 4px; background: #1e293b; border-radius: 2px; overflow: hidden; margin-top: 2px; }
.crit-fill { height: 100%; background: var(--accent); border-radius: 2px; }

.decarb-strip {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: var(--bg-surface); padding: 10px; border-radius: 4px;
  border: 1px solid var(--border-subtle);
}
.decarb-box { display: flex; flex-direction: column; }
.decarb-k { font-size: 10px; color: var(--text-muted); }
.decarb-v { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: #fff; }

.maplibregl-popup-content {
  background: var(--bg-surface) !important; color: var(--text-primary) !important;
  border: 1px solid var(--border-subtle) !important; border-radius: 6px !important;
  padding: 12px !important; box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--border-subtle) !important; }
.manif-popup-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.manif-popup-meta { font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; }
.manif-popup-data { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }

.screening-loader {
  background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle);
  border-radius: 6px; padding: 14px; display: flex; align-items: center; gap: 12px;
}
.loader-spinner {
  width: 22px; height: 22px; border: 2.5px solid var(--border-subtle);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.75s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.loader-status { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.loader-bar { height: 4px; background: #1e293b; border-radius: 2px; overflow: hidden; }
.loader-progress {
  height: 100%; background: var(--accent); border-radius: 2px;
  animation: progressPulse 1.4s ease-in-out infinite; width: 60%;
}
@keyframes progressPulse {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.pdf-ready-box {
  background: rgba(34, 197, 94, 0.08); border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.pdf-ready-head { display: flex; align-items: center; gap: 8px; }
.pdf-ready-title { font-size: 13px; font-weight: 700; color: #22c55e; }
.pdf-ready-details { font-size: 11px; color: var(--text-secondary); }
.direct-dl-btn { height: 36px; font-size: 12px; border-color: #22c55e; color: #22c55e; text-decoration: none; }

/* Mobile Viewport: Clean Navbar & Floating Modal Trigger (< 768px) */
@media (max-width: 768px) {
  header { padding: 0 16px; height: 56px; }
  .header-brand { gap: 0; }
  .header-logo { height: 28px; width: auto; }
  .header-badge-desktop { display: none; }
  .desktop-text { display: none; }
  .mobile-text { display: inline; font-size: 12px; }
  .header-portal-btn { height: 36px; padding: 0 14px; font-size: 12px; }

  #map { position: absolute; inset: 0; width: 100%; height: 100%; }

  /* Floating Action Button (FAB) */
  .floating-screening-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--accent); color: #ffffff; height: 46px; padding: 0 20px;
    border-radius: 23px; font-size: 13px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(234, 88, 12, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer; z-index: 25; white-space: nowrap;
    transition: transform 150ms ease, background 150ms ease;
  }
  .floating-screening-btn:active { transform: translateX(-50%) scale(0.96); }
  .floating-screening-btn svg { stroke: #ffffff; width: 17px; height: 17px; }

  /* Modal Backdrop */
  .modal-backdrop {
    display: block; position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(2px);
    z-index: 35; opacity: 0; pointer-events: none;
    transition: opacity 220ms ease;
  }
  .modal-backdrop.active { opacity: 1; pointer-events: auto; }

  /* Bottom Sheet Modal */
  .side-panel {
    position: absolute; bottom: 0; left: 0; right: 0; width: 100%;
    max-height: 85vh; height: auto; overflow-y: auto;
    background: var(--bg-surface); border-top: 1px solid var(--border-hover);
    border-left: none; border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.7); z-index: 40;
    transform: translateY(105%);
    transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  .side-panel.mobile-active { transform: translateY(0); }
  .sheet-handle-zone {
    display: flex; justify-content: center; padding: 10px 0 4px; cursor: pointer;
  }
  .sheet-handle-bar {
    width: 38px; height: 4px; background: #475569; border-radius: 2px;
  }
  .panel-head { padding: 12px 16px; }
  .panel-title { font-size: 15px; }
  .btn-icon-close {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle); border-radius: 6px;
    color: var(--text-primary); cursor: pointer;
  }
  .btn-icon-close svg { width: 16px; height: 16px; }
  .panel-body { padding: 16px; gap: 14px; }
  .btn { height: 44px; }
}
