:root {
  --bg: #f3efe7;
  --paper: #fffdf8;
  --paper-2: #f7f1e5;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #ddd4c5;
  --brand: #0f766e;
  --brand-soft: #d7f2ee;
  --danger: #b42318;
  --warn: #b86e00;
  --ok: #1d7a38;
  --shadow: 0 18px 50px rgba(68, 53, 34, 0.08);
}

* {
  box-sizing: border-box;
}

.sticky-controls {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px 280px 14px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}

.surface-switch {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 1400;
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.surface-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 14px;
  font-weight: 700;
}

.surface-switch a.active {
  background: var(--brand);
  color: white;
}

.surface-switch .current-user {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: min(100%, 440px);
  padding: 40px 36px;
}

.auth-card .eyebrow {
  margin: 0 0 6px;
}

.auth-card h1 {
  max-width: none;
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.15;
}

.auth-card .muted {
  margin: 0 0 28px;
  line-height: 1.5;
}

.auth-card form {
  display: grid;
  gap: 18px;
}

.auth-card label {
  min-width: 0;
}

.auth-card input,
.auth-card button {
  width: 100%;
}

.auth-card .status.error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.auth-card .status.error:empty {
  display: none;
}

.sticky-controls .row {
  margin-bottom: 0;
  justify-content: space-between;
  align-items: center;
}

.metric-view-header {
  display: flex;
  flex: 1 1 420px;
  justify-content: flex-end;
  max-width: 100%;
}

.watermark {
  position: fixed;
  bottom: 14px;
  right: 18px;
  font-size: 11px;
  font-family: Georgia, serif;
  color: rgba(107, 114, 128, 0.45);
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
  z-index: 9999;
}

.coach-detail-panel {
  border: 2px solid #1d4ed8;
  box-shadow: 0 18px 45px rgba(29, 78, 216, 0.12);
}

.coach-detail-panel .evidence {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.coach-link {
  color: #1d4ed8;
  font-weight: 700;
  cursor: pointer;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.1), transparent 28%),
    linear-gradient(180deg, #f8f4ed 0%, #f1ebdf 100%);
}

body.modal-open {
  overflow: hidden;
}

.layout {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 88px 32px 40px;
}

.hero,
.panel,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 24px;
  padding: 28px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  font-weight: 700;
}

