/* Shared dark/light control. Landing tokens fall back to the app tokens. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  padding: .4rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--land-border, var(--border));
  background: var(--land-surface, var(--card));
  color: var(--land-text, var(--text));
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--land-lime, var(--primary)); }
.theme-toggle:focus-visible {
  outline: 3px solid var(--land-lime, var(--primary));
  outline-offset: 2px;
}
html[data-theme="dark"] .theme-icon-moon,
html[data-theme="dark"] .theme-label-to-dark { display: none; }
html[data-theme="light"] .theme-icon-sun,
html[data-theme="light"] .theme-label-to-light { display: none; }

@media (max-width: 520px) {
  .theme-toggle-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .theme-toggle {
    position: relative;
    min-width: 44px;
    justify-content: center;
    padding-inline: .7rem;
  }
}

/* En la barra: el icono queda en la primera fila, a la derecha del logo,
   y el resto del menú baja. Así no se esconde bajo la hamburguesa en el iPhone. */
.topbar-inner > .brand { min-width: 0; }
.topbar-inner > .theme-toggle {
  margin-left: auto;
  flex-shrink: 0;
}
@media (max-width: 860px) {
  .topbar-inner > .nav { flex: 1 0 100%; }
}

@media print {
  .theme-toggle { display: none !important; }
}

