/* Dashboard inteligencia comercial — DESIGN.md v2.2 · Sales Intelligence · dark */

.app {
  position: relative;
  z-index: 1;
  max-width: var(--layout-dashboard-max);
  margin: 0 auto;
  padding: var(--space-xl) 24px var(--space-xxl);
}

/* —— Header band (integrado al fondo) —— */
.app-header {
  position: relative;
  margin-bottom: var(--space-xl);
  padding: var(--space-xl) 0 var(--space-lg);
  color: var(--color-on-dark);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.app-header::after {
  content: "";
  position: absolute;
  right: 6%;
  bottom: 0;
  left: 6%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 75, 210, 0.12) 18%,
    rgba(255, 75, 210, 0.55) 50%,
    rgba(255, 75, 210, 0.12) 82%,
    transparent 100%
  );
  pointer-events: none;
}

.app-header__content {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-xl) var(--space-xxl);
  align-items: flex-start;
}

.app-header .panel-header {
  margin-bottom: 0;
}

.app-header .panel-header__title {
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 700;
  letter-spacing: normal;
  color: var(--color-on-dark);
}

.app-header .panel-header__desc {
  color: var(--color-on-dark-muted);
}

.app-header .panel-header__eyebrow {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--color-on-dark-muted);
}

.app-header__logos {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  grid-row: 1;
}

.app-header__aside {
  display: grid;
  grid-template-rows: auto auto;
  justify-items: end;
  align-content: start;
  gap: var(--space-md);
}

.app-header__actions {
  grid-row: 2;
  display: flex;
  justify-content: flex-end;
  min-height: 40px;
  align-items: center;
}

body.is-view-upload .app-header__actions {
  visibility: hidden;
  pointer-events: none;
}

body.is-view-analysis #section-upload {
  display: none !important;
}

body.is-view-upload #dashboard-analysis-placeholder {
  display: none !important;
}

body.is-view-upload #dashboard-progress:not(:has(#pipeline-status:not([hidden]))) {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  #section-upload {
    transition: opacity var(--duration-normal) var(--ease-out);
  }

  body.is-view-analysis #section-upload {
    opacity: 0;
  }
}

.app-header__logo {
  display: block;
  height: 36px;
  width: auto;
  object-fit: contain;
}

.app-header__logo--360 {
  height: 59px;
}

body.is-booting .skeleton-layer--header .sk {
  background: linear-gradient(
    90deg,
    var(--sk-base-dark) 0%,
    var(--sk-shine-dark) 42%,
    var(--sk-base-dark) 84%
  );
  background-size: 220% 100%;
}

@media (max-width: 720px) {
  .app-header {
    padding: var(--space-lg) 0 var(--space-md);
  }

  .app-header::after {
    right: 0;
    left: 0;
  }

  .app-header__content {
    grid-template-columns: 1fr;
  }

  .app-header__logos {
    justify-content: flex-start;
  }

  .app-header__aside {
    justify-items: flex-start;
  }

  .app-header__actions {
    justify-content: flex-start;
  }
}

/* —— Secciones —— */
.dashboard-section {
  margin-bottom: var(--space-xl);
  animation: fade-up var(--duration-normal) var(--ease-out) both;
  animation-delay: calc(var(--reveal-i, 0) * 55ms);
}

.dashboard-progress {
  margin-bottom: 0;
}

.dashboard-progress .panel-stage--inline {
  display: grid;
  grid-template-columns: 1fr;
}

.dashboard-progress .panel-stage__main {
  grid-column: 1;
  grid-row: 1;
}

#dashboard-progress.is-progress-loading .skeleton-layer--progress {
  display: flex;
  visibility: visible;
}

#dashboard-progress.is-progress-loading .panel-stage__main {
  visibility: hidden;
  pointer-events: none;
}

.skeleton-layer--progress {
  display: none;
  flex-direction: column;
  gap: var(--space-md);
  grid-column: 1;
  grid-row: 1;
  visibility: hidden;
  pointer-events: none;
}