h1 {
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1;
  max-width: 13ch;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.lead,
.hero-note,
.status,
label,
button,
select,
input,
table,
.muted {
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

.hero-note,
.subpanel,
.source-card {
  background: linear-gradient(180deg, #faf8f1, #f3ece0);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--line);
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  padding: 20px;
  margin-bottom: 22px;
  align-items: start;
}

.controls-bi {
  grid-template-columns: minmax(0, 1fr);
}

.subpanel {
  margin-top: 18px;
}

.controls .subpanel {
  margin-top: 0;
}

.commercial-guide {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.guide-callout,
.dyn-help-card {
  background: linear-gradient(180deg, #fffaf0, #f6eee1);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
}

.guide-grid,
.dyn-help-grid,
.request-flow {
  display: grid;
  gap: 14px;
}

.guide-grid,
.request-flow {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.guide-card,
.request-step {
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.guide-card-title,
.dyn-help-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.guide-card-action {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 8px;
}

.guide-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.guide-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink);
}

.dashboard-panel {
  margin-bottom: 22px;
}

.admin-access-config {
  margin-top: 22px;
}

.admin-config-form {
  display: grid;
  gap: 12px;
  align-content: start;
}

.access-catalog-sync {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
}

.access-catalog-sync > strong {
  align-self: center;
}

.access-catalog-sync label {
  display: grid;
  gap: 4px;
}

.admin-config-form label {
  display: grid;
  gap: 6px;
}

.company-access-validation {
  min-height: 1.5rem;
  margin: 0;
  color: var(--muted);
}

.company-access-validation.ready {
  color: #176b4d;
}

.company-access-validation.error {
  color: #a12622;
  font-weight: 700;
}

.access-check-group {
  display: grid;
  gap: 8px;
}

.access-check-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.access-check-header span {
  display: flex;
  gap: 6px;
}

.access-checkbox-list {
  display: grid;
  gap: 5px;
  max-height: 230px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.access-check-option {
  display: grid !important;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px !important;
  padding: 5px 7px;
  border-radius: 7px;
}

.access-check-option:hover {
  background: var(--paper-2);
}

.access-check-option input {
  width: auto;
  margin: 0;
}

.access-check-option small {
  color: var(--muted);
}

.access-inline-add {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 6px;
}

.coach-brief {
  --coach-navy: #173553;
  --coach-blue: #eaf4fc;
  --coach-gold: #f2c44e;
  padding: 0;
  overflow: hidden;
  background: #fff;
}

.coach-brief-hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 26px 30px;
  color: #fff;
  background: var(--coach-navy);
}

.coach-brief-hero h2,
.coach-brief-hero .eyebrow {
  color: #fff;
}

.coach-brief-hero .muted {
  color: #d9e5ef;
}

.coach-seller-picker {
  min-width: min(320px, 100%);
}

.coach-hero-actions {
  display: grid;
  gap: 10px;
  min-width: min(430px, 100%);
}

.coach-print-actions {
  display: flex;
  gap: 8px;
}

.coach-print-actions .print-orientation {
  flex: 0 0 auto;
  width: auto;
  padding: 9px 10px;
}

.coach-print-actions button {
  flex: 1;
  padding: 9px 12px;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
}

.coach-seller-picker span {
  display: block;
  margin-bottom: 6px;
  color: #d9e5ef;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.coach-seller-picker select {
  width: 100%;
  background: #fff;
}

.coach-message {
  display: grid;
  gap: 6px;
  margin: 26px 30px 18px;
  padding: 18px;
  border: 1px solid #bad8ee;
  border-radius: 12px;
  background: var(--coach-blue);
}

.coach-comparison-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 16px 30px;
  border-bottom: 1px solid #dbe4ec;
  background: #f8fafc;
}

.coach-comparison-bar > strong {
  align-self: center;
  margin-right: 4px;
  color: var(--coach-navy);
}

.coach-comparison-bar label span {
  display: block;
  margin-bottom: 4px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.coach-comparison-bar input {
  min-width: 145px;
}

.coach-kpi-grid {
  display: block;
  margin: 0 30px 24px;
}

.coach-kpi-grid > .metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr));
  gap: 12px;
}

.coach-kpi-grid.compact {
  margin: 20px 0;
}

.coach-kpi-grid.compact > .metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.coach-kpi-grid .executive-kpi {
  min-width: 0;
}

.coach-section-heading,
.coach-table-wrap,
.coach-two-col,
.coach-week-plan,
.coach-team-details {
  margin-left: 30px;
  margin-right: 30px;
}

.coach-table-wrap {
  overflow-x: auto;
}

.coach-client-heading {
  margin-top: 24px;
}

.coach-mix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.coach-mix-table th {
  padding: 9px 8px;
  color: #fff;
  line-height: 1.15;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  background: var(--coach-navy);
}

.coach-mix-table td {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
}

.coach-mix-table tbody tr:nth-child(odd) {
  background: #f8fafc;
}

.coach-mix-value {
  display: inline-block;
  min-width: 52px;
}

.coach-mix-bar {
  display: inline-block;
  width: 62px;
  height: 4px;
  vertical-align: middle;
  background: #e2e8f0;
}

.coach-mix-bar i {
  display: block;
  height: 100%;
  background: var(--coach-gold);
}

.coach-positive {
  color: #16794a;
  font-weight: 700;
}

.coach-negative {
  color: #b42318;
  font-weight: 700;
}

.coach-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 24px;
}

.coach-callout {
  padding: 20px;
  border: 1px solid;
  border-radius: 12px;
}

.coach-callout h3 {
  margin-top: 0;
}

.coach-callout li,
.coach-week-plan li {
  margin: 8px 0;
  line-height: 1.45;
}

.coach-callout-recognition {
  border-color: #edcf78;
  background: #fff7d9;
}

.coach-callout-action {
  border-color: #bad8ee;
  background: var(--coach-blue);
}

.coach-week-plan {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

.coach-closing {
  margin: 18px 0 0;
  color: var(--coach-navy);
  font-weight: 700;
  text-align: center;
}

.coach-team-details {
  margin-top: 22px;
  margin-bottom: 30px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

.coach-team-details summary {
  color: var(--coach-navy);
  font-weight: 700;
  cursor: pointer;
}

.coach-table-link {
  padding: 0;
  color: #1d4ed8;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 800px) {
  .coach-brief-hero,
  .coach-two-col,
  .coach-comparison-bar {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .coach-kpi-grid > .metric-grid,
  .coach-kpi-grid.compact > .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.dashboard-selector-panel {
  margin-bottom: 22px;
}

.dashboard-view-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.meeting-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.meeting-actions label {
  min-width: 260px;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 9mm;
  }

  body.coach-print {
    color: #172033;
    background: #fff !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body.coach-print .layout {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  body.coach-print .layout > .hero,
  body.coach-print .layout > .sticky-controls,
  body.coach-print .layout > .controls,
  body.coach-print #results > *:not(.print-target),
  body.coach-print .coach-comparison-bar,
  body.coach-print .coach-hero-actions,
  body.coach-print .coach-team-details summary {
    display: none !important;
  }

  body.coach-print #results,
  body.coach-print .print-target {
    display: block !important;
  }

  body.coach-print .coach-brief {
    border: 0;
    box-shadow: none;
  }

  body.coach-print .coach-brief-hero {
    padding: 7mm;
  }

  body.coach-print .coach-brief-hero h2 {
    margin: 0 0 2mm;
    font-size: 20pt;
  }

  body.coach-print .coach-brief-hero .muted {
    font-size: 9pt;
  }

  body.coach-print .coach-message,
  body.coach-print .coach-kpi-grid,
  body.coach-print .coach-section-heading,
  body.coach-print .coach-table-wrap,
  body.coach-print .coach-two-col,
  body.coach-print .coach-week-plan,
  body.coach-print .coach-team-details {
    margin-left: 0;
    margin-right: 0;
  }

  body.coach-print .coach-message {
    margin-top: 5mm;
    margin-bottom: 4mm;
    padding: 4mm;
  }

  body.coach-print .coach-kpi-grid {
    margin-bottom: 4mm;
  }

  body.coach-print .metric-tile {
    padding: 3mm;
    break-inside: avoid;
  }

  body.coach-print .metric-main {
    font-size: min(16pt, 13.5cqi);
  }

  body.coach-print .coach-table-wrap {
    overflow: visible;
  }

  body.coach-print .coach-mix-table {
    width: 100%;
    font-size: 7.5pt;
  }

  body.coach-print .coach-mix-table th,
  body.coach-print .coach-mix-table td {
    padding: 1.5mm 1.2mm;
  }

  /* En A4 vertical las tablas anchas (10 columnas) no entran con encabezados
     en una sola línea: se parten los títulos y se achica la barra de mix. */
  body.coach-print .coach-mix-table th {
    white-space: normal;
    line-height: 1.2;
  }

  body.coach-print .coach-mix-table td {
    white-space: nowrap;
  }

  /* En vertical no entran 12 columnas con importes completos: se permite
     partir la celda (p. ej. "$" arriba del número) en lugar de cortar la tabla. */
  body.coach-print.print-portrait .coach-mix-table {
    font-size: 7pt;
  }

  body.coach-print.print-portrait .coach-mix-table td {
    white-space: normal;
  }

  body.coach-print.print-landscape .coach-kpi-grid > .metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  body.coach-print .coach-mix-table td:nth-child(2) {
    white-space: normal;
  }

  body.coach-print .coach-mix-value {
    min-width: 0;
  }

  body.coach-print .coach-mix-bar {
    display: block;
    width: 100%;
    max-width: 14mm;
  }

  body.coach-print .coach-client-heading {
    margin-top: 5mm;
  }

  body.coach-print .coach-mix-table thead {
    display: table-header-group;
  }

  body.coach-print .coach-callout,
  body.coach-print .coach-week-plan {
    padding: 4mm;
    break-inside: avoid;
  }

  body.coach-print .coach-two-col {
    margin-top: 4mm;
  }

  body.coach-print .coach-week-plan {
    margin-top: 4mm;
  }

  body.print-coach-seller .coach-team-details,
  body.print-coach-team .coach-individual-sheet {
    display: none !important;
  }

  body.print-coach-team .coach-team-details {
    display: block !important;
    margin-top: 5mm;
    padding-top: 0;
    border-top: 0;
  }

  body.print-coach-team .coach-kpi-grid.compact > .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .surface-switch,
  .sticky-controls,
  .controls-bi,
  .floating-nav,
  .dashboard-selector-panel {
    display: none !important;
  }
}

.dashboard-view-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.dashboard-view-chip.active {
  border-color: rgba(15, 118, 110, 0.35);
  background: linear-gradient(180deg, #eff9f6, #e2f2ed);
  color: #0f766e;
}

.dashboard-view-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3ecdf;
  border: 1px solid #e1d4c0;
  font-size: 12px;
}

.executive-kpis {
  margin-top: 16px;
}

.executive-kpis .metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.compact-kpis .metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 12px;
}

.compact-kpis .metric-tile {
  padding: 14px;
}

.planning-controls {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.planning-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 14px;
}

.planning-field {
  display: grid;
  gap: 6px;
}

.planning-field label {
  font-size: 13px;
  color: var(--muted);
}

.planning-field input,
.planning-field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  padding: 10px 12px;
  font: inherit;
}

.planning-hint {
  font-size: 13px;
  color: var(--muted);
}

.budget-step-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.executive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr));
  gap: 18px;
  margin-top: 18px;
}

