/* Xouba Flow · apariencia persistente. Se carga al final para tematizar todos los módulos. */
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

/* Selector disponible dentro de Cuenta y permisos, exista o no una sesión activa. */
#identity-dialog .identity-shell { grid-template-rows: auto auto auto minmax(0,1fr) auto; }
#identity-dialog .identity-appearance {
  min-height: 70px;
  padding: 11px 22px;
  display: grid;
  grid-template-columns: 38px minmax(190px,1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid rgba(166,195,204,.09);
  background: rgba(101,214,170,.025);
}
#identity-dialog .identity-appearance-icon {
  position: relative;
  width: 36px;
  height: 36px;
  display: block;
  border: 1px solid rgba(101,214,170,.2);
  border-radius: 11px;
  background: linear-gradient(145deg,rgba(101,214,170,.16),rgba(69,183,231,.05));
}
#identity-dialog .identity-appearance-icon::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 9px;
  top: 8px;
  border-radius: 50%;
  background: #65d6aa;
  box-shadow: 0 0 15px rgba(101,214,170,.38);
}
#identity-dialog .identity-appearance-icon::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 16px;
  top: 6px;
  border-radius: 50%;
  background: #0b1c25;
}
#identity-dialog .identity-appearance small,
#identity-dialog .identity-appearance strong,
#identity-dialog .identity-appearance p { display: block; }
#identity-dialog .identity-appearance small { color:#65d6aa;font-size:7.5px;font-weight:700;letter-spacing:.8px; }
#identity-dialog .identity-appearance strong { margin-top:3px;color:#c9d8d7;font-size:11px; }
#identity-dialog .identity-appearance p { margin-top:3px;color:#61777e;font-size:8.5px; }
#identity-dialog .identity-theme-options { display:flex;gap:5px;padding:4px;border:1px solid rgba(166,195,204,.1);border-radius:10px;background:#07151d; }
#identity-dialog .identity-theme-options button { min-width:76px;height:34px;padding:0 9px;display:flex;align-items:center;justify-content:center;gap:6px;border:1px solid transparent;border-radius:7px;color:#71878d;background:transparent;font:700 8px Roboto,sans-serif;cursor:pointer; }
#identity-dialog .identity-theme-options button:hover { color:#c7d6d5;background:rgba(255,255,255,.035); }
#identity-dialog .identity-theme-options button.active { border-color:rgba(101,214,170,.28);color:#65d6aa;background:rgba(101,214,170,.1);box-shadow:inset 0 1px rgba(255,255,255,.03); }
#identity-dialog .theme-glyph { position:relative;width:13px;height:13px;display:block;border:1px solid currentColor;border-radius:50%; }
#identity-dialog .theme-glyph.dark::after { content:"";position:absolute;inset:-2px -1px 3px 4px;border-radius:50%;background:#07151d; }
#identity-dialog .theme-glyph.system { border-radius:4px; }
#identity-dialog .theme-glyph.system::after { content:"";position:absolute;left:1px;right:1px;top:5px;border-top:1px solid currentColor; }
#identity-dialog .theme-glyph.light { background:currentColor;box-shadow:0 0 7px rgba(101,214,170,.32); }

/* Paleta clara base. */
html[data-theme="light"] {
  --bg:#edf3f2;
  --panel:#ffffff;
  --panel-2:#f7faf9;
  --panel-3:#eef4f3;
  --stroke:rgba(39,83,76,.14);
  --stroke-strong:rgba(39,83,76,.24);
  --text:#17322d;
  --muted:#607873;
  --muted-2:#79908c;
  --mint:#158b6d;
  --mint-dark:#dcefe9;
  --ops-bg:#edf3f2;
  --ops-panel:#ffffff;
  --ops-panel-2:#f5f9f8;
  --ops-line:rgba(39,83,76,.14);
  --ops-line-2:rgba(39,83,76,.24);
  --ops-text:#17322d;
  --ops-muted:#607873;
  --ops-green:#168c6e;
  --shadow:0 18px 48px rgba(31,66,60,.14);
}