.sk--progress-bar {
  width: 100%;
  height: 52px;
  border-radius: var(--rounded-md);
}

.sk--progress-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-xl);
  align-items: center;
  background: none;
  animation: none;
}

.sk--progress-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
  background: none;
  animation: none;
}

.sk--progress-logo {
  width: 153px;
  height: 36px;
  border-radius: var(--rounded-md);
}

.sk--progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  background: none;
  animation: none;
}

.sk--progress-step {
  width: 88px;
  height: 24px;
  border-radius: var(--rounded-full);
}

.dashboard-analysis-placeholder[hidden] {
  display: none !important;
}

.skeleton-layer--analysis-placeholder {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: var(--space-md) 0 var(--space-lg);
}

.sk--chart-compact {
  min-height: 320px;
}

.sk--table-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: none;
  animation: none;
}

.sk--table-row {
  width: 100%;
  height: 36px;
  border-radius: var(--rounded-sm);
}

.sk--table-row--head {
  height: 28px;
  margin-bottom: var(--space-xs);
}

.sk--filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
  background: none;
  animation: none;
}

.sk--filter-chip {
  height: 56px;
  border-radius: var(--rounded-md);
}

.sk--toolbar-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-md);
  background: none;
  animation: none;
}

.sk--toolbar-search,
.sk--toolbar-select {
  height: 40px;
  border-radius: var(--rounded-md);
}

.skeleton-layer--upload {
  display: none;
  flex-direction: column;
  gap: var(--space-xl);
  grid-column: 1;
  grid-row: 1;
  visibility: hidden;
  pointer-events: none;
}

body.dashboard-shell.is-booting #section-upload .skeleton-layer--upload,
#section-upload.is-section-loading .skeleton-layer--upload {
  display: flex;
  visibility: visible;
}

body.dashboard-shell.is-booting #section-upload .panel-stage__main,
#section-upload.is-section-loading .panel-stage__main {
  visibility: hidden;
  pointer-events: none;
}

.sk--upload-hero {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-lg);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: none;
  animation: none;
}

.sk--upload-hero-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  grid-column: 1;
  background: none;
  animation: none;
}

.sk--upload-logo {
  grid-column: 2;
  width: 187px;
  height: 44px;
  max-width: 100%;
  margin: 0;
  border-radius: var(--rounded-md);
}

.sk--upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
  background: none;
  animation: none;
}

.sk--upload-card {
  min-height: 132px;
  border-radius: var(--rounded-md);
}

#section-upload .sk,
.dashboard-analysis-placeholder .sk,
#dashboard-progress .sk,
.dashboard-panel-section .sk {
  background: linear-gradient(
    90deg,
    var(--sk-base-dark) 0%,
    var(--sk-shine-dark) 42%,
    var(--sk-base-dark) 84%
  );
  background-size: 220% 100%;
}

@media (prefers-reduced-motion: reduce) {
  #section-upload .sk,
  .dashboard-analysis-placeholder .sk,
  #dashboard-progress .sk,
  .dashboard-panel-section .sk {
    animation: none;
    background: var(--sk-base-dark);
  }
}

@media (max-width: 900px) {
  .sk--upload-hero {
    grid-template-columns: 1fr;
  }

  .sk--upload-hero-copy,
  .sk--upload-logo {
    grid-column: 1;
  }

  .sk--upload-logo {
    width: 153px;
    height: 36px;
    margin-inline: auto;
  }

  .sk--upload-grid {
    grid-template-columns: 1fr;
  }

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

  .sk--toolbar-row {
    grid-template-columns: 1fr;
  }
}

.dashboard-progress .pipeline-status {
  margin-top: 0;
}

body.dashboard-shell .pipeline-status:not([hidden]) {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-xl);
}

body.dashboard-shell .pipeline-status__body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--space-md) * var(--pipeline-scale, 1.2)) calc(var(--space-lg) * var(--pipeline-scale, 1.2));
  min-width: 0;
}

