* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  background: #f0f2f5;
  margin: 0;
  overflow: hidden;        /* prevent page-level scroll; panes scroll internally */
}

/* ── Loading overlay ───────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Header bar ────────────────────────────────────────────────── */
.tool-header {
  background: linear-gradient(90deg, #0a1628 0%, #0f2044 100%);
  color: #e2e8f0;
  border-bottom: 2px solid #3b4eff44;
  padding: 14px 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.header-left { display: flex; flex-direction: column; gap: 5px; }
.header-title {
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.header-desc {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
}
.header-link {
  color: #7aa0ff;
  text-decoration: none;
  border-bottom: 1px solid #4f7eff55;
}
.header-link:hover { color: #a5b4fc; border-bottom-color: #a5b4fc; }
.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.data-status-text {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .tool-header {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .header-right { align-items: flex-start; }
  .header-title { font-size: 18px; }
  .header-desc { font-size: 12px; }
}
.error-inner {
  font-size: 11px;
  color: #fbbf24;
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 4px;
  padding: 2px 8px;
}

/* ── Disclaimer bar ────────────────────────────────────────────── */
.disclaimer-bar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  border-bottom: 2px solid #f59e0b;
  padding: 8px 20px;
  flex-shrink: 0;
}
.disclaimer-icon {
  font-size: 14px;
  color: #b45309;
  flex-shrink: 0;
  line-height: 1.5;
}
.disclaimer-text {
  font-size: 12px;
  color: #78350f;
  line-height: 1.55;
}
.disclaimer-text strong {
  font-weight: 700;
  color: #92400e;
}
.disclaimer-link {
  color: #92400e;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.disclaimer-link:hover { color: #78350f; }

/* ── Scenario bar ──────────────────────────────────────────────── */
.scenario-bar {
  background: #fff;
  border-bottom: 2px solid #e2e8f0;
  padding: 8px 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 20px;
}
.scenario-year-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.scenario-label {
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.scenario-year-input {
  width: 80px;
  border: 2px solid #4f7eff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 16px;
  font-weight: 700;
  color: #0a1628;
  text-align: center;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.scenario-year-input:focus {
  border-color: #3b4eff;
  box-shadow: 0 0 0 3px rgba(79,126,255,0.18);
}
.scenario-hint {
  font-size: 11px;
  color: #64748b;
  font-style: italic;
}

/* ── Main two-column layout ────────────────────────────────────── */
.main-layout {
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.table-pane {
  flex: 0 0 auto;
  width: 62%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  min-width: 320px;
}
.table-scroll {
  flex: 1 1 0;
  overflow: auto;
}

/* Draggable vertical divider */
.pane-divider {
  flex: 0 0 5px;
  background: #e2e8f0;
  cursor: col-resize;
  position: relative;
  transition: background 0.15s;
  z-index: 3;
}
.pane-divider:hover,
.pane-divider.dragging {
  background: #3b82f6;
}
.pane-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
  height: 32px;
  background: #94a3b8;
  border-radius: 2px;
}

/* ── Historical right pane ─────────────────────────────────────── */
.hist-pane {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
  min-width: 0;
}

.hist-pane-header {
  flex-shrink: 0;
  padding: 7px 14px 6px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hist-pane-header-left { display: flex; flex-direction: column; gap: 1px; }
.hist-pane-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}
.hist-pane-sub {
  font-size: 10px;
  color: #94a3b8;
}

/* Mode toggle buttons (Employment / Median Wage) */
.hist-pane-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.hist-mode-btns {
  display: flex;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
}
.hist-mode-btn {
  background: #f8fafc;
  border: none;
  border-right: 1px solid #cbd5e1;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.hist-mode-btn:last-child { border-right: none; }
.hist-mode-btn:hover { background: #e2e8f0; color: #1e293b; }
.hist-mode-btn.active {
  background: #1e293b;
  color: #fff;
}

/* Total Employment toggle */
.total-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.total-toggle input[type="checkbox"] {
  appearance: none;
  width: 32px;
  height: 17px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.total-toggle input[type="checkbox"]:checked { background: #1e293b; }
.total-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.total-toggle input[type="checkbox"]:checked::after { transform: translateX(15px); }
.total-toggle-label { font-size: 10px; color: #475569; white-space: nowrap; }

.hist-chart-wrap {
  flex: 0 0 260px;
  position: relative;
  padding: 8px 14px 4px;
  border-bottom: 1px solid #e2e8f0;
}

/* Occupation chips ───────────────────────────────────────────── */
.hist-picker {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.hist-picker-label {
  font-size: 10px;
  color: #94a3b8;
  white-space: nowrap;
  margin-top: 3px;
}
.hist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.hist-chip {
  font-size: 10px;
  line-height: 1;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.hist-chip:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}
.hist-chip.active {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #1e293b;
}

/* Wage data availability note ───────────────────────────────── */
.hist-wage-note {
  flex-shrink: 0;
  margin: 0;
  padding: 7px 14px;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  border-bottom: 1px solid #fde68a;
  font-size: 11px;
  color: #78350f;
  line-height: 1.5;
}
.wage-note-item {
  margin-bottom: 4px;
}
.wage-note-item:last-child { margin-bottom: 0; }
.wage-note-item strong { color: #92400e; }

/* Historical data table ─────────────────────────────────────── */
.hist-table-scroll {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 4px 14px 8px;
}
.hist-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.hist-data-table th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  font-weight: 600;
  color: #475569;
  padding: 4px 8px;
  border-bottom: 2px solid #cbd5e1;
  text-align: right;
  white-space: nowrap;
  z-index: 1;
}
.hist-data-table th:first-child { text-align: left; }
.hist-data-table td {
  padding: 3px 8px;
  border-bottom: 1px solid #f1f5f9;
  text-align: right;
  color: #374151;
}
.hist-data-table td:first-child { text-align: left; color: #64748b; font-weight: 600; }
.hist-data-table tbody tr:hover td { background: #eff6ff; }
.hist-data-table .col-total { font-weight: 600; color: #1e293b; }
.hist-data-table .soc-break td { background: #fefce8 !important; }

/* ── Main spreadsheet table ────────────────────────────────────── */
.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.sheet-table thead th {
  background: #1e293b;
  color: #cbd5e1;
  font-weight: 600;
  padding: 6px 8px;
  white-space: nowrap;
  border: 1px solid #334155;
  font-size: 11px;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 2;
}

.col-sub {
  font-size: 9px;
  font-weight: 400;
  color: #64748b;
  margin-top: 2px;
  white-space: normal;
  line-height: 1.4;
}
.col-sub-input {
  color: #fcd34d;   /* amber — matches the input box accent color */
  font-weight: 600;
}
.col-def-hint {
  color: #93c5fd;
  font-weight: 600;
  font-size: 10px;
}
.col-def-hint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  font-size: 9px;
  font-weight: 700;
  border: 1px solid #93c5fd;
  border-radius: 50%;
  background: rgba(147,197,253,0.15);
  color: #93c5fd;
  vertical-align: middle;
}

.col-input-hdr {
  min-width: 110px;
}

.sheet-table tbody tr:nth-child(even) { background: #f8fafc; }
.sheet-table tbody tr:hover { background: #eff6ff; }

.sheet-table tbody tr.row-total {
  background: #1e293b !important;
  color: #f1f5f9;
  font-weight: 700;
}
.sheet-table tbody tr.row-total:hover { background: #1e293b !important; }
.sheet-table tbody tr.row-total td { border-color: #334155 !important; }

/* Sum of named occupations row */
.sheet-table tbody tr.row-tracked-sum {
  background: #eff6ff !important;
  font-style: italic;
}
.sheet-table tbody tr.row-tracked-sum:hover { background: #dbeafe !important; }

.sum-badge {
  font-size: 9px;
  background: #3b82f6;
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 5px;
  font-style: normal;
  font-weight: 600;
}

/* Implied other row */
.sheet-table tbody tr.row-implied {
  background: #fef9c3 !important;
  font-style: italic;
}
.sheet-table tbody tr.row-implied:hover { background: #fef08a !important; }
.sheet-table tbody tr.row-implied.row-implied-error {
  background: #fee2e2 !important;
}

.sheet-table td {
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  vertical-align: middle;
}

/* Column widths */
.col-name  { min-width: 200px; }
.col-num   { width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.col-dlevel,
.col-dshare { width: 140px; }

/* Allow header text to wrap so longer labels fit cleanly */
.sheet-table thead th {
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.3;
}

.soc-badge {
  font-size: 10px;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 5px;
  font-family: monospace;
}

.warn-icon {
  font-size: 11px;
  cursor: help;
  margin-left: 4px;
  color: #d97706;
}

.implied-badge {
  font-size: 9px;
  background: #fbbf24;
  color: #78350f;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 5px;
  font-style: normal;
  font-weight: 600;
}

/* ── Delta column cell sizing ──────────────────────────────────── */
/*  Every cell in Δ% Level / Δ% Share columns is one of three kinds:
    1. .delta-wrap   – live input (yellow, editable)
    2. .calc-val     – computed read-only (gray box)
    3. .na-val       – not applicable (dashed muted box)
    All three are sized identically so columns stay aligned.          */

.col-dlevel,
.col-dshare { text-align: left; }

/* shared sizing token */
.delta-wrap,
.calc-val,
.na-val {
  display: inline-flex;
  align-items: center;
  height: 24px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  vertical-align: middle;
}

/* ── Editable input ── */
.delta-wrap {
  border: 1.5px solid #f59e0b;
  background: #fffbeb;
  box-shadow: 0 0 0 1px rgba(245,158,11,0.15);
  gap: 0;
}
.delta-wrap:focus-within {
  border-color: #d97706;
  background: #fef3c7;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.22);
}
.delta-input {
  width: 62px;
  border: none;
  border-right: 1px solid #f59e0b;
  border-radius: 3px 0 0 3px;
  padding: 0 5px;
  font-size: 12px;
  text-align: right;
  outline: none;
  background: transparent;
  color: #1c1917;
  height: 100%;
}
.delta-unit {
  padding: 0 6px;
  font-size: 11px;
  color: #92400e;
  background: transparent;
  line-height: 1;
  white-space: nowrap;
}

/* ── Calculated (read-only) display ── */
.calc-val {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0 8px;
  min-width: 88px;
  justify-content: flex-end;
  color: #475569;
  font-style: italic;
}

/* ── N/A display ── */
.na-val {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 0 8px;
  min-width: 88px;
  justify-content: center;
  color: #9ca3af;
  font-style: normal;
  letter-spacing: 0.05em;
}

/* Result coloring on calc cells */
.calc-val.val-pos { color: #15803d; font-weight: 600; font-style: normal; border-color: #bbf7d0; background: #f0fdf4; }
.calc-val.val-neg { color: #b91c1c; font-weight: 600; font-style: normal; border-color: #fecaca; background: #fff1f2; }
.calc-val.val-neu { color: #374151; font-style: normal; }
.calc-val.val-na  { color: #9ca3af; }

/* Result cell coloring (for plain <td> cells) */
td.val-pos { color: #15803d; font-weight: 600; }
td.val-neg { color: #b91c1c; font-weight: 600; }
td.val-neu { color: #374151; }

/* ── Total row overrides (dark bg) ── */
.row-total .delta-wrap {
  border-color: #4ade80;
  background: rgba(74,222,128,0.08);
  box-shadow: 0 0 0 1px rgba(74,222,128,0.15);
}
.row-total .delta-wrap:focus-within {
  border-color: #22c55e;
  background: rgba(74,222,128,0.14);
  box-shadow: 0 0 0 3px rgba(74,222,128,0.25);
}
.row-total .delta-input {
  color: #f0fdf4;
  border-right-color: #4ade80;
}
.row-total .delta-unit { color: #86efac; }
.row-total .na-val {
  background: rgba(255,255,255,0.06);
  border-color: #334155;
  color: #475569;
}
.row-total td.val-pos,
.row-total td.val-neg,
.row-total td.val-neu { color: #f1f5f9 !important; font-weight: 700; }

.break-label { font-size: 10px; color: #92400e; }

/* ── Misc ──────────────────────────────────────────────────────── */
footer { font-size: 11px; background: #f8fafc; height: 32px; flex-shrink: 0; }
canvas { max-width: 100%; }

/* Scrollable body wrapper */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.tool-header  { flex-shrink: 0; }
.info-banner  { flex-shrink: 0; }
.scenario-bar { flex-shrink: 0; }
.main-layout  { flex: 1 1 0; min-height: 0; }
footer        { flex-shrink: 0; }

/* ── SOC Definition button ─────────────────────────────────────── */
.occ-def-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid #93c5fd;
  border-radius: 50%;
  background: #eff6ff;
  color: #3b82f6;
  cursor: pointer;
  margin-left: 5px;
  padding: 0;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
}
.occ-def-btn:hover {
  background: #3b82f6;
  color: #fff;
  border-color: #2563eb;
}

/* ── SOC Definition Modal ─────────────────────────────────────── */
.soc-modal-header {
  background: linear-gradient(90deg, #0a1628 0%, #0f2044 100%);
  color: #fff;
  border-bottom: 1px solid #1e3a6e;
  padding: 12px 20px;
}
.soc-modal-code {
  font-size: 11px;
  font-family: monospace;
  color: #93c5fd;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.soc-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.soc-modal-body {
  padding: 16px 20px;
  max-height: 60vh;
}
.soc-modal-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #e2e8f0;
  padding: 10px 20px;
}
.soc-modal-source {
  flex: 1;
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}

/* Group intro text */
.soc-group-intro {
  font-size: 13px;
  color: #475569;
  margin-bottom: 12px;
  border-left: 3px solid #3b82f6;
  padding-left: 10px;
  font-style: italic;
}

/* Each sub-occupation section */
.soc-sub-section {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}
.soc-sub-heading {
  background: #f8fafc;
  padding: 7px 12px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.soc-sub-code {
  font-family: monospace;
  font-size: 11px;
  color: #64748b;
  background: #e2e8f0;
  border-radius: 3px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.soc-sub-title {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

/* Definition block (used for both direct and sub entries) */
.soc-def-block {
  padding: 10px 12px;
}
.soc-definition {
  font-size: 13px;
  color: #334155;
  line-height: 1.55;
  margin-bottom: 8px;
}
.soc-definition:last-child { margin-bottom: 0; }
.soc-examples {
  font-size: 12px;
  color: #64748b;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.soc-ex-label {
  font-weight: 600;
  color: #475569;
  margin-right: 2px;
}
.soc-ex-chip {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 1px 7px;
  font-size: 11px;
  color: #475569;
}

/* ── Mobile layout ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Unlock the viewport-height lock so the page scrolls normally */
  body {
    overflow: auto !important;
    height: auto !important;
  }

  /* Stack all flex children as a normal scrolling column */
  .main-layout {
    flex-direction: column !important;
    overflow: visible !important;
    height: auto !important;
    flex: none !important;
    min-height: 0;
  }

  /* Table pane: full width, natural height, horizontally scrollable */
  .table-pane {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    flex: none !important;
  }

  .table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    max-height: none;
    flex: none !important;
    height: auto !important;
  }

  /* Hide the drag divider */
  .pane-divider { display: none !important; }

  /* Historical pane: sits below table, natural height */
  .hist-pane {
    flex: none !important;
    height: auto !important;
    overflow: visible !important;
    min-height: 0;
  }

  .hist-chart-wrap {
    flex: none !important;
    height: 280px;
  }

  .hist-table-scroll {
    overflow-x: auto;
    max-height: 300px;
  }

  .scenario-bar { flex-wrap: wrap; }

  .disclaimer-bar { padding: 8px 14px; }
}