html[data-theme="light"] body,
html[data-theme="light"] body.cam-platform { color:#17322d;background:#edf3f2; }
html[data-theme="light"] body.cam-platform .app-shell,
html[data-theme="light"] body.cam-platform .main-stage,
html[data-theme="light"] body.cam-platform .cam-view,
html[data-theme="light"] body.cam-platform .analysis-view,
html[data-theme="light"] body.cam-platform .analysis-main,
html[data-theme="light"] body.cam-platform .analysis-content,
html[data-theme="light"] body.cam-platform .network-state-workspace { color:#17322d;background:#edf3f2; }

html[data-theme="light"] body.cam-platform .sidebar { border-color:rgba(39,83,76,.14);background:#f6faf9;box-shadow:8px 0 30px rgba(31,66,60,.045); }
html[data-theme="light"] body.cam-platform .topbar { border-color:rgba(39,83,76,.14);background:rgba(250,252,252,.97);box-shadow:0 8px 28px rgba(31,66,60,.06); }
html[data-theme="light"] body.cam-platform .brand,
html[data-theme="light"] body.cam-platform .page-heading h1,
html[data-theme="light"] body.cam-platform .mobile-brand { color:#16332d; }
html[data-theme="light"] body.cam-platform .nav-item { color:#617b76; }
html[data-theme="light"] body.cam-platform .nav-item:hover { color:#17322d;background:rgba(22,140,110,.06); }
html[data-theme="light"] body.cam-platform .nav-item.active { color:#17322d;background:linear-gradient(90deg,rgba(22,140,110,.14),rgba(22,140,110,.035)); }
html[data-theme="light"] body.cam-platform .sidebar-health,
html[data-theme="light"] body.cam-platform .sidebar-settings { color:#4e6964;border-color:rgba(39,83,76,.13);background:#fff; }

html[data-theme="light"] body.cam-platform :is(.top-source,.top-help,.top-user,.analysis-report-button,.shell-menu-toggle,.top-municipality-search,.top-live-kpis) { border-color:rgba(39,83,76,.14);background:#fff;color:#23423c;box-shadow:0 6px 18px rgba(31,66,60,.045); }
html[data-theme="light"] body.cam-platform :is(.top-source,.top-help,.analysis-report-button,.top-municipality-search) small { color:#6a817d; }
html[data-theme="light"] body.cam-platform .top-municipality-search input { color:#17322d; }

html[data-theme="light"] body.cam-platform .analysis-rail { border-color:rgba(39,83,76,.14);background:#f7faf9; }
html[data-theme="light"] body.cam-platform .analysis-rail > header strong,
html[data-theme="light"] body.cam-platform .analysis-tool strong { color:#27453f; }
html[data-theme="light"] body.cam-platform .analysis-tool { color:#65807b; }
html[data-theme="light"] body.cam-platform .analysis-tool:hover { background:rgba(22,140,110,.055); }
html[data-theme="light"] body.cam-platform .analysis-tool.active { color:#137d63;background:rgba(22,140,110,.11); }
html[data-theme="light"] body.cam-platform :is(.tool-search,.analysis-rail-collapse,.analysis-rail-handle) { color:#58736e;border-color:rgba(39,83,76,.14);background:#fff; }
html[data-theme="light"] body.cam-platform .tool-search input { color:#17322d; }

html[data-theme="light"] body.cam-platform #view-analysis :is(.contract-matrix-workspace,.contract-case-workspace,.corridor-monitor-workspace,.congestion-workspace,.forecast-workspace,.scenario-workspace,.day-type-workspace,.bottleneck-workspace,.works-workspace,.corridor-speed-workspace,.performance-workspace,.event-profile-workspace,.speed-alert-workspace,.itinerary-workspace,.od-workspace,.count-workspace,.network-state-workspace) { color:#17322d;background:#edf3f2!important; }
html[data-theme="light"] body.cam-platform #view-analysis :is(.contract-matrix-workspace,.contract-case-workspace,.corridor-monitor-workspace,.congestion-workspace,.forecast-workspace,.scenario-workspace,.day-type-workspace,.bottleneck-workspace,.works-workspace,.corridor-speed-workspace,.performance-workspace,.event-profile-workspace,.speed-alert-workspace,.itinerary-workspace,.od-workspace,.count-workspace,.network-state-workspace) > header { background:transparent; }
html[data-theme="light"] body.cam-platform #view-analysis :is(.contract-matrix-workspace,.contract-case-workspace,.corridor-monitor-workspace,.congestion-workspace,.forecast-workspace,.scenario-workspace,.day-type-workspace,.bottleneck-workspace,.works-workspace,.corridor-speed-workspace,.performance-workspace,.event-profile-workspace,.speed-alert-workspace,.itinerary-workspace,.od-workspace,.count-workspace,.network-state-workspace) :is(strong,dd) { color:#24443d; }
html[data-theme="light"] body.cam-platform #view-analysis :is(.contract-matrix-workspace,.contract-case-workspace,.corridor-monitor-workspace,.congestion-workspace,.forecast-workspace,.scenario-workspace,.day-type-workspace,.bottleneck-workspace,.works-workspace,.corridor-speed-workspace,.performance-workspace,.event-profile-workspace,.speed-alert-workspace,.itinerary-workspace,.od-workspace,.count-workspace,.network-state-workspace) :is(p,small,dt) { color:#617b76; }
html[data-theme="light"] body.cam-platform #view-analysis :is(.corridor-monitor-query,.congestion-query,.forecast-query,.scenario-query,.day-type-query,.bottleneck-query,.works-query,.performance-query,.event-profile-query,.itinerary-query,.od-query,.count-query,.network-state-query) > :is(label,fieldset),
html[data-theme="light"] body.cam-platform #view-analysis .corridor-monitor-selected dl div { border-color:rgba(39,83,76,.11);background:#fff; }
html[data-theme="light"] body.cam-platform #view-analysis :is(.corridor-monitor-stage,.congestion-stage,.corridor-speed-stage,.itinerary-stage,.performance-stage,.works-stage,.day-type-stage,.bottleneck-stage,.od-stage) { border-color:rgba(39,83,76,.13);background:#fff; }
html[data-theme="light"] body.cam-platform #view-analysis :is(.corridor-monitor-truth,.event-profile-truth,.forecast-truth,.scenario-status,.performance-method,.itinerary-method) { border-color:rgba(214,145,50,.22);background:#fffaf2; }
html[data-theme="light"] body.cam-platform #view-analysis .corridor-monitor-map-legend { color:#526d67;border-color:rgba(39,83,76,.16);background:rgba(255,255,255,.94); }
html[data-theme="light"] body.cam-platform #view-analysis :is(.corridor-monitor-selected,.corridor-monitor-context-card,.corridor-monitor-sequence-card) { border-color:rgba(39,83,76,.1);background:#fff; }
html[data-theme="light"] body.cam-platform #view-analysis .corridor-monitor-selected dl div { background:#f4f8f7; }
html[data-theme="light"] body.cam-platform #view-analysis .corridor-monitor-query select option { color:#17322d;background:#fff; }
html[data-theme="light"] body.cam-platform #view-analysis .corridor-monitor-query input::-webkit-calendar-picker-indicator { filter:none;opacity:.58; }
html[data-theme="light"] body.cam-platform #view-analysis .scenario-assumptions {
  color:#294740;
  border:1px solid rgba(39,83,76,.13);
  background:linear-gradient(135deg,#f8fbfa,#eef6f3);
  box-shadow:0 8px 22px rgba(31,66,60,.055);
}
html[data-theme="light"] body.cam-platform #view-analysis .scenario-assumptions > label {
  color:#607a75;
  border-color:rgba(39,83,76,.1);
  background:#fff;
}
html[data-theme="light"] body.cam-platform #view-analysis .congestion-source {
  color:#385650;
  border-color:rgba(39,83,76,.14);
  background:#fff;
  box-shadow:0 6px 18px rgba(31,66,60,.045);
}
html[data-theme="light"] body.cam-platform #view-analysis .congestion-source.pending {
  border-color:rgba(214,145,50,.24);
  background:#fffaf1;
}

/* Superficies de los módulos: mantiene los colores de datos y aclara el soporte. */
html[data-theme="light"] body.cam-platform :is(article,section,aside,div)[class*="-panel"],
html[data-theme="light"] body.cam-platform :is(article,section,aside,div)[class*="-card"] { border-color:rgba(39,83,76,.13);background:#fff;box-shadow:0 8px 24px rgba(31,66,60,.045); }
html[data-theme="light"] body.cam-platform :is(.analysis-filters,.congestion-query,.corridor-speed-query,.performance-query,.itinerary-query,.works-query,.day-type-query,.bottleneck-query,.network-state-query,.forecast-query,.scenario-query,.od-query,.speed-alert-query,.corridor-monitor-query,.event-profile-query) { border-color:rgba(39,83,76,.13);background:#f7faf9; }
html[data-theme="light"] body.cam-platform :is(input,select,textarea) { color:#17322d;border-color:rgba(39,83,76,.17);background:#fff;color-scheme:light; }
html[data-theme="light"] body.cam-platform :is(input,select,textarea)::placeholder { color:#829691; }
html[data-theme="light"] body.cam-platform :is(label,legend,dt,small,.eyebrow) { border-color:rgba(39,83,76,.13); }
html[data-theme="light"] body.cam-platform :is(h1,h2,h3,h4) { color:#17322d; }
html[data-theme="light"] body.cam-platform article > header { border-color:rgba(39,83,76,.11); }
html[data-theme="light"] body.cam-platform :is(.analysis-kpis,.congestion-kpis,.corridor-monitor-kpis,.network-state-kpis,.count-kpis) { border-color:rgba(39,83,76,.13);background:#fff; }
html[data-theme="light"] body.cam-platform :is(.analysis-kpis,.congestion-kpis,.corridor-monitor-kpis,.network-state-kpis,.count-kpis) article { border-color:rgba(39,83,76,.1);background:#fff; }
html[data-theme="light"] body.cam-platform :is(.analysis-table,.performance-table,.itinerary-table,.network-state-table,.count-table) { color:#36534d;background:#fff; }
html[data-theme="light"] body.cam-platform [class*="-row"] { border-color:rgba(39,83,76,.09); }
html[data-theme="light"] body.cam-platform [class*="-row"].head,
html[data-theme="light"] body.cam-platform [class*="-row"].header { color:#607a75;background:#eef4f3; }

/* Los motores analíticos dibujan sobre lienzo con la paleta nocturna de Xouba.
   En claro, esta transformación conserva los colores semánticos de las series
   mientras convierte fondo, rejilla y rotulación a una superficie luminosa. */
html[data-theme="light"] body.cam-platform #view-analysis canvas:not(.maplibregl-canvas),
html[data-theme="light"] body.cam-platform #view-counts canvas:not(.maplibregl-canvas) {
  filter:invert(.92) hue-rotate(180deg) saturate(1.08) contrast(1.03);
}

/* Visor y mapas. */
html[data-theme="light"] body.cam-platform .ops-map-stage { background:#dfe8e6; }
html[data-theme="light"] body.cam-platform :is(.ops-layers,.ops-query,.ops-kpis,.ops-time,.ops-legend,.ops-segment-panel) { color:#27443e;border-color:rgba(39,83,76,.16);background:rgba(255,255,255,.94);box-shadow:0 12px 34px rgba(31,66,60,.14); }
html[data-theme="light"] body.cam-platform .ops-layer { border-color:rgba(39,83,76,.1); }
html[data-theme="light"] body.cam-platform .ops-layer strong { color:#284740; }
html[data-theme="light"] body.cam-platform .maplibregl-ctrl-group,
html[data-theme="light"] body.cam-platform .maplibregl-ctrl-attrib { color:#425e58;background:rgba(255,255,255,.92)!important;border-color:rgba(39,83,76,.16); }
html[data-theme="light"] body.cam-platform .maplibregl-ctrl button { filter:invert(.78); }
html[data-theme="light"] body.cam-platform .maplibregl-popup-content { color:#284640;background:#fff;box-shadow:0 12px 30px rgba(31,66,60,.2); }
html[data-theme="light"] body.cam-platform .maplibregl-popup-tip { border-top-color:#fff; }

/* Perfil / cuenta. */
html[data-theme="light"] #identity-dialog { color:#24443d;border-color:rgba(22,140,110,.22);background:#f7faf9;box-shadow:0 30px 90px rgba(31,66,60,.22); }
html[data-theme="light"] #identity-dialog::backdrop { background:rgba(217,229,226,.68); }
html[data-theme="light"] #identity-dialog .identity-shell { background:radial-gradient(circle at 82% 10%,rgba(22,140,110,.08),transparent 34%),linear-gradient(145deg,#fff,#f3f7f6 62%); }
html[data-theme="light"] #identity-dialog :is(.identity-shell > header,.identity-status-line,.identity-appearance,.identity-admin) { border-color:rgba(39,83,76,.1); }
html[data-theme="light"] #identity-dialog .identity-brand h3,
html[data-theme="light"] #identity-dialog .identity-account h4,
html[data-theme="light"] #identity-dialog .identity-login-copy h4,
html[data-theme="light"] #identity-dialog .identity-bootstrap h4 { color:#17322d; }
html[data-theme="light"] #identity-dialog .identity-shell > header > button,
html[data-theme="light"] #identity-dialog .identity-account button,
html[data-theme="light"] #identity-dialog .identity-admin button { color:#4d6b65;border-color:rgba(39,83,76,.14);background:#fff; }
html[data-theme="light"] #identity-dialog .identity-appearance { background:rgba(22,140,110,.035); }
html[data-theme="light"] #identity-dialog .identity-appearance strong { color:#23433c; }
html[data-theme="light"] #identity-dialog .identity-appearance-icon::after { background:#f4f8f7; }
html[data-theme="light"] #identity-dialog .identity-theme-options { border-color:rgba(39,83,76,.13);background:#edf3f2; }
html[data-theme="light"] #identity-dialog .theme-glyph.dark::after { background:#edf3f2; }
html[data-theme="light"] #identity-dialog .identity-theme-options button { color:#607a75; }
html[data-theme="light"] #identity-dialog .identity-theme-options button:hover { color:#17322d;background:#fff; }
html[data-theme="light"] #identity-dialog .identity-theme-options button.active { color:#147f64;border-color:rgba(22,140,110,.28);background:#fff;box-shadow:0 4px 12px rgba(31,66,60,.08); }
html[data-theme="light"] #identity-dialog :is(.identity-login,.identity-bootstrap,.identity-admin) form,
html[data-theme="light"] #identity-dialog .identity-user-list article,
html[data-theme="light"] #identity-dialog .identity-permissions span { color:#36534d;border-color:rgba(39,83,76,.11);background:#fff; }
html[data-theme="light"] #identity-dialog .identity-tool-selector { border-color:rgba(22,140,110,.16);background:linear-gradient(145deg,rgba(22,140,110,.045),rgba(247,250,249,.9)); }
html[data-theme="light"] #identity-dialog .identity-tool-selector legend strong { color:#24443d; }
html[data-theme="light"] #identity-dialog .identity-tool-grid section { border-color:rgba(39,83,76,.1);background:#fff; }
html[data-theme="light"] #identity-dialog .identity-tool-grid h6 { color:#668079; }
html[data-theme="light"] #identity-dialog .identity-tool-grid label strong { color:#36534d; }
html[data-theme="light"] #identity-dialog .identity-tool-grid input[type="checkbox"] { border-color:rgba(39,83,76,.28);background:#fff; }
html[data-theme="light"] #identity-dialog .identity-tool-grid input[type="checkbox"]:checked { border-color:#168c6e;background:#35b68f;box-shadow:inset 0 0 0 3px #fff; }
html[data-theme="light"] #identity-dialog .identity-tool-presets button { color:#58736e;border-color:rgba(39,83,76,.13);background:#fff; }
html[data-theme="light"] #identity-dialog .identity-user-actions button { color:#147f64;border-color:rgba(22,140,110,.2);background:#f6fbf9; }
html[data-theme="light"] #identity-dialog .identity-user-actions button.danger { color:#ba4d5d;border-color:rgba(186,77,93,.2);background:#fff7f8; }
html[data-theme="light"] #identity-dialog .identity-tool-selector > p { color:#668079; }
html[data-theme="light"] #identity-dialog :is(input,select) { color:#17322d;border-color:rgba(39,83,76,.16);background:#fff; }
html[data-theme="light"] #identity-dialog .identity-shell > footer { color:#58736e;border-color:rgba(39,83,76,.1);background:#eef4f3; }

/* Asistente: conserva su identidad verde, pero se integra con el tema claro. */
html[data-theme="light"] .xouba-assistant-launch { color:#21433b;border-color:rgba(22,140,110,.22);background:linear-gradient(135deg,#fff,#eff7f4);box-shadow:0 7px 22px rgba(31,66,60,.1); }
html[data-theme="light"] .xouba-assistant-launch small { color:#6e847f; }
html[data-theme="light"] .xouba-assistant-panel { color:#294740;border-color:rgba(22,140,110,.2);background:radial-gradient(circle at 90% 0,rgba(42,151,126,.1),transparent 32%),linear-gradient(180deg,#fff,#f3f8f6);box-shadow:0 30px 80px rgba(31,66,60,.24); }
html[data-theme="light"] .xouba-assistant-head,
html[data-theme="light"] .xouba-assistant-context,
html[data-theme="light"] .xouba-assistant-form { border-color:rgba(39,83,76,.11);background:rgba(246,250,249,.92); }
html[data-theme="light"] .xouba-assistant-identity h2,
html[data-theme="light"] .xouba-assistant-message p { color:#1d3b35; }
html[data-theme="light"] .xouba-assistant-message.user > div,
html[data-theme="light"] .xouba-assistant-evidence,
html[data-theme="light"] .xouba-assistant-form > div { color:#294740;border-color:rgba(39,83,76,.13);background:#fff; }
html[data-theme="light"] .xouba-assistant-form textarea { color:#17322d;background:transparent; }

@media (max-width:720px) {
  #identity-dialog .identity-appearance { grid-template-columns:38px 1fr; }
  #identity-dialog .identity-theme-options { grid-column:1/-1; }
  #identity-dialog .identity-theme-options button { flex:1;min-width:0; }
}

@media print {
  html,html[data-theme="dark"],html[data-theme="light"] { color-scheme:light; }
}