body.dashboard-shell .pipeline-status__brand {
  flex-shrink: 0;
  align-self: center;
}

body.dashboard-shell .pipeline-status__logo {
  display: block;
  height: 36px;
  width: auto;
  max-width: min(187px, 30vw);
  object-fit: contain;
  object-position: right center;
}

@media (max-width: 720px) {
  body.dashboard-shell .pipeline-status:not([hidden]) {
    grid-template-columns: 1fr auto;
    gap: var(--space-md);
  }

  body.dashboard-shell .pipeline-status__logo {
    height: 28px;
  }

  .sk--progress-logo {
    width: 120px;
    height: 28px;
  }
}

body.is-booting .dashboard-section {
  animation: none;
}

.dashboard-panel-section[hidden] {
  display: none !important;
}

body.dashboard-shell.is-booting .dashboard-panel-section .skeleton-layer--panel {
  visibility: hidden;
}

body.dashboard-shell.is-booting .dashboard-panel-section .panel-stage__main {
  visibility: visible;
}

.dashboard-section__title {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-on-dark);
}

.card-panel .dashboard-section__title {
  color: var(--color-on-dark);
}

.card-panel .text-muted {
  color: var(--color-on-dark-muted);
}

.card-panel .text-muted strong {
  color: rgba(255, 255, 255, 0.88);
}

.card-panel .upload-field > label,
.card-panel .filter-bar .field__label,
.card-panel .strategic-map-adjustments__title,
.card-panel .strategic-ctrl-label,
.card-panel .table-toolbar .field__label {
  color: rgba(255, 255, 255, 0.55);
}

.card-panel .filter-bar,
.card-panel .strategic-filters-panel,
.card-panel .table-toolbar {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.card-panel .global-filters__row .field + .field {
  border-left-color: rgba(255, 255, 255, 0.08);
}

.card-panel .strategic-ctrl--actions {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.dashboard-section--bare .dashboard-section__title {
  margin-bottom: var(--space-md);
}

.dashboard-section--bare .text-muted {
  color: var(--color-on-dark-muted);
}

.dashboard-section--bare .text-muted strong {
  color: var(--color-on-dark);
}

.text-muted {
  margin: 0 0 var(--space-md);
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-ink-muted);
}

.text-muted.text-sm {
  font-size: 13px;
}

.text-muted strong {
  color: var(--color-ink-secondary);
  font-weight: 600;
}

/* —— Filter bar —— */
.filter-bar {
  padding: var(--space-md) 0 0;
  margin-bottom: var(--space-md);
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
}

.strategic-filters-panel {
  padding: var(--space-lg) 0 0;
  margin-bottom: var(--space-lg);
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
}

.filter-bar .field__label,
.strategic-map-adjustments__title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
}

.strategic-ctrl-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
}

.global-filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg) var(--space-xl);
  align-items: flex-end;
}

.global-filters__row .field {
  min-width: 180px;
}

.global-filters__row .field + .field {
  padding-left: var(--space-xl);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

#section-global-filters .filter-bar {
  margin-bottom: 0;
}

#section-kpis .kpi-card,
#section-margin-kpis .kpi-card,
#section-kpis .kpi-card:hover,
#section-margin-kpis .kpi-card:hover {
  background: rgba(255, 255, 255, 0.03);
}

.file-status--sr {
  display: none !important;
}

.strategic-select {
  width: 100%;
  max-width: none;
}

/* —— Custom select (menú ghost) —— */
.custom-select {
  position: relative;
  width: 100%;
}

.custom-select__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.custom-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  color: var(--color-on-dark);
  cursor: pointer;
  appearance: none;
}

.custom-select__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select__chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--duration-fast) ease;
}

.custom-select.is-open .custom-select__chevron {
  transform: rotate(180deg);
}

