﻿    * { box-sizing: border-box; }

    /* ── Theme tokens (Analista = :root default; Admin overrides on body.role-admin) ── */
    :root,
    body.role-analyst {
      --pt-bg-base:            #112530;
      --pt-bg-screen:          #112530;
      --pt-card-bg:              #162f3d;
      --pt-card-border:          rgba(3,255,134,.10);
      --pt-card-border-hover:    rgba(3,255,134,.22);
      --pt-accent:               #03FF86;
      --pt-accent-soft:          #FFDE0A;
      --pt-accent-muted:         rgba(3,255,134,.35);
      --pt-session-bg:           rgba(22,47,61,.92);
      --pt-session-border:       rgba(255,255,255,.04);
      --pt-dash-session-color:   #e2edf3;
      --pt-tl-play-bg:           rgba(255,222,10,.18);
      --pt-tl-play-bg-hover:     rgba(255,222,10,.30);
      --pt-tl-badge-bg:          rgba(255,222,10,.12);
      --pt-tl-badge-border:      rgba(255,222,10,.25);
      --pt-tl-thumb-shadow:      rgba(255,222,10,.6);
      --pt-tl-panel-border:      rgba(255,255,255,.1);
      --pt-tl-panel-shadow:      0 10px 25px -5px rgba(0,0,0,.3);
      --pt-scrollbar-track:      #112530;
    }

    body.role-admin {
      --pt-bg-base:            #0f2433;
      --pt-bg-screen:          #0f2433;
      --pt-card-bg:              #0f1e2e;
      --pt-card-border:          rgba(56,189,248,.13);
      --pt-card-border-hover:    rgba(56,189,248,.25);
      --pt-accent:               #38bdf8;
      --pt-accent-soft:          #38bdf8;
      --pt-accent-muted:         rgba(56,189,248,.35);
      --pt-session-bg:           rgba(9,13,22,.92);
      --pt-session-border:       rgba(56,189,248,.18);
      --pt-dash-session-color:   #38bdf8;
      --pt-tl-play-bg:           rgba(56,189,248,.18);
      --pt-tl-play-bg-hover:     rgba(56,189,248,.30);
      --pt-tl-badge-bg:          rgba(56,189,248,.12);
      --pt-tl-badge-border:      rgba(56,189,248,.25);
      --pt-tl-thumb-shadow:      rgba(56,189,248,.6);
      --pt-tl-panel-border:      rgba(56,189,248,.32);
      --pt-tl-panel-shadow:      0 8px 36px rgba(0,0,0,.5), 0 0 0 1px rgba(56,189,248,.08);
      --pt-scrollbar-track:      #0f2433;
    }

    /*
     * AUTH GATE — hides the entire body until bootstrapAuth() decides which
     * screen to show. Prevents ANY flash of content before the session check.
     * JS sets body.style.visibility = 'visible' once the route is resolved.
     */
    body { background: var(--pt-bg-base); color: #e2edf3; font-family: Inter, system-ui, sans-serif; margin: 0;
           visibility: hidden; }

    #screen-upload,
    #screen-dashboard,
    #screen-kpi-select {
      background-color: var(--pt-bg-screen);
    }

    #session-strip {
      background: var(--pt-session-bg);
      border-bottom-color: var(--pt-session-border);
    }

    #dash-session-name { color: var(--pt-dash-session-color); }

    /*
     * SCREEN GUARD — every top-level screen starts hidden regardless of
     * Tailwind utility ordering. The JS show() removes the hidden class;
     * hide() adds it back. Using display:none !important ensures no ID-level
     * CSS rule can accidentally override the gate.
     */
    #screen-login,
    #screen-upload,
    #screen-dashboard,
    #screen-kpi-select,
    #screen-loading,
    #screen-admin  { display: none !important; }
    #screen-login.pt-visible,
    #screen-upload.pt-visible,
    #screen-dashboard.pt-visible,
    #screen-kpi-select.pt-visible,
    #screen-loading.pt-visible,
    #screen-admin.pt-visible   { display: flex !important; }
    /* dashboard and admin are block-level roots, not flex */
    #screen-dashboard.pt-visible,
    #screen-admin.pt-visible   { display: block !important; }
    /* loading is fixed overlay */
    #screen-loading.pt-visible { display: flex !important; }

    /* ── Scrollbar ── */
    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: var(--pt-scrollbar-track); }
    ::-webkit-scrollbar-thumb { background: #1e3d50; border-radius: 3px; }

    /* ── Drag zone ── */
    #drop-zone.drag-over { border-color: var(--pt-accent); background: rgba(3,255,134,.06); }

    /* ── Loader spinner (mini, used inside cards) ── */
    .spinner {
      width: 48px; height: 48px; border: 3px solid rgba(3,255,134,.2);
      border-top-color: var(--pt-accent); border-radius: 50%;
      animation: spin .8s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    /* ── Progress loading screen ── */
    #screen-loading { transition: opacity .45s ease; }
    #screen-loading.pt-fade-out { opacity: 0 !important; pointer-events: none !important; }

    /* ── Time-unit drop-up selector ── */
    .time-selector-container { position: relative; display: inline-block; z-index: 110; }
    .time-dropup {
      position: absolute; bottom: 100%; right: 0; margin-bottom: 6px;
      background: #1e293b; border: 1px solid rgba(255,255,255,.12);
      border-radius: 8px; box-shadow: 0 -4px 16px rgba(0,0,0,.55);
      z-index: 200; display: none; flex-direction: column; min-width: 120px;
      overflow: hidden;
    }
    .time-dropup.show { display: flex; }
    .time-dropup-item {
      padding: 8px 14px; font-size: 12px; color: #cbd5e1;
      cursor: pointer; transition: background .15s; white-space: nowrap;
      font-family: inherit;
    }
    .time-dropup-item:hover     { background: rgba(255,255,255,.07); color: #fff; }
    .time-dropup-item.active    { color: #03FF86; font-weight: 700; }
    #time-lapse-filter-btn {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 2px 9px; border-radius: 6px; font-size: 11px; font-weight: 600;
      cursor: pointer; white-space: nowrap; transition: background .18s, border-color .18s;
      background: rgba(96,165,250,.10); color: #60a5fa;
      border: 1px solid rgba(96,165,250,.22); font-family: inherit;
      user-select: none;
    }
    #time-lapse-filter-btn:hover {
      background: rgba(96,165,250,.20); border-color: rgba(96,165,250,.45);
    }

    /* ── Pulse ring on KPI cards ── */
    .kpi-ring { box-shadow: 0 0 0 1px rgba(3,255,134,.18); }
    /* ── Pulse ring on KPI cards ── */
    .kpi-ring { box-shadow: 0 0 0 1px rgba(3,255,134,.18); }

    /* ── KPI selection cards ── */
    .kpi-select-card { cursor: pointer; }
    .kpi-select-card:hover { border-color: rgba(3,255,134,.3) !important; transform: translateY(-1px); }
    .kpi-select-card.is-selected:hover { border-color: rgba(3,255,134,.55) !important; }

    /* ── KPI selection accordion (checkboxes) ── */
    .kpi-checkbox {
      width: 17px; height: 17px; min-width: 17px;
      background: transparent;
      border: 1.5px solid rgba(255,255,255,.2);
    }
    .kpi-checkbox.is-checked {
      background: #03FF86;
      border-color: #03FF86;
    }
    .kpi-checkbox.is-checked.is-recommended {
      background: #a78bfa;
      border-color: #a78bfa;
    }
    .kpi-row.selected { background: rgba(255,255,255,.03); }
    .kpi-row:hover .kpi-checkbox:not(.is-checked) { border-color: rgba(255,255,255,.4); }

    /* ── Export menu ── */
    .export-menu-item {
      flex-shrink: 0;
    }
    .export-menu-item:hover { background: rgba(255,255,255,.05); }
    .export-menu-item:active { background: rgba(255,255,255,.08); }
    body.exporting-pdf .nav-group--tools,
    body.exporting-pdf .nav-group--actions,
    body.exporting-pdf .nav-group--campaign,
    body.exporting-pdf .nav-group--user,
    body.exporting-pdf #nav-actions-dropdown,
    body.exporting-pdf .reset-campaign-btn { display: none !important; }

    /* ── Resumen de campaña (debajo de navbar, antes de metadatos) ── */
    .dashboard-campaign-summary {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: flex-start;
      gap: 8px;
      margin: 0 0 12px 0;
      padding: 8px 12px;
      border-radius: 10px;
      background: rgba(14, 31, 41, .85);
      border: 1px solid rgba(3, 255, 134, .12);
      position: relative;
      z-index: 1;
      flex-shrink: 0;
      min-height: 0;
    }
    .dashboard-campaign-summary.hidden {
      display: none !important;
    }
    .dashboard-summary-rows {
      font-size: 13px;
      font-weight: 600;
      color: #e2edf3;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .dashboard-summary-period {
      font-size: 12px;
      font-weight: 500;
      color: #60a5fa;
      background: rgba(96, 165, 250, .1);
      border: 1px solid rgba(96, 165, 250, .22);
      padding: 3px 10px;
      border-radius: 6px;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .dashboard-summary-period.hidden,
    .dashboard-status-banner.hidden,
    .data-confidence-badge.hidden {
      display: none !important;
    }
    .dashboard-status-banner {
      gap: 6px;
      padding: 4px 10px;
      border-radius: 8px;
      font-size: 11px;
      line-height: 1.35;
      color: #8ba3b0;
      background: rgba(56, 189, 248, .08);
      border: 1px solid rgba(56, 189, 248, .2);
      max-width: 100%;
      min-width: 0;
      flex-shrink: 1;
    }
    .dashboard-status-banner:not(.hidden) {
      display: inline-flex;
      align-items: center;
    }
    .dashboard-status-banner strong {
      color: #e2edf3;
      font-weight: 600;
    }
    .data-confidence-badge {
      padding: 4px 10px;
      border-radius: 8px;
      font-size: 11px;
      font-weight: 600;
      white-space: nowrap;
      cursor: help;
      flex-shrink: 0;
    }
    .data-confidence-badge:not(.hidden) {
      display: inline-flex;
      align-items: center;
    }
    .data-confidence-badge.confidence-high {
      color: #03FF86;
      background: rgba(3, 255, 134, .1);
      border: 1px solid rgba(3, 255, 134, .28);
    }
    .data-confidence-badge.confidence-warn {
      color: #fb923c;
      background: rgba(251, 146, 60, .1);
      border: 1px solid rgba(251, 146, 60, .32);
    }
    .data-confidence-badge[title] {
      cursor: help;
    }
    /* ── Modal detalle confianza ── */
    #modal-confidence-detail .conf-detail-box {
      width: min(480px, 92vw);
      max-height: 90vh;
      overflow-y: auto;
      padding: 24px;
      box-shadow: 0 20px 60px rgba(0,0,0,.55);
    }
    .conf-bar-row {
      padding: 12px 14px;
      border-radius: 12px;
      background: #0e1f29;
      border: 1px solid rgba(255,255,255,.06);
    }
    .conf-bar-label {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 12px;
      font-weight: 600;
      color: #c4d6e0;
      margin-bottom: 8px;
    }
    .conf-bar-track {
      height: 8px;
      border-radius: 999px;
      background: rgba(255,255,255,.08);
      overflow: hidden;
    }
    .conf-bar-fill {
      height: 100%;
      border-radius: 999px;
      transition: width .35s ease;
    }
    .conf-bar-detail {
      font-size: 11px;
      color: #8ba3b0;
      margin-top: 6px;
      line-height: 1.4;
    }

    /* ── Dashboard navbar — 5 grupos flex (solo layout; PDF ignora el header) ── */
    .dash-navbar {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: nowrap;
      min-width: 0;
      overflow: visible;
    }
    .nav-group {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    /* Grupos 1–2: comprimen primero en pantallas estrechas */
    .nav-group--gestion {
      flex: 1 1 0;
      min-width: 0;
      gap: 10px;
    }
    .nav-group--tools {
      flex: 0 1 auto;
      min-width: 0;
    }
    /* Grupos 3–5: siempre visibles */
    .nav-group--actions {
      flex: 0 0 auto;
      margin-left: auto;
    }
    .nav-group--campaign,
    .nav-group--user {
      flex: 0 0 auto;
      overflow: visible;
    }
    #nav-user-dropdown,
    #nav-actions-dropdown {
      overflow: visible;
    }
    .nav-dropdown-anchor {
      position: relative;
      display: inline-flex;
      align-items: center;
      flex-shrink: 0;
    }

    /* ── Nav dropdown panels (usuario, acciones) ── */
    .nav-dropdown-panel {
      position: fixed;
      top: auto;
      left: auto;
      right: auto;
      bottom: auto;
      margin-top: 0;
      height: auto;
      min-height: 0;
      max-height: min(360px, calc(100vh - 16px));
      overflow-x: hidden;
      overflow-y: auto;
      z-index: 1000;
      padding: 6px 0;
      border-radius: 12px;
      background: #16303f;
      border: 1px solid rgba(255, 255, 255, 0.1);
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    }
    .nav-dropdown-panel .export-menu-item {
      flex-shrink: 0;
      align-items: center;
      width: 100%;
      box-sizing: border-box;
    }
    .nav-dropdown-panel .export-menu-item:not(.hidden) {
      display: flex;
    }
    .nav-dropdown-panel .export-menu-item.hidden,
    .nav-dropdown-panel .export-menu-item[hidden] {
      display: none !important;
    }
    /* Rol analista (usuario): nunca mostrar Admin en el menú de usuario */
    body.role-analyst #btn-admin-panel,
    body:not(.role-admin) #btn-admin-panel {
      display: none !important;
    }
    body.role-admin #btn-admin-panel:not(.hidden):not([hidden]) {
      display: flex !important;
    }
    #btn-admin-panel.hidden + .nav-dropdown-divider {
      display: none;
    }
    .nav-dropdown-panel .nav-dropdown-divider {
      flex-shrink: 0;
      height: 1px;
      margin: 4px 0;
      background: rgba(255, 255, 255, 0.06);
    }
    #nav-user-menu.nav-dropdown-panel,
    #nav-actions-menu.nav-dropdown-panel {
      width: 13rem;
    }
    #nav-actions-menu.nav-dropdown-panel {
      width: 16rem;
    }
    .nav-brand-label {
      min-width: 0;
      max-width: min(280px, 28vw);
    }
    @media (max-width: 900px) {
      .nav-brand-label { max-width: min(160px, 22vw); }
      .dash-navbar { gap: 6px; }
    }

    /* ── PDF export — .pdf-mode en #screen-dashboard (captura alta fidelidad) ── */
    body.pdf-mode {
      background-color: #112530 !important;
      overflow: visible !important;
    }
    #screen-dashboard.pdf-mode {
      display: block !important;
      position: static !important;
      background: #112530 !important;
      background-color: #112530 !important;
      color: #ffffff !important;
      min-height: 100vh !important;
      width: 100% !important;
    }
    #screen-dashboard.pdf-mode,
    #screen-dashboard.pdf-mode * {
      background-color: #112530 !important;
      color: #ffffff !important;
    }
    #screen-dashboard.pdf-mode canvas {
      background-color: transparent !important;
    }
    #screen-dashboard.pdf-mode > header,
    #screen-dashboard.pdf-mode #dash-navbar {
      display: flex !important;
      position: relative !important;
      top: auto !important;
      z-index: 1 !important;
    }
    /* Ocultar controles interactivos — conservar logo + marca en grupo Gestión */
    #screen-dashboard.pdf-mode .nav-group--tools,
    #screen-dashboard.pdf-mode .nav-group--actions,
    #screen-dashboard.pdf-mode .nav-group--campaign,
    #screen-dashboard.pdf-mode .nav-group--user,
    #screen-dashboard.pdf-mode #nav-actions-dropdown,
    #screen-dashboard.pdf-mode #nav-user-dropdown,
    #screen-dashboard.pdf-mode #layout-view-toggle,
    #screen-dashboard.pdf-mode .dashboard-module-header,
    #screen-dashboard.pdf-mode .pt-module-drag-handle,
    #screen-dashboard.pdf-mode #btnTimeLapse,
    #screen-dashboard.pdf-mode .reset-campaign-btn,
    #screen-dashboard.pdf-mode .dash-profile-btn,
    #screen-dashboard.pdf-mode .dash-logout-btn,
    #screen-dashboard.pdf-mode #btn-admin-panel,
    #screen-dashboard.pdf-mode #session-strip,
    #screen-dashboard.pdf-mode #meta-banners-wrap,
    #screen-dashboard.pdf-mode #file-details-widget,
    #screen-dashboard.pdf-mode #brand-bottom-grid,
    #screen-dashboard.pdf-mode #sub-dashboard-view,
    #screen-dashboard.pdf-mode #database-view,
    #screen-dashboard.pdf-mode footer,
    #screen-dashboard.pdf-mode .pt-drag-handle,
    /* Gráficos sin datos ya llevan .hidden — reforzar en PDF */
    #screen-dashboard.pdf-mode .chart-card-unified.hidden {
      display: none !important;
    }
    #screen-dashboard.pdf-mode main,
    #screen-dashboard.pdf-mode #dashboard-content {
      padding: 12px 16px 24px !important;
      max-width: 100% !important;
      background-color: #112530 !important;
    }
    #screen-dashboard.pdf-mode #dashboard-campaign-summary:not(.hidden) {
      display: flex !important;
      flex-wrap: wrap !important;
      margin-bottom: 12px !important;
    }
    #screen-dashboard.pdf-mode main > *:not(#dashboard-container) {
      display: none !important;
    }
    #screen-dashboard.pdf-mode #dashboard-container,
    #screen-dashboard.pdf-mode #dashboard-print-area {
      display: block !important;
      background: transparent !important;
      padding: 0 !important;
      margin: 0 !important;
    }
    #screen-dashboard.pdf-mode .chart-card-unified {
      transform: none !important;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16) !important;
      break-inside: avoid;
      page-break-inside: avoid;
    }
    #screen-dashboard.pdf-mode .chart-card-unified:hover {
      transform: none !important;
    }
    #screen-dashboard.pdf-mode .kpi-ring {
      break-inside: avoid;
      page-break-inside: avoid;
    }

    /* ── Filter select ── */
    select {
      appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238ba3b0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
      background-repeat: no-repeat; background-position: right 12px center;
      padding-right: 36px !important;
    }

    /* ── Insight card colours ── */
    .insight-success { border-left-color: #03FF86; }
    .insight-warning  { border-left-color: #FFDE0A; }
    .insight-alert    { border-left-color: #f87171; }
    .insight-info     { border-left-color: #60a5fa; }

    /* ── Chart canvas containers ── */
    .chart-wrap { position: relative; width: 100%; min-height: 320px; }

    /* ── KPI Registry — grid dinámico (8–31+ gráficos) ── */
    .kpi-registry-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
    }
    .kpi-registry-grid.kpi-registry-grid--compact {
      grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
    }
    .kpi-registry-grid.kpi-registry-grid--dense {
      grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
    }
    .kpi-registry-card.chart-card-unified {
      padding: 0.85rem 1rem;
    }
    .kpi-registry-grid .chart-wrap {
      min-height: 240px;
    }
    .kpi-registry-card .kpi-registry-title {
      font-size: 0.8125rem;
      margin-bottom: 0.35rem;
    }
    .kpi-registry-card .kpi-scalar-rich__value {
      font-size: clamp(2.2rem, 5.5vw, 3.5rem);
    }
    .kpi-registry-card .kpi-scalar-rich__progress {
      width: min(100%, 360px);
      height: 7px;
    }
    .kpi-registry-card .kpi-scalar-rich.flex {
      padding: 1rem 1.1rem;
    }
    .kpi-registry-card .kpi-scalar-bar__value {
      font-size: clamp(1.75rem, 4.5vw, 2.75rem);
      margin-bottom: 0.65rem;
    }
    .kpi-registry-card .kpi-scalar-bar.flex {
      padding: 0.85rem 0.75rem;
      min-width: 0;
      overflow: hidden;
    }
    .kpi-registry-card .kpi-scalar-bar__meter {
      width: 100%;
      max-width: 100%;
      padding: 0 4px;
      box-sizing: border-box;
    }
    .kpi-registry-card .kpi-scalar-bar__track {
      width: 100%;
      max-width: 100%;
      height: 11px;
      overflow: hidden;
      margin: 0 auto;
    }
    .kpi-registry-card .kpi-scalar-bar__marker {
      height: 11px;
      top: 0;
      width: 2px;
    }
    .kpi-registry-card .kpi-scalar-bar__scale {
      max-width: 100%;
      width: 100%;
      margin: 0.4rem auto 0;
      font-size: 10px;
      gap: 0.35rem;
    }
    .kpi-registry-card .kpi-scalar-bar__cap {
      text-align: right;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .kpi-registry-card .kpi-value-card-wrap,
    .kpi-registry-card .chart-wrap {
      overflow: hidden;
      max-width: 100%;
    }
    .kpi-registry-card .kpi-scalar-bar,
    .kpi-registry-card .kpi-scalar-rich,
    .kpi-registry-card .kpi-scalar-status {
      max-width: 100%;
      min-width: 0;
    }
    .kpi-registry-card .kpi-scalar-status__value {
      font-size: clamp(2rem, 5vw, 3.25rem);
    }
    .kpi-registry-card .kpi-card-caption {
      margin-top: 0.45rem;
      padding: 0.45rem 0.55rem;
      font-size: 10px;
    }
    .kpi-registry-card.kpi-card--tall .chart-wrap,
    .kpi-registry-card.kpi-card--wide .chart-wrap {
      min-height: 320px;
    }
    .kpi-registry-show-more:hover {
      background: rgba(3,255,134,.2) !important;
    }
    .kpi-registry-placeholder {
      min-height: 160px;
    }
    .kpi-registry-grid.kpi-registry-grid--monthly-mode {
      transition: grid-template-columns .25s ease;
    }
    .kpi-registry-grid .kpi-registry-section-header {
      grid-column: 1 / -1;
      margin-top: 0.5rem;
    }
    .kpi-registry-grid .kpi-registry-section-header:first-child {
      margin-top: 0;
    }
    .kpi-registry-card.kpi-monthly-tl-active {
      border-color: rgba(3,255,134,.35);
      box-shadow: 0 0 0 1px rgba(3,255,134,.12), 0 12px 32px rgba(0,0,0,.22);
    }
    .kpi-value-card-wrap {
      display: flex;
      align-items: stretch;
      justify-content: center;
      background: linear-gradient(165deg, rgba(22,47,61,.95) 0%, rgba(15,30,36,.88) 100%);
      border-radius: 12px;
      border: 1px solid rgba(255,255,255,.06);
    }
    .kpi-registry-value-card {
      width: 100%;
    }
    .kpi-registry-value-card .kpi-card-value {
      text-shadow: 0 0 24px rgba(3,255,134,.15);
    }
    /* ── Scalar KPI visuals ── */
    .kpi-scalar-context {
      font-size: 11px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: #8ba3b0;
      opacity: 0.85;
      margin-top: 0.75rem;
    }
    .kpi-scalar-rich__hero {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.35rem;
      margin-bottom: 0.5rem;
    }
    .kpi-scalar-rich__value {
      font-size: clamp(2.75rem, 7vw, 4.75rem);
      font-weight: 800;
      line-height: 1;
      letter-spacing: -0.02em;
      text-shadow: 0 0 32px rgba(3,255,134,.18);
    }
    .kpi-scalar-rich__unit {
      font-size: 0.75rem;
      font-weight: 700;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: #8ba3b0;
      padding: 0.2rem 0.55rem;
      border-radius: 999px;
      border: 1px solid rgba(255,255,255,.08);
      background: rgba(255,255,255,.04);
    }
    .kpi-scalar-rich__meta {
      font-size: 0.95rem;
      color: #8ba3b0;
      margin: 0.25rem 0 0.75rem;
    }
    .kpi-scalar-rich__meta span {
      color: #FFDE0A;
      font-weight: 700;
    }
    .kpi-scalar-rich__progress {
      width: min(100%, 420px);
      height: 8px;
      border-radius: 999px;
      background: rgba(255,255,255,.08);
      overflow: hidden;
      margin: 0.25rem auto 0;
    }
    .kpi-scalar-rich__progress-fill {
      height: 100%;
      border-radius: 999px;
      transition: width .4s ease;
    }
    .kpi-card--scalar-rich .kpi-value-card-wrap {
      min-height: 100%;
      background: linear-gradient(165deg, rgba(22,47,61,.98) 0%, rgba(12,28,34,.92) 100%);
    }
    .kpi-card--scalar-rich .kpi-registry-title {
      font-size: 0.95rem;
      margin-bottom: 0.35rem;
    }
    .kpi-scalar-bar__value {
      font-size: clamp(2rem, 5vw, 3.25rem);
      font-weight: 800;
      line-height: 1.1;
      margin-bottom: 1rem;
    }
    .kpi-scalar-bar__track {
      position: relative;
      width: 100%;
      max-width: 520px;
      height: 14px;
      border-radius: 999px;
      background: rgba(255,255,255,.08);
      overflow: visible;
      margin: 0 auto;
    }
    .kpi-scalar-bar__fill {
      height: 100%;
      border-radius: 999px;
      min-width: 4px;
      transition: width .45s ease;
    }
    .kpi-scalar-bar__marker {
      position: absolute;
      top: -4px;
      width: 3px;
      height: 22px;
      background: #FFDE0A;
      border-radius: 2px;
      transform: translateX(-50%);
      box-shadow: 0 0 8px rgba(255,222,10,.45);
    }
    .kpi-scalar-bar__scale {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
      max-width: 520px;
      width: 100%;
      margin: 0.5rem auto 0;
      font-size: 11px;
      color: #8ba3b0;
    }
    .kpi-scalar-bar__meta {
      color: #FFDE0A;
      font-weight: 600;
    }
    .kpi-scalar-status__value {
      font-size: clamp(2.5rem, 6vw, 4rem);
      font-weight: 800;
      line-height: 1;
    }
    .kpi-card--tall .chart-wrap,
    .kpi-card--wide .chart-wrap {
      min-height: 400px;
    }
    .kpi-card--tall .chart-wrap canvas {
      max-height: none !important;
    }
    .kpi-scalar-rich .kpi-card-value,
    .kpi-scalar-comparison,
    .kpi-scalar-delta,
    .kpi-scalar-status {
      width: 100%;
    }
    .kpi-card-caption {
      font-size: 11px;
      line-height: 1.55;
      color: #7a9aad;
      margin: 0.65rem 0 0;
      padding: 0.55rem 0.65rem;
      border-radius: 8px;
      background: rgba(255,255,255,.03);
      border-left: 2px solid rgba(3,255,134,.35);
    }
    .kpi-card-caption::before {
      content: '💡 ';
      opacity: 0.85;
    }
    .chart-wrap canvas {
      max-height: 100%;
    }

    /* ── Unified chart cards (dashboard grid) ── */
    .chart-card-unified {
      background: var(--pt-card-bg);
      border: 1px solid var(--pt-card-border);
      box-shadow: 0 10px 28px rgba(0,0,0,.16);
      transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
      position: relative;
    }
    .chart-card-unified:hover {
      border-color: var(--pt-card-border-hover);
      box-shadow: 0 14px 36px rgba(0,0,0,.24);
      transform: translateY(-2px);
    }

    /* ── Drag & Drop ── */
    .pt-drag-handle {
      position: absolute;
      top: 10px; right: 12px;
      width: 20px; height: 20px;
      display: flex; align-items: center; justify-content: center;
      cursor: grab;
      opacity: 0;
      transition: opacity .2s;
      color: #8ba3b0;
      font-size: 13px;
      line-height: 1;
      user-select: none;
      z-index: 2;
      border-radius: 4px;
    }
    .pt-drag-handle:hover { opacity: 1 !important; background: rgba(255,255,255,.06); }
    .chart-card-unified:hover .pt-drag-handle,
    .kpi-ring:hover .pt-drag-handle,
    .kpi-registry-card:hover .pt-drag-handle { opacity: .45; }
    .pt-drag-handle:active { cursor: grabbing; }

    /* ── Dashboard module blocks (drag-reorderable sections) ── */
    .dashboard-modules-stack { position: relative; }
    .dashboard-module {
      position: relative;
      border-radius: 16px;
      border: 1px solid rgba(255,255,255,.06);
      background: rgba(255,255,255,.015);
      padding: 12px 14px 14px;
      transition: border-color .2s, box-shadow .2s;
    }
    .dashboard-module:hover { border-color: rgba(255,255,255,.1); }
    .dashboard-module-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 10px;
      padding-bottom: 8px;
      border-bottom: 1px solid rgba(255,255,255,.06);
    }
    .dashboard-module-title {
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: .08em;
      color: #8ba3b0;
    }
    .pt-module-drag-handle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 22px;
      height: 22px;
      cursor: grab;
      color: #8ba3b0;
      font-size: 14px;
      line-height: 1;
      border-radius: 5px;
      opacity: .55;
      transition: opacity .15s, background .15s;
      user-select: none;
      flex-shrink: 0;
    }
    .dashboard-module:hover .pt-module-drag-handle { opacity: 1; }
    .pt-module-drag-handle:hover { background: rgba(255,255,255,.08); }
    .pt-module-drag-handle:active { cursor: grabbing; }
    .dashboard-module.pt-sortable-ghost {
      opacity: .45;
      border-color: rgba(3,255,134,.35);
      box-shadow: 0 8px 24px rgba(0,0,0,.25);
    }
    .dashboard-module.pt-sortable-chosen {
      border-color: rgba(3,255,134,.4);
      box-shadow: 0 12px 32px rgba(0,0,0,.3);
    }

    .kpi-row:hover .kpi-checkbox:not(.is-checked):not(.is-mandatory) { border-color: rgba(255,255,255,.4); }
    .kpi-row.is-mandatory { cursor: not-allowed !important; }
    .kpi-row.is-mandatory:hover { background: transparent; }
    .kpi-checkbox.is-mandatory {
      cursor: not-allowed !important;
      background: rgba(252,211,77,.18);
      border-color: rgba(252,211,77,.45);
    }
    .kpi-checkbox.is-mandatory.is-checked {
      background: #fcd34d;
      border-color: #fcd34d;
    }

    body.kiosk-active .pt-module-drag-handle,
    body.kiosk-active #layout-view-toggle { display: none !important; }
    body.kiosk-active .dashboard-module-header { display: none; }
    body.kiosk-active .dashboard-module {
      border: none;
      background: transparent;
      padding: 0;
    }

    /* Layout view toggle */
    .layout-view-toggle .layout-view-btn {
      background: transparent;
      color: #8ba3b0;
      border: none;
      cursor: pointer;
      font-family: inherit;
    }
    .layout-view-toggle .layout-view-btn.is-active {
      background: rgba(3,255,134,.12);
      color: #03FF86;
    }
    .layout-view-toggle .layout-view-btn:not(.is-active):hover {
      background: rgba(255,255,255,.06);
      color: #e2edf3;
    }

    #sub-dashboard-modal {
      position: fixed !important;
      inset: 0 !important;
      background: rgba(15,23,42,0.98);
      z-index: 99999 !important;
      display: none;            /* JS sets style.display='flex' before adding sdash-active */
      flex-direction: column;
      padding: 0;
      color: #fff;
      overflow-y: auto;
      isolation: isolate;
      opacity: 0;
      transform: scale(0.96);
      transition: opacity .28s cubic-bezier(.4,0,.2,1), transform .28s cubic-bezier(.4,0,.2,1);
    }
    #sub-dashboard-modal.sdash-active {
      opacity: 1;
      transform: scale(1);
    }
    #sub-dashboard-modal.sdash-hidden {
      display: none !important;
      pointer-events: none !important;
    }
    .sdash-topbar {
      display: flex; align-items: center; justify-content: space-between; gap: 16px;
      padding: 14px 24px; flex-shrink: 0;
      background: rgba(10,18,28,.92);
      border-bottom: 1px solid rgba(255,255,255,.08);
      position: sticky; top: 0; z-index: 10;
      backdrop-filter: blur(14px);
    }
    .file-report-btn {
      display: inline-flex; align-items: center; gap: 4px;
      padding: 3px 8px; border-radius: 6px;
      background: transparent;
      border: 1px solid rgba(96,165,250,.30);
      color: rgba(148,185,255,.70); font-size: 10px; font-weight: 600;
      cursor: pointer; white-space: nowrap; flex-shrink: 0;
      transition: background .15s, border-color .15s, color .15s;
      letter-spacing: .03em;
    }
    .file-report-btn:hover {
      background: rgba(96,165,250,.14);
      border-color: rgba(96,165,250,.65);
      color: #93c5fd;
    }
    .sdash-close-btn {
      display: flex; align-items: center; gap: 6px;
      padding: 7px 16px; border-radius: 9px;
      background: rgba(255,255,255,.07);
      border: 1px solid rgba(255,255,255,.15);
      color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
      transition: background .18s, border-color .18s, color .18s;
      white-space: nowrap;
    }
    .sdash-close-btn:hover {
      background: rgba(248,113,113,.18); border-color: rgba(248,113,113,.4); color: #fca5a5;
    }
    .sdash-body {
      display: flex; gap: 36px; padding: 36px;
      align-items: flex-start; justify-content: center;
      flex: 1; flex-wrap: wrap;
    }
    .sdash-body.mode-a { justify-content: center; align-items: center; min-height: 70vh; }
    #sdash-loading {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      flex: 1; gap: 14px; color: #8ba3b0; font-size: 13px;
    }
    .sdash-spinner {
      width: 36px; height: 36px; border-radius: 50%;
      border: 3px solid rgba(3,255,134,.15);
      border-top-color: #03FF86;
      animation: spin .8s linear infinite;
    }
    .sdash-section-title {
      font-size: 11px; font-weight: 700; text-transform: uppercase;
      letter-spacing: .07em; color: #60a5fa; margin-bottom: 14px;
    }
    .sdash-impact-total {
      font-size: 13px; font-weight: 600; color: #03FF86;
      background: rgba(3,255,134,.08); border: 1px solid rgba(3,255,134,.2);
      border-radius: 8px; padding: 8px 12px; margin-bottom: 14px;
    }

    /* ── Sub-dashboard dynamic layout ─────────────────────────────── */
    .sdash-inner {
      display: flex; flex-direction: column; gap: 22px;
      padding: 28px; overflow-y: auto; flex: 1;
    }
    /* AI insight row */
    .sdash-ai-row {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 12px;
    }
    @media (max-width: 900px) { .sdash-ai-row { grid-template-columns: 1fr; } }
    .sdash-ai-card {
      padding: 14px 16px; border-radius: 14px;
      display: flex; flex-direction: column; gap: 8px;
    }
    .sdash-ai-label {
      font-size: 9px; font-weight: 800; text-transform: uppercase;
      letter-spacing: .09em; display: flex; align-items: center; gap: 7px;
    }
    .sdash-ai-text { font-size: 11.5px; line-height: 1.55; color: #cbd5e1; }
    /* Section header */
    .sdash-sec-title {
      font-size: 10px; font-weight: 700; text-transform: uppercase;
      letter-spacing: .08em; color: #60a5fa; margin-bottom: 12px;
    }
    /* Photo grid — Case A (large 5-col) */
    .sdash-grid-lg {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 10px;
    }
    @media (max-width: 1100px) { .sdash-grid-lg { grid-template-columns: repeat(4, 1fr); } }
    @media (max-width: 800px)  { .sdash-grid-lg { grid-template-columns: repeat(3, 1fr); } }
    /* Photo grid — Case C (compact 3-col) */
    .sdash-grid-sm {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }
    .sdash-thumb {
      width: 100%; aspect-ratio: 3/4; object-fit: cover;
      border-radius: 10px; cursor: zoom-in; display: block;
      background: #0a1520;
      transition: transform .2s, filter .2s;
    }
    .sdash-thumb:hover { transform: scale(1.04); filter: brightness(1.1); }
    .sdash-thumb-wrap { position: relative; overflow: hidden; border-radius: 10px; }
    .sdash-thumb-label {
      position: absolute; bottom: 0; left: 0; right: 0;
      background: linear-gradient(to top, rgba(0,0,0,.82) 0%, transparent 100%);
      padding: 18px 7px 6px; pointer-events: none;
    }
    /* Mixed 2-column layout — Case C */
    .sdash-mixed {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 24px; align-items: start;
    }
    @media (max-width: 860px) { .sdash-mixed { grid-template-columns: 1fr; } }
    /* Impact micro-cards — Case B & C */
    .sdash-impact-card {
      background: rgba(255,255,255,.04);
      border: 1px solid rgba(255,255,255,.08);
      border-radius: 12px; padding: 14px 16px;
      display: flex; flex-direction: column; gap: 7px;
    }
    .sdash-kpi-num {
      font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1;
    }
    .sdash-bar-track {
      height: 4px; background: rgba(255,255,255,.09);
      border-radius: 2px; overflow: hidden; margin-top: 2px;
    }
    .sdash-bar-fill {
      height: 100%; border-radius: 2px;
      background: linear-gradient(90deg, #03FF86, #38bdf8);
    }
    /* Dark-mode scrollbars for sdash panels */
    .sdash-scrollable { scrollbar-width: thin; scrollbar-color: rgba(156,163,175,.25) rgba(255,255,255,.02); }
    .sdash-scrollable::-webkit-scrollbar { width: 6px; }
    .sdash-scrollable::-webkit-scrollbar-track { background: rgba(255,255,255,.02); border-radius: 4px; }
    .sdash-scrollable::-webkit-scrollbar-thumb { background: rgba(156,163,175,.25); border-radius: 4px; transition: background .2s; }
    .sdash-scrollable::-webkit-scrollbar-thumb:hover { background: rgba(156,163,175,.45); }
    /* Case C: cycling presentation columns */
    .sdash-cycle-frame {
      position: relative; border-radius: 16px; overflow: hidden;
      background: #000; aspect-ratio: 3/4; width: 100%; max-height: 420px;
    }
    .sdash-cycle-frame img {
      width: 100%; height: 100%; object-fit: cover; display: block;
      transition: opacity .3s ease;
    }
    .sdash-cycle-meta {
      position: absolute; bottom: 0; left: 0; right: 0;
      padding: 28px 12px 10px;
      background: linear-gradient(to top, rgba(0,0,0,.85) 0%, transparent 100%);
      pointer-events: none;
    }
    .sdash-cycle-nav {
      display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 6px;
    }
    .sdash-cycle-arrow {
      width: 34px; height: 34px; border-radius: 50%;
      background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
      color: #fff; font-size: 22px; cursor: pointer; line-height: 1;
      display: flex; align-items: center; justify-content: center;
      transition: background .15s, border-color .15s;
    }
    .sdash-cycle-arrow:hover { background: rgba(3,255,134,.22); border-color: rgba(3,255,134,.45); }
    .sdash-cycle-insight-box {
      background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
      border-radius: 14px; padding: 18px 16px;
      display: flex; flex-direction: column; gap: 10px;
      min-height: 200px; transition: opacity .25s ease;
    }
    /* Total-impact hero badge */
    .sdash-total-hero {
      display: flex; align-items: center; gap: 14px;
      background: rgba(3,255,134,.07);
      border: 1px solid rgba(3,255,134,.2);
      border-radius: 14px; padding: 14px 18px; margin-bottom: 6px;
    }
    /* chips para feed de impactos */
    .gm-row { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
    .gm-chip {
      font-size: 10px; color: #e2e8f0;
      background: rgba(255,255,255,.12); border-radius: 4px;
      padding: 2px 6px; white-space: nowrap;
    }
    .gm-tipo { font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
    .tipo-ingreso { background: rgba(59,130,246,.28) !important; color: #93c5fd !important; }
    .tipo-salida  { background: rgba(239,68,68,.22)  !important; color: #fca5a5 !important; }
    .tipo-default { background: rgba(3,255,134,.14)  !important; color: #03FF86  !important; }
    .tl-active-insight { outline: 1px solid rgba(3,255,134,.45); background: rgba(3,255,134,.05) !important; transition: outline .2s, background .2s; }

    /* KPI card handle — top-right corner offset for compact cards */
    .kpi-ring { position: relative; }
    .kpi-ring .pt-drag-handle { top: 6px; right: 8px; }

    /* ── Ranking overlay (canvas stays visible, message layered on top) ── */
    .ranking-overlay-msg {
      position: absolute; inset: 0; display: flex;
      align-items: center; justify-content: center;
      pointer-events: none;
      background: rgba(17,37,48,.82);
      border-radius: 8px;
      padding: 12px;
    }
    .ranking-overlay-msg span {
      font-size: 11px; color: #8ba3b0; font-style: italic;
      text-align: center; line-height: 1.6;
    }

    /* Placeholder de gráfico sin datos (CHART_REGISTRY) */
    .chart-placeholder-box {
      position: absolute;
      inset: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 10px;
      pointer-events: none;
      background: rgba(22, 47, 61, 0.92);
      border: 1px dashed rgba(3, 255, 134, 0.22);
      border-radius: 10px;
      padding: 20px 16px;
      text-align: center;
    }
    .chart-placeholder-title {
      display: block;
      font-size: 13px;
      font-weight: 600;
      color: #e2edf3;
      font-style: normal;
      line-height: 1.4;
    }
    .chart-placeholder-text {
      display: block;
      font-size: 11px;
      color: #8ba3b0;
      font-style: italic;
      line-height: 1.5;
      max-width: 240px;
    }

    /* Sortable ghost (placeholder while dragging) */
    .pt-sortable-ghost {
      opacity: .25 !important;
      background: rgba(3,255,134,.05) !important;
      border: 1px dashed rgba(3,255,134,.35) !important;
      transform: none !important;
    }
    /* Element being dragged */
    .pt-sortable-chosen {
      box-shadow: 0 16px 48px rgba(0,0,0,.55) !important;
      transform: scale(1.015) !important;
      border-color: rgba(3,255,134,.45) !important;
      z-index: 1000;
    }
    /* Drag animation for siblings */
    #charts-grid-dynamic > *, #charts-grid-static > *, #kpi-grid > * {
      transition: transform .18s ease;
    }
    .charts-section-label {
      display: flex; align-items: center; gap: 10px;
      font-size: 9.5px; font-weight: 700; letter-spacing: .1em;
      text-transform: uppercase; color: #4a6475; margin: 0 0 8px;
    }
    .charts-section-label span { flex-shrink: 0; }
    .charts-section-label::before, .charts-section-label::after {
      content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.05);
    }

    /* ── Plan de Acción: pestañas + feed compacto de alertas ── */
    .action-tab-btn {
      color: #8ba3b0; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
    }
    .action-tab-btn.is-active {
      color: #03FF86; background: rgba(3,255,134,.1); border-color: rgba(3,255,134,.3);
    }
    .feed-item:hover { background: rgba(255,255,255,.025); }

    /* ── Smooth transitions ── */
    .fade-in { animation: fadeIn .35s ease; }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

    /* ── Tooltip custom ── */
    .tag-pill {
      display: inline-flex; align-items: center; gap: 6px;
      background: rgba(3,255,134,.12); border: 1px solid rgba(3,255,134,.3);
      color: #03FF86; border-radius: 99px; padding: 2px 10px; font-size: 12px;
    }

    /* ── Campaign history dropdown ── */
    #campaign-dropdown {
      max-height: 300px;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: #1e3d50 transparent;
    }
    .camp-item { display:flex; align-items:center; justify-content:space-between;
                 padding:9px 12px; border-radius:10px; cursor:pointer; gap:8px;
                 transition:background .15s; }
    .camp-item:hover { background:rgba(3,255,134,.08); }
    .camp-item-name { font-size:13px; font-weight:600; color:#e2edf3; min-width:0; flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .camp-item-meta { font-size:11px; color:#8ba3b0; white-space:nowrap; }
    .camp-item-load { font-size:11px; font-weight:600; color:#03FF86; background:rgba(3,255,134,.1);
                      border:1px solid rgba(3,255,134,.25); border-radius:6px; padding:2px 8px;
                      cursor:pointer; white-space:nowrap; flex-shrink:0; }
    .camp-item-load:hover { background:rgba(3,255,134,.2); }

    /* ── Auth: Login screen ── */
    #screen-login input:focus {
      outline: none;
      box-shadow: 0 0 0 2px rgba(3,255,134,.35);
    }

    /* ── Auth: Welcome toast ── */
    #auth-toast {
      position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-80px);
      z-index: 9999; transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s;
      opacity: 0; pointer-events: none;
    }
    #auth-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

    /* ── Admin panel: dark navy ── */
    #screen-admin {
      background: #070f16;
      min-height: 100vh;
    }
    #screen-admin .admin-card {
      background: #0c1a24;
      border: 1px solid rgba(56,189,248,.15);
    }
    #screen-admin input, #screen-admin select {
      background: #101f2b;
      border: 1px solid rgba(56,189,248,.2);
      color: #e2edf3;
      border-radius: 10px;
      padding: 10px 14px;
      font-size: 13px;
      width: 100%;
    }
    #screen-admin input:focus, #screen-admin select:focus {
      outline: none;
      box-shadow: 0 0 0 2px rgba(56,189,248,.3);
    }
    #screen-admin label { font-size: 12px; color: #8ba3b0; font-weight: 500; display: block; margin-bottom: 4px; }
    .admin-user-row:hover { background: rgba(56,189,248,.04); }

    /* ── Profile modal ── */
    /* Default: hidden. NEVER put display:flex here — ID specificity (0-1-0)
       beats Tailwind's .hidden class (0-0-1) and would override it silently. */
    #modal-profile {
      display: none;
      position: fixed; inset: 0; z-index: 999;
      align-items: center; justify-content: center;
      background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
    }
    /* Shown only when .pt-open is added by JS */
    #modal-profile.pt-open { display: flex !important; }
    #modal-profile .modal-box {
      background: #162f3d; border: 1px solid rgba(3,255,134,.15);
      border-radius: 20px; padding: 28px; width: 100%; max-width: 500px;
      box-shadow: 0 20px 60px rgba(0,0,0,.5);
      max-height: 90vh; overflow-y: auto;
    }
    #profile-history-list { scrollbar-width: thin; scrollbar-color: #1e3d50 transparent; }
    .hist-row { display:flex; align-items:center; justify-content:space-between; gap:8px;
                padding:8px 10px; border-radius:10px; transition:background .15s; cursor:default; }
    .hist-row:hover { background:rgba(255,255,255,.04); }
    .hist-row-name { font-size:12px; font-weight:600; color:#e2edf3; min-width:0; flex:1;
                     white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .hist-row-meta { font-size:11px; color:#8ba3b0; white-space:nowrap; }
    .hist-row-btn { font-size:11px; font-weight:600; color:#38bdf8;
                    background:rgba(56,189,248,.1); border:1px solid rgba(56,189,248,.25);
                    border-radius:6px; padding:2px 8px; cursor:pointer; white-space:nowrap;
                    flex-shrink:0; transition:background .15s; }
    .hist-row-btn:hover { background:rgba(56,189,248,.2); }
    .hist-group-header { font-size:10px; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
                         color:#4a6475; padding:8px 10px 4px; margin-top:4px; }
    .hist-group-header:first-child { margin-top:0; }
    #hist-search { background:#0f2535; border:1px solid rgba(255,255,255,.08); color:#e2edf3;
                   border-radius:8px; padding:6px 10px; font-size:12px; width:100%;
                   outline:none; transition:border .15s; }
    #hist-search:focus { border-color:rgba(3,255,134,.35); }
    #hist-search::placeholder { color:#4a6475; }
    /* ── Campana combobox ───────────────────────────────────────────────── */
    #campana-combobox-wrap {
      position: relative;
      overflow: visible;
    }
    #campana-combobox-list {
      position:absolute; top:calc(100% + 4px); left:0; right:0; z-index:200;
      background:#162f3d; border:1px solid rgba(3,255,134,.22); border-radius:12px;
      max-height:250px; overflow-x:hidden; overflow-y:auto;
      box-shadow:0 16px 40px rgba(0,0,0,.55);
      scrollbar-width:thin; scrollbar-color:#1e3d50 transparent;
    }
    .campana-option {
      display:flex; flex-direction:column; gap:2px;
      padding:10px 14px; cursor:pointer; transition:background .12s;
      border-bottom:1px solid rgba(255,255,255,.04);
    }
    .campana-option:last-child { border-bottom:none; }
    .campana-option:hover { background:rgba(3,255,134,.07); }
    .campana-option-label {
      font-size:11px; font-weight:700; color:#03FF86; letter-spacing:.04em;
      text-transform:uppercase;
    }
    .campana-option-name { font-size:13px; font-weight:600; color:#e2edf3; }
    .campana-option-meta { font-size:11px; color:#8ba3b0; }
    .campana-option-create { border-top:1px solid rgba(3,255,134,.15); }
    .campana-option-create:hover { background:rgba(3,255,134,.1); }
    /* ── Ver Dashboard button ───────────────────────────────────────────── */
    #btn-ver-dashboard-wrap { display:none; flex-direction:column; gap:6px; margin-bottom:1.25rem; }
    #btn-ver-dashboard {
      width:100%; padding:14px; border-radius:14px; border:none; cursor:pointer;
      font-size:14px; font-weight:700; letter-spacing:.02em;
      background:linear-gradient(135deg,rgba(3,255,134,.18),rgba(3,255,134,.08));
      border:1px solid rgba(3,255,134,.35); color:#03FF86;
      transition:all .2s;
    }
    #btn-ver-dashboard:hover { background:rgba(3,255,134,.25); box-shadow:0 0 20px rgba(3,255,134,.2); }
    #btn-ver-dashboard-hint { font-size:11px; color:#4a6475; text-align:center; }
    #btn-ver-dashboard-hint button {
      background:none; border:none; color:#38bdf8; cursor:pointer; font-size:11px;
      text-decoration:underline; padding:0;
    }
    #btn-ver-dashboard-hint button:hover { color:#7dd3fc; }
    /* ── Existing-campaign update flow ─────────────────────────────────── */
    #drop-zone-existing-hint {
      display:none; background:rgba(3,255,134,.06); border:1px solid rgba(3,255,134,.15);
      border-radius:10px; padding:10px 14px; font-size:12px; color:#8ba3b0;
      margin-bottom:12px; text-align:center; line-height:1.6;
    }
    #btn-update-campaign {
      display:none; width:100%; padding:14px; border-radius:14px;
      border:1px solid rgba(251,191,36,.35); cursor:pointer;
      font-size:14px; font-weight:700; letter-spacing:.02em;
      background:linear-gradient(135deg,rgba(251,191,36,.18),rgba(245,158,11,.06));
      color:#fbbf24; transition:all .2s; margin-bottom:8px;
    }
    #btn-update-campaign:hover { background:rgba(251,191,36,.25); box-shadow:0 0 20px rgba(251,191,36,.2); }
    #modal-profile input {
      background: #1e3d50; border: 1px solid rgba(255,255,255,.1); color: #e2edf3;
      border-radius: 10px; padding: 10px 14px; font-size: 13px; width: 100%;
    }
    #modal-profile input:focus { outline: none; box-shadow: 0 0 0 2px rgba(3,255,134,.3); }

    /* ── Share modal ── */
    #modal-share {
      display: none; position: fixed; inset: 0; z-index: 1000;
      align-items: center; justify-content: center;
      background: rgba(0,0,0,.65); backdrop-filter: blur(8px);
    }
    #modal-share.pt-open { display: flex !important; }
    #modal-share .share-box {
      background: #162f3d; border: 1px solid rgba(3,255,134,.2);
      border-radius: 22px; padding: 30px; width: 100%; max-width: 460px;
      box-shadow: 0 24px 64px rgba(0,0,0,.55);
      animation: fadeIn .25s ease;
    }
    #share-link-input {
      background: #0f2230; border: 1px solid rgba(255,255,255,.1); color: #e2edf3;
      border-radius: 10px; padding: 10px 14px; font-size: 12px; width: 100%;
      font-family: ui-monospace, Menlo, Consolas, monospace;
    }
    #share-link-input:focus { outline: none; }
    #share-copy-btn {
      transition: all .15s;
    }
    #share-copy-btn.copied {
      background: rgba(3,255,134,.22) !important;
      border-color: rgba(3,255,134,.5) !important;
    }
    /* ── Share modal — email section ── */
    #share-email-divider { border:none; border-top:1px solid rgba(255,255,255,.08); margin:18px 0; }
    #share-email-input {
      flex:1; background:#0f2230; border:1px solid rgba(255,255,255,.1); color:#e2edf3;
      border-radius:10px; padding:10px 14px; font-size:13px; font-family:inherit; outline:none;
      transition:border-color .15s;
    }
    #share-email-input:focus { border-color:rgba(56,189,248,.4); }
    #share-email-input::placeholder { color:#4a6475; }
    #share-email-btn {
      flex-shrink:0; padding:10px 16px; border-radius:10px; cursor:pointer;
      font-size:12px; font-weight:700; transition:all .15s;
      background:rgba(56,189,248,.12); color:#38bdf8; border:1px solid rgba(56,189,248,.3);
    }
    #share-email-btn:hover:not(:disabled) { background:rgba(56,189,248,.22); }
    #share-email-btn:disabled { opacity:.5; cursor:not-allowed; }

    /* ── Welcome popup (public view) ── */
    #modal-welcome-public {
      display: none; position: fixed; inset: 0; z-index: 2000;
      align-items: center; justify-content: center;
      background: rgba(4,11,18,.82); backdrop-filter: blur(14px) saturate(1.4);
    }
    #modal-welcome-public.pt-open { display: flex !important; }
    #modal-welcome-public .welcome-box {
      background: linear-gradient(145deg, #0e2030 0%, #112a3c 60%, #0a1e2c 100%);
      border: 1px solid rgba(3,255,134,.2);
      border-radius: 26px; padding: 44px 40px 40px;
      width: 100%; max-width: 520px; text-align: center;
      box-shadow: 0 0 0 1px rgba(3,255,134,.06), 0 32px 80px rgba(0,0,0,.7);
      animation: welcomeFadeIn .55s cubic-bezier(.22,1,.36,1) both;
    }
    @keyframes welcomeFadeIn {
      from { opacity: 0; transform: translateY(24px) scale(.97); }
      to   { opacity: 1; transform: none; }
    }
    #modal-welcome-public.pt-closing {
      animation: welcomeFadeOut .35s ease forwards;
    }
    @keyframes welcomeFadeOut {
      to { opacity: 0; transform: scale(.97); }
    }
    #btn-enter-dashboard {
      background: linear-gradient(135deg, #03FF86 0%, #00d46b 100%);
      color: #04100a; font-weight: 800; font-size: 14px; letter-spacing: .01em;
      border: none; border-radius: 14px; padding: 15px 36px;
      cursor: pointer; width: 100%;
      box-shadow: 0 0 28px rgba(3,255,134,.35), 0 4px 16px rgba(0,0,0,.3);
      transition: transform .15s, box-shadow .15s;
    }
    #btn-enter-dashboard:hover {
      transform: translateY(-1px);
      box-shadow: 0 0 38px rgba(3,255,134,.5), 0 6px 20px rgba(0,0,0,.4);
    }
    #btn-enter-dashboard:active { transform: scale(.98); }

    /* ── NDA / Confidencialidad (todos los roles) ── */
    #nda-modal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 25000;
      align-items: center;
      justify-content: center;
      padding: 20px 16px;
      background: rgba(4, 11, 18, .88);
      backdrop-filter: blur(14px) saturate(1.4);
    }
    #nda-modal.pt-open { display: flex !important; }
    #nda-modal.pt-closing { animation: welcomeFadeOut .35s ease forwards; }
    body.nda-modal-open { overflow: hidden; }
    #nda-modal .nda-box {
      background: linear-gradient(145deg, #0e2030 0%, #112a3c 60%, #0a1e2c 100%);
      border: 1px solid rgba(3, 255, 134, .2);
      border-radius: 22px;
      width: 100%;
      max-width: 560px;
      max-height: min(90vh, 720px);
      display: flex;
      flex-direction: column;
      box-shadow: 0 0 0 1px rgba(3, 255, 134, .06), 0 32px 80px rgba(0, 0, 0, .75);
      animation: welcomeFadeIn .45s cubic-bezier(.22, 1, .36, 1) both;
      overflow: hidden;
    }
    #nda-modal .nda-box-header {
      padding: 28px 28px 12px;
      text-align: center;
      flex-shrink: 0;
    }
    .nda-logo-mark {
      width: 52px;
      height: 52px;
      border-radius: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #03FF86, #00b35a);
      box-shadow: 0 0 24px rgba(3, 255, 134, .28);
    }
    .nda-title {
      font-size: 1.15rem;
      font-weight: 800;
      color: #e2edf3;
      line-height: 1.35;
      margin: 0 0 6px;
    }
    .nda-subtitle {
      font-size: 12px;
      color: #7a9eae;
      margin: 0;
    }
    .nda-scroll {
      flex: 1 1 auto;
      overflow-y: auto;
      padding: 8px 28px 16px;
      text-align: left;
      scrollbar-width: thin;
      scrollbar-color: #1e3d50 transparent;
    }
    .nda-section {
      margin-bottom: 16px;
    }
    .nda-section h3 {
      font-size: 12px;
      font-weight: 700;
      color: #03FF86;
      margin: 0 0 6px;
      letter-spacing: .02em;
    }
    .nda-section p,
    .nda-section li {
      font-size: 12px;
      line-height: 1.55;
      color: #8ba3b0;
      margin: 0 0 6px;
    }
    .nda-section ul {
      margin: 0;
      padding-left: 18px;
    }
    .nda-section strong { color: #c4d6e0; font-weight: 600; }
    .nda-body-text {
      font-size: 13px;
      line-height: 1.65;
      color: #8ba3b0;
      margin: 0;
      text-align: center;
    }
    .nda-actions {
      flex-shrink: 0;
      padding: 16px 28px 24px;
      border-top: 1px solid rgba(255, 255, 255, .06);
    }
    .nda-btn-accept {
      width: 100%;
      padding: 14px 20px;
      border: none;
      border-radius: 12px;
      font-size: 14px;
      font-weight: 800;
      cursor: pointer;
      color: #04100a;
      background: linear-gradient(135deg, #03FF86 0%, #00d46b 100%);
      box-shadow: 0 0 24px rgba(3, 255, 134, .3);
      transition: transform .15s, box-shadow .15s;
    }
    .nda-btn-accept:hover {
      transform: translateY(-1px);
      box-shadow: 0 0 32px rgba(3, 255, 134, .45);
    }
    .nda-btn-close {
      width: 100%;
      padding: 12px 20px;
      border-radius: 12px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      color: #c4d6e0;
      background: rgba(255, 255, 255, .06);
      border: 1px solid rgba(255, 255, 255, .12);
      transition: background .15s;
    }
    .nda-btn-close:hover { background: rgba(255, 255, 255, .1); }
    .pt-global-legal-footer {
      text-align: center;
      padding: 14px 16px 18px;
      border-top: 1px solid rgba(255, 255, 255, .04);
      background: var(--pt-bg-base);
      flex-shrink: 0;
    }
    .pt-global-legal-footer__text {
      margin: 0;
      font-size: 11px;
      line-height: 1.5;
      color: #4a6475;
    }
    .pt-global-legal-footer__brand {
      color: #6b8294;
      font-weight: 600;
    }
    body.pt-screen-login .pt-global-legal-footer,
    body.pt-screen-loading .pt-global-legal-footer,
    body.pdf-mode .pt-global-legal-footer {
      display: none !important;
    }
    .nda-footer-link {
      background: none;
      border: none;
      padding: 0;
      font: inherit;
      font-size: inherit;
      color: #38bdf8;
      cursor: pointer;
      text-decoration: underline;
      text-underline-offset: 2px;
    }
    .nda-footer-link:hover { color: #7dd3fc; }

    /* ── 3-Layer navigation ── */
    #sub-dashboard-view, #database-view {
      padding: 0 0 40px 0;
      animation: layerSlideIn .22s cubic-bezier(.22,1,.36,1) both;
    }
    @keyframes layerSlideIn {
      from { opacity: 0; transform: translateX(24px); }
      to   { opacity: 1; transform: none; }
    }
    .layer-back-btn {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
      cursor: pointer; transition: background .15s;
      background: rgba(255,255,255,.05); color: #cbd9e0;
      border: 1px solid rgba(255,255,255,.1); font-family: inherit;
    }
    .layer-back-btn:hover { background: rgba(255,255,255,.09); }
    .layer-db-btn {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
      cursor: pointer; transition: background .15s;
      background: rgba(168,85,247,.12); color: #c084fc;
      border: 1px solid rgba(168,85,247,.3); font-family: inherit;
    }
    .layer-db-btn:hover { background: rgba(168,85,247,.2); }
    .sub-stat-card {
      background: #162f3d; border: 1px solid rgba(255,255,255,.07);
      border-radius: 14px; padding: 14px 18px; text-align: center;
    }
    .sub-stat-card .sv { font-size: 20px; font-weight: 800; color: #03FF86; }
    .sub-stat-card .sl { font-size: 10px; color: #8ba3b0; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

    /* Database table */
    #db-table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid rgba(255,255,255,.07); }
    #db-table { width: 100%; border-collapse: collapse; font-size: 12px; }
    #db-table thead tr { background: #0f2230; }
    #db-table thead th { padding: 10px 14px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #8ba3b0; border-bottom: 1px solid rgba(255,255,255,.07); white-space: nowrap; }
    #db-table tbody tr { border-bottom: 1px solid rgba(255,255,255,.04); transition: background .1s; }
    #db-table tbody tr:hover { background: rgba(255,255,255,.03); }
    #db-table tbody td { padding: 9px 14px; color: #e2edf3; white-space: nowrap; }
    #db-table tbody td.td-val { color: #03FF86; font-weight: 700; font-variant-numeric: tabular-nums; }
    #db-table tbody td.td-pct { color: #FFDE0A; font-weight: 600; }
    #db-search { background: #0f2230; border: 1px solid rgba(255,255,255,.1); color: #e2edf3; border-radius: 8px; padding: 8px 14px; font-size: 12px; outline: none; width: 100%; max-width: 340px; }
    #db-search:focus { border-color: rgba(3,255,134,.4); }
    .db-page-btn { padding: 5px 12px; border-radius: 7px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04); color: #e2edf3; font-family: inherit; transition: background .12s; }
    .db-page-btn:hover { background: rgba(255,255,255,.09); }
    .db-page-btn.active { background: rgba(3,255,134,.15); color: #03FF86; border-color: rgba(3,255,134,.35); }

    /* AI Insight Modal */
    #modal-ia-insight { display:none; position:fixed; inset:0; z-index:1500; align-items:center; justify-content:center; background:rgba(4,11,18,.75); backdrop-filter:blur(8px); }
    #modal-ia-insight.pt-open { display:flex !important; }
    #modal-ia-insight .ia-box { background:linear-gradient(145deg,#0e2030,#112a3c); border:1px solid rgba(168,85,247,.25); border-radius:22px; padding:32px 36px; max-width:560px; width:90%; animation:layerSlideIn .3s both; }
    #ia-insight-text { font-size:13px; line-height:1.75; color:#cbd9e0; }
    #ia-insight-text strong { color:#03FF86; }
    #ia-insight-text em { color:#8ba3b0; font-style:italic; font-size:11px; }

    /* Chart cards dblclick hint */
    .chart-card-unified { cursor: default; }
    .chart-card-unified:hover { cursor: zoom-in; }
    #charts-grid-dynamic .chart-card-unified::after,
    #charts-grid-static .chart-card-unified::after {
      content: '⤢ doble clic para explorar';
      position: absolute; bottom: 8px; right: 12px;
      font-size: 9px; font-weight: 600; color: rgba(3,255,134,.0);
      text-transform: uppercase; letter-spacing: .05em;
      transition: color .2s; pointer-events: none;
    }
    #charts-grid-dynamic .chart-card-unified:hover::after,
    #charts-grid-static .chart-card-unified:hover::after { color: var(--pt-accent-muted); }

    /* ── Share button hover ── */
    #share-view-btn:hover { background:#264d62 !important; border-color:#3a6a82 !important; }

    /* ── Public view: ocultar solo controles de modificación de campaña / sesión analista ── */
    body.public-view .nav-group--campaign,
    body.public-view .nav-group--user,
    body.public-view #nav-user-dropdown,
    body.public-view .reset-campaign-btn,
    body.public-view #btn-admin-panel,
    body.public-view .dash-profile-btn,
    body.public-view .dash-logout-btn,
    body.public-view #dash-session-label,
    body.public-view #nav-user-btn,
    body.public-view #session-strip,
    body.public-view #share-view-btn,
    body.public-view #btn-kpi-back { display: none !important; }
    body.public-view #btn-kpi-back-dashboard { display: inline-flex !important; }
    body:not(.public-view) #btn-kpi-back-dashboard { display: none !important; }
    /* #btnTimeLapse intentionally NOT hidden in public view — clients can use Time Lapse */
    /* #kiosk-mode-btn intentionally NOT listed here — visible in public view too */

    /* ── Kiosk / Presentation Mode ─────────────────────────────────────────── */
    body.kiosk-active #screen-dashboard > nav,
    body.kiosk-active #dash-navbar,
    body.kiosk-active #session-strip,
    body.kiosk-active .nav-group--tools,
    body.kiosk-active .nav-group--actions,
    body.kiosk-active .nav-group--campaign,
    body.kiosk-active .nav-group--user,

    body.kiosk-active #configure-kpis-btn,
    body.kiosk-active #btn-admin-panel,
    body.kiosk-active .dash-profile-btn,
    body.kiosk-active .dash-logout-btn,
    body.kiosk-active .reset-campaign-btn,
    body.kiosk-active #nav-actions-dropdown,
    body.kiosk-active #nav-user-dropdown,
    body.kiosk-active #meta-banners,
    body.kiosk-active #meta-banners-wrap { display: none !important; }

    /* ── Upload Mode Modals ────────────────────────────────────────────────── */
    .umode-overlay {
      display:none; position:fixed; inset:0; z-index:12000;
      background:rgba(0,0,0,.65); backdrop-filter:blur(4px);
      align-items:center; justify-content:center;
    }
    .umode-overlay.open { display:flex; }
    .umode-box {
      background:#0d1b26; border:1px solid rgba(255,255,255,.12);
      border-radius:16px; padding:28px 32px; max-width:480px; width:92vw;
      box-shadow:0 24px 60px rgba(0,0,0,.6);
    }
    .umode-box h3 { color:#e2edf3; font-size:1rem; font-weight:700; margin-bottom:8px; }
    .umode-box p  { color:#8ba3b0; font-size:.85rem; line-height:1.5; margin-bottom:20px; }
    .umode-actions { display:flex; gap:10px; flex-wrap:wrap; }
    .umode-btn {
      flex:1; min-width:140px; padding:12px 16px; border-radius:10px;
      border:none; cursor:pointer; text-align:left; transition:opacity .15s;
    }
    .umode-btn:hover { opacity:.85; }
    .umode-btn strong { display:block; font-size:.85rem; color:#e2edf3; }
    .umode-btn small  { font-size:.75rem; opacity:.65; color:#e2edf3; }
    .umode-btn.append  { background:rgba(3,255,134,.12); border:1px solid rgba(3,255,134,.3); }
    .umode-btn.replace { background:rgba(248,113,113,.12); border:1px solid rgba(248,113,113,.3); }
    .umode-btn.confirm { background:rgba(248,113,113,.18); border:1px solid rgba(248,113,113,.5); flex:0 0 auto; }
    .umode-cancel { margin-top:12px; background:none; border:none; color:#4a6475; font-size:.8rem; cursor:pointer; }
    .umode-warn-icon { font-size:2rem; margin-bottom:12px; }
    /* File Details Widget */
    #file-details-widget {
      display:none; align-items:center; gap:8px; padding:6px 14px;
      background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08);
      border-radius:8px; cursor:pointer; transition:background .15s;
      font-size:.78rem; color:#8ba3b0; user-select:none;
    }
    #file-details-widget:hover { background:rgba(255,255,255,.07); }
    #file-details-widget .fd-icon { font-size:.9rem; }
    #file-details-widget .fd-count { color:#e2edf3; font-weight:600; }
    #file-details-widget .fd-hint  { font-size:.7rem; opacity:.5; }
    body.public-view #file-details-widget,
    body.kiosk-active #file-details-widget { display:none !important; }
    /* File Details Modal */
    .fd-modal-table { width:100%; border-collapse:collapse; font-size:.78rem; margin-top:12px; }
    .fd-modal-table th { color:#4a6475; font-weight:600; text-align:left; padding:6px 8px; border-bottom:1px solid rgba(255,255,255,.08); }
    .fd-modal-table td { color:#8ba3b0; padding:6px 8px; border-bottom:1px solid rgba(255,255,255,.04); }
    .fd-modal-table td:first-child { color:#e2edf3; max-width:160px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

    /* ── Time Lapse Controller ─────────────────────────────────────────────── */
    /* Time Lapse button — always visible; disabled state signals "no temporal data" */
    #btnTimeLapse { display: flex !important; }
    #btnTimeLapse:disabled,
    #btnTimeLapse.tl-unavailable {
      opacity: 0.42;
      cursor: not-allowed !important;
      pointer-events: none;
      filter: grayscale(0.6);
    }

    .tl-panel {
      display: none;
      position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
      z-index: 9999;
      background: rgba(30,41,59,.95); backdrop-filter: blur(8px);
      border: 1px solid var(--pt-tl-panel-border); border-radius: 30px;
      padding: 10px 24px; gap: 15px; align-items: center;
      box-shadow: var(--pt-tl-panel-shadow);
      min-width: 520px; max-width: 92vw;
    }
    .tl-panel.tl-open { display: flex !important; }
    .capa-2-activa #timeLapsePanel,
    .capa-2-activa .tl-panel { display: none !important; }
    /* Public view: TL panel fully visible */
    body.public-view .tl-panel.tl-open { display: flex !important; }
    /* Kiosk mode: force panel on top with slate theme */
    body.kiosk-active .tl-panel.tl-open {
      display: flex !important;
      position: fixed !important; bottom: 25px !important;
      left: 50% !important; transform: translateX(-50%) !important;
      z-index: 10000 !important;
      background: rgba(15,23,42,.9) !important;
      backdrop-filter: blur(8px) !important;
      border: 1px solid rgba(255,255,255,.1) !important;
      padding: 8px 20px !important; border-radius: 30px !important;
      box-shadow: 0 10px 30px rgba(0,0,0,.5) !important;
    }

    #tlPlayBtn {
      width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
      background: var(--pt-tl-play-bg); color: var(--pt-accent-soft); font-size: 13px;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; transition: background .15s; font-family: inherit;
    }
    #tlPlayBtn:hover { background: var(--pt-tl-play-bg-hover); }

    #tl-unit-badge {
      font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
      color: var(--pt-accent-soft); background: var(--pt-tl-badge-bg);
      border: 1px solid var(--pt-tl-badge-border); border-radius: 999px;
      padding: 2px 9px; white-space: nowrap; flex-shrink: 0;
    }

    #tlLabel {
      font-size: 11px; font-weight: 700; color: #e2edf3;
      white-space: nowrap; min-width: 80px; text-align: center; flex-shrink: 0;
    }
    .tl-range-edge { font-size: 10px; color: #4a6475; white-space: nowrap; flex-shrink: 0; }

    #timeLapseSlider {
      -webkit-appearance: none; appearance: none;
      flex: 1; height: 4px; border-radius: 2px; outline: none; cursor: pointer;
      background: rgba(255,255,255,.1);
      background-image: linear-gradient(var(--pt-accent-soft), var(--pt-accent-soft));
      background-repeat: no-repeat; background-size: 0% 100%;
      transition: background-size .12s;
    }
    #timeLapseSlider::-webkit-slider-thumb {
      -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
      background: var(--pt-accent-soft); cursor: pointer;
      box-shadow: 0 0 8px var(--pt-tl-thumb-shadow);
    }
    #timeLapseSlider::-moz-range-thumb {
      width: 14px; height: 14px; border-radius: 50%; background: var(--pt-accent-soft); cursor: pointer; border: none;
    }
    #tl-close-btn {
      width: 22px; height: 22px; border-radius: 50%; border: none; cursor: pointer;
      background: rgba(255,255,255,.07); color: #4a6475; font-size: 14px; line-height: 1;
      display: flex; align-items: center; justify-content: center; flex-shrink: 0;
      transition: background .12s, color .12s; font-family: inherit;
    }
    #tl-close-btn:hover { background: rgba(248,113,113,.15); color: #f87171; }

    body.kiosk-active #screen-dashboard {
      padding: 0 !important;
      margin: 0 !important;
    }
    body.kiosk-active #screen-dashboard main {
      max-width: 100vw !important;
      width: 100vw !important;
      padding: 16px !important;
      margin: 0 !important;
      box-sizing: border-box;
    }
    body.kiosk-active #kpi-grid {
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    }
    body.kiosk-active #charts-grid-dynamic,
    body.kiosk-active #charts-grid-static {
      grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Floating kiosk control panel */
    #kiosk-panel {
      position: fixed;
      bottom: 20px; right: 20px;
      background: rgba(9,13,22,.92);
      backdrop-filter: blur(14px);
      border: 1px solid rgba(168,85,247,.35);
      border-radius: 999px;
      padding: 8px 16px;
      display: flex; align-items: center; gap: 10px;
      z-index: 9999;
      box-shadow: 0 8px 32px rgba(0,0,0,.55);
      font-family: Inter, system-ui, sans-serif;
      font-size: 12px;
      color: #e2edf3;
      animation: kioskPanelIn .3s cubic-bezier(.22,1,.36,1) both;
    }
    @keyframes kioskPanelIn {
      from { opacity: 0; transform: translateY(16px) scale(.95); }
      to   { opacity: 1; transform: none; }
    }
    #kiosk-panel .kp-indicator { color: #c084fc; font-weight: 700; letter-spacing: .01em; }
    #kiosk-panel button {
      background: rgba(255,255,255,.07);
      border: 1px solid rgba(255,255,255,.12);
      border-radius: 999px;
      color: #e2edf3;
      font-size: 11px;
      font-weight: 600;
      padding: 4px 10px;
      cursor: pointer;
      transition: background .15s;
      font-family: inherit;
    }
    #kiosk-panel button:hover { background: rgba(255,255,255,.13); }
    #kiosk-panel #kp-scroll-btn.active { color: #03FF86; border-color: rgba(3,255,134,.4); }