.executive-grid .chart-panel {
  min-width: 0;
}

.chart-panel,
.table-panel {
  background: linear-gradient(180deg, #fffdfa, #f7f1e5);
}

.echart-host {
  width: 100%;
  min-height: 380px;
}

.echart-host.xl-chart {
  min-height: 500px;
}

.interactive-report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  margin-top: 18px;
}

.interactive-report-chart {
  min-width: 0;
}

.compact-header {
  align-items: end;
  gap: 16px;
}

.interactive-report-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.interactive-report-controls label {
  display: grid;
  gap: 5px;
  min-width: 145px;
  font-size: 12px;
  color: var(--muted);
}

.interactive-report-controls select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
}

.interactive-slicers .filter-fields-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.interactive-slicers .filter-box {
  max-width: none;
  min-width: 0;
  width: 100%;
}

.interactive-slicers .filter-box-list {
  max-height: 220px;
}

.tabulator-host {
  margin-top: 12px;
}

.tabulator {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

.tabulator .tabulator-header {
  background: #f5ede0;
  border-bottom: 1px solid var(--line);
}

.tabulator .tabulator-header .tabulator-col {
  background: #f5ede0;
}

.tabulator .tabulator-row {
  background: #fffdfa;
}

.tabulator .tabulator-row.tabulator-row-even {
  background: #fbf6ee;
}

.dashboard-notes {
  margin-top: 18px;
}

@media (max-width: 1440px) {
  .executive-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .executive-grid {
    grid-template-columns: 1fr;
  }

  .interactive-report-layout {
    grid-template-columns: 1fr;
  }
}

.request-flow {
  margin-bottom: 14px;
}

.dyn-task-help {
  margin-bottom: 16px;
}

.dyn-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.controls .status {
  grid-column: 1 / -1;
}

.controls-side.hidden {
  display: none;
}

.controls:has(.controls-side.hidden) {
  grid-template-columns: minmax(0, 1fr);
}

.subpanel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.metric-view-bar {
  margin-bottom: 18px;
}

.metric-toggle {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.metric-view-header .subpanel-header {
  width: 100%;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.metric-view-header .subpanel-header > div:first-child {
  text-align: right;
  max-width: 320px;
}

.metric-chip {
  min-width: 88px;
  border-radius: 999px;
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
  font-weight: 600;
}

.metric-chip.active {
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
}

.metric-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.line-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.line-legend-swatch {
  width: 18px;
  height: 0;
  border-top: 3px solid var(--line-color, var(--brand));
}

.line-legend-swatch.dashed {
  border-top-style: dashed;
}

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  min-width: 180px;
  color: var(--muted);
  font-size: 14px;
}

label.wide {
  min-width: 280px;
}

.password-field {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.password-field input {
  flex: 1;
  min-width: 0;
}

.password-toggle {
  padding: 0 12px;
  line-height: 1;
  font-size: 16px;
  background: white;
}

select,
input,
button {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 11px 14px;
  font-size: 14px;
  background: white;
}

button {
  cursor: pointer;
}

button.primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.file-library,
.source-grid,
.dataset-grid,
.mapping-grid,
.cards,
.two-col,
.three-col,
.chart-grid {
  display: grid;
  gap: 18px;
}

.file-library {
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.sales-source-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  margin-bottom: 14px;
}

.sales-source {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: white;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.check-inline {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  margin: 6px 0 14px;
  color: var(--muted);
  line-height: 1.35;
}

.check-inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 2px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  -webkit-appearance: checkbox;
  appearance: checkbox;
  accent-color: var(--brand);
}

.check-inline span {
  display: block;
}

.segmented {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  margin-top: 14px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
}

.segmented button.active {
  background: var(--brand);
  color: white;
}

.erp-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: white;
}

.erp-status {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
}

.erp-status.ok {
  background: #e7f6ee;
  color: var(--ok);
}

.erp-status.warn {
  background: #fff3df;
  color: var(--warn);
}

.erp-status.danger {
  background: #fdeceb;
  color: var(--danger);
}

.mongo-summary {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf8f1;
  font-size: 14px;
}

.bi-surface-note {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
}

.dataset-grid {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 16px;
}

.file-item {
  border: 1px solid var(--line);
  background: white;
  border-radius: 16px;
  padding: 14px;
}

.source-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  margin-top: 18px;
}

.source-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.mapping-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  margin-top: 12px;
}

.mapping-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
}

.preview {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

table {
  border-collapse: collapse;
  width: 100%;
  background: white;
}

th,
td {
  border-bottom: 1px solid #eee4d2;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #faf5ea;
}

.results {
  margin-top: 22px;
}

.admin-ops {
  margin-top: 22px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.progress-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(44, 34, 21, 0.28);
  backdrop-filter: blur(4px);
}

.progress-card {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(520px, 100%);
  padding: 24px 26px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdf8, #f4eee1);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(42, 31, 18, 0.18);
}

.progress-card h3 {
  margin-bottom: 6px;
}

.progress-card .muted {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

#progressMeta {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.92;
}

.progress-spinner {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 4px solid rgba(15, 118, 110, 0.18);
  border-top-color: var(--brand);
  animation: progress-spin 0.9s linear infinite;
  flex: 0 0 auto;
}

@keyframes progress-spin {
  to {
    transform: rotate(360deg);
  }
}

.floating-nav {
  position: fixed;
  right: 18px;
  bottom: 28px;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.floating-nav button {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(31, 41, 55, 0.12);
  background: rgba(255, 253, 248, 0.96);
  color: var(--brand);
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(42, 31, 18, 0.15);
}

.floating-nav button:hover {
  background: white;
  transform: translateY(-1px);
}

.filters-panel {
  margin-bottom: 18px;
}

/* ─── Pestañas de filtros ───────────────────────────────────────────────── */

.filter-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--line);
  margin: 14px 0 0;
  padding-bottom: 0;
}

.filter-tab {
  padding: 7px 18px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  bottom: -2px;
  border-bottom: 2px solid transparent;
  transition: color .12s, background .12s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-tab:hover {
  color: var(--ink);
  background: var(--paper-2);
}

.filter-tab.active {
  color: var(--brand);
  border-bottom: 2px solid var(--brand);
  background: var(--paper);
}

.filter-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.filter-tab-body {
  padding: 16px 0 4px;
}

.filter-tab-hint {
  font-size: 11px;
  margin-bottom: 12px;
}

.filter-fields-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.filter-fields-row > label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
}