.custom-select__menu {
  z-index: 5000;
  margin: 0;
  padding: var(--space-xs);
  list-style: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(10, 12, 16, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--rounded-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  scrollbar-width: thin;
}

.custom-select__menu::-webkit-scrollbar {
  width: 8px;
}

.custom-select__menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.custom-select__option {
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  border-radius: var(--rounded-sm);
  cursor: pointer;
  transition: background-color var(--duration-fast) ease;
}

.custom-select__option:hover,
.custom-select__option.is-highlighted {
  background: rgba(255, 255, 255, 0.06);
}

.custom-select__option.is-selected {
  color: var(--color-on-dark);
  background: rgba(255, 75, 210, 0.1);
}

.custom-select.is-open .custom-select__trigger {
  border: 2px solid var(--color-border-focus);
  padding: 8px 11px;
  box-shadow: 0 0 0 3px var(--color-focus-halo);
}

body.dashboard-shell .custom-select__trigger:not(:disabled) {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dashboard-shell .custom-select__trigger:hover:not(:disabled) {
  border-color: rgba(255, 75, 210, 0.28);
}

/* —— Upload —— */
.upload-panel__hero {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-lg) var(--space-xl);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.upload-panel__intro {
  grid-column: 1;
  text-align: left;
}

.upload-panel__brand {
  grid-column: 2;
  margin-bottom: 0;
  justify-self: center;
}

.upload-panel__brand.brand-logo-wrap::before {
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%) scale(0.6);
}

@media (prefers-reduced-motion: reduce) {
  body:not(.is-booting) .upload-panel__brand.brand-logo-wrap::before {
    animation: none;
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1);
  }
}

.upload-panel__logo {
  width: auto;
  height: 44px;
  max-width: min(220px, 100%);
  object-position: center;
  transform-origin: center center;
}

.upload-panel__intro .dashboard-section__title {
  margin-bottom: var(--space-xs);
}

.upload-panel__intro .text-muted {
  margin-bottom: 0;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
}

.upload-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.upload-field > label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.55);
}

.surface-preview-note {
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-left: 2px solid rgba(28, 81, 221, 0.45);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 0 var(--rounded-sm) var(--rounded-sm) 0;
}

.surface-preview-note strong {
  color: rgba(255, 255, 255, 0.88);
}

.surface-preview-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

/* —— Panel ghost (upload section) —— */
body.dashboard-shell .card-panel--ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

body.dashboard-shell .card-panel--ghost::before {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1) 50%,
    transparent
  );
}

body.dashboard-shell .card-panel--ghost:focus-within {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

/* —— Surface preview: A Ghost / B Carbón / C Elevación —— */
.input-file-upload.surface-preview--ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-style: solid;
}

.input-file-upload.surface-preview--ghost:hover {
  border-color: rgba(28, 81, 221, 0.45);
  background: transparent;
}

.input-file-upload.surface-preview--ghost.is-active,
.input-file-upload.surface-preview--ghost.is-filled {
  border: 1px solid rgba(28, 81, 221, 0.45);
  padding: var(--space-lg);
  box-shadow: none;
}

.input-file-upload.surface-preview--ghost::before {
  background-color: transparent;
  border-color: rgba(255, 255, 255, 0.12);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231c51dd' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='12' y1='18' x2='12' y2='12'/%3E%3Cline x1='9' y1='15' x2='15' y2='15'/%3E%3C/svg%3E");
}

.input-file-upload.surface-preview--ghost .btn-file-picker {
  color: rgba(255, 255, 255, 0.88);
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

.input-file-upload.surface-preview--ghost .btn-file-picker:hover {
  background: transparent;
  border-color: rgba(28, 81, 221, 0.45);
}

.input-file-upload.surface-preview--charcoal {
  background: #141414;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-style: solid;
}

.input-file-upload.surface-preview--charcoal:hover {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.14);
}

.input-file-upload.surface-preview--charcoal.is-active,
.input-file-upload.surface-preview--charcoal.is-filled {
  border: 1px solid rgba(28, 81, 221, 0.35);
  padding: var(--space-lg);
  box-shadow: none;
}