/* Modo claro en paneles con sesión. Las páginas públicas siguen en public-theme.css. */
html[data-theme="light"] body:not(.landing):not(.public) {
  color-scheme: light;
  --bg: #f4f5f1;
  --bg2: #ffffff;
  --card: #ffffff;
  --border: #e0e3d8;
  --text: #232323;
  --muted: #5c6358;
  --primary: var(--hc-color-brand-verde);
  --primary-d: var(--hc-color-verde-700);
  --primary-contrast: var(--hc-color-brand-carbon);
  --ok: #3f6600;
  --warn: #8a6400;
  --danger: #9f1d1d;
  --info: #1d5f8a;
  --live: #3d6200;
  --shadow: 0 10px 28px rgba(35, 35, 35, 0.08);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(132, 189, 0, 0.16), transparent 55%),
    linear-gradient(165deg, #f4f5f1 0%, #ffffff 52%, #e7edd9 100%);
}
html[data-theme="light"] body:not(.landing):not(.public) .topbar {
  background: rgba(244, 245, 241, 0.94);
  border-bottom-color: var(--border);
}
html[data-theme="light"] body.theme-dash:not(.public) {
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(255, 120, 40, 0.12), transparent 55%),
    linear-gradient(165deg, #f7f4f1 0%, #ffffff 55%, #f3e7df 100%);
}
html[data-theme="light"] body.theme-dash:not(.public) .topbar {
  background: rgba(255, 250, 246, 0.94);
  border-bottom-color: #f0d8c8;
  box-shadow: 0 1px 0 rgba(255, 90, 0, 0.25);
}
html[data-theme="light"] body:not(.landing):not(.public) a:not(.btn):not(.brand) {
  color: var(--hc-color-text-link);
}
html[data-theme="light"] body:not(.landing):not(.public) .brand { color: var(--text); }
html[data-theme="light"] body:not(.landing):not(.public) .btn {
  background: #ffffff;
  color: var(--text);
}
html[data-theme="light"] body:not(.landing):not(.public) .btn-primary,
html[data-theme="light"] body:not(.landing):not(.public) .btn-ok {
  background: var(--primary);
  border-color: var(--primary-d);
  color: var(--primary-contrast);
}
html[data-theme="light"] body:not(.landing):not(.public) .btn-ghost { background: transparent; }
html[data-theme="light"] body:not(.landing):not(.public) .btn-danger {
  background: #fde8e8;
  border-color: #e8b4b4;
  color: #6e1414;
}
html[data-theme="light"] body:not(.landing):not(.public) .btn-icon {
  background: rgba(35, 35, 35, 0.04);
  color: var(--text);
}
html[data-theme="light"] body:not(.landing):not(.public) .btn-glass {
  color: #1a2208;
}
html[data-theme="light"] body:not(.landing):not(.public) .btn-crystal,
html[data-theme="light"] body:not(.landing):not(.public) .btn-crystal-hot {
  color: #2a1208;
}
html[data-theme="light"] body:not(.landing):not(.public) input,
html[data-theme="light"] body:not(.landing):not(.public) select,
html[data-theme="light"] body:not(.landing):not(.public) textarea {
  background: #ffffff;
  color: var(--text);
}
html[data-theme="light"] body:not(.landing):not(.public) input::placeholder {
  color: #6d7468;
}
html[data-theme="light"] body:not(.landing):not(.public) code {
  background: rgba(35, 35, 35, 0.06);
}
html[data-theme="light"] body:not(.landing):not(.public) .map { background: #e7e9e2; }
html[data-theme="light"] body:not(.landing):not(.public) .sidebar {
  background: rgba(255, 255, 255, 0.96);
}
html[data-theme="light"] body:not(.landing):not(.public) .sidebar-link.is-active {
  color: #2f4d00;
}
html[data-theme="light"] body:not(.landing):not(.public) .lime-chip {
  color: #3f6600 !important;
}
html[data-theme="light"] body:not(.landing):not(.public) .badge-muted {
  background: #eceee6;
  color: #3a3a3a;
  border-color: #d5d8ce;
}
html[data-theme="light"] body:not(.landing):not(.public) .badge-info {
  background: #e5f2fa;
  color: #143e5c;
  border-color: #b7d4e8;
}
html[data-theme="light"] body:not(.landing):not(.public) .badge-warn {
  background: #fff4d6;
  color: #6a4e00;
  border-color: #ead48a;
}
html[data-theme="light"] body:not(.landing):not(.public) .badge-live,
html[data-theme="light"] body:not(.landing):not(.public) .badge-ok {
  background: #e7f3c8;
  color: #243b00;
  border-color: #c5de8a;
}
html[data-theme="light"] body:not(.landing):not(.public) .badge-danger {
  background: #fde8e8;
  color: #6e1414;
  border-color: #f0c4c4;
}
.badge.hc-chip {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  border: 0;
  border-radius: var(--hc-radius-pill);
  padding: .2em .7em;
  font: 600 .8rem/1.4 var(--hc-font-family-ui);
}
html[data-theme="light"] body:not(.landing):not(.public) .alert-ok,
html[data-theme="light"] body:not(.landing):not(.public) .alert-success {
  background: #e7f3c8;
  border-color: #c5de8a;
  color: #243b00;
}
html[data-theme="light"] body:not(.landing):not(.public) .alert-danger {
  background: #fde8e8;
  border-color: #f0c4c4;
  color: #6e1414;
}
html[data-theme="light"] body:not(.landing):not(.public) .alert-info {
  background: #e5f2fa;
  border-color: #b7d4e8;
  color: #143e5c;
}
html[data-theme="light"] body:not(.landing):not(.public) .kpi-card,
html[data-theme="light"] body:not(.landing):not(.public) .dash-card,
html[data-theme="light"] body:not(.landing):not(.public) .mini-portal {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: var(--shadow);
}
html[data-theme="light"] body:not(.landing):not(.public) .kpi-card:not(.kpi-hot):not(.kpi-lime) .kpi-value,
html[data-theme="light"] body:not(.landing):not(.public) .kpi-label,
html[data-theme="light"] body:not(.landing):not(.public) .kpi-sub,
html[data-theme="light"] body:not(.landing):not(.public) .mini-stats,
html[data-theme="light"] body:not(.landing):not(.public) .mini-stats span {
  color: var(--text);
}
html[data-theme="light"] body:not(.landing):not(.public) .kpi-label,
html[data-theme="light"] body:not(.landing):not(.public) .kpi-sub,
html[data-theme="light"] body:not(.landing):not(.public) .mini-stats {
  color: var(--muted);
}
html[data-theme="light"] body:not(.landing):not(.public) .mini-bar { background: #e7e9e2; }