.filter-grid {
  margin-top: 14px;
}

.filter-box {
  position: relative;
  min-width: 180px;
  flex: 1 1 220px;
  max-width: 280px;
}

.filter-box-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdfa;
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
}

.filter-box.open .filter-box-toggle {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

.filter-box-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.filter-box-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.filter-box-summary {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-box-caret {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.filter-box.open .filter-box-caret {
  transform: rotate(180deg);
}

.filter-box-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: max(100%, 260px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdfa;
  padding: 10px 10px 8px;
  box-shadow: var(--shadow);
}

.filter-box.open .filter-box-panel {
  display: block;
}

.filter-box-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 8px;
}

.filter-box-actions {
  display: flex;
  gap: 6px;
}

.filter-box-actions button {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
}

.filter-box-actions button:hover {
  color: var(--ink);
}

.filter-search {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 8px;
}

.filter-box-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.check-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 10px;
  row-gap: 0;
  padding: 7px 8px;
  border-radius: 10px;
  background: white;
  border: 1px solid #eee4d2;
  font-size: 12px;
  cursor: pointer;
}

.check-option:hover {
  border-color: #d9cdb9;
  background: #fff8ed;
}

.check-option input {
  margin: 0;
}

.check-option input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  justify-self: start;
  align-self: center;
}

.check-option-count {
  color: var(--muted);
  font-size: 11px;
}

.two-col {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  margin-top: 22px;
}

.three-col {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  margin-top: 22px;
}

.chart-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  margin-top: 22px;
}

.chart-span-full {
  grid-column: 1 / -1;
}

.inner-panel {
  padding: 20px;
}

.card {
  min-width: 0;
  padding: 18px;
  overflow: hidden;
}

.card .label {
  color: var(--muted);
  font-size: 13px;
}

.card .value {
  max-width: 100%;
  font-size: clamp(22px, 1.7vw, 28px);
  font-weight: 700;
  margin-top: 10px;
  line-height: 1.08;
  overflow-wrap: normal;
  word-break: normal;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.summary-card .value-sm {
  font-size: clamp(18px, 1.35vw, 23px);
  line-height: 1.12;
}

.summary-card .value-xs {
  font-size: clamp(16px, 1.15vw, 20px);
  line-height: 1.16;
}

.card .sub {
  color: var(--muted);
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: break-word;
}

.semaphore,
.alert,
.insight-item,
.ranking-item,
.scenario-item,
.action-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  background: white;
}

.insight-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.reset-password-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 8px;
}

.green {
  background: var(--ok);
}

.yellow {
  background: var(--warn);
}

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

.alert.high {
  border-left: 6px solid var(--danger);
}

.alert.medium {
  border-left: 6px solid var(--warn);
}

.alert.low {
  border-left: 6px solid var(--ok);
}

.insight-list {
  display: grid;
  gap: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 14px;
}