.input-file-upload.surface-preview--charcoal::before {
  background-color: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='12' y1='18' x2='12' y2='12'/%3E%3Cline x1='9' y1='15' x2='15' y2='15'/%3E%3C/svg%3E");
}

.input-file-upload.surface-preview--charcoal .btn-file-picker {
  background: #141414;
  border-color: rgba(255, 255, 255, 0.08);
}

.input-file-upload.surface-preview--charcoal .btn-file-picker:hover {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.14);
}

.input-file-upload.surface-preview--elevation {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-style: solid;
}

.input-file-upload.surface-preview--elevation:hover {
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(255, 255, 255, 0.12);
}

.input-file-upload.surface-preview--elevation.is-active,
.input-file-upload.surface-preview--elevation.is-filled {
  border: 1px solid rgba(28, 81, 221, 0.35);
  padding: var(--space-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.input-file-upload.surface-preview--elevation::before {
  background-color: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231c51dd' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='12' y1='18' x2='12' y2='12'/%3E%3Cline x1='9' y1='15' x2='15' y2='15'/%3E%3C/svg%3E");
}

.input-file-upload.surface-preview--elevation .btn-file-picker {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.08);
}

.input-file-upload.surface-preview--elevation .btn-file-picker:hover {
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(255, 255, 255, 0.12);
}

.input-file-upload.surface-preview--ghost.is-filled::before,
.input-file-upload.surface-preview--charcoal.is-filled::before,
.input-file-upload.surface-preview--elevation.is-filled::before {
  background-color: rgba(22, 163, 74, 0.1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  border-color: rgba(22, 163, 74, 0.25);
}

.input-file-upload {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-md);
  min-height: 132px;
  padding: var(--space-lg);
  background: rgba(0, 0, 0, 0.28);
  border: 1px dashed rgba(255, 75, 210, 0.22);
  border-radius: var(--rounded-md);
  transition:
    background-color var(--duration-fast) ease,
    border-color var(--duration-input-border) ease,
    box-shadow var(--duration-fast) ease;
}

.input-file-upload::before {
  content: "";
  display: block;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  background-color: rgba(255, 75, 210, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23ff4bd2' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='12' y1='18' x2='12' y2='12'/%3E%3Cline x1='9' y1='15' x2='15' y2='15'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  border: 1px solid rgba(255, 75, 210, 0.15);
  border-radius: var(--rounded-md);
}

.input-file-upload:hover {
  border-color: var(--color-border-focus);
  background: rgba(255, 75, 210, 0.04);
}

.input-file-upload.is-active,
.input-file-upload.is-filled {
  border-style: solid;
  border: 2px solid var(--color-border-focus);
  padding: calc(var(--space-lg) - 1px);
  box-shadow: 0 0 0 3px var(--color-focus-halo);
}

.input-file-upload.is-filled::before {
  background-color: rgba(22, 163, 74, 0.1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  border-color: rgba(22, 163, 74, 0.25);
}

.input-file-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.btn-file-picker {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--rounded-md);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) ease,
    border-color var(--duration-fast) ease;
}

.btn-file-picker:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-file-picker:focus-visible {
  outline: 2px solid var(--color-action-primary);
  outline-offset: 2px;
}

.input-file-upload__name {
  display: block;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input-file-upload.is-filled .input-file-upload__name {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
}

#upload-alerts.alert {
  margin-top: var(--space-lg);
  margin-bottom: 0;
  border: none;
  box-shadow: none;
}

#upload-alerts.alert--success {
  align-items: center;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: #212121;
  background: linear-gradient(90deg, #e8e8e8 0%, #f2f2f2 45%, #f8f8f8 100%);
  border-radius: 12px;
}

#upload-alerts.alert--success .alert__dot,
#upload-alerts.alert--success .alert__dot--success {
  width: 8px;
  height: 8px;
  margin-top: 0;
  background: var(--color-action-primary, #1c51dd);
  box-shadow: none;
}

#upload-alerts.alert--info {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 75, 210, 0.25);
}

