:root {
  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --success: #10b981;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --warning-bg: #422006;
  --warning-text: #fbbf24;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 2.5rem 2rem;
  min-height: 160px;
  border-radius: 12px;
  overflow: hidden;
  background-color: #1a5499;
  background-image: url('/Picture1.jpg');
  background-size: 105%;
  background-position: 35% 20%;
  isolation: isolate;
}

/* Dark mode */
[data-theme="dark"] header {
  background-color: #060008;
  background-image: url('/Picture2.jpg');
  background-size: 110%;
  background-position: 51% 5%;
}

.header-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.logo-link { display: block; line-height: 0; }
.logo-link:focus-visible { outline: 2px solid rgba(255,255,255,0.6); border-radius: 4px; }

.site-logo {
  max-height: 48px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  display: block;
}

.subtitle { color: rgba(255,255,255,0.85); font-size: 0.9rem; position: relative; z-index: 1; }

.icon-btn {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}

[data-theme="dark"] .icon-btn {
  background: rgba(30, 41, 59, 0.7);
}

/* Inputs */
.input-section { margin-bottom: 2rem; }

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.input-header label { font-weight: 600; font-size: 0.95rem; }
.input-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.index-load-group {
  display: flex;
  gap: 0;
}

.index-load-group select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
}

.index-load-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  white-space: nowrap;
}

textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  color: var(--text);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.875rem;
  resize: vertical;
  transition: border-color 0.15s;
}

textarea:focus { outline: none; border-color: var(--primary); }

.ticker-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

#indexAsOf {
  font-style: italic;
  opacity: 0.75;
}

.options-row {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0;
  align-items: end;
}

.option label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.875rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-secondary { background: var(--bg-alt); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-alt); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.65rem 1.5rem; font-size: 1rem; margin-top: 0.75rem; }

/* Preview section */
.preview-section { margin-bottom: 2rem; }

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preview-header h2 { font-size: 1.25rem; }
.preview-actions { display: flex; gap: 0.5rem; align-items: center; }

.badge {
  background: var(--primary);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Errors panel */
.errors-panel {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.errors-panel strong { display: block; margin-bottom: 0.25rem; }
.errors-panel ul { margin: 0; padding-left: 1.25rem; }

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-alt);
  font-weight: 600;
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-alt); }

.col-check { width: 40px; text-align: center; }
.col-check input { cursor: pointer; }

td a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.8rem;
}

td a:hover { text-decoration: underline; }

/* Progress section */
.progress-section { margin-bottom: 2rem; }
.progress-section h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }

.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-text {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.progress-log {
  max-height: 250px;
  overflow-y: auto;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.progress-log .log-line { padding: 0.15rem 0; }
.progress-log .log-warning { color: var(--danger); }
.progress-log .log-success { color: var(--success); }

/* Format toggle (HTML / PDF) */
.format-section {
  margin: 1rem 0 0.5rem;
}

.folder-structure-section {
  margin: 1rem 0 0.5rem;
}

/* ── Download Options collapsible ── */
.download-options {
  margin: 1rem 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.download-options-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--bg-alt);
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  gap: 0.5rem;
}
.download-options-toggle:hover { background: var(--border); }

.toggle-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.download-options-toggle.open .toggle-chevron {
  transform: rotate(180deg);
}

.download-options-body {
  display: none;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.download-options-body.open { display: flex; }

.opt-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.opt-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 100px;
  flex-shrink: 0;
}
.opt-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 3px;
}

.format-pill {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-alt);
}

.format-opt {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.format-opt input[type="radio"] {
  display: none;
}

.format-opt span {
  padding: 0.4rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.format-opt input[type="radio"]:checked + span {
  background: var(--primary);
  color: #fff;
}

.format-opt:not(:last-child) span {
  border-right: 1px solid var(--border);
}

.format-note {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.recommended-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: #10b981;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 5px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.embed-warning {
  margin-top: 0.6rem;
  padding: 0.65rem 0.9rem;
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Date mode selector */
.date-mode-section {
  margin: 1rem 0 0.5rem;
}

.mode-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  cursor: pointer;
  transition: border-color 0.15s;
  flex-wrap: wrap;
}

.mode-row:has(input:checked) {
  border-color: var(--primary);
  background: var(--bg);
}

.mode-row--inactive {
  opacity: 0.5;
}

.mode-row input[type="radio"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  cursor: pointer;
}

.mode-label {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.mode-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.mode-ctrl {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
}

.mode-ctrl:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.date-input {
  width: 140px;
}

/* ── Custom Tooltips ─────────────────────────────────────────── */
/* Replaces browser title= tooltips — appears instantly, no delay */
.quick-chip,
.tax-item {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 260px;
  padding: 0.5rem 0.7rem;
  background: rgba(15, 23, 42, 0.95);
  color: #f1f5f9;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.5;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s ease;
  z-index: 1000;
  white-space: normal;
}

[data-tooltip]:hover::before {
  opacity: 1;
}

/* Tax items: pop tooltip upward, right-aligned so it doesn't overflow left */
.tax-items [data-tooltip]::before {
  left: auto;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 2000;
}

/* ── Filing Type Section ─────────────────────────────────────── */
.filing-type-section {
  margin: 1rem 0 0.5rem;
}

.filing-type-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.filing-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filing-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Quick Link Chips ────────────────────────────────────────── */
.quick-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.quick-chip {
  display: flex;
  cursor: pointer;
  user-select: none;
}

.quick-chip input[type="checkbox"] {
  display: none;
}

.chip-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg-alt);
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
  min-width: 80px;
  text-align: center;
}

.chip-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.2;
}

