/* ============================================================
   H-GAC Call for Projects — Application Styles
   ============================================================ */

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

:root {
  --primary:    #005288;
  --primary-dk: #003a61;
  --accent:     #e07b00;
  --success:    #2e7d32;
  --danger:     #c62828;
  --bg:         #f5f6f8;
  --panel-bg:   #ffffff;
  --border:     #dde1e7;
  --text:       #1a1a2e;
  --text-muted: #6b7280;
  --step-done:  #005288;
  --step-active:#e07b00;
  --step-todo:  #c9cdd4;
  --panel-w:    650px;
  --header-h:   56px;
  --stepper-h:  64px;
}

html, body { height: 100%; font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); overflow: hidden; }

/* ── Login overlay ───────────────────────────────────────── */
#login-overlay {
  position: fixed; inset: 0; background: linear-gradient(135deg, #003a61 0%, #005288 60%, #0072b8 100%);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.login-box {
  background: #fff; border-radius: 12px; padding: 48px 40px; text-align: center;
  width: 360px; box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.login-box h2 { color: var(--primary); font-size: 22px; margin-bottom: 8px; }
.login-box p  { color: var(--text-muted); margin-bottom: 28px; line-height: 1.5; }
.login-signup { margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.login-signup a { color: var(--primary); font-weight: 600; text-decoration: none; margin-left: 4px; }
.login-signup a:hover { text-decoration: underline; }

/* ── Splash page modal (shown after login) ───────────────── */
#splash-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
#splash-modal-box {
  background: #f5f6f8;
  border-radius: 12px;
  width: 80%; max-width: 860px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 56px rgba(0,0,0,0.35);
  position: relative;
  display: flex; flex-direction: column;
}
#splash-modal-close {
  position: sticky; top: 10px; float: right; margin: 10px 10px -36px 0;
  z-index: 10; background: rgba(0,0,0,0.18); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 20px; line-height: 1; cursor: pointer;
  color: #fff; display: flex; align-items: center; justify-content: center;
}

.splash-page {
  display: flex; flex-direction: column; min-height: 100%;
}