#upload-alerts.alert--info .alert__dot {
  background: var(--color-accent-impact);
  box-shadow: 0 0 8px rgba(255, 75, 210, 0.35);
}

body.dashboard-shell #upload-alerts.alert:not(.alert--success):not(.alert--info) {
  color: rgba(255, 210, 210, 0.95);
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.28);
}

#file-load-hint.text-muted {
  padding: var(--space-sm) var(--space-md);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--rounded-md);
  color: rgba(255, 255, 255, 0.5);
}

/* —— KPIs —— */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.kpi-card {
  position: relative;
  padding: var(--space-lg);
  padding-left: calc(var(--space-lg) + 4px);
  background: linear-gradient(160deg, #1c2230 0%, #151a24 100%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--rounded-md);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: fade-up var(--duration-normal) var(--ease-out) both;
  animation-delay: calc(var(--stagger-i, 0) * 45ms);
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: var(--space-md);
  bottom: var(--space-md);
  left: 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: rgba(255, 255, 255, 0.12);
}

.kpi-card--ok::before { background: var(--color-metric-positive); }
.kpi-card--warn::before { background: var(--color-metric-warning); }
.kpi-card--danger::before { background: var(--color-metric-danger); }
.kpi-card--high::before { background: var(--color-metric-positive); }
.kpi-card--mid::before { background: var(--color-metric-warning); }
.kpi-card--low::before { background: var(--color-metric-danger); }

.kpi-card--clickable {
  cursor: pointer;
}

.kpi-card--clickable:focus-visible {
  outline: 2px solid rgba(255, 75, 210, 0.55);
  outline-offset: 2px;
}

.kpi-card:hover {
  border-color: rgba(255, 75, 210, 0.2);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.kpi-label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
}

.kpi-label--tier {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.kpi-label__main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-on-dark);
  font-variant-numeric: tabular-nums;
}

.kpi-value.ok { color: var(--color-metric-positive); }
.kpi-value.warn { color: var(--color-metric-warning); }
.kpi-value.danger { color: var(--color-metric-danger); }

.kpi-sub,
.muted.small {
  margin-top: 6px;
}

/* —— Mapa estratégico —— */
.strategic-lead {
  margin-bottom: var(--space-lg);
}

.strategic-map-adjustments__title {
  margin: 0 0 var(--space-md);
}

.strategic-controls-row--embedded {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md) var(--space-lg);
  align-items: end;
}

.strategic-output {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-accent-impact);
}

body.dashboard-shell .kpi-sub {
  color: rgba(255, 255, 255, 0.42);
}

.strategic-range {
  width: 100%;
  height: 4px;
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.strategic-range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent-impact);
  border: 2px solid #1a2030;
  box-shadow: 0 1px 3px rgba(15, 20, 25, 0.15);
  cursor: pointer;
  transition: transform 80ms ease-out;
}

.strategic-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent-impact);
  border: 2px solid #1a2030;
  box-shadow: 0 1px 3px rgba(15, 20, 25, 0.15);
  cursor: pointer;
}

.strategic-range::-webkit-slider-thumb:active {
  transform: scale(0.95);
}

.strategic-ctrl--actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: flex-end;
  justify-content: space-between;
  padding-top: var(--space-sm);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.strategic-ctrl--search {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  margin: 0;
}

.strategic-ctrl--search .input-text {
  width: 100%;
}

.map-legend-bar {
  margin-bottom: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--rounded-md);
}

.map-legend-bar__title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.map-legend-median {
  margin: 0 0 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
}

.map-legend-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.map-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--rounded-full);
}

.map-cat strong {
  font-weight: 600;
  color: var(--color-on-dark);
}

.map-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.map-cat-ideal .map-cat-dot { background: var(--color-quadrant-ideal); }
.map-cat-opp .map-cat-dot { background: var(--color-quadrant-opportunity); }
.map-cat-prices .map-cat-dot { background: var(--color-quadrant-prices); }
.map-cat-urgent .map-cat-dot { background: var(--color-quadrant-urgent); }

