:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --border: #e8e6dc;
  --text: #141413;
  --text-muted: #b0aea5;
  --accent: #d97757;
  --accent-hover: #c4613f;
  --green: #788c5d;
  --green-bg: #eef2e8;
  --red: #c44;
  --red-bg: #fceaea;
  --header-bg: #141413;
  --header-text: #faf9f5;
  --radius: 6px;

  /* Level colors */
  --level-junior: #DAEEF3;
  --level-mid: #E2EFDA;
  --level-mid-senior: #FFF2CC;
  --level-psl: #F2DCDB;
  --level-senior: #D9E2F3;
}

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

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────── */

.header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-family: 'Poppins', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
}

.header .subtitle {
  font-size: 0.8rem;
  opacity: 0.6;
  margin-top: 0.15rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-right .admin-link {
  color: var(--accent);
  text-decoration: none;
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
}

.header-right .admin-link:hover { text-decoration: underline; }

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--header-text);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-logout:hover { border-color: rgba(255,255,255,0.6); }

/* ── Login ──────────────────────────────────────────── */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 360px;
  text-align: center;
}

.login-card h1 {
  font-family: 'Poppins', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.login-card .brand {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lora', Georgia, serif;
  font-size: 0.9375rem;
  outline: none;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card .error {
  color: var(--red);
  font-size: 0.8rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

/* ── Buttons ────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: 'Poppins', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
  margin-top: 1rem;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-secondary:hover { background: rgba(217, 119, 87, 0.08); }

.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover { background: #a33; }

.btn-success {
  background: var(--green);
  color: white;
}

.btn-success:hover { background: #607044; }

/* ── Tabs ───────────────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 2rem;
  position: sticky;
  top: var(--header-height, 56px);
  z-index: 99;
}

.tab {
  padding: 0.75rem 1.25rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Main content ───────────────────────────────────── */

.main {
  padding: 1.5rem 2rem;
}

/* ── Sections / Cards ───────────────────────────────── */

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.section-header {
  font-family: 'Poppins', sans-serif;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.section-body {
  padding: 1rem;
}

/* ── Matrix Table ───────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  position: sticky;
  top: calc(var(--header-height, 73px) + var(--tabs-height, 45px));
  z-index: 97;
}

.filter-bar select,
.filter-bar input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lora', serif;
  font-size: 0.8rem;
}

.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-bar label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── Global Date Filter Bar ────────────────────────── */

.date-filter-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: 'Poppins', sans-serif;
  position: sticky;
  top: calc(var(--header-height, 56px) + var(--tabs-height, 42px));
  z-index: 98;
}

.date-filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.date-filter-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-filter-inputs label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.date-period-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lora', serif;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
  min-width: 130px;
}

.date-period-select:focus {
  outline: none;
  border-color: var(--accent);
}

.date-filter-inputs .btn {
  font-size: 0.7rem;
  padding: 0.3rem 0.7rem;
}

.date-filter-summary {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.date-filter-summary .active-filter {
  color: var(--accent);
  font-weight: 500;
}

.global-filter-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.firm-type-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lora', serif;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
}

.firm-type-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Hide global bar on matrix tab */
.date-filter-bar.hidden-bar {
  display: none;
}

@media (max-width: 600px) {
  .date-filter-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.5rem 1rem;
  }
  .global-filter-separator {
    width: 100%;
    height: 1px;
  }
}

/* ── Period Comparison Badges ──────────────────────── */

.period-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.6rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  margin-left: 0.5rem;
}

.period-badge.up {
  color: var(--green);
  background: var(--green-bg);
}

.period-badge.down {
  color: #c44;
  background: rgba(196, 68, 68, 0.1);
}

.period-badge.neutral {
  color: var(--text-muted);
  background: var(--bg);
}

.chart-header-with-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-header-with-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-header-select {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lora', serif;
  font-size: 0.75rem;
  background: var(--surface);
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  max-width: 220px;
}