/* Hero */
.splash-hero {
  background: linear-gradient(145deg, #002f4e 0%, #005288 55%, #0072b8 100%);
  color: #fff;
  text-align: center;
  padding: 64px 24px 72px;
  display: flex; flex-direction: column; align-items: center;
}
.splash-logo {
  height: 64px; object-fit: contain; margin-bottom: 24px;
}
.splash-title {
  font-size: 13px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; opacity: 0.75; margin-bottom: 8px;
}
.splash-subtitle {
  font-size: 36px; font-weight: 800; letter-spacing: -0.5px;
  margin-bottom: 18px; line-height: 1.2;
}
.splash-tagline {
  font-size: 15px; max-width: 560px; line-height: 1.7;
  opacity: 0.88; margin-bottom: 36px;
}
.splash-signin-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 14px 36px; font-size: 15px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.2px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  transition: background 0.15s, transform 0.1s;
}
.splash-signin-btn:hover { background: #c96e00; transform: translateY(-1px); }
.splash-request {
  margin-top: 18px; font-size: 13px; opacity: 0.8;
}
.splash-request a { color: #90caf9; font-weight: 600; text-decoration: none; margin-left: 4px; }
.splash-request a:hover { text-decoration: underline; }
.splash-no-show {
  margin-top: 16px; font-size: 13px; opacity: 0.75;
  display: flex; align-items: center; gap: 7px; cursor: pointer;
}
.splash-no-show input { cursor: pointer; width: 15px; height: 15px; }

/* Content sections */
.splash-section {
  padding: 56px 24px;
  background: #fff;
}
.splash-section-alt {
  background: #f0f4f9;
}
.splash-section-inner {
  max-width: 960px; margin: 0 auto;
}
.splash-section-title {
  font-size: 22px; font-weight: 700; color: var(--primary);
  margin-bottom: 14px; text-align: center;
}
.splash-section-title::after {
  content: ""; display: block; width: 48px; height: 3px;
  background: var(--accent); margin: 10px auto 0; border-radius: 2px;
}
.splash-section-text {
  font-size: 14px; color: var(--text); line-height: 1.75;
  max-width: 760px; margin: 0 auto 12px; text-align: center;
}

/* Steps */
.splash-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 32px;
}
.splash-step {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 28px 20px; text-align: center; position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.splash-step-num {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.splash-step-icon { font-size: 32px; margin-bottom: 10px; margin-top: 4px; }
.splash-step h4 { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.splash-step p  { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }

/* Goal themes */
.splash-themes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.splash-theme {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 22px 16px; text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  transition: box-shadow 0.15s;
}
.splash-theme:hover { box-shadow: 0 4px 16px rgba(0,82,136,0.15); }
.splash-theme-icon { font-size: 28px; margin-bottom: 10px; }
.splash-theme h4 { font-size: 12.5px; font-weight: 700; color: var(--primary); margin-bottom: 6px; line-height: 1.35; }
.splash-theme p  { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }

/* Footer */
.splash-footer {
  background: var(--primary-dk); color: rgba(255,255,255,0.65);
  text-align: center; padding: 24px 16px; font-size: 12.5px; line-height: 1.7;
  margin-top: auto;
}
.splash-footer a { color: rgba(255,255,255,0.75); text-decoration: none; }
.splash-footer a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────── */
header {
  height: var(--header-h); background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px; flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 16px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 10px; }
#user-name { font-size: 13px; opacity: 0.9; }

/* ── Step indicator ──────────────────────────────────────── */
#step-indicator {
  height: var(--stepper-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 0; flex-shrink: 0;
}
.step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 0 24px; position: relative; cursor: default;
}
.step:not(:last-child)::after {
  content: ""; position: absolute; right: 0; top: 16px;
  width: 1px; height: 20px; background: var(--border);
}
.step span {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 700;
  background: var(--step-todo); color: #fff; transition: background 0.25s;
}
.step label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.step.active span  { background: var(--step-active); }
.step.done span    { background: var(--step-done); }
.step.done span::before { content: "✓"; }
.step.done .step-num { display: none; }

/* ── Main layout ─────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }
.hidden { display: none !important; }

#main-content {
  display: flex; flex: 1; overflow: hidden;
}

/* ── Left panel ──────────────────────────────────────────── */
#left-panel {
  width: var(--panel-w); min-width: 312px; max-width: 60vw;
  flex-shrink: 0; background: var(--panel-bg);
  border-right: none; display: flex; flex-direction: column;
  overflow: hidden;
}
.step-panel {
  flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 20px 16px;
}
.step-panel h3 {
  font-size: 15px; font-weight: 700; color: var(--primary);
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--border);
}

/* ── Panel resize handle ─────────────────────────────────── */
#panel-resizer {
  width: 5px; flex-shrink: 0; cursor: col-resize;
  background: var(--border);
  transition: background 0.15s;
  position: relative; z-index: 10;
}
#panel-resizer:hover,
#panel-resizer.dragging { background: var(--primary); }

/* ── Map container ───────────────────────────────────────── */
#map-container { flex: 1; position: relative; }
#viewDiv { width: 100%; height: 100%; }

/* ── Mode toggle (Step 1) ────────────────────────────────── */
#mode-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.mode-btn {
  flex: 1; padding: 9px 8px; border: 2px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text-muted); font-size: 13px; cursor: pointer;
  transition: all 0.2s; font-weight: 500;
}
.mode-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.mode-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ── Instructions box ────────────────────────────────────── */
.instructions {
  background: #eef4fb; border: 1px solid #b8d4ee; border-radius: 6px;
  padding: 10px 12px; font-size: 13px; color: #004a7c; line-height: 1.5; margin-bottom: 14px;
}

/* ── Draw controls ───────────────────────────────────────── */
#draw-controls { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
#draw-controls label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
#draw-controls select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff;
}

/* ── Selection summary ───────────────────────────────────── */
#selection-summary {
  background: #f0faf0; border: 1px solid #a5d6a7; border-radius: 6px;
  padding: 10px 12px; margin-bottom: 14px;
}
#selection-count { font-size: 13px; font-weight: 600; color: var(--success); }