.strategic-map-empty {
  margin: 0 0 var(--space-md);
  padding: var(--space-md);
  font-size: 14px;
  color: var(--color-metric-warning);
  background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--rounded-md);
}

.plotly-stage {
  display: grid;
  grid-template-columns: 1fr;
}

.plotly-stage__main {
  grid-column: 1;
  grid-row: 1;
}

.plotly-box--map {
  min-height: 480px;
  background: var(--color-canvas-chart);
  border: 1px solid var(--color-hairline-dark);
  border-radius: var(--rounded-md);
  overflow: hidden;
}

.map-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--rounded-full);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease;
}

.map-chip:hover {
  border-color: rgba(255, 75, 210, 0.35);
  color: rgba(255, 255, 255, 0.88);
}

.map-chip.is-active {
  background: var(--color-action-primary);
  border-color: var(--color-action-primary);
  color: var(--color-on-primary);
}

/* —— Tabla —— */
.risks-summary {
  margin: 0 0 var(--space-md);
  padding: 10px 14px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--rounded-md);
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: flex-end;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.table-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.table-toolbar .field__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
}

.table-toolbar .input-text {
  min-width: 160px;
}

.table-toolbar .btn {
  min-height: 40px;
  padding: 10px 18px;
}

.data-table-wrap {
  overflow: auto;
  max-height: 56vh;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--rounded-md);
  background: rgba(0, 0, 0, 0.28);
}

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

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table th:first-child,
.data-table td:first-child,
.data-table th[data-text],
.data-table td[data-text] {
  text-align: left;
}

.data-table tbody tr {
  transition: background-color var(--duration-fast) ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 75, 210, 0.07);
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--color-accent-impact);
}

.row-danger { background: rgba(220, 38, 38, 0.12); }
.row-warn { background: rgba(217, 119, 6, 0.1); }

.badge-cat {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  border-radius: var(--rounded-full);
  white-space: nowrap;
}

.badge-cat.cat-ideal {
  color: #15803d;
  background: rgba(22, 163, 74, 0.12);
}

.badge-cat.cat-opp {
  color: #b45309;
  background: rgba(217, 119, 6, 0.12);
}

.badge-cat.cat-prices,
.badge-cat.cat-precios {
  color: #1644b8;
  background: rgba(28, 81, 221, 0.1);
}

.badge-cat.cat-urgent {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.1);
}

.badge-cat.cat-unknown,
.badge-cat.cat-none {
  color: var(--color-ink-muted);
  background: var(--color-canvas-soft);
}

.cat-ideal { color: var(--color-metric-positive); font-weight: 600; }
.cat-opp { color: var(--color-metric-warning); font-weight: 600; }
.cat-prices,
.cat-precios { color: var(--color-action-primary); font-weight: 600; }
.cat-urgent { color: var(--color-metric-danger); font-weight: 600; }
.cat-unknown { color: var(--color-ink-muted); }

@media (max-width: 900px) {
  .upload-panel__hero {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .upload-panel__intro {
    grid-column: 1;
  }

  .upload-panel__brand {
    grid-column: 1;
    justify-self: center;
  }

  .upload-panel__logo {
    height: 36px;
  }

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

  .global-filters__row .field + .field {
    padding-left: 0;
    border-left: none;
  }

  .strategic-controls-row--embedded {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .app {
    padding-inline: 16px;
  }

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

  .card-main-tool,
  .card-panel {
    padding: var(--space-lg);
  }

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

@media (prefers-reduced-motion: reduce) {
  .dashboard-section,
  .kpi-card {
    animation: none;
  }

  .kpi-card:hover {
    transform: none;
    box-shadow:
      0 4px 20px rgba(0, 0, 0, 0.35),
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  .pipeline-status__dot,
  .section-loading-status__dots span {
    animation: none;
  }
}
