:root {
  color-scheme: light;
  --ink: #292c23;
  --ink-soft: #4b5142;
  --muted: #747969;
  --muted-2: #969987;
  --line: #e6dfcc;
  --canvas: #f3f0e6;
  --white: #fffdf7;
  --navy: #24372b;
  --navy-2: #354b3b;
  --teal: #21866d;
  --teal-dark: #176b57;
  --teal-light: #e8f3e8;
  --gold: #c28b39;
  --gold-light: #fbf2dc;
  --purple: #7967a5;
  --purple-light: #f0edf7;
  --blue: #6d8a63;
  --blue-light: #edf2e7;
  --rose: #bb6755;
  --rose-light: #faebe4;
  --green: #4d815a;
  --green-light: #e8f2e7;
  --shadow: 0 12px 32px rgba(45, 49, 34, .065);
  --surface-raised: #fffef9;
  --surface-subtle: #f8f5ec;
}

:root[data-theme="light"] { color-scheme: light; }

body, .main-area { background: var(--canvas); color: var(--ink); }
.sidebar { background: linear-gradient(180deg, #293d2f 0%, #1c2d22 100%); }
.topbar { border-bottom-color: #e7e0cf; background: rgba(255, 253, 247, .95); }
.breadcrumb strong, h1, h2, h3 { color: #2a3b2e; }
.heading-copy, .card-heading p, .form-section-heading p { color: #747969; }
.global-note, .view-card, .login-card { border-color: var(--line); background: var(--white); }
.global-note { color: #626b59; }
.info-icon { background: #e9f1e7; color: #4d7658; }
.page-footer { border-top-color: var(--line); color: #777c6b; }
.button-secondary, .button-quiet { border-color: #e3ddcb; background: var(--surface-raised); color: #50604d; }
.button-secondary:hover:not(:disabled), .button-quiet:hover:not(:disabled) { border-color: #adc6a5; background: #f5f8ef; color: var(--teal-dark); }
.step-chip { border-color: #dfdfcb; background: #fffdf7; color: #47795f; }
.view-card { box-shadow: var(--shadow); }
.metric-card { border-color: #e8e1cf; background: linear-gradient(145deg, #fffef9 25%, #f8f5eb 100%); }
.metric-card strong { color: #344d37; }
.callout-gold { border-color: #ead9ae; background: #fff8e7; color: #77613c; }
.callout-blue { border-color: #dce5d3; background: #f0f4e9; color: #5f7158; }
.callout-teal { border-color: #d5e5d5; background: #eff6ec; color: #527451; }
.callout-rose { border-color: #efd8d0; background: #fcf2ed; color: #88584d; }
.status-pending { background: #fbf1d9; color: #8a682e; }
.status-readonly { background: #f0efe7; color: #6b7163; }
.status-ready { background: #e9f3e7; color: #3e754b; }
.tag { background: #f1eee4; color: #697160; }
.type-pill { background: #edf1e7; color: #5e7659; }
.type-pill.numérica, .type-pill.numeric { background: #e6f2e8; color: #32745a; }
.type-pill.fecha { background: #faf0dc; color: #8b6b36; }
.type-pill.sin-datos { background: #f0efe8; color: #72776b; }
.table-wrap { border-color: #e6e0d0; }
.data-table thead { background: #f5f1e5; }
.data-table th { color: #777967; }
.data-table td { border-top-color: #ebe5d7; color: #5c6654; }
.data-table td:first-child { color: #394a38; }
.inline-note.info { background: #edf2e7; color: #5f7158; }
.inline-note.warning { background: #fbf2dc; color: #806840; }
.inline-note.success { background: #e8f2e7; color: #47744f; }
.source-strip, .case-context { border-color: #e3e6d7; background: #fbfcf4; }
.source-strip-icon, .context-tag { background: #e6f2e7; color: #39775e; }
.source-strip strong, .case-context strong { color: #465b45; }
.context-question, .source-strip-detail { color: #747969; }
.field { color: #485744; }
.field input, .field select, .field textarea { border-color: #dedfce; background: #fffef9; color: #343f32; }
.field input::placeholder, .field textarea::placeholder { color: #999b8c; }
.choice-card { border-color: #e6e1d3; background: linear-gradient(145deg, #fffef9, #f9f7ef); }
.choice-card:hover { border-color: #a8c8ad; background: #fbfdf6; }
.choice-card:has(input:checked) { border-color: #60a17c; background: linear-gradient(145deg, #eff7ec, #fffef9); }
.choice-card strong { color: #354a37; }
.choice-card small { color: #747969; }
.section-index { border-color: #dce8d9; background: #edf5e9; color: #3f785d; }
.icon-blue { background: #edf2e7; color: #6d8a63; }
.icon-teal { background: #e7f2e7; color: #21866d; }
.icon-violet { background: #f0edf7; color: #7967a5; }
.icon-amber { background: #fbf2dc; color: #bd8737; }
.icon-rose { background: #faebe4; color: #bb6755; }
.source-tabs { border-color: #e5dfcf; background: #f3f0e6; }
.source-tab { color: #6e7567; }
.source-tab.is-selected { background: #fffdf7; color: #287457; }
.dropzone { border-color: #a8c7a9; background: linear-gradient(135deg, #f7fbf2, #f0f6ec); color: #687563; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--teal); background: #edf6e9; }
.upload-symbol { border-color: #dcebd8; background: #fffef9; color: var(--teal); }
.file-summary, .history-card, .detail-fact, .timeline-step, .timeline-json, .output-item, .mapping-plan-row, .saved-rule-row { border-color: #e6e1d3; background: var(--surface-raised); }
.file-info strong, .history-card h3, .detail-summary h2, .timeline-step-head, .mapping-plan-row strong, .saved-rule-row strong { color: #405540; }
.file-info small, .history-question, .history-date, .history-card-meta, .detail-fact small, .detail-fact strong, .timeline-json summary { color: #747969; }
.db-icon { background: #edf2e7; color: #6d8a63; }
.database-aside { border-color: #e6dfcc; background: #f8f5ec; }
.security-note { border-color: #d2a952; background: #fbf5e7; color: #806840; }
.history-tabs { border-color: #e6dfcc; }
.history-tab { color: #747969; }
.history-tab.is-selected { color: #287457; }
.history-tab.is-selected::after { background: #3b9a78; }
.history-load-message { border-color: #e0e5d6; background: #f9faf4; color: #687563; }
.status-chip { background: #efefe7; color: #68715f; }
.status-in_progress { background: #fbf1d9; color: #8a682e; }
.status-completed, .status-retained { background: #e8f2e7; color: #3e754b; }
.status-failed, .status-not-retained { background: #f4e9e3; color: #8a5f51; }
.backend-transfer { border-color: #dce8da; background: #f8fbf3; }
.backend-transfer h2 { color: #46634b; }
.backend-transfer p, .backend-transfer-status { color: #687967; }
.retain-csv-option, .retain-csv-option strong { color: #526d58; }
.quality-controls p, .standardize-controls p, .finding-list, .variant-stat span, .small-note { color: #747969; }
.variant-stat, .saved-rule-row, .mapping-plan-row { border-color: #e6e1d3; background: #faf9f2; }
.mapping-hint, .objective-guidance { border-color: #94bd9e; background: #f0f6eb; color: #5d735d; }
.mapping-input { border-color: #dedfce; background: #fffef9; color: #344435; }
.pattern-pill { background: #f0efe7; color: #6d7466; }
.pattern-found { background: #fbf2dc; color: #8a682e; }
.exclude-row-option { color: #806840; }
.mapping-plan-exclusion { background: #f8eae2; color: #925e49; }
.recipe-preview { border-color: #dce8da; background: #f4f8ef; color: #5e735f; }
.recipe-preview strong { color: #426b4e; }
.suggestion-pill { background: #f7efdc; color: #8a6c38; }
.target-pill { background: #e7f2e7; color: #32745a; }
.analysis-note { border-color: #d0a954; background: #fbf5e7; color: #806840; }
.backend-pending { border-color: #eadbb9; background: #fbf6e9; }
.backend-pending h2 { color: #695638; }
.backend-pending p { color: #7c6e50; }
.summary-card { border-color: #e6dfcc; background: #fffdf7; }
.summary-card small, .summary-card p { color: #747969; }
.summary-card strong { color: #405540; }
.output-index { background: #e7f2e7; color: #287457; }
.login-mark { border-color: #dce8d9; background: #edf5e9; color: #287457; }
.login-intro h2 { color: #354a37; }
.login-intro p, .login-footnote { color: #747969; }
.login-error { border-color: #eed8cf; background: #fcf2ed; color: #915d50; }
.toast { border-color: #e2ddcc; background: #fffdf7; color: #4e5c49; }
.theme-toggle {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid #e0ddcd;
  border-radius: 10px;
  background: #fbf8ef;
  color: #58634e;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.theme-toggle:hover { transform: translateY(-1px); border-color: #c3cba9; background: #f2f4e8; color: #286b51; }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f5eee5;
  --ink-soft: #e0d6ca;
  --muted: #c2b8ae;
  --muted-2: #9a8f8c;
  --line: #433d49;
  --canvas: #19171e;
  --white: #24212a;
  --navy: #17151d;
  --navy-2: #302a38;
  --teal: #55d2a5;
  --teal-dark: #39b88a;
  --teal-light: #293d37;
  --gold: #f1c267;
  --gold-light: #41351f;
  --purple: #c4adff;
  --purple-light: #3c334d;
  --blue: #b4c48e;
  --blue-light: #37372d;
  --rose: #f09a82;
  --rose-light: #422c2d;
  --green: #8bdd9a;
  --green-light: #2d3d33;
  --shadow: 0 16px 38px rgba(0, 0, 0, .3);
  --surface-raised: #2d2934;
  --surface-subtle: #201e25;
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .main-area { background: var(--canvas); color: var(--ink); }
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #202d22 0%, #141c16 100%); }
:root[data-theme="dark"] .topbar { border-bottom-color: #344037; background: rgba(31, 40, 32, .96); }
:root[data-theme="dark"] .breadcrumb,
:root[data-theme="dark"] .breadcrumb strong { color: #c6cbb8; }
:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3,
:root[data-theme="dark"] .form-section-heading h2,
:root[data-theme="dark"] .card-heading h2,
:root[data-theme="dark"] .history-filter-heading h2,
:root[data-theme="dark"] .login-intro h2 { color: #f0eddf; }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .heading-copy,
:root[data-theme="dark"] .form-section-heading p,
:root[data-theme="dark"] .card-heading p,
:root[data-theme="dark"] .history-filter-heading p,
:root[data-theme="dark"] .page-footer,
:root[data-theme="dark"] .form-footnote,
:root[data-theme="dark"] .small-note { color: #aeb6a2; }
:root[data-theme="dark"] .global-note,
:root[data-theme="dark"] .view-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .history-card,
:root[data-theme="dark"] .detail-fact,
:root[data-theme="dark"] .timeline-step,
:root[data-theme="dark"] .timeline-json,
:root[data-theme="dark"] .output-item,
:root[data-theme="dark"] .file-summary,
:root[data-theme="dark"] .source-strip,
:root[data-theme="dark"] .case-context,
:root[data-theme="dark"] .summary-card { border-color: var(--line); background: var(--white); color: var(--ink); }
:root[data-theme="dark"] .global-note { color: #c8cbb9; box-shadow: none; }
:root[data-theme="dark"] .info-icon { background: #334238; color: #8fd1ac; }
:root[data-theme="dark"] .step-chip { border-color: #465447; background: #263127; color: #85d2ad; }
:root[data-theme="dark"] .button-secondary,
:root[data-theme="dark"] .button-quiet { border-color: #465347; background: #293329; color: #d4dbc8; }
:root[data-theme="dark"] .button-secondary:hover:not(:disabled),
:root[data-theme="dark"] .button-quiet:hover:not(:disabled) { border-color: #699278; background: #304335; color: #b6e5c7; }
:root[data-theme="dark"] .button-disabled,
:root[data-theme="dark"] .button:disabled { border-color: #384239; background: #2b322c; color: #7e877b; }
:root[data-theme="dark"] .theme-toggle { border-color: #485546; background: #29342b; color: #e5d18f; }
:root[data-theme="dark"] .theme-toggle:hover { border-color: #74865f; background: #354334; color: #f0dc9a; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .metric-card { border-color: var(--line); background: linear-gradient(145deg, #263027 20%, #202820 100%); }
:root[data-theme="dark"] .metric-card small,
:root[data-theme="dark"] .metric-card span,
:root[data-theme="dark"] .metric-card p,
:root[data-theme="dark"] .summary-card small,
:root[data-theme="dark"] .summary-card p,
:root[data-theme="dark"] .history-question,
:root[data-theme="dark"] .history-date,
:root[data-theme="dark"] .history-card-meta,
:root[data-theme="dark"] .context-question,
:root[data-theme="dark"] .source-strip-detail,
:root[data-theme="dark"] .detail-fact small,
:root[data-theme="dark"] .detail-fact strong,
:root[data-theme="dark"] .timeline-step-head,
:root[data-theme="dark"] .timeline-json summary,
:root[data-theme="dark"] .source-aside p,
:root[data-theme="dark"] .source-aside li,
:root[data-theme="dark"] .database-aside li,
:root[data-theme="dark"] .finding-list,
:root[data-theme="dark"] .variant-stat span,
:root[data-theme="dark"] .quality-controls p,
:root[data-theme="dark"] .standardize-controls p,
:root[data-theme="dark"] .history-results-heading,
:root[data-theme="dark"] .history-load-message { color: #adb6a5; }
:root[data-theme="dark"] .metric-card strong,
:root[data-theme="dark"] .summary-card strong,
:root[data-theme="dark"] .history-card h3,
:root[data-theme="dark"] .detail-summary h2,
:root[data-theme="dark"] .timeline-step-head,
:root[data-theme="dark"] .file-info strong,
:root[data-theme="dark"] .source-strip strong,
:root[data-theme="dark"] .case-context strong,
:root[data-theme="dark"] .variant-stat strong,
:root[data-theme="dark"] .saved-rule-row strong,
:root[data-theme="dark"] .mapping-plan-row strong { color: #e7eadb; }
:root[data-theme="dark"] .callout-gold { border-color: #665633; background: #30291d; color: #e5cf96; }
:root[data-theme="dark"] .callout-blue { border-color: #43533d; background: #273126; color: #c4d4b0; }
:root[data-theme="dark"] .callout-teal { border-color: #3e5945; background: #243329; color: #b6d8bc; }
:root[data-theme="dark"] .callout-rose { border-color: #62453d; background: #332722; color: #e7b2a0; }
:root[data-theme="dark"] .status-pending { background: #443922; color: #e8c871; }
:root[data-theme="dark"] .status-readonly { background: #333a32; color: #c0c7b5; }
:root[data-theme="dark"] .status-ready,
:root[data-theme="dark"] .status-completed,
:root[data-theme="dark"] .status-retained { background: #293b2c; color: #96d7a0; }
:root[data-theme="dark"] .status-failed,
:root[data-theme="dark"] .status-not-retained { background: #3b2c27; color: #e1a78f; }
:root[data-theme="dark"] .tag,
:root[data-theme="dark"] .type-pill,
:root[data-theme="dark"] .status-chip { background: #303a30; color: #c1c9b7; }
:root[data-theme="dark"] .type-pill.numérica,
:root[data-theme="dark"] .type-pill.numeric { background: #263c30; color: #9bd9b0; }
:root[data-theme="dark"] .type-pill.fecha { background: #403721; color: #e5c881; }
:root[data-theme="dark"] .type-pill.sin-datos { background: #303630; color: #b1b9ab; }
:root[data-theme="dark"] .table-wrap { border-color: var(--line); }
:root[data-theme="dark"] .data-table thead { background: #2b352c; }
:root[data-theme="dark"] .data-table th { color: #b6beac; }
:root[data-theme="dark"] .data-table td { border-top-color: #38443a; color: #c2c9b8; }
:root[data-theme="dark"] .data-table td:first-child { color: #e0e4d4; }
:root[data-theme="dark"] .empty-message { color: #aeb6a5; }
:root[data-theme="dark"] .inline-note.info { background: #29352a; color: #c3d4b4; }
:root[data-theme="dark"] .inline-note.warning { background: #39311f; color: #e1cb92; }
:root[data-theme="dark"] .inline-note.success { background: #29392b; color: #b6d8b4; }
:root[data-theme="dark"] .context-tag,
:root[data-theme="dark"] .source-strip-icon { background: #2b3e31; color: #a1d5ae; }
:root[data-theme="dark"] .field,
:root[data-theme="dark"] .field-label { color: #d2d8c8; }
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .mapping-input,
:root[data-theme="dark"] .search-field { border-color: #465246; background: #1b231c; color: #e4e8da; }
:root[data-theme="dark"] .field input::placeholder,
:root[data-theme="dark"] .field textarea::placeholder,
:root[data-theme="dark"] .search-field input::placeholder { color: #889182; }
:root[data-theme="dark"] select option { background: #1b231c; color: #e4e8da; }
:root[data-theme="dark"] .choice-card { border-color: #3c483c; background: linear-gradient(145deg, #263027, #202820); }
:root[data-theme="dark"] .choice-card:hover { border-color: #608d70; background: #2a382d; }
:root[data-theme="dark"] .choice-card:has(input:checked) { border-color: #55b58a; background: linear-gradient(145deg, #293b2e, #263027); }
:root[data-theme="dark"] .choice-card strong { color: #e1e6d7; }
:root[data-theme="dark"] .choice-card small { color: #adb7a7; }
:root[data-theme="dark"] .choice-check { border-color: #7f8a7b; }
:root[data-theme="dark"] .section-index { border-color: #405243; background: #2b3b2e; color: #9bd6ae; }
:root[data-theme="dark"] .icon-blue { background: #2e3a2b; color: #b0ce94; }
:root[data-theme="dark"] .icon-teal { background: #263b30; color: #75d4ad; }
:root[data-theme="dark"] .icon-violet { background: #352f45; color: #c2b1ef; }
:root[data-theme="dark"] .icon-amber { background: #403721; color: #e9c66b; }
:root[data-theme="dark"] .icon-rose { background: #3a2b27; color: #e99a7d; }
:root[data-theme="dark"] .source-tabs { border-color: #3a463a; background: #1d261f; }
:root[data-theme="dark"] .source-tab { color: #adb6a5; }
:root[data-theme="dark"] .source-tab.is-selected { background: #303a30; color: #a1d9b4; }
:root[data-theme="dark"] .dropzone { border-color: #567c5c; background: linear-gradient(135deg, #253329, #1e2b22); color: #b7c3b0; }
:root[data-theme="dark"] .dropzone:hover,
:root[data-theme="dark"] .dropzone.is-dragover { border-color: #62bf91; background: #293b2d; }
:root[data-theme="dark"] .upload-symbol { border-color: #405744; background: #2a352c; color: #70c99c; }
:root[data-theme="dark"] .file-icon { background: #2b3e31; color: #91d5a9; }
:root[data-theme="dark"] .file-remove { color: #e4a28d; }
:root[data-theme="dark"] .database-aside { border-color: var(--line); background: #1d261f; }
:root[data-theme="dark"] .db-icon { background: #2e3a2b; color: #b0ce94; }
:root[data-theme="dark"] .security-note { border-color: #806d3e; background: #302b20; color: #ddca96; }
:root[data-theme="dark"] .security-note strong { color: #f0d998; }
:root[data-theme="dark"] .db-feedback { border-color: #3d5a45; background: #243329; color: #b8d8bc; }
:root[data-theme="dark"] .history-tabs { border-color: var(--line); }
:root[data-theme="dark"] .history-tab { color: #aeb6a5; }
:root[data-theme="dark"] .history-tab.is-selected { color: #7ed2a9; }
:root[data-theme="dark"] .history-tab.is-selected::after { background: #55bf91; }
:root[data-theme="dark"] .history-load-message { border-color: #3b483b; background: #1d261f; }
:root[data-theme="dark"] .status-in_progress { background: #443922; color: #e8c871; }
:root[data-theme="dark"] .backend-transfer { border-color: #3e5743; background: #212d24; }
:root[data-theme="dark"] .backend-transfer h2 { color: #bcd9c0; }
:root[data-theme="dark"] .backend-transfer p,
:root[data-theme="dark"] .backend-transfer-status,
:root[data-theme="dark"] .retain-csv-option,
:root[data-theme="dark"] .retain-csv-option strong,
:root[data-theme="dark"] .retain-csv-option small { color: #b1bfad; }
:root[data-theme="dark"] .variant-stat,
:root[data-theme="dark"] .mapping-plan-row,
:root[data-theme="dark"] .saved-rule-row,
:root[data-theme="dark"] .mapping-empty { border-color: var(--line); background: var(--surface-raised); }
:root[data-theme="dark"] .variant-stat strong { color: #dbe6d4; }
:root[data-theme="dark"] .mapping-hint,
:root[data-theme="dark"] .objective-guidance { border-color: #527d5d; background: #26362a; color: #c1d9bd; }
:root[data-theme="dark"] .mapping-empty p { color: #adb6a5; }
:root[data-theme="dark"] .mapping-input:disabled { border-color: #39443a; background: #293129; color: #a3ac9c; }
:root[data-theme="dark"] .pattern-pill { background: #30382f; color: #b9c0b2; }
:root[data-theme="dark"] .pattern-found { background: #403721; color: #e7c976; }
:root[data-theme="dark"] .exclude-row-option { color: #ddc798; }
:root[data-theme="dark"] .mapping-plan-exclusion { background: #3c2e27; color: #e4ae92; }
:root[data-theme="dark"] .recipe-preview { border-color: #3e5743; background: #222f25; color: #bdcfb8; }
:root[data-theme="dark"] .recipe-preview strong { color: #a8d7ad; }
:root[data-theme="dark"] .suggestion-pill { background: #403721; color: #e7c976; }
:root[data-theme="dark"] .target-pill { background: #263b30; color: #9bd9b0; }
:root[data-theme="dark"] .analysis-note { border-color: #77653b; background: #302b20; color: #e1ca91; }
:root[data-theme="dark"] .backend-pending { border-color: #615334; background: #2d291f; }
:root[data-theme="dark"] .backend-pending h2 { color: #ead9a8; }
:root[data-theme="dark"] .backend-pending p { color: #c0b58f; }
:root[data-theme="dark"] .output-index { background: #2b3e31; color: #a1d9b4; }
:root[data-theme="dark"] .login-mark { border-color: #405243; background: #2b3b2e; color: #9bd6ae; }
:root[data-theme="dark"] .login-intro p,
:root[data-theme="dark"] .login-footnote { color: #adb6a5; }
:root[data-theme="dark"] .login-error { border-color: #62453d; background: #332722; color: #e7b2a0; }
:root[data-theme="dark"] .toast { border-color: #414b3e; background: #263027; color: #e1e5d7; }
:root[data-theme="dark"] .history-pagination,
:root[data-theme="dark"] .history-results-heading span { color: #aeb6a5; }
:root[data-theme="dark"] .timeline-json { border-color: #3b463c; }
:root[data-theme="dark"] .timeline-json pre { border-top-color: #3b463c; color: #c7cebd; }
:root[data-theme="dark"] .empty-message,
:root[data-theme="dark"] .history-no-results { color: #adb6a5; }
:root[data-theme="dark"] .feature-item { border-color: #3c483c; background: #263027; }
:root[data-theme="dark"] .feature-item:hover { border-color: #5e8064; background: #2b382d; }
:root[data-theme="dark"] .feature-copy strong { color: #e1e6d7; }
:root[data-theme="dark"] .feature-copy small { color: #adb6a5; }
:root[data-theme="dark"] .feature-check { border-color: #71806f; background: #1d261f; }
:root[data-theme="dark"] .search-field svg { stroke: #aeb6a5; }
:root[data-theme="dark"] .connection-status { color: #b7c0ad; }
:root[data-theme="dark"] .avatar { border-color: #415044; background: #29372c; color: #9dd8b2; }
:root[data-theme="dark"] .status-label.status-pending { background: #443922; color: #e8c871; }
:root[data-theme="dark"] .project-progress { background: rgba(238, 247, 248, .15); }
:root[data-theme="dark"] .sidebar-foot { border-top-color: rgba(226, 239, 241, .14); }
:root[data-theme="dark"] .page-footer { border-top-color: #354136; }

@media (max-width: 620px) {
  .theme-toggle { width: 37px; min-width: 37px; padding: 0; }
  .theme-toggle span { display: none; }
  .theme-toggle svg { width: 17px; height: 17px; }
}

/* Acabado del modo oscuro: carbón ciruela, esmeralda luminosa y acentos cálidos. */
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #2b2231 0%, #19171e 100%); }
:root[data-theme="dark"] .topbar { border-bottom-color: #403846; background: rgba(36, 33, 42, .97); }
:root[data-theme="dark"] .breadcrumb,
:root[data-theme="dark"] .breadcrumb strong { color: #d4c9d6; }
:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3,
:root[data-theme="dark"] .form-section-heading h2,
:root[data-theme="dark"] .card-heading h2,
:root[data-theme="dark"] .history-filter-heading h2,
:root[data-theme="dark"] .login-intro h2 { color: #f5eee5; }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .heading-copy,
:root[data-theme="dark"] .form-section-heading p,
:root[data-theme="dark"] .card-heading p,
:root[data-theme="dark"] .history-filter-heading p,
:root[data-theme="dark"] .page-footer,
:root[data-theme="dark"] .form-footnote,
:root[data-theme="dark"] .small-note { color: #bfb5ad; }
:root[data-theme="dark"] .brand-mark { border-color: rgba(113, 226, 180, .5); background: linear-gradient(145deg, rgba(69, 198, 151, .24), rgba(192, 160, 231, .12)); color: #a4f0ce; }
:root[data-theme="dark"] .project-card { border-color: rgba(218, 197, 225, .2); background: rgba(255, 255, 255, .055); }
:root[data-theme="dark"] .project-label,
:root[data-theme="dark"] .sidebar-label { color: #b7aabd; }
:root[data-theme="dark"] .project-card > strong { color: #f4ecdf; }
:root[data-theme="dark"] .project-subtitle,
:root[data-theme="dark"] .progress-caption { color: #c0b3bf; }
:root[data-theme="dark"] .phase-link { color: #d3c9d5; }
:root[data-theme="dark"] .phase-link:disabled { opacity: .58; }
:root[data-theme="dark"] .phase-link:hover:not(:disabled) { background: rgba(196, 173, 255, .1); color: #fff7ed; }
:root[data-theme="dark"] .phase-link.is-active { border-color: rgba(85, 210, 165, .42); background: linear-gradient(90deg, rgba(46, 172, 128, .3), rgba(116, 83, 150, .18)); color: #c6f6dc; }
:root[data-theme="dark"] .phase-number { border-color: rgba(221, 205, 230, .28); color: #d2c5d8; }
:root[data-theme="dark"] .phase-link.is-active .phase-number { border-color: rgba(122, 233, 184, .65); color: #b8f3d1; }
:root[data-theme="dark"] .nav-status { color: #ac9db2; }
:root[data-theme="dark"] .phase-link.is-active .nav-status,
:root[data-theme="dark"] .phase-link.is-complete .nav-status { color: #a5e8c1; }
:root[data-theme="dark"] .environment-pill { border-color: rgba(218, 197, 225, .2); background: rgba(255, 255, 255, .055); }
:root[data-theme="dark"] .environment-pill strong { color: #efe8dc; }
:root[data-theme="dark"] .environment-pill small,
:root[data-theme="dark"] .sidebar-foot { color: #b7aabd; }
:root[data-theme="dark"] .sidebar-foot span { color: #93879a; }
:root[data-theme="dark"] .global-note { border-color: #433d49; background: #24212a; color: #d1c6bb; }
:root[data-theme="dark"] .info-icon { background: #3a3043; color: #c4adff; }
:root[data-theme="dark"] .step-chip { border-color: #53664d; background: #2a382a; color: #9be8b6; }
:root[data-theme="dark"] .button-primary { background: #32a982; color: #10251d; box-shadow: 0 5px 16px rgba(53, 195, 145, .22); }
:root[data-theme="dark"] .button-primary:hover:not(:disabled) { background: #55d2a5; box-shadow: 0 8px 22px rgba(53, 195, 145, .3); }
:root[data-theme="dark"] .button-secondary,
:root[data-theme="dark"] .button-quiet { border-color: #51485a; background: #302b36; color: #e4d9e8; }
:root[data-theme="dark"] .button-secondary:hover:not(:disabled),
:root[data-theme="dark"] .button-quiet:hover:not(:disabled) { border-color: #8d78ab; background: #3a3243; color: #f1e5ff; }
:root[data-theme="dark"] .theme-toggle { border-color: #62546d; background: #342d3c; color: #f1c267; }
:root[data-theme="dark"] .theme-toggle:hover { border-color: #ad8dc9; background: #41374a; color: #ffda86; }
:root[data-theme="dark"] .view-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .history-card,
:root[data-theme="dark"] .summary-card,
:root[data-theme="dark"] .detail-fact,
:root[data-theme="dark"] .timeline-step,
:root[data-theme="dark"] .timeline-json,
:root[data-theme="dark"] .output-item { border-color: #433d49; background: #24212a; }
:root[data-theme="dark"] .metric-card { border-color: #494151; background: linear-gradient(145deg, #2b2632 0%, #24212a 100%); }
:root[data-theme="dark"] .metric-card strong,
:root[data-theme="dark"] .summary-card strong,
:root[data-theme="dark"] .history-card h3,
:root[data-theme="dark"] .detail-summary h2,
:root[data-theme="dark"] .file-info strong,
:root[data-theme="dark"] .source-strip strong,
:root[data-theme="dark"] .case-context strong,
:root[data-theme="dark"] .variant-stat strong,
:root[data-theme="dark"] .saved-rule-row strong,
:root[data-theme="dark"] .mapping-plan-row strong { color: #f0e9dd; }
:root[data-theme="dark"] .metric-card small,
:root[data-theme="dark"] .metric-card span,
:root[data-theme="dark"] .metric-card p,
:root[data-theme="dark"] .summary-card small,
:root[data-theme="dark"] .summary-card p,
:root[data-theme="dark"] .history-question,
:root[data-theme="dark"] .history-date,
:root[data-theme="dark"] .history-card-meta,
:root[data-theme="dark"] .context-question,
:root[data-theme="dark"] .source-strip-detail,
:root[data-theme="dark"] .detail-fact small,
:root[data-theme="dark"] .detail-fact strong,
:root[data-theme="dark"] .source-aside p,
:root[data-theme="dark"] .source-aside li,
:root[data-theme="dark"] .database-aside li,
:root[data-theme="dark"] .finding-list,
:root[data-theme="dark"] .variant-stat span,
:root[data-theme="dark"] .quality-controls p,
:root[data-theme="dark"] .standardize-controls p,
:root[data-theme="dark"] .history-results-heading,
:root[data-theme="dark"] .history-load-message { color: #c0b7ad; }
:root[data-theme="dark"] .callout-gold { border-color: #78603b; background: #3a3022; color: #f0d08c; }
:root[data-theme="dark"] .callout-blue { border-color: #5e6447; background: #30332a; color: #d6dfa9; }
:root[data-theme="dark"] .callout-teal { border-color: #3c725b; background: #25382f; color: #b8efd0; }
:root[data-theme="dark"] .callout-rose { border-color: #784c4a; background: #3b292b; color: #f0b0a2; }
:root[data-theme="dark"] .status-pending,
:root[data-theme="dark"] .status-in_progress { background: #48391f; color: #f2ca72; }
:root[data-theme="dark"] .status-readonly { background: #35313a; color: #c9becf; }
:root[data-theme="dark"] .status-ready,
:root[data-theme="dark"] .status-completed,
:root[data-theme="dark"] .status-retained { background: #263c32; color: #9be8b6; }
:root[data-theme="dark"] .status-failed,
:root[data-theme="dark"] .status-not-retained { background: #452d2b; color: #f0a493; }
:root[data-theme="dark"] .tag,
:root[data-theme="dark"] .type-pill,
:root[data-theme="dark"] .status-chip { background: #37323c; color: #d1c6d4; }
:root[data-theme="dark"] .type-pill.numérica,
:root[data-theme="dark"] .type-pill.numeric { background: #263e34; color: #a7edc2; }
:root[data-theme="dark"] .type-pill.fecha { background: #443820; color: #f0cf80; }
:root[data-theme="dark"] .type-pill.sin-datos { background: #37343a; color: #c2bac3; }
:root[data-theme="dark"] .data-table thead { background: #302b36; }
:root[data-theme="dark"] .data-table th { color: #c5b8c8; }
:root[data-theme="dark"] .data-table td { border-top-color: #403946; color: #d2c9d0; }
:root[data-theme="dark"] .data-table td:first-child { color: #f0e8dc; }
:root[data-theme="dark"] .inline-note.info { background: #30332a; color: #d6dfa9; }
:root[data-theme="dark"] .inline-note.warning { background: #3a3022; color: #f0d08c; }
:root[data-theme="dark"] .inline-note.success { background: #25382f; color: #b8efd0; }
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .mapping-input,
:root[data-theme="dark"] .search-field { border-color: #51485a; background: #1e1c23; color: #f0e9dd; }
:root[data-theme="dark"] .field input::placeholder,
:root[data-theme="dark"] .field textarea::placeholder,
:root[data-theme="dark"] .search-field input::placeholder { color: #a196a0; }
:root[data-theme="dark"] .choice-card { border-color: #494151; background: linear-gradient(145deg, #2b2632, #24212a); }
:root[data-theme="dark"] .choice-card:hover { border-color: #8c6ea2; background: #342c3b; }
:root[data-theme="dark"] .choice-card:has(input:checked) { border-color: #55d2a5; background: linear-gradient(145deg, #293d36, #292631); }
:root[data-theme="dark"] .choice-card strong { color: #f0e9dd; }
:root[data-theme="dark"] .choice-card small { color: #c1b7b1; }
:root[data-theme="dark"] .icon-blue { background: #37372d; color: #d0df9d; }
:root[data-theme="dark"] .icon-teal { background: #293d37; color: #70e0b3; }
:root[data-theme="dark"] .icon-violet { background: #3c334d; color: #cfbaff; }
:root[data-theme="dark"] .icon-amber { background: #41351f; color: #f1c267; }
:root[data-theme="dark"] .icon-rose { background: #422c2d; color: #f09a82; }
:root[data-theme="dark"] .source-tabs { border-color: #433d49; background: #201e25; }
:root[data-theme="dark"] .source-tab { color: #c0b7ad; }
:root[data-theme="dark"] .source-tab.is-selected { background: #34303a; color: #9be8c1; }
:root[data-theme="dark"] .dropzone { border-color: #6a8d69; background: linear-gradient(135deg, #29372e, #211f26); color: #d0c8ba; }
:root[data-theme="dark"] .dropzone:hover,
:root[data-theme="dark"] .dropzone.is-dragover { border-color: #55d2a5; background: #2d4034; }
:root[data-theme="dark"] .mapping-hint,
:root[data-theme="dark"] .objective-guidance { border-color: #697347; background: #30332a; color: #d6dfa9; }
:root[data-theme="dark"] .pattern-found,
:root[data-theme="dark"] .suggestion-pill { background: #443820; color: #f0cf80; }
:root[data-theme="dark"] .mapping-plan-exclusion { background: #422e2b; color: #f0ad91; }
:root[data-theme="dark"] .recipe-preview { border-color: #3c725b; background: #25382f; color: #c5dfc8; }
:root[data-theme="dark"] .recipe-preview strong { color: #a8edbe; }
:root[data-theme="dark"] .backend-pending { border-color: #78603b; background: #30291f; }
:root[data-theme="dark"] .backend-pending h2 { color: #f0d89e; }
:root[data-theme="dark"] .backend-pending p { color: #d0c09e; }
:root[data-theme="dark"] .output-index { background: #293d37; color: #9be8c1; }
:root[data-theme="dark"] .login-mark { border-color: #3c725b; background: #293d37; color: #8de3b4; }
:root[data-theme="dark"] .theme-icon-sun { color: #f1c267; }
:root[data-theme="dark"] .toast { border-color: #51485a; background: #2a2630; color: #f0e9dd; }
:root[data-theme="dark"] .feature-item { border-color: #494151; background: #2b2632; }
:root[data-theme="dark"] .feature-item:hover { border-color: #8c6ea2; background: #342c3b; }
:root[data-theme="dark"] .feature-copy strong { color: #f0e9dd; }
:root[data-theme="dark"] .feature-copy small { color: #c1b7b1; }
:root[data-theme="dark"] .feature-check { border-color: #897c89; background: #1e1c23; }
:root[data-theme="dark"] .connection-status { color: #d1c6d4; }
:root[data-theme="dark"] .avatar { border-color: #53664d; background: #2b392c; color: #a8e8b7; }

/* Misma identidad cromática en ambos temas: bosque, jade y dorado. */
:root[data-theme="dark"] {
  --ink: #f2efe3;
  --ink-soft: #dedbc9;
  --muted: #bdc5b4;
  --muted-2: #929d8e;
  --line: #3c4b3e;
  --canvas: #171f18;
  --white: #222c23;
  --navy: #162219;
  --navy-2: #2b3c2d;
  --teal: #58d0a0;
  --teal-dark: #36ad7d;
  --teal-light: #263b30;
  --gold: #e9b957;
  --gold-light: #3d321d;
  --purple: #bca5dc;
  --purple-light: #373044;
  --blue: #a9bc8b;
  --blue-light: #30382a;
  --rose: #e58d73;
  --rose-light: #3a2a26;
  --green: #86d894;
  --green-light: #293a2d;
  --shadow: 0 16px 36px rgba(0, 0, 0, .28);
  --surface-raised: #29362b;
  --surface-subtle: #1d271f;
}
:root[data-theme="dark"] body,
:root[data-theme="dark"] .main-area { background: var(--canvas); color: var(--ink); }
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #26392a 0%, #172219 100%); }
:root[data-theme="dark"] .topbar { border-bottom-color: #3b493d; background: rgba(34, 44, 35, .97); }
:root[data-theme="dark"] .breadcrumb,
:root[data-theme="dark"] .breadcrumb strong { color: #d1d9c9; }
:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3,
:root[data-theme="dark"] .form-section-heading h2,
:root[data-theme="dark"] .card-heading h2,
:root[data-theme="dark"] .history-filter-heading h2,
:root[data-theme="dark"] .login-intro h2 { color: #f2efe3; }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .heading-copy,
:root[data-theme="dark"] .form-section-heading p,
:root[data-theme="dark"] .card-heading p,
:root[data-theme="dark"] .history-filter-heading p,
:root[data-theme="dark"] .page-footer,
:root[data-theme="dark"] .form-footnote,
:root[data-theme="dark"] .small-note { color: #bac3b3; }
:root[data-theme="dark"] .brand-mark { border-color: rgba(113, 226, 180, .5); background: linear-gradient(145deg, rgba(69, 198, 151, .25), rgba(226, 183, 87, .13)); color: #a4f0ce; }
:root[data-theme="dark"] .project-label,
:root[data-theme="dark"] .sidebar-label { color: #aebeaa; }
:root[data-theme="dark"] .project-card > strong,
:root[data-theme="dark"] .environment-pill strong { color: #f0efdf; }
:root[data-theme="dark"] .project-subtitle,
:root[data-theme="dark"] .progress-caption,
:root[data-theme="dark"] .environment-pill small { color: #b9c5b5; }
:root[data-theme="dark"] .phase-link { color: #d0d9cc; }
:root[data-theme="dark"] .phase-link:disabled { opacity: .58; }
:root[data-theme="dark"] .phase-link:hover:not(:disabled) { background: rgba(88, 208, 160, .12); color: #f4f3e7; }
:root[data-theme="dark"] .phase-link.is-active { border-color: rgba(88, 208, 160, .45); background: linear-gradient(90deg, rgba(42, 151, 107, .34), rgba(185, 151, 77, .12)); color: #c8f4d9; }
:root[data-theme="dark"] .phase-number { border-color: rgba(199, 220, 194, .3); color: #d2ddcd; }
:root[data-theme="dark"] .phase-link.is-active .phase-number { border-color: #78dca8; color: #baf2d0; }
:root[data-theme="dark"] .nav-status { color: #a9b7a5; }
:root[data-theme="dark"] .phase-link.is-active .nav-status,
:root[data-theme="dark"] .phase-link.is-complete .nav-status { color: #a5e8c1; }
:root[data-theme="dark"] .global-note { border-color: #3c4b3e; background: #222c23; color: #d1dacb; }
:root[data-theme="dark"] .info-icon { background: #304331; color: #9cdeb2; }
:root[data-theme="dark"] .view-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .history-card,
:root[data-theme="dark"] .summary-card,
:root[data-theme="dark"] .detail-fact,
:root[data-theme="dark"] .timeline-step,
:root[data-theme="dark"] .timeline-json,
:root[data-theme="dark"] .output-item { border-color: #3c4b3e; background: #222c23; }
:root[data-theme="dark"] .metric-card { border-color: #425344; background: linear-gradient(145deg, #29372b 0%, #222c23 100%); }
:root[data-theme="dark"] .metric-card strong,
:root[data-theme="dark"] .summary-card strong,
:root[data-theme="dark"] .history-card h3,
:root[data-theme="dark"] .detail-summary h2,
:root[data-theme="dark"] .file-info strong,
:root[data-theme="dark"] .source-strip strong,
:root[data-theme="dark"] .case-context strong,
:root[data-theme="dark"] .variant-stat strong,
:root[data-theme="dark"] .saved-rule-row strong,
:root[data-theme="dark"] .mapping-plan-row strong { color: #edf0df; }
:root[data-theme="dark"] .metric-card small,
:root[data-theme="dark"] .metric-card span,
:root[data-theme="dark"] .metric-card p,
:root[data-theme="dark"] .summary-card small,
:root[data-theme="dark"] .summary-card p,
:root[data-theme="dark"] .history-question,
:root[data-theme="dark"] .history-date,
:root[data-theme="dark"] .history-card-meta,
:root[data-theme="dark"] .context-question,
:root[data-theme="dark"] .source-strip-detail,
:root[data-theme="dark"] .detail-fact small,
:root[data-theme="dark"] .detail-fact strong,
:root[data-theme="dark"] .source-aside p,
:root[data-theme="dark"] .source-aside li,
:root[data-theme="dark"] .database-aside li,
:root[data-theme="dark"] .finding-list,
:root[data-theme="dark"] .variant-stat span,
:root[data-theme="dark"] .quality-controls p,
:root[data-theme="dark"] .standardize-controls p,
:root[data-theme="dark"] .history-results-heading,
:root[data-theme="dark"] .history-load-message { color: #b9c4b2; }
:root[data-theme="dark"] .button-secondary,
:root[data-theme="dark"] .button-quiet { border-color: #4b5c4b; background: #29362b; color: #e0e6d8; }
:root[data-theme="dark"] .button-secondary:hover:not(:disabled),
:root[data-theme="dark"] .button-quiet:hover:not(:disabled) { border-color: #75b98d; background: #314334; color: #eaf6e5; }
:root[data-theme="dark"] .theme-toggle { border-color: #53644a; background: #2b392b; color: #f0c66d; }
:root[data-theme="dark"] .theme-toggle:hover { border-color: #83bd79; background: #344633; color: #ffdf8d; }
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .mapping-input,
:root[data-theme="dark"] .search-field { border-color: #465747; background: #1b241c; color: #edf0df; }
:root[data-theme="dark"] .choice-card { border-color: #405041; background: linear-gradient(145deg, #29362b, #222c23); }
:root[data-theme="dark"] .choice-card:hover { border-color: #78ac78; background: #2e3d30; }
:root[data-theme="dark"] .choice-card:has(input:checked) { border-color: #58d0a0; background: linear-gradient(145deg, #294033, #263329); }
:root[data-theme="dark"] .choice-card strong { color: #edf0df; }
:root[data-theme="dark"] .choice-card small { color: #b9c4b2; }
:root[data-theme="dark"] .icon-blue { background: #303a2b; color: #c2d697; }
:root[data-theme="dark"] .icon-teal { background: #263b30; color: #70e0b3; }
:root[data-theme="dark"] .icon-violet { background: #373044; color: #c9b4e7; }
:root[data-theme="dark"] .icon-amber { background: #3d321d; color: #f0c267; }
:root[data-theme="dark"] .icon-rose { background: #3a2a26; color: #e9947b; }
:root[data-theme="dark"] .callout-gold { border-color: #76603b; background: #39301f; color: #f0d18e; }
:root[data-theme="dark"] .callout-blue { border-color: #566344; background: #2d3528; color: #d2dfa9; }
:root[data-theme="dark"] .callout-teal { border-color: #3b6b50; background: #24362b; color: #b9edc8; }
:root[data-theme="dark"] .callout-rose { border-color: #744d3e; background: #382a24; color: #efb49c; }
:root[data-theme="dark"] .data-table thead { background: #2b372c; }
:root[data-theme="dark"] .data-table th { color: #c2ceb8; }
:root[data-theme="dark"] .data-table td { border-top-color: #3b4a3d; color: #d0d9c9; }
:root[data-theme="dark"] .data-table td:first-child { color: #edf0df; }
:root[data-theme="dark"] .source-tabs { border-color: #3c4b3e; background: #1d271f; }
:root[data-theme="dark"] .source-tab { color: #bec8b7; }
:root[data-theme="dark"] .source-tab.is-selected { background: #2d3b2e; color: #a8e9c2; }
:root[data-theme="dark"] .tag,
:root[data-theme="dark"] .type-pill,
:root[data-theme="dark"] .status-chip { background: #303b30; color: #d0d9c9; }
:root[data-theme="dark"] .dropzone { border-color: #6a8d69; background: linear-gradient(135deg, #293a2c, #202920); color: #d0d9c9; }
:root[data-theme="dark"] .dropzone:hover,
:root[data-theme="dark"] .dropzone.is-dragover { border-color: #58d0a0; background: #2d4030; }
:root[data-theme="dark"] .feature-item { border-color: #405041; background: #29362b; }
:root[data-theme="dark"] .feature-item:hover { border-color: #78ac78; background: #2e3d30; }
:root[data-theme="dark"] .feature-copy strong { color: #edf0df; }
:root[data-theme="dark"] .feature-copy small { color: #b9c4b2; }
:root[data-theme="dark"] .feature-check { border-color: #82917b; background: #1b241c; }