/* ── AI Campaign Insights (resumen encapsulado por marca/campaña) ─────────── */
.ai-campaign-insights {
  border: 1px solid rgba(3, 255, 134, 0.18);
  border-radius: 14px;
  background: rgba(3, 255, 134, 0.04);
  padding: 14px 16px;
  margin-bottom: 4px;
}
.ai-campaign-insights__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.ai-campaign-insights__title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  margin: 0;
}
.ai-campaign-insights__period {
  font-size: 10px;
  color: #8ba3b0;
  margin: 4px 0 0;
  letter-spacing: 0.04em;
}
.ai-campaign-insights__badge {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #03FF86;
  background: rgba(3, 255, 134, 0.1);
  border: 1px solid rgba(3, 255, 134, 0.28);
  border-radius: 999px;
  padding: 3px 8px;
}
.ai-campaign-insights__paragraph {
  font-size: 12px;
  line-height: 1.85;
  color: #c4d6e0;
  margin: 0 0 8px;
}
.ai-campaign-insights--dashboard .ai-campaign-insights__paragraph {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.65;
  margin-bottom: 6px;
}
.ai-campaign-insights--dashboard {
  margin-bottom: 8px;
  padding: 10px 12px;
}

/* ── Resumen IA — columnas armonizadas (misma densidad, sin hueco vacío) ── */
#brand-bottom-grid {
  align-items: stretch;
}
#brand-bottom-grid > div > .rounded-2xl {
  display: flex;
  flex-direction: column;
}
#brand-bottom-grid #insights-feed,
#brand-bottom-grid #data-recs-feed {
  display: flex;
  flex-direction: column;
}
.insight-compact-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.insight-compact-panel__body {
  min-width: 0;
}
.insight-compact-panel__footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.ai-campaign-insights__meta {
  font-size: 10px;
  color: #6b8494;
  margin: 0;
}
.ai-campaign-insights__notes {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 10px;
  color: #8ba3b0;
  line-height: 1.5;
}