.chart-header-select:focus {
  outline: none;
  border-color: var(--accent);
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

.matrix-table th {
  background: #2F5496;
  color: white;
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.6rem 0.75rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  position: sticky;
  top: calc(var(--header-height, 73px) + var(--tabs-height, 45px) + var(--matrix-filter-height, 114px));
  z-index: 2;
}

.matrix-table th:hover { background: #254280; }
.matrix-table th .sort-arrow { margin-left: 0.25rem; opacity: 0.6; }

.matrix-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.4;
}

.matrix-table tbody tr { cursor: pointer; }
.matrix-table tr:nth-child(even) td { background: #f8f7f3; }
.matrix-table tr:hover td { background: #f0efe9; }

.matrix-table .level-cell {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  display: inline-block;
}

.level-junior { background: var(--level-junior); }
.level-mid-level { background: var(--level-mid); }
.level-mid-senior { background: var(--level-mid-senior); }
.level-psl { background: var(--level-psl); }
.level-senior { background: var(--level-senior); }

.reqs-list {
  list-style: none;
  padding: 0;
}

.reqs-list li {
  padding: 0.15rem 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.reqs-list li::before {
  content: "\2022";
  color: var(--accent);
  margin-right: 0.4rem;
}

.skill-tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  background: rgba(217, 119, 87, 0.1);
  color: var(--accent);
  border-radius: 3px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.65rem;
  font-weight: 500;
  margin: 0.1rem 0.15rem;
}

/* ── Charts Grid ────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.charts-grid .chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.charts-grid .chart-card.full-width {
  grid-column: 1 / -1;
}

.chart-header {
  font-family: 'Poppins', sans-serif;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.chart-body {
  padding: 0;
  flex: 1;
  min-height: 280px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.chart-body svg {
  display: block;
  flex: 1;
  width: 100%;
  min-height: 0;
}

.chart-body > .empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.chart-body .trend-legend {
  flex-shrink: 0;
}

/* ── Trend Section ─────────────────────────────────── */

.trends-section {
  margin-top: 2rem;
}

.trends-header {
  margin-bottom: 1rem;
}

.trends-header h3 {
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.trends-header p {
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ── Trend Chart Internals ─────────────────────────── */

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 1rem 0;
  justify-content: center;
}

.trend-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.6rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: opacity 0.2s, background 0.15s;
  padding: 0.2rem 0.45rem;
  border-radius: 3px;
  border: 1px solid transparent;
  user-select: none;
}

.trend-legend-item:hover {
  background: var(--bg);
  border-color: var(--border);
}

.trend-legend-item.dimmed {
  opacity: 0.35;
  text-decoration: line-through;
}

.trend-legend-toggle {
  font-size: 1.1rem;
  line-height: 1;
}

.trend-legend-swatch {
  width: 18px;
  height: 5px;
  border-radius: 3px;
}

.trend-tooltip {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  max-width: 220px;
  transition: opacity 0.15s;
}

.trend-tooltip .tooltip-period {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.trend-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.trend-tooltip .tooltip-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}

/* ── Predictor ──────────────────────────────────────── */

.predictor-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
}

.predictor-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.predictor-controls h3 {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.control-group {
  margin-bottom: 1.25rem;
}

.control-group label {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.control-group .slider-value {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  float: right;
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-family: 'Lora', serif;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  transition: border-color 0.15s, background 0.15s;
}

.checkbox-group label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(217, 119, 87, 0.08);
}

.checkbox-group input[type="checkbox"] {
  accent-color: var(--accent);
}

.radio-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.radio-group label {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0.5rem;
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  border-right: 1px solid var(--border);
  transition: background 0.15s;
}

.radio-group label:last-child { border-right: none; }
.radio-group input { display: none; }
.radio-group label:has(input:checked) { background: var(--accent); color: white; }

/* Predictor results */

.predictor-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.salary-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.salary-result .label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.salary-result .range {
  font-family: 'Poppins', sans-serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0.5rem 0;
}

.salary-result .median {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.salary-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 0.75rem;
  position: relative;
  overflow: hidden;
}

.salary-bar .fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: left 0.3s, width 0.3s;
}

.titles-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.titles-result h4 {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.title-pill {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.78rem;
  margin: 0.2rem;
}

.matching-jobs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.matching-jobs h4 {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.match-item {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}

.match-item:last-child { border-bottom: none; }

.match-item .match-title {
  font-weight: 500;
  font-size: 0.85rem;
}

.match-item .match-firm {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.match-item .match-score {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

.match-item:hover {
  background: var(--green-bg);
}

.match-item .match-salary {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Row highlight animation when navigating from predictor */
@keyframes row-flash {
  0%   { background: var(--accent); color: #fff; }
  100% { background: transparent; color: inherit; }
}
.matrix-table tbody tr.highlight-row {
  animation: row-flash 2s ease-out;
}

/* ── Admin Panel ────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(217, 119, 87, 0.04);
}

.upload-zone .icon {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.upload-zone p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-zone .formats {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  opacity: 0.7;
}

.text-paste {
  width: 100%;
  min-height: 120px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  resize: vertical;
}

.text-paste:focus { outline: none; border-color: var(--accent); }

.draft-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.draft-table th {
  background: var(--bg);
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.draft-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-draft { background: #FFF2CC; color: #8a6d3b; }
.status-published { background: var(--green-bg); color: var(--green); }

/* ── Loading / Empty states ─────────────────────────── */

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Back to Predictor Button ──────────────────────── */

.btn-back-predictor {
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

/* ── Job Detail Modal ───────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 19, 0.55);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 3vh 1rem;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  transform: translateY(12px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0;
}

.modal-header-info h2 {
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.modal-header-info .modal-firm {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-header-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0.25rem;
  line-height: 1;
  margin-left: 0.5rem;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

/* Detail fields grid */
.jd-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.jd-meta-item {
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.jd-meta-item .meta-label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.jd-meta-item .meta-value {
  font-size: 0.85rem;
  line-height: 1.4;
}

.jd-meta-item.full-width {
  grid-column: 1 / -1;
}

/* Source text formatting */
.jd-source {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
}

.jd-source-header {
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.jd-source-text {
  font-size: 0.85rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.jd-source-text .jd-section-head {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  color: #2F5496;
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.jd-source-text .jd-list {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0.5rem 0;
  white-space: normal;
}

.jd-source-text .jd-list li {
  padding: 0.2rem 0 0.2rem 1rem;
  position: relative;
  line-height: 1.5;
}

.jd-source-text .jd-list li::before {
  content: "\2022";
  color: var(--accent);
  position: absolute;
  left: 0;
}

.jd-source-text .jd-firm-line {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 0.5rem;
}

.jd-source-text .jd-title-line {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.75rem;
}

.jd-constructed {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
}

.jd-constructed-header {
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.jd-constructed-header .note {
  font-size: 0.65rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ── Word Cloud ────────────────────────────────────── */

.word-cloud-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem;
  min-height: 260px;
  flex: 1;
  width: 100%;
}

.word-cloud-item {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  cursor: default;
  transition: opacity 0.2s;
  white-space: nowrap;
  line-height: 1.3;
}

.word-cloud-item:hover {
  opacity: 0.7;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .predictor-layout { grid-template-columns: 1fr; }
  .header { padding: 0.75rem 1rem; }
  .main { padding: 1rem; }
  .tabs { padding: 0 1rem; }
}

@media (max-width: 600px) {
  .filter-bar { flex-direction: column; }
  .matrix-table { font-size: 0.75rem; }
}