.metric-tile {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(180deg, #fffdf9, #f7f1e6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.metric-tile.good {
  border-color: rgba(29, 122, 56, 0.28);
  background: linear-gradient(180deg, #fbfefb, #edf7ef);
}

.metric-tile.warn {
  border-color: rgba(184, 110, 0, 0.28);
  background: linear-gradient(180deg, #fffdf8, #f9efdc);
}

.metric-tile.bad {
  border-color: rgba(180, 35, 24, 0.28);
  background: linear-gradient(180deg, #fffdfb, #faece9);
}

.metric-kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

.metric-main {
  margin-top: 10px;
  font-size: clamp(22px, 1.7vw, 30px);
  font-weight: 700;
  line-height: 1.04;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* El número se achica según el ancho real de la tarjeta para que importes
   como "$ 179.410.793" no rebasen el recuadro. */
.metric-tile {
  min-width: 0;
  container-type: inline-size;
}

@supports (font-size: 1cqi) {
  .metric-main {
    font-size: min(clamp(22px, 1.7vw, 30px), max(14px, 13.5cqi));
    overflow-wrap: normal;
  }

  .metric-main.value-sm {
    font-size: min(clamp(18px, 1.35vw, 23px), max(12px, 10.5cqi));
  }

  .metric-main.value-xs {
    font-size: min(clamp(16px, 1.15vw, 20px), max(11px, 8cqi));
  }
}

.metric-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none;
}

.chart-shell {
  display: grid;
  gap: 12px;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #eee5d8;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #58b3a7);
}

.bar-fill.negative {
  background: linear-gradient(90deg, #d46c4e, #b42318);
}

.line-chart {
  width: 100%;
  height: 220px;
}

.supplier-coverage-panel .line-chart {
  height: 340px;
}

.supplier-coverage-panel .chart-shell {
  gap: 16px;
}

.supplier-coverage-panel .line-legend {
  gap: 18px;
  font-size: 14px;
}

.line-chart svg {
  width: 100%;
  height: 100%;
}

.spark-list {
  display: grid;
  gap: 14px;
}

.spark-row {
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(221, 212, 197, 0.8);
}

.spark-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.spark-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.spark-label {
  font-size: 13px;
  font-weight: 700;
}

.spark-value {
  font-size: 13px;
  color: var(--ink);
}

.spark-chart-wrap {
  border-radius: 14px;
  background: linear-gradient(180deg, #faf7f0, #f3ecdf);
  padding: 8px 10px 6px;
}

.spark-chart {
  display: grid;
  gap: 4px;
}

.spark-chart svg {
  width: 100%;
  height: 72px;
}

.spark-axis {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}

.line-axis {
  position: relative;
  min-height: 18px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.line-axis-label {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.line-axis-label.edge-start {
  transform: none;
}

.line-axis-label.edge-end {
  transform: translateX(-100%);
}

.line-axis-summary {
  margin-top: 6px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}

.line-axis-side {
  fill: var(--muted);
  font-size: 11px;
}

.line-point-label {
  fill: var(--line-label-color, var(--ink));
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
}

.line-axis-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.line-chart-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.line-summary-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  background: #f6efe3;
  border: 1px solid #e6d9c4;
  color: var(--ink);
  font-size: 12px;
}

.supplier-coverage-panel .line-axis {
  min-height: 22px;
  font-size: 13px;
}

.supplier-coverage-panel .line-axis-label {
  font-weight: 700;
}

.pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 12px;
  border: 1px solid var(--line);
}

@media (max-width: 840px) {
  .sticky-controls {
    padding: 14px 16px;
  }

  .sticky-controls .row {
    justify-content: stretch;
    align-items: stretch;
  }

  .metric-view-header {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .metric-view-header .subpanel-header {
    justify-content: flex-start;
  }

  .metric-view-header .subpanel-header > div:first-child {
    text-align: left;
    max-width: none;
  }

  .surface-switch {
    top: 12px;
    right: 12px;
  }

  .layout {
    padding: 82px 16px 16px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .panel.inner-panel.dashboard-panel,
  .panel.inner-panel.chart-panel {
    padding: 14px;
  }

  .echart-host {
    min-height: 430px;
  }

  .echart-host.xl-chart {
    min-height: 560px;
  }
}

/* ─── Fase 6: Motor dinámico de análisis ────────────────────────────────── */

.dyn-panel {
  margin-top: 24px;
}

.dyn-task-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 18px;
}

.dyn-domain-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.dyn-domain-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  margin-right: 2px;
}

.dyn-task-pill {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}

/* ─── Interfaz premium 2026: capa visual, sin cambios de negocio ───────── */

:root {
  --bg: #f6f7f9;
  --paper: #ffffff;
  --paper-2: #f7f8fa;
  --ink: #17202d;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #087f73;
  --brand-soft: #e7f6f3;
  --danger: #c4322c;
  --warn: #b25e09;
  --ok: #16825d;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px rgba(16, 24, 40, .055);
  --shadow-hover: 0 2px 5px rgba(16, 24, 40, .06), 0 18px 44px rgba(16, 24, 40, .09);
  --radius: 16px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.lead,
.hero-note,
.status,
label,
button,
select,
input,
table,
.muted,
h1,
h2,
h3 {
  font-family: inherit;
}

.layout {
  padding: 92px clamp(16px, 2.5vw, 42px) 48px;
}

.surface-switch {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1400;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px clamp(16px, 2.5vw, 42px);
  border: 0;
  border-bottom: 1px solid rgba(228, 231, 236, .9);
  border-radius: 0;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 1px 12px rgba(16, 24, 40, .04);
  backdrop-filter: blur(18px) saturate(150%);
}

.brand-lockup,
.surface-switch .brand-lockup {
  min-width: 0;
  justify-self: start;
  gap: 10px;
  padding: 0;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, #12a594, #076a63);
  box-shadow: 0 7px 18px rgba(8, 127, 115, .22);
  font-weight: 800;
}

.brand-lockup > span:last-child {
  display: grid;
  line-height: 1.05;
  text-align: left;
}

.brand-lockup strong {
  font-size: 14px;
}

.brand-lockup small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.surface-links {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper-2);
}

.surface-switch .surface-links a {
  min-width: 0;
  padding: 8px 15px;
  border-radius: 9px;
  font-size: 13px;
}

.surface-switch .surface-links a.active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(16, 24, 40, .1);
}

.surface-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-period {
  padding-right: 10px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.surface-switch .current-user {
  overflow: hidden;
  max-width: 190px;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button,
.surface-switch button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--paper);
  font-weight: 650;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #c9ced7;
  box-shadow: 0 6px 16px rgba(16, 24, 40, .08);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(8, 127, 115, .24);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

button.primary,
.primary {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.icon-button,
.surface-switch .icon-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 18px;
}

.hero,
.panel,
.card {
  border-color: var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  min-height: 0;
  align-items: center;
  padding: 22px 26px;
  margin-bottom: 16px;
}

.hero h1 {
  max-width: none;
  margin-bottom: 7px;
  font-size: clamp(25px, 2.6vw, 36px);
  line-height: 1.12;
  letter-spacing: -.035em;
}

.hero .lead {
  max-width: 880px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.hero-note {
  display: none;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--brand);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
}

.sticky-controls {
  position: sticky;
  top: 78px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 4px 18px rgba(16, 24, 40, .055);
  backdrop-filter: blur(14px);
}

.controls {
  padding: 16px;
  margin-bottom: 16px;
}

.controls-bi {
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  transition: max-height .28s ease, opacity .2s ease, padding .28s ease, margin .28s ease;
}

.controls-bi:has(.filter-box.open) {
  overflow: visible;
}

.controls-bi.parameters-collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border-width: 0;
  opacity: 0;
}

.subpanel,
.source-card {
  border-color: var(--line);
  border-radius: 13px;
  background: var(--paper-2);
}

h2 {
  font-size: clamp(20px, 2vw, 24px);
  letter-spacing: -.025em;
}

h3 {
  font-size: 16px;
  letter-spacing: -.01em;
}

.results {
  display: grid;
  gap: 16px;
}

.results > *,
.dashboard-panel > * {
  animation: premiumReveal .32s ease both;
}

@keyframes premiumReveal {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.cards,
.metric-grid,
.executive-kpis .metric-grid,
.dyn-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 12px;
}

.card,
.metric-tile,
.executive-kpi,
.dyn-kpi-card {
  min-height: 124px;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .035);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover,
.metric-tile:hover,
.executive-kpi:hover,
.dyn-kpi-card:hover {
  transform: translateY(-2px);
  border-color: #d4d9e1;
  box-shadow: var(--shadow-hover);
}

.card strong,
.metric-value,
.executive-kpi-value,
.dyn-kpi-value {
  letter-spacing: -.035em;
}

.dashboard-panel,
.dashboard-selector-panel {
  padding: clamp(16px, 2vw, 24px);
  margin-bottom: 0;
}

.executive-grid,
.chart-grid {
  gap: 16px;
}

.chart-panel {
  min-height: 440px;
  padding: 18px;
}

.echart-host {
  min-height: 390px;
}

.echart-host.xl-chart {
  min-height: 540px;
}

.table-panel {
  overflow: hidden;
}

.filters-panel {
  position: relative;
  z-index: 5;
  overflow: visible;
  padding: 16px;
}

.filter-tabs {
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--paper-2);
}

.filter-tab {
  border: 0;
  border-radius: 9px;
}

.filter-tab.active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(16, 24, 40, .1);
}

input,
select,
textarea {
  min-height: 42px;
  border-color: var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper);
}

.tabulator {
  border-color: var(--line) !important;
  border-radius: 12px;
  font-family: inherit !important;
}

.floating-nav {
  right: 18px;
  bottom: 18px;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --paper: #151b23;
  --paper-2: #1b222c;
  --ink: #edf1f7;
  --muted: #a3adbd;
  --line: #2b3442;
  --brand-soft: #143b37;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 32px rgba(0, 0, 0, .18);
}

[data-theme="dark"] .surface-switch,
[data-theme="dark"] .sticky-controls,
[data-theme="dark"] .floating-nav {
  background: rgba(21, 27, 35, .92);
}

[data-theme="dark"] .surface-switch .surface-links a.active {
  background: #29313d;
}

[data-theme="dark"] .tabulator,
[data-theme="dark"] .tabulator-row,
[data-theme="dark"] .tabulator-header {
  color: var(--ink);
  background: var(--paper);
}

@media (max-width: 1024px) {
  .surface-switch {
    grid-template-columns: auto 1fr auto;
  }

  .brand-lockup > span:last-child,
  .header-period {
    display: none;
  }

  .surface-switch .current-user {
    max-width: 120px;
  }

  .executive-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .layout {
    padding: 132px 12px 24px;
  }

  .surface-switch {
    min-height: 120px;
    grid-template-columns: auto 1fr;
    grid-template-rows: 48px 48px;
    gap: 4px 10px;
    padding: 8px 12px;
  }

  .surface-links {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .surface-switch .surface-links a {
    padding: 8px 6px;
  }

  .surface-actions {
    grid-column: 2;
    grid-row: 1;
    gap: 6px;
  }

  .surface-switch .current-user {
    display: none;
  }

  .surface-switch button {
    min-height: 38px;
    padding: 0 11px;
  }

  .hero {
    padding: 18px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .hero .lead {
    display: none;
  }

  .sticky-controls {
    top: 128px;
  }

  .sticky-controls .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .metric-view-header {
    grid-column: 1 / -1;
  }

  .panel,
  .dashboard-panel,
  .filters-panel {
    border-radius: 14px;
  }

  .cards,
  .metric-grid,
  .executive-kpis .metric-grid,
  .dyn-kpi-grid,
  .coach-kpi-grid > .metric-grid,
  .coach-kpi-grid.compact > .metric-grid {
    grid-template-columns: 1fr;
  }

  .two-col,
  .coach-two-col {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    min-height: 360px;
    padding: 12px;
  }

  .echart-host,
  .echart-host.xl-chart {
    min-height: 340px;
  }

  .filter-grid,
  .filter-fields-row {
    grid-template-columns: 1fr;
  }

  .filter-box-list {
    max-height: 220px;
  }

  .filter-box-panel {
    position: static;
    width: 100%;
    margin-top: 6px;
    box-shadow: none;
  }

  .tabulator-host {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .floating-nav button:nth-child(-n+2) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

.dyn-task-pill:hover {
  background: var(--paper-2);
  border-color: var(--brand);
}

.dyn-task-pill.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.dyn-combo-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 14px 16px;
  background: var(--paper-2);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.dyn-combo-row select {
  min-width: 230px;
}

.dyn-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 260px));
  align-items: stretch;
  gap: 14px;
  margin-bottom: 22px;
}

.dyn-kpi-card {
  min-width: 0;
  padding: 16px 18px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(68,53,34,.05);
  overflow: hidden;
}

.dyn-kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}

.dyn-kpi-value {
  max-width: 100%;
  font-size: clamp(19px, 1.7vw, 24px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.05;
  overflow-wrap: anywhere;
  word-break: normal;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.dyn-kpi-delta {
  font-size: 12px;
  font-weight: 600;
  margin-top: 3px;
}

.dyn-kpi-context {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.25;
}

.dyn-kpi-delta.up   { color: var(--ok); }
.dyn-kpi-delta.down { color: var(--danger); }
.dyn-kpi-delta.flat { color: var(--muted); }

.dyn-viz {
  margin-top: 22px;
  min-height: 40px;
}

.dyn-viz-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--ink);
}

/* Insight badges */
.ins-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
  vertical-align: middle;
}

.ins-alert       { background: #fef2f2; color: #b91c1c; }
.ins-opportunity { background: #f0fdf4; color: #15803d; }
.ins-positive    { background: #d7f2ee; color: #0f766e; }
.ins-trend       { background: #eff6ff; color: #1d4ed8; }
.ins-context     { background: var(--paper-2); color: var(--muted); }

/* Donut */
.donut-wrap {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 8px;
}

.donut-svg {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  padding-top: 4px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* Scatter */
.scatter-svg {
  width: 100%;
  max-width: 520px;
  height: auto;
  display: block;
  margin-top: 8px;
}

/* --- PDV 360 --------------------------------------------------------------- */

.pdv360 .pdv-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin: 8px 0 16px;
}

.pdv360 .pdv-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.pdv360 .pdv-search {
  position: relative;
  flex: 1 1 320px;
  max-width: 520px;
}

.pdv360 .pdv-search input {
  width: 100%;
}

.pdv-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.pdv-search-results button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.pdv-search-results button:hover {
  background: var(--brand-soft);
}

.pdv-search-results button span,
.pdv-search-results .muted {
  font-size: 12px;
  color: var(--muted);
}

.pdv-search-results .muted {
  padding: 10px 12px;
}

.pdv-empty {
  padding: 24px 0;
}

.pdv-identity {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.pdv-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.pdv-chip.good {
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ok);
}

.pdv-chip.warn {
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  color: var(--warn);
}

.pdv-chip.bad {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.pdv-company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
}

.pdv-company-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--company-color, var(--brand));
  border-radius: 14px;
  background: var(--paper);
}

.pdv-company-card.is-empty {
  background: var(--paper-2);
}

.pdv-company-name {
  font-weight: 700;
}

.pdv-company-skus {
  font-size: 14px;
  color: var(--muted);
}

.pdv-company-skus strong {
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.pdv-company-sales,
.pdv-company-peer,
.pdv-company-via {
  font-size: 12px;
  color: var(--muted);
}

.pdv-company-via {
  color: var(--ink);
}

.pdv-opportunities {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pdv-opportunity {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.pdv-opportunity-rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.pdv-opportunity-title {
  font-weight: 700;
}

.pdv-opportunity-how {
  margin-top: 6px;
  padding: 6px 10px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--ink);
}

.pdv-opportunity-potential {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pdv-opportunity-potential span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.pdv-table-wrap {
  overflow-x: auto;
}

.pdv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pdv-table th {
  padding: 8px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.pdv-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.pdv-table td:nth-child(n + 2) {
  font-variant-numeric: tabular-nums;
}

.pdv-bar {
  width: 100%;
  max-width: 120px;
  height: 5px;
  margin-top: 4px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.pdv-bar span {
  display: block;
  height: 100%;
  background: var(--brand);
}

.pdv-bar span.warn {
  background: var(--warn);
}

.pdv-bar span.bad {
  background: var(--danger);
}

.pdv-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 720px) {
  .pdv-opportunity {
    grid-template-columns: 28px 1fr;
  }

  .pdv-opportunity-potential {
    grid-column: 2;
    text-align: left;
  }
}

.pdv-pen-row {
  display: grid;
  grid-template-columns: minmax(120px, 170px) 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 6px 0;
  font-size: 13px;
}

.pdv-pen-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdv-pen-track {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: var(--line);
}

.pdv-pen-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 5px;
  background: var(--ok);
}

.pdv-pen-fill.warn {
  background: var(--warn);
}

.pdv-pen-fill.bad {
  background: var(--danger);
}

.pdv-pen-expected {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
}

.pdv-pen-value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pdv360 h4 {
  margin: 4px 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.tabulator-cell.pdv-cell-gap {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
  font-weight: 700;
}

.tabulator-cell.pdv-cell-low {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn);
}

.tabulator-cell.pdv-cell-ok {
  color: var(--ok);
}

.tabulator-cell.pdv-cell-na {
  color: var(--muted);
}

.pdv-cell-peer {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

/* Comercial vs Sales Coach: secciones propias de cada superficie. */
body[data-workspace="coach"] [data-workspace-only="bi"],
body[data-workspace="bi"] [data-workspace-only="coach"] {
  display: none !important;
}

/* --- Modo oscuro: superficies con colores fijos ------------------------------
   Muchas reglas usan fondos claros literales (#fffdfa, white, degradés
   crema). En oscuro se remapean a los tokens del tema para que el texto
   (que sí usa --ink/--muted) no quede claro sobre blanco. */

[data-theme="dark"] {
  --coach-blue: #17283a;
  --warn: #e0a24a;
  --ok: #4cc27a;
  --danger: #f07b70;
}

/* Superficie base (tarjetas, controles, tablas). */
[data-theme="dark"] .guide-card,
[data-theme="dark"] .request-step,
[data-theme="dark"] .access-checkbox-list,
[data-theme="dark"] .coach-brief,
[data-theme="dark"] .coach-seller-picker select,
[data-theme="dark"] .planning-field input,
[data-theme="dark"] .planning-field select,
[data-theme="dark"] .interactive-report-controls select,
[data-theme="dark"] select,
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] button,
[data-theme="dark"] .password-toggle,
[data-theme="dark"] .sales-source,
[data-theme="dark"] .check-inline input[type="checkbox"],
[data-theme="dark"] .erp-panel,
[data-theme="dark"] .file-item,
[data-theme="dark"] .preview,
[data-theme="dark"] table,
[data-theme="dark"] .progress-card,
[data-theme="dark"] .filter-box-toggle,
[data-theme="dark"] .filter-box-panel,
[data-theme="dark"] .filter-box-actions button,
[data-theme="dark"] .filter-search,
[data-theme="dark"] .check-option,
[data-theme="dark"] .semaphore,
[data-theme="dark"] .alert,
[data-theme="dark"] .insight-item,
[data-theme="dark"] .ranking-item,
[data-theme="dark"] .scenario-item,
[data-theme="dark"] .action-item,
[data-theme="dark"] .tabulator .tabulator-row {
  background: var(--paper);
  color: var(--ink);
}

/* Botones primarios y chips activos conservan su color de marca. */
[data-theme="dark"] button.primary,
[data-theme="dark"] .primary {
  background: var(--brand);
  color: #fff;
}

/* Superficie secundaria (paneles contenedores, encabezados, filas alternas). */
[data-theme="dark"] .hero-note,
[data-theme="dark"] .subpanel,
[data-theme="dark"] .source-card,
[data-theme="dark"] .guide-callout,
[data-theme="dark"] .dyn-help-card,
[data-theme="dark"] .chart-panel,
[data-theme="dark"] .table-panel,
[data-theme="dark"] .mongo-summary,
[data-theme="dark"] th,
[data-theme="dark"] .coach-comparison-bar,
[data-theme="dark"] .coach-week-plan,
[data-theme="dark"] .coach-mix-table tbody tr:nth-child(odd),
[data-theme="dark"] .tabulator .tabulator-header,
[data-theme="dark"] .tabulator .tabulator-header .tabulator-col,
[data-theme="dark"] .tabulator .tabulator-row.tabulator-row-even,
[data-theme="dark"] .metric-tile,
[data-theme="dark"] .spark-chart-wrap,
[data-theme="dark"] .line-summary-chip,
[data-theme="dark"] .dashboard-view-badge,
[data-theme="dark"] .segmented {
  background: var(--paper-2);
  color: var(--ink);
}

[data-theme="dark"] .check-option:hover,
[data-theme="dark"] .floating-nav button:hover,
[data-theme="dark"] .tabulator .tabulator-row.tabulator-selectable:hover {
  background: #232c38;
}

[data-theme="dark"] .bar-track,
[data-theme="dark"] .coach-mix-bar {
  background: var(--line);
}

/* Superficies con tono semántico. */
[data-theme="dark"] .metric-tile.good,
[data-theme="dark"] .erp-status.ok,
[data-theme="dark"] .ins-opportunity {
  background: color-mix(in srgb, var(--ok) 12%, var(--paper-2));
}

[data-theme="dark"] .metric-tile.warn,
[data-theme="dark"] .erp-status.warn,
[data-theme="dark"] .coach-callout-recognition,
[data-theme="dark"] .metric-chip {
  background: color-mix(in srgb, var(--warn) 12%, var(--paper-2));
}

[data-theme="dark"] .metric-tile.bad,
[data-theme="dark"] .erp-status.danger,
[data-theme="dark"] .ins-alert {
  background: color-mix(in srgb, var(--danger) 12%, var(--paper-2));
}

[data-theme="dark"] .ins-trend {
  background: color-mix(in srgb, #3b82f6 12%, var(--paper-2));
}

[data-theme="dark"] .metric-chip.active {
  background: #ea580c;
  color: #fff;
}

[data-theme="dark"] .dashboard-view-chip.active {
  background: var(--brand-soft);
  color: #5fd3c1;
}

/* Textos con color oscuro fijo: se aclaran para mantener contraste. */
[data-theme="dark"] .coach-link,
[data-theme="dark"] .coach-table-link,
[data-theme="dark"] .ins-trend {
  color: #8db4ff;
}

[data-theme="dark"] .coach-positive,
[data-theme="dark"] .company-access-validation.ready,
[data-theme="dark"] .ins-opportunity,
[data-theme="dark"] .ins-positive {
  color: #5fd39a;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--muted);
}

[data-theme="dark"] input[type="date"] {
  color-scheme: dark;
}

/* Shared responsive shell. Table contents scroll inside their own region. */
.mobile-menu-toggle { display: none; }
.layout, .layout :where(section, article, form, .row, .subpanel, .two-col, .three-col,
  .chart-grid, .executive-grid, .coach-hero-actions, .coach-seller-picker, .filter-grid,
  .metric-grid, .cards, .table-panel, .tabulator-host, .echart-host) { min-width: 0; }
.echart-host { width: 100%; }
:where(.table-wrap, .coach-table-wrap, .pdv-table-wrap, .tabulator-host) {
  min-width: 0;
  max-width: 100%;
  overscroll-behavior-x: contain;
}
button, a, input, select, textarea { touch-action: manipulation; }
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}
body[data-surface="intelligence-admin"] .layout > .panel { margin-bottom: 18px; padding: 20px; }
.deposit-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.deposit-form label { min-width: 0; }
.deposit-form textarea { min-height: 100px; resize: vertical; font: inherit; }
.deposit-form .full-width, .deposit-form .check-inline { grid-column: 1 / -1; }
.deposit-catalog-item { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.deposit-catalog-item span { overflow-wrap: anywhere; }
.deposit-catalog-item button { flex-shrink: 0; }
#output { max-width: 100%; overflow: auto; }

@media screen and (max-width: 1100px) {
  .layout { padding: 84px 16px 40px; }
  .surface-switch {
    min-height: 68px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
    gap: 8px 12px;
    padding: 10px 16px;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
  }
  .brand-lockup > span:last-child { display: grid; }
  .navigation-ready .mobile-menu-toggle { display: block; grid-column: 2; grid-row: 1; }
  .surface-switch .surface-links {
    grid-column: 1 / -1;
    grid-row: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .surface-switch .surface-links a { min-height: 44px; padding: 10px; }
  .surface-switch .surface-actions {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-self: stretch;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 0;
  }
  .surface-switch.navigation-ready:not(.menu-open) :is(.surface-links, .surface-actions) { display: none; }
  .surface-switch .current-user {
    display: block;
    flex: 1;
    max-width: none;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
  }
  .header-period { display: none; }
  .surface-switch button { min-height: 44px; }
  .sticky-controls { top: 78px; }
  .coach-brief-hero { flex-direction: column; align-items: stretch; }
  .coach-comparison-bar { flex-wrap: wrap; }
  .coach-print-actions { flex-wrap: wrap; }
  .coach-hero-actions, .coach-seller-picker { min-width: 0; }
}

@media screen and (max-width: 700px) {
  html { scroll-padding-top: 84px; }
  .layout { padding: 80px 12px calc(80px + env(safe-area-inset-bottom, 0px)); }
  .surface-switch { padding: 10px 12px; }
  .hero { padding: 16px; }
  .hero h1 { font-size: 26px; overflow-wrap: anywhere; }
  .hero .lead { display: block; font-size: 14px; }
  .sticky-controls { position: static; padding: 12px; }
  .sticky-controls .row { display: flex; align-items: stretch; gap: 8px; }
  .sticky-controls .row > * { flex: 1 1 180px; min-width: 0; }
  .sticky-controls .row > .metric-view-header { flex-basis: 100%; }
  .controls-bi:not(.parameters-collapsed) { max-height: none; overflow: visible; }
  .controls-bi.parameters-collapsed { visibility: hidden; }
  .panel, .subpanel, .source-card, .source-item, .erp-panel { padding: 14px; }
  .coach-brief, .admin-ops { padding: 0; }
  .two-col, .three-col, .chart-grid, .executive-grid, .controls,
  .source-grid, .mapping-grid, .mapping-grid.compact, .access-inline-add,
  .coach-two-col, .coach-kpi-grid.compact > .metric-grid { grid-template-columns: minmax(0, 1fr); }
  .row, .subpanel-header, .access-check-header, .metric-view-header { flex-wrap: wrap; }
  .row > label, .meeting-actions > label { flex: 1 1 100%; }
  label, label.wide, .meeting-actions label, .dyn-combo-row select { min-width: 0; max-width: 100%; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    width: 100%; min-width: 0; max-width: 100%; min-height: 44px; font-size: 16px;
  }
  input[type="file"] { padding: 10px 4px; }
  button { min-height: 44px; height: auto; white-space: normal; padding: 10px 12px; }
  .button-row > button { flex: 1 1 140px; }
  .segmented { flex-wrap: wrap; }
  .segmented button { flex: 1 1 auto; }
  .filter-fields-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .filter-box { min-width: 0; max-width: none; width: 100%; }
  .filter-box-toggle { min-height: 44px; }
  .filter-box-option, .access-check-option { min-height: 44px; }
  .access-check-option { grid-template-columns: auto minmax(0, 1fr); }
  .access-check-option span { overflow-wrap: anywhere; }
  .access-check-option small { grid-column: 2; overflow-wrap: anywhere; }
  .insight-item, .pill, .status { overflow-wrap: anywhere; }
  .dashboard-view-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dashboard-view-selector button { width: 100%; min-width: 0; }
  .coach-brief-hero, .coach-comparison-bar { padding: 16px; }
  .coach-message { margin: 16px; padding: 12px; }
  .coach-kpi-grid, .coach-section-heading, .coach-table-wrap, .coach-two-col,
  .coach-week-plan, .coach-team-details { margin-left: 16px; margin-right: 16px; }
  .coach-kpi-grid.compact { margin-left: 0; margin-right: 0; }
  .coach-print-actions > * { flex: 1 1 100%; }
  .coach-print-actions .print-orientation { width: 100%; }
  .coach-callout, .coach-week-plan { padding: 14px; }
  .chart-panel { min-height: 0; }
  .echart-host, .echart-host.xl-chart { height: 340px; min-height: 340px; }
  .table-wrap, .coach-table-wrap, .pdv-table-wrap, .tabulator-host { overflow-x: auto; }
  :is(.coach-table-wrap, .pdv-table-wrap):has(table)::before {
    content: "Deslizá la tabla para ver todas las columnas";
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
  }
  .tabulator .tabulator-footer .tabulator-footer-contents { flex-wrap: wrap; gap: 8px; }
  .tabulator .tabulator-footer .tabulator-paginator { white-space: normal; }
  .pdv-search { flex-basis: 100%; }
  .pdv-pen-row { grid-template-columns: minmax(0, 1fr) auto; }
  .pdv-pen-label { grid-column: 1 / -1; white-space: normal; }
  .progress-modal { padding: 12px; }
  .progress-card { padding: 20px; gap: 12px; max-height: 85dvh; overflow-y: auto; flex-direction: column; align-items: stretch; }
  .progress-card > * { min-width: 0; overflow-wrap: anywhere; }
  .floating-nav { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); flex-direction: row; gap: 6px; }
  .floating-nav button { width: 44px; height: 44px; }
  .auth-layout { min-height: 100svh; padding: 20px 12px; }
  .auth-card { width: 100%; min-width: 0; padding: 24px 18px; }
  .deposit-form { grid-template-columns: minmax(0, 1fr); }
  .deposit-catalog-item { flex-direction: column; align-items: stretch; }
  body[data-surface="intelligence-admin"] .panel > button { width: 100%; margin-top: 8px; }
}