/* ── Summary display (Step 2) ────────────────────────────── */
.summary-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.summary-table td { padding: 7px 4px; font-size: 13px; border-bottom: 1px solid var(--border); }
.summary-table td:first-child { color: var(--text-muted); font-weight: 600; width: 45%; }
.summary-table td:last-child { color: var(--text); }
.summary-section-header { padding: 8px 4px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); border-bottom: 2px solid var(--primary); }
.gis-badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px;
  font-weight: 700; margin: 2px;
}
.badge-yes { background: #e8f5e9; color: #2e7d32; }
.badge-no  { background: #fce4ec; color: #c62828; }
.badge-info{ background: #e3f2fd; color: #1565c0; }

/* ── Form (Step 3) ───────────────────────────────────────── */
.form-section { margin-bottom: 20px; }
.form-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.5px; margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
/* ── GIS read-only key-value table ─────────────────────── */
.gis-kv-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px; margin-bottom: 10px;
}
.gis-kv-table tr:nth-child(odd) td  { background: #fafbfc; }
.gis-kv-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.gis-kv-table td:first-child { color: var(--text-muted); width: 65%; }
.gis-kv-table td:last-child  { font-weight: 600; color: var(--text); text-align: right; }

.form-subsection-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--primary); letter-spacing: 0.4px;
  margin: 14px 0 8px; padding: 4px 8px;
  background: #eef4fa; border-left: 3px solid var(--primary); border-radius: 2px;
}
.checkbox-group { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.checkbox-item  { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 400; cursor: pointer; }
.checkbox-item input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.form-group label .req { color: var(--accent); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff; color: var(--text); transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group input[readonly] { background: #f5f6f8; color: var(--text-muted); cursor: default; }
.form-group textarea { resize: vertical; min-height: 72px; }
.form-group .yn-row { display: flex; gap: 8px; }
.yn-btn {
  flex: 1; padding: 8px; border: 2px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 13px; cursor: pointer; font-weight: 600; transition: all 0.2s;
}
.yn-btn.yes.active { border-color: var(--primary); background: #dce8f5; color: var(--primary); }
.yn-btn.no.active  { border-color: #6b7280;       background: #e9eaec; color: #374151; }
.yn-btn:hover:not(.active) { border-color: var(--primary); }

/* ── Review (Step 4) ─────────────────────────────────────── */
.review-section { margin-bottom: 18px; }
.review-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.5px; margin-bottom: 8px;
}
.review-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.review-row .rk { color: var(--text-muted); width: 45%; flex-shrink: 0; }
.review-row .rv { color: var(--text); font-weight: 500; }

/* ── Submissions table (Step 5) ──────────────────────────── */
.sub-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sub-table th { background: var(--primary); color: #fff; padding: 8px 6px; text-align: left; font-size: 12px; }
.sub-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.sub-table tr:hover td { background: #f0f5fb; }
.sub-row-zoom { cursor: pointer; }
.sub-row-zoom:hover td { background: #e8f0fb; }

/* ── Safety Countermeasure (PSC) accordion ───────────────── */
.psc-accordion {
  border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; margin-top: 4px;
}
.psc-acc-item { border-bottom: 1px solid var(--border); }
.psc-acc-item:last-child { border-bottom: none; }
.psc-acc-header {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f7f8fa; border: none;
  cursor: pointer; font-size: 12.5px; font-weight: 600;
  color: var(--text); text-align: left; transition: background 0.1s;
}
.psc-acc-header:hover { background: #edf2f8; }
.psc-acc-title { flex: 1; }
.psc-acc-count {
  display: none; font-size: 11px; font-weight: 700;
  color: #fff; background: var(--primary);
  border-radius: 10px; padding: 1px 7px; line-height: 1.6;
}
.psc-acc-count.has-selection { display: inline; }
.psc-acc-arrow {
  font-size: 10px; color: var(--text-muted);
  transition: transform 0.2s; flex-shrink: 0;
}
.psc-acc-item.open .psc-acc-arrow { transform: rotate(180deg); }
.psc-acc-item.open .psc-acc-header { background: #edf2f8; color: var(--primary); }
.psc-acc-body { display: none; background: #fff; }
.psc-acc-item.open .psc-acc-body { display: block; }
label.psc-item {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer;
  border-bottom: 1px solid #f0f2f5; transition: background 0.1s;
  margin-bottom: 0;
}
label.psc-item:last-child { border-bottom: none; }
label.psc-item:hover { background: #f5f8ff; }
label.psc-item input[type="checkbox"] {
  flex-shrink: 0; cursor: pointer;
  width: 15px; height: 15px;
  padding: 0; border: revert; border-radius: 0;
  background: revert; box-shadow: none;
}
label.psc-item span { flex: 1; line-height: 1.4; }
.psc-info {
  flex-shrink: 0; color: var(--primary); font-size: 13px;
  text-decoration: none; opacity: 0.6; line-height: 1;
  transition: opacity 0.15s;
}
.psc-info:hover { opacity: 1; }

/* ── Guide info icon button ──────────────────────────────── */
.guide-info-btn {
  background: none; border: none; cursor: pointer;
  color: var(--primary); font-size: 15px; line-height: 1;
  padding: 0 0 0 6px; vertical-align: middle; opacity: 0.7;
  transition: opacity 0.15s;
}
.guide-info-btn:hover { opacity: 1; }
.btn-view {
  padding: 3px 10px; font-size: 11px; font-weight: 600; border-radius: 4px;
  background: #fff; color: #6b7280; border: 1.5px solid #9ca3af;
  cursor: pointer; white-space: nowrap; margin-right: 4px;
}
.btn-view:hover { background: #f3f4f6; color: #374151; border-color: #6b7280; }
.btn-edit {
  padding: 3px 10px; font-size: 11px; font-weight: 600; border-radius: 4px;
  background: #fff; color: var(--primary); border: 1.5px solid var(--primary);
  cursor: pointer; white-space: nowrap;
}
.btn-edit:hover { background: var(--primary); color: #fff; }
.btn-edit:disabled { opacity: 0.35; cursor: not-allowed; border-style: dashed; }
.btn-edit:disabled:hover { background: #fff; color: var(--primary); }
.btn-delete {
  padding: 3px 10px; font-size: 11px; font-weight: 600; border-radius: 4px;
  background: #fff; color: #dc2626; border: 1.5px solid #dc2626;
  cursor: pointer; white-space: nowrap; margin-left: 4px;
}
.btn-delete:hover { background: #dc2626; color: #fff; }
.btn-delete:disabled { opacity: 0.35; cursor: not-allowed; border-style: dashed; }
.btn-delete:disabled:hover { background: #fff; color: #dc2626; }

/* ── File attachments ──────────────────────────────────── */
.file-drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border); border-radius: 8px; padding: 20px 16px;
  cursor: pointer; text-align: center; transition: border-color 0.2s, background 0.2s; gap: 4px;
}
.file-drop-zone:hover, .file-drop-zone.drag-over {
  border-color: var(--primary); background: #eef4fb;
}
.file-drop-zone input[type="file"] { display: none; }
.file-drop-zone span { font-size: 13px; color: var(--primary); font-weight: 600; }
.file-drop-zone small { font-size: 11px; color: var(--text-muted); }

.file-list { list-style: none; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.file-list-item {
  display: flex; align-items: center; gap: 8px;
  background: #f5f6f8; border-radius: 6px; padding: 6px 10px; font-size: 12px;
  transition: opacity 0.2s;
}
.file-list-item.file-deleted { opacity: 0.4; text-decoration: line-through; }
.file-icon { font-size: 14px; flex-shrink: 0; }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.btn-remove-file {
  background: none; border: none; color: var(--danger); cursor: pointer;
  font-size: 13px; padding: 0 2px; line-height: 1; font-weight: 700; flex-shrink: 0;
}
.btn-remove-file:hover { opacity: 0.7; }

/* ── Per-narrative attachment ──────────────────────────── */
.narr-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.narr-attach-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; font-size: 11.5px; font-weight: 600;
  color: var(--primary); background: #eef4fb;
  border: 1px solid #c5d4e0; border-radius: 4px;
  cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
.narr-attach-btn:hover { background: #dbeafe; }
.narr-attach-btn input[type="file"] { display: none; }
.narr-file-list { margin-top: 4px; }

.status-chip {
  display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 700;
}
.status-Submitted    { background: #e3f2fd; color: #1565c0; }
.status-Draft        { background: #fef3c7; color: #92400e; }
.status-Under-Review { background: #fff8e1; color: #e65100; }
.status-Approved     { background: #e8f5e9; color: #2e7d32; }
.status-Rejected     { background: #fce4ec; color: #c62828; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-row { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
button, .btn-primary, .btn-secondary, .btn-submit, .btn-icon {
  padding: 9px 16px; border-radius: 6px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none; transition: all 0.2s;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dk); }
.btn-secondary { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-secondary:hover { background: #eef4fb; }
.btn-submit   { flex: 1; background: var(--success); color: #fff; font-size: 15px; padding: 12px; }
.btn-submit:hover { background: #1b5e20; }
.btn-submit:disabled { background: #9e9e9e; cursor: not-allowed; }
.btn-draft    { background: #fff; color: #b45309; border: 2px solid #d97706; }
.btn-draft:hover { background: #fffbeb; border-color: #b45309; }
.btn-draft:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
#btn-next-step2, #btn-next-step3, #btn-next-step4 { width: 100%; margin-top: 12px; }
#btn-new-application { width: 100%; margin-top: 12px; }

/* Header buttons */
header button {
  background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 12px; font-size: 12px; border-radius: 5px;
}
header button:hover { background: rgba(255,255,255,0.25); }

/* ── Loading spinner ─────────────────────────────────────── */
.loading {
  display: flex; align-items: center; gap: 10px; padding: 16px;
  color: var(--text-muted); font-size: 13px;
}
.spinner {
  width: 20px; height: 20px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 8000;
}
.modal-content {
  background: #fff; border-radius: 12px; padding: 40px; text-align: center;
  max-width: 400px; width: 90%; box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.modal-content h2 { color: var(--success); font-size: 22px; margin-bottom: 12px; }
.modal-content p  { color: var(--text-muted); margin-bottom: 8px; line-height: 1.5; }
.modal-content strong { color: var(--text); }
.modal-content button { margin-top: 20px; width: 100%; }

/* ── Toast notification ──────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 12px 24px; border-radius: 6px;
  font-size: 13px; z-index: 9000; opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
#toast.show { opacity: 1; }

/* ── Error state ─────────────────────────────────────────── */
.error-msg {
  background: #fce4ec; border: 1px solid #ef9a9a; border-radius: 6px;
  padding: 10px 12px; font-size: 13px; color: var(--danger); margin-bottom: 12px;
}

/* ── Map toolbar (floating) ──────────────────────────────── */
#map-toolbar {
  position: absolute; top: 12px; left: 62px; z-index: 10;
  display: flex; flex-direction: column; gap: 6px;
}
#map-toolbar .toolbar-label {
  background: rgba(255,255,255,0.95); padding: 6px 12px;
  border-radius: 6px; font-size: 12px; font-weight: 700;
  color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── Scrollbar ───────────────────────────────────────────── */
.step-panel::-webkit-scrollbar { width: 6px; }
.step-panel::-webkit-scrollbar-track { background: transparent; }
.step-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Reviewer Portal ─────────────────────────────────────── */
#reviewer-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.rv-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #003a61 0%, #005288 60%, #0072b8 100%);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
#reviewer-body {
  display: flex; height: calc(100vh - var(--header-h)); overflow: hidden;
}
#reviewer-left {
  width: 616px; flex-shrink: 0;
  background: var(--panel-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
#list-view {
  display: flex; flex-direction: column; flex: 1; overflow: hidden;
}
#detail-view {
  display: none; flex-direction: column; flex: 1; overflow: hidden;
}
#reviewer-filters {
  padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#reviewer-filters input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12.5px; font-family: inherit; outline: none;
}
#reviewer-filters input:focus { border-color: var(--primary); }
#reviewer-filters select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: inherit; background: #fff; outline: none;
}
#reviewer-count {
  padding: 5px 12px; font-size: 11.5px; color: var(--text-muted);
  background: var(--bg); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#reviewer-table-wrap { flex: 1; overflow-y: auto; }
#reviewer-table { width: 100%; border-collapse: collapse; }
#reviewer-table thead th {
  position: sticky; top: 0; background: var(--bg);
  padding: 7px 10px; text-align: left; font-size: 10.5px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.rv-row { border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
.rv-row:hover { background: #f0f4f8; }
.rv-row td   { padding: 8px 10px; font-size: 12px; vertical-align: top; }
.rv-submitter { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.rv-agency { font-size: 11px; color: var(--text-muted); }
.rv-cat    { font-size: 11px; color: var(--text-muted); }
.rv-date   { font-size: 11px; white-space: nowrap; color: var(--text-muted); }

#reviewer-resizer {
  width: 6px; flex-shrink: 0; cursor: col-resize;
  background: var(--border); transition: background 0.15s;
  position: relative;
}
#reviewer-resizer:hover,
#reviewer-resizer.dragging { background: var(--primary); }
#reviewer-resizer::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 32px; border-radius: 2px;
  background: rgba(255,255,255,0.6);
}
#reviewer-map-wrap { flex: 1; position: relative; overflow: hidden; }
#reviewDiv         { width: 100%; height: 100%; }

#status-legend {
  position: absolute; bottom: 130px; right: 12px; z-index: 10;
  background: rgba(255,255,255,0.96); border-radius: 8px;
  padding: 10px 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.legend-title { font-size: 11px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.legend-item  { display: flex; align-items: center; gap: 8px; font-size: 11.5px; margin-bottom: 3px; }
.legend-dot   { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Detail panel */
#detail-back-row {
  padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#detail-content { flex: 1; overflow-y: auto; padding: 14px 14px 32px; }

.rv-detail-name {
  font-size: 15px; font-weight: 700; color: var(--primary);
  margin-bottom: 14px; line-height: 1.4;
}
.rv-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
  margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.rv-subsection-title {
  font-size: 10.5px; font-weight: 600; color: var(--primary);
  margin: 10px 0 4px; padding-left: 2px;
}
.rv-info-grid { display: flex; flex-direction: column; gap: 5px; }
.rv-kv        { display: flex; gap: 8px; font-size: 12.5px; }
.rv-label     { color: var(--text-muted); width: 110px; flex-shrink: 0; }
.rv-value     { color: var(--text); font-weight: 500; word-break: break-word; }

.rv-meta {
  font-size: 11px; color: var(--text-muted); margin: -10px 0 14px;
}
.rv-narrative {
  margin-bottom: 10px; padding: 8px 10px;
  background: var(--bg); border-radius: 6px; border-left: 3px solid var(--border);
}
.rv-narrative-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 4px; letter-spacing: 0.3px;
}
.rv-narrative-text {
  font-size: 12.5px; line-height: 1.55; color: var(--text); white-space: pre-wrap;
}
/* ── Review Comments ─────────────────────────────────────── */
.rv-comments-thread { margin-bottom: 10px; }
.rv-no-comments { font-size: 12.5px; color: var(--text-muted); padding: 6px 0 10px; }
.rv-comment {
  border-left: 3px solid var(--primary);
  padding: 7px 10px; margin-bottom: 8px;
  background: #f7f8fa; border-radius: 0 6px 6px 0;
}
.rv-comment-meta { font-size: 11.5px; color: var(--text-muted); margin-bottom: 3px; }
.rv-comment-text { font-size: 13px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.rv-comment-log { border-left-color: #64748b; background: #f1f5f9; }
.rv-log-badge { display:inline-block; font-size:10px; font-weight:700; background:#64748b; color:#fff; border-radius:3px; padding:1px 5px; margin-right:4px; letter-spacing:0.3px; text-transform:uppercase; }
.rv-changelog { margin-top:4px; display:flex; flex-direction:column; gap:2px; }
.rv-changelog-row { display:flex; gap:8px; font-size:11.5px; }
.rv-changelog-field { color:var(--text-muted); flex-shrink:0; min-width:160px; max-width:200px; }
.rv-changelog-arrow { color:var(--text); word-break:break-word; }
.rv-comment-new { margin-bottom: 4px; }
.rv-comment-new textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; font-family: inherit;
  resize: vertical; outline: none; color: var(--text); box-sizing: border-box;
}
.rv-comment-new textarea:focus { border-color: var(--primary); }

/* Attachments */
.rv-attachment-list {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; margin-bottom: 4px;
}
.rv-attachment {
  display: flex; flex-direction: column; align-items: center;
  width: 100px; text-align: center;
}
.rv-attachment-thumb {
  width: 90px; height: 70px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
  transition: opacity 0.15s;
}
.rv-attachment-thumb:hover { opacity: 0.85; }
.rv-attachment-file {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none; color: var(--primary);
  width: 90px; padding: 10px 6px;
  border: 1px solid var(--border); border-radius: 6px;
  background: #f7f8fa; transition: background 0.15s;
}
.rv-attachment-file:hover { background: #eaf1f8; }
.rv-attachment-icon { font-size: 28px; line-height: 1; }
.rv-attachment-name {
  font-size: 11px; color: var(--text); margin-top: 4px;
  word-break: break-word; line-height: 1.3;
}
.rv-attachment-meta { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

.rv-status-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px;
}
.rv-status-box select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12.5px; font-family: inherit; background: #fff; outline: none;
}
.rv-status-box select:focus { border-color: var(--primary); }
#rv-save-msg { font-size: 12px; }

/* ── Scoring Panel ───────────────────────────────────────── */
.rv-score-summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text);
  padding: 8px 10px; background: var(--bg); border-radius: 6px;
  border: 1px solid var(--border); margin-bottom: 10px;
}
.rv-score-table {
  width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px;
}
.rv-score-table th {
  background: #f1f5f9; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--text-muted);
  padding: 5px 7px; border-bottom: 2px solid var(--border); text-align: left;
}
.rv-score-table td { padding: 5px 7px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.rv-score-theme-row td {
  background: #f8fafc; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.3px; color: var(--primary);
  padding: 6px 7px; border-top: 2px solid var(--border);
}
.rv-score-input {
  width: 52px; text-align: center; padding: 3px 4px;
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 12.5px; font-family: inherit; outline: none;
}
.rv-score-input:focus { border-color: var(--primary); }

/* ── Edit Panel ──────────────────────────────────────────── */
.rv-edit-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.rv-edit-title {
  font-size: 13px; font-weight: 700; color: var(--text); flex: 1;
}
.rv-edit-note {
  font-size: 11px; color: var(--text-muted); margin: 0 0 10px;
}
.rv-edit-msg {
  font-size: 12px; align-self: center;
}
.rv-edit-grid {
  display: flex; flex-direction: column; gap: 8px;
  padding: 2px 0 6px;
}
.rv-edit-row {
  display: flex; gap: 8px; align-items: flex-start;
}
.rv-edit-label {
  width: 160px; flex-shrink: 0; font-size: 11.5px;
  color: var(--text-muted); padding-top: 6px; line-height: 1.3;
}
.rv-edit-ctrl {
  flex: 1; font-size: 12.5px; font-family: inherit;
  padding: 4px 7px; border: 1px solid var(--border);
  border-radius: 5px; outline: none; background: #fff;
  color: var(--text); min-width: 0;
}
.rv-edit-ctrl:focus { border-color: var(--primary); box-shadow: 0 0 0 2px #2563eb18; }
.rv-edit-ta { resize: vertical; line-height: 1.5; }

/* Status chip (shared) */
.status-chip {
  display: inline-block; padding: 3px 9px; border-radius: 12px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --panel-w: 100%; }
  #main-content { flex-direction: column; }
  #map-container { height: 40vh; }
  #left-panel { width: 100%; border-right: none; border-top: 1px solid var(--border); }
}

/* ── AI Chat Widget ──────────────────────────────────────── */
#chat-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff 0%, #bf5af2 30%, #ff375f 55%, #ff9f0a 78%, #30d158 100%);
  background-size: 400% 400%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(10,132,255,0.5), 0 0 0 0 rgba(191,90,242,0.45);
  animation: aiGradient 3s ease infinite, aiRing 2.8s ease-out infinite;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
#chat-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 26px rgba(10,132,255,0.65), 0 0 0 6px rgba(191,90,242,0.18);
}
#chat-btn.open {
  box-shadow: 0 6px 24px rgba(191,90,242,0.7), 0 0 0 4px rgba(191,90,242,0.22);
}
#chat-btn svg {
  width: 22px; height: 22px;
  animation: sparkleIdle 3s ease-in-out infinite;
}
#chat-btn.open svg {
  animation: sparkleActive 1.4s ease-in-out infinite;
}

@keyframes aiGradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes aiRing {
  0%   { box-shadow: 0 4px 16px rgba(10,132,255,0.5),  0 0 0 0   rgba(191,90,242,0.5); }
  70%  { box-shadow: 0 4px 16px rgba(10,132,255,0.25), 0 0 0 14px rgba(191,90,242,0); }
  100% { box-shadow: 0 4px 16px rgba(10,132,255,0.5),  0 0 0 0   rgba(191,90,242,0); }
}
@keyframes sparkleIdle {
  0%, 100% { transform: rotate(0deg)  scale(1);    filter: drop-shadow(0 0 3px rgba(255,255,255,0.7)); }
  50%       { transform: rotate(45deg) scale(1.12); filter: drop-shadow(0 0 7px rgba(255,255,255,1));   }
}
@keyframes sparkleActive {
  0%, 100% { transform: rotate(0deg)  scale(1);    filter: drop-shadow(0 0 4px rgba(255,255,255,0.9)); }
  50%       { transform: rotate(45deg) scale(1.18); filter: drop-shadow(0 0 10px rgba(255,255,255,1));  }
}

#chat-panel {
  position: fixed; bottom: 88px; right: 24px; z-index: 2000;
  width: 340px; height: 480px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  display: flex; flex-direction: column; overflow: hidden;
  transform: scale(0.9) translateY(20px); opacity: 0;
  transform-origin: bottom right;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
#chat-panel.open {
  transform: scale(1) translateY(0); opacity: 1; pointer-events: all;
}

#chat-header {
  background: var(--primary); color: #fff;
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.chat-title {
  font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px;
}
.chat-title .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4caf50;
  box-shadow: 0 0 0 2px rgba(76,175,80,0.35);
}
#chat-close {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 2px 4px; opacity: 0.75;
}
#chat-close:hover { opacity: 1; }

#chat-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-msg { display: flex; flex-direction: column; max-width: 85%; }
.chat-msg.user      { align-self: flex-end;   align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 12.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user      .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: #f0f2f5; color: var(--text); border-bottom-left-radius: 4px; }

/* typing dots */
.chat-typing .chat-bubble { display: flex; align-items: center; gap: 5px; padding: 12px 14px; }
.chat-typing .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: chatBounce 1.1s infinite ease-in-out;
}
.chat-typing .dot:nth-child(2) { animation-delay: 0.18s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

#chat-input-area {
  border-top: 1px solid var(--border); padding: 10px 12px;
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0;
}
#chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; font-family: inherit;
  resize: none; outline: none; line-height: 1.45; max-height: 100px;
  transition: border-color 0.15s;
}
#chat-input:focus { border-color: var(--primary); }
#chat-send {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.15s;
}
#chat-send:hover    { background: var(--primary-dk); }
#chat-send:disabled { background: var(--border); cursor: not-allowed; }
#chat-send          { font-size: 18px; }
.chat-bubble code {
  background: rgba(0,0,0,0.08); border-radius: 3px;
  padding: 1px 5px; font-family: "Consolas", monospace; font-size: 11.5px;
}