.chip-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 1.2;
}

.quick-chip:hover .chip-inner {
  border-color: var(--primary);
  background: var(--bg);
}

.quick-chip input[type="checkbox"]:checked + .chip-inner {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.quick-chip input[type="checkbox"]:checked + .chip-inner .chip-name,
.quick-chip input[type="checkbox"]:checked + .chip-inner .chip-sub {
  color: #fff;
}

/* FMP-sourced chips (Transcripts) — green accent */
.quick-chip--fmp input[type="checkbox"]:checked + .chip-inner {
  border-color: #059669;
  background: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.quick-chip--fmp:hover .chip-inner { border-color: #059669; }

/* Price Data chip — indigo/slate accent */
.quick-chip--price input[type="checkbox"]:checked + .chip-inner {
  border-color: #7c3aed;
  background: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.quick-chip--price:hover .chip-inner { border-color: #7c3aed; }

/* ── More Types Toggle ───────────────────────────────────────── */
.more-types-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  margin-bottom: 0.5rem;
}

.more-types-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg-alt);
}

.more-types-toggle.open { color: var(--primary); border-color: var(--primary); }
.more-types-toggle.open .toggle-chevron { transform: rotate(180deg); }

.more-types-body {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  margin-bottom: 0.5rem;
}

.more-types-body.open { display: flex; }

/* ── Taxonomy Categories ─────────────────────────────────────── */
.tax-category {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* overflow: visible so ::before tooltips aren't clipped */
  overflow: visible;
  position: relative;
}

.tax-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  /* Round top corners to match parent card */
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

.tax-cat-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tax-source-tag {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tax-source-edgar { background: #fefce8; color: #854d0e; }
.tax-source-fmp   { background: #f0fdf4; color: #166534; }
.tax-source-fds   { background: #eff6ff; color: #1d4ed8; }

[data-theme="dark"] .tax-source-edgar { background: #422006; color: #fde68a; }
[data-theme="dark"] .tax-source-fmp   { background: #14532d; color: #86efac; }
[data-theme="dark"] .tax-source-fds   { background: #1e3a5f; color: #93c5fd; }

.tax-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem;
}

/* ── Taxonomy Item (checkbox) ────────────────────────────────── */
.tax-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.tax-item:hover {
  border-color: var(--primary);
  background: var(--bg);
}

.tax-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.tax-item-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.tax-item-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.tax-item input[type="checkbox"]:checked ~ .tax-item-name {
  color: var(--primary);
}

/* Caution item */
.tax-item--caution {
  border-color: #f59e0b;
  border-style: dashed;
}

.tax-item--caution:hover { border-color: #d97706; }

.caution-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 3px;
  vertical-align: middle;
}

[data-theme="dark"] .caution-tag { background: #422006; color: #fbbf24; }
[data-theme="dark"] .tax-item--caution { border-color: #b45309; }

/* Form 4 count selector inline */
.tax-item--form4 { flex-wrap: wrap; }

.form4-count-wrap {
  display: none;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.4rem;
  flex-wrap: nowrap;
}

.form4-count-wrap.visible { display: inline-flex; }

.form4-count-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.form4-count-select {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
}

/* Filing type checkboxes (legacy) */
.filing-types-section {
  margin: 1rem 0 0.5rem;
}

/* ── Taxonomy Category Color Coding ─────────────────────────── */
.tax-category[data-cat-color] {
  border-left-width: 3px;
  border-left-style: solid;
}

/* Blue — Periodic Reports */
.tax-category[data-cat-color="blue"] { border-left-color: #3b82f6; }
.tax-category[data-cat-color="blue"] .tax-cat-header { background: #eff6ff; }
[data-theme="dark"] .tax-category[data-cat-color="blue"] .tax-cat-header { background: #1e3a5f; }

/* Amber — Earnings & Guidance */
.tax-category[data-cat-color="amber"] { border-left-color: #f59e0b; }
.tax-category[data-cat-color="amber"] .tax-cat-header { background: #fffbeb; }
[data-theme="dark"] .tax-category[data-cat-color="amber"] .tax-cat-header { background: #422006; }

/* Orange — Current Events */
.tax-category[data-cat-color="orange"] { border-left-color: #f97316; }
.tax-category[data-cat-color="orange"] .tax-cat-header { background: #fff7ed; }
[data-theme="dark"] .tax-category[data-cat-color="orange"] .tax-cat-header { background: #431407; }

/* Purple — Proxy & Governance */
.tax-category[data-cat-color="purple"] { border-left-color: #8b5cf6; }
.tax-category[data-cat-color="purple"] .tax-cat-header { background: #f5f3ff; }
[data-theme="dark"] .tax-category[data-cat-color="purple"] .tax-cat-header { background: #2e1065; }

/* Teal — Ownership & Insider */
.tax-category[data-cat-color="teal"] { border-left-color: #14b8a6; }
.tax-category[data-cat-color="teal"] .tax-cat-header { background: #f0fdfa; }
[data-theme="dark"] .tax-category[data-cat-color="teal"] .tax-cat-header { background: #042f2e; }

/* Rose — M&A */
.tax-category[data-cat-color="rose"] { border-left-color: #f43f5e; }
.tax-category[data-cat-color="rose"] .tax-cat-header { background: #fff1f2; }
[data-theme="dark"] .tax-category[data-cat-color="rose"] .tax-cat-header { background: #4c0519; }

/* Green — Registration */
.tax-category[data-cat-color="green"] { border-left-color: #22c55e; }
.tax-category[data-cat-color="green"] .tax-cat-header { background: #f0fdf4; }
[data-theme="dark"] .tax-category[data-cat-color="green"] .tax-cat-header { background: #052e16; }

/* ── Quick-link mirrors inside taxonomy ──────────────────────── */
.tax-item--ql {
  background: var(--bg);
  border-style: solid;
  border-color: var(--primary);
  border-width: 1px;
  opacity: 0.85;
}

.tax-item--ql:hover { opacity: 1; }

.ql-tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(37,99,235,0.08);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

[data-theme="dark"] .ql-tag {
  background: rgba(59,130,246,0.15);
  color: #93c5fd;
}

/* ── Form 4 transaction code filter ─────────────────────────── */
.form4-codes-wrap {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.form4-codes-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form4-codes-hint {
  font-weight: 400;
  font-style: italic;
}

.form4-codes-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.f4code-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  position: relative;
}

.f4code-chip:hover { border-color: var(--primary); color: var(--text); }
.f4code-chip input[type="checkbox"] { display: none; }
.f4code-chip input[type="checkbox"]:checked + * { color: inherit; }
.f4code-chip:has(input:checked) {
  border-color: #14b8a6;
  background: #14b8a6;
  color: #fff;
}

/* ── Form 4 — grey out date range when it's the only type ────── */
.date-mode-section.form4-only-mode {
  opacity: 0.38;
  pointer-events: none;
  user-select: none;
}

.form4-date-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-alt);
  border-radius: var(--radius);
  border-left: 3px solid #14b8a6;
  display: none;
}

.form4-date-note.visible { display: block; }

.section-label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}

.filing-types-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.checkbox-label:hover {
  border-color: var(--primary);
  background: var(--bg);
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-text strong {
  color: var(--primary);
}

.checkbox-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.checkbox-text strong {
  font-size: 0.875rem;
  font-weight: 600;
}

.checkbox-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.form-type-warning {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--danger);
}

/* FMP-only checkboxes get a subtle accent border */
.checkbox-fmp {
  border-color: #10b981;
  border-style: dashed;
}
.checkbox-fmp:hover { border-color: #059669; }

.fmp-note {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.fmp-note code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05em 0.3em;
  font-size: 0.85em;
}

.muted { color: var(--text-muted); font-weight: 400; }

/* Form type badges in the table */
.type-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-teal   { background: #ccfbf1; color: #0f766e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-gray   { background: #f1f5f9; color: #475569; }

[data-theme="dark"] .badge-purple { background: #3b0764; color: #c4b5fd; }
[data-theme="dark"] .badge-blue   { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-teal   { background: #134e4a; color: #5eead4; }
[data-theme="dark"] .badge-orange { background: #431407; color: #fdba74; }
[data-theme="dark"] .badge-red    { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-green  { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-gray   { background: #1e293b; color: #94a3b8; }

/* Source badges (FinancialDatasets / EDGAR / FMP) */
.source-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.source-fds   { background: #eff6ff; color: #1d4ed8; }
.source-edgar { background: #fefce8; color: #854d0e; }
.source-fmp   { background: #f0fdf4; color: #166534; }

[data-theme="dark"] .source-fds   { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .source-edgar { background: #422006; color: #fde68a; }
[data-theme="dark"] .source-fmp   { background: #14532d; color: #86efac; }

/* Source summary line below preview header */
.source-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -0.5rem 0 0.75rem;
}

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 640px) {
  .container { padding: 1rem; }
  header { padding: 1.25rem; }
  .site-logo { height: 36px; }
  .options-row { flex-direction: column; }
}
