/* AutrixWeb — refactor.css: clases que sustituyen a los style="" inline.
 * Se carga EL ÚLTIMO para que, a igual especificidad, gane como ganaba el inline.
 * Visibilidad inicial .is-hidden + JS setHidden() (js/utils/dom.js). */
.is-hidden, [hidden] { display: none !important; }

/* hints y notas */
.u-info{color:#084c8d}
.note-muted{display:block;color:#666;margin-top:4px}
.note-line{display:block;margin-top:4px}
.u-muted{color:#666}
.hint-box{display:block;margin-top:8px;padding:8px;background:#eef6ff;border-radius:4px}
.u-center-note{display:block;text-align:center;color:#888;font-size:11px}
.u-link{color:#4A90E2;text-decoration:none}
.u-link-light{color:#93c5fd}
.u-ok{color:#4ade80}
.u-pink-soft{color:#fecaca}
.city-multi{margin-bottom:12px;color:#666}
.match-line{font-size:.85em;font-weight:600}
.match-sub{color:#666;font-weight:400}
.suggest-box{font-size:.8em;color:#0a58ca;background:#e7f1ff;border-radius:6px;padding:6px 8px}
.ev-sub{margin-top:4px;font-size:.8em;color:#95a5a6}
.lbl-block{display:block;margin-bottom:8px;font-weight:600}
.lbl-block-16{display:block;margin:16px 0 8px 0;font-weight:600}
.lbl-block-20-c{display:block;margin:20px 0 8px 0;font-weight:600;text-align:center}
.u-fw600{font-weight:600}

/* tamaños y espaciados */
.u-fs-09{font-size:.9em}
.u-fs-08{font-size:.8em;color:#666}
.u-mt-4{margin-top:4px}
.u-mt-6{margin-top:6px}
.u-mt-8{margin-top:8px}
.u-mb-8{margin-bottom:8px}
.u-my-8{margin:8px 0}
.u-lh14{line-height:1.4}
.u-ico-20{width:20px;height:20px}
.u-btn-sm{padding:4px 10px;font-size:.8em}
.u-block{display:block}
.vol-ico{color:#666;font-size:14px}

/* filas flex */
.u-flex-6{display:flex;gap:6px;align-items:center}
.u-flex-8-wrap{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.u-flex-12{display:flex;gap:12px;align-items:center}
.u-flex-sb{display:flex;justify-content:space-between}
.u-flex-sb-c{display:flex;justify-content:space-between;align-items:center}
.u-flex-sb-8{display:flex;justify-content:space-between;align-items:center;gap:8px}
.box-head{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}
.ev-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}
.ev-score{display:flex;justify-content:space-between;font-size:.9em}
.ev-score-soon{display:flex;justify-content:space-between;font-size:.9em;margin-top:2px}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.section-sep{margin-top:16px;padding-top:12px;border-top:1px solid #e0e0e0}
.card-plain{margin-top:12px;padding:12px;border:1px solid #dee2e6;border-radius:8px;background:#fff}
.ev-card{display:flex;flex-direction:column;gap:8px;padding:12px;background:white;border-radius:8px}
.u-hr{margin:12px 0;border:none;border-top:1px solid rgba(255,255,255,.12)}
.volume-control-container{display:flex;align-items:center;gap:8px;background:#f8f9fa;padding:4px 12px;border-radius:20px;border:1px solid #e0e0e0}
.modal-dialog--wide{max-width:900px}

/* presets de color del diseñador de texto (antes style="background:#XXXX") */
.sw-ffffff, [data-preset-color="#FFFFFF"] { background: #FFFFFF !important; }
.sw-ffb300, [data-preset-color="#FFB300"] { background: #FFB300 !important; }
.sw-00e676, [data-preset-color="#00E676"] { background: #00E676 !important; }
.sw-00e5ff, [data-preset-color="#00E5FF"] { background: #00E5FF !important; }
.sw-ff4081, [data-preset-color="#FF4081"] { background: #FF4081 !important; }
.sw-ff5252, [data-preset-color="#FF5252"] { background: #FF5252 !important; }
.sw-000000, [data-preset-color="#000000"] { background: #000000 !important; }
.sw-102a43, [data-preset-color="#102A43"] { background: #102A43 !important; }
.sw-1b1b1b, [data-preset-color="#1B1B1B"] { background: #1B1B1B !important; }
.sw-3e2723, [data-preset-color="#3E2723"] { background: #3E2723 !important; }
.sw-0d3311, [data-preset-color="#0D3311"] { background: #0D3311 !important; }
.sw-330d0d, [data-preset-color="#330D0D"] { background: #330D0D !important; }

/* ex-inline por #id (equivalencia exacta incl. display donde importa) */
#sidebar_active_sub{font-size:11px}
#dev_mem{display:block;text-align:center;font-size:11px;margin-top:6px;cursor:pointer}
#settings_token_warn{margin-top:8px;padding:8px;background:rgba(239,68,68,.12);border:1px solid rgba(239,68,68,.5);border-radius:8px}
#alarm_repeat_config{margin-top:16px}
#espn_live_box{margin-top:12px;border:1px solid #dee2e6;border-radius:8px;padding:12px;background:#fff}
#espn_live_status{font-size:.8em;color:#666;margin-bottom:8px}
#espn_live_results{margin:0;max-height:220px}
#draw_visible_row{margin-top:8px}
#draw_templates_card{margin-top:12px}
#city_results_list{max-height:300px;overflow-y:auto}
#pizza_preview_canvas{width:160px;height:40px;max-width:100%;background:#000;border:1px solid rgba(255,255,255,.18);border-radius:4px;image-rendering:pixelated}
#pizza_preview_status{font-size:.8em;color:#666}
#global_volume{width:80px;cursor:pointer}
#volume_value{font-size:12px;font-weight:600;color:#666;min-width:20px;text-align:center}
#conn_mode_pill{margin-left:6px}
#cloud_token_box{border:none;border-radius:0;padding:0;background:transparent;margin-bottom:4px}
#settings_cloud_device{flex:1;min-width:180px}

/* ====================================================
   Landing Page: Barra superior, Grid Completo y CTA
   ==================================================== */
.landing-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.landing-top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.landing-features-container {
  width: 100%;
  margin: 16px 0 28px;
}
.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.landing-enter-section {
  text-align: center;
  margin: 36px auto 20px;
}
.landing-enter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px 36px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.landing-enter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 38px rgba(37, 99, 235, 0.6);
  filter: brightness(1.1);
}
.landing-enter-btn:active {
  transform: translateY(0);
}
.landing-enter-hint {
  margin-top: 10px;
  font-size: 13px;
  color: #94a3b8;
}

/* ====================================================
   Main App: Topbar con accesos en la esquina superior derecha
   ==================================================== */
.main-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 10px 18px;
  background: var(--card, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--card-border, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  backdrop-filter: blur(8px);
}
.main-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.main-topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-auth {
  display: flex;
  align-items: center;
  margin: 0 !important;
}
.landing-auth-top {
  display: flex;
  align-items: center;
  margin: 0 !important;
}
.topbar-auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 9px;
  height: 24px;
  box-sizing: border-box;
  margin: 0 !important;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.topbar-auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}
.topbar-user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0 !important;
}

.topbar-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0 9px;
  height: 24px;
  box-sizing: border-box;
  margin: 0 !important;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  color: #f1f5f9;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.topbar-user-profile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0 9px;
  height: 24px;
  box-sizing: border-box;
  margin: 0 !important;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  color: #f1f5f9;
}

.topbar-logout-btn {
  background: transparent !important;
  border: none !important;
  color: #94a3b8;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease;
}

.topbar-logout-btn:hover {
  color: #ef4444;
  background: transparent !important;
}

.topbar-user-trigger:hover,
.topbar-user-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.topbar-user-trigger .user-avatar-ico {
  color: #60a5fa;
  font-size: 12px;
}

.topbar-user-email {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-trigger .user-chevron-ico {
  font-size: 9px;
  color: #94a3b8;
  margin-left: 2px;
  transition: transform 0.2s ease;
}

.topbar-user-trigger[aria-expanded="true"] .user-chevron-ico {
  transform: rotate(180deg);
}

.topbar-user-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  min-width: 190px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 5px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.2);
  z-index: 1050;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: userMenuPop 0.15s ease-out;
}

@keyframes userMenuPop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
  padding: 5px 8px;
}

.user-dropdown-label {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 2px;
}

.user-dropdown-email {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 3px 0;
}

.user-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 500;
  color: #cbd5e1;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.user-dropdown-item--danger {
  color: #f87171;
}

.user-dropdown-item--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.user-dropdown-item--danger i {
  color: #ef4444;
}
.mode-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.mode-badge-pill.lan {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}
.mode-badge-pill.lan .dot {
  background: #22c55e;
}
.mode-badge-pill.cloud {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}
.mode-badge-pill.cloud .dot {
  background: #3b82f6;
}

/* ====================================================
   Modales: LAN IP Prompt & Cloud Auth Modal
   ==================================================== */
.lan-ip-dialog {
  max-width: 450px;
}
.lan-ip-body {
  padding: 22px;
}
.lan-ip-desc {
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
  margin-bottom: 18px;
}
body.authed .lan-ip-desc {
  color: var(--muted);
}
.lan-ip-form-row {
  margin-bottom: 14px;
}
.lan-ip-form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
body.authed .lan-ip-form-row label {
  color: var(--ink);
}
.lan-ip-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.lan-ip-input-wrap i {
  position: absolute;
  left: 12px;
  color: #9ca3af;
  font-size: 14px;
  pointer-events: none;
}
.lan-ip-input-wrap input {
  width: 100%;
  padding: 11px 12px 11px 36px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
  font-family: monospace;
  background: #ffffff;
  color: #1f2937;
  box-sizing: border-box;
}
body.authed .lan-ip-input-wrap input {
  background: var(--card-solid, #151f3a);
  border-color: var(--card-border, rgba(255, 255, 255, 0.2));
  color: var(--ink, #ffffff);
}
.lan-setup-msg {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.45;
}
.lan-setup-btn {
  width: 100%;
  padding: 11px;
  font-size: 15px;
}
.lan-cloud-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0 14px;
  color: #9ca3af;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
body.authed .lan-cloud-divider {
  color: var(--muted-dim);
}
.lan-cloud-divider::before,
.lan-cloud-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e5e7eb;
}
body.authed .lan-cloud-divider::before,
body.authed .lan-cloud-divider::after {
  border-bottom-color: var(--card-border);
}
.lan-cloud-divider:not(:empty)::before {
  margin-right: 12px;
}
.lan-cloud-divider:not(:empty)::after {
  margin-left: 12px;
}
.lan-cloud-btn {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  justify-content: center;
}
.lan-cloud-hint {
  display: block;
  text-align: center;
  margin-top: 6px;
  font-size: 11px;
  color: #6b7280;
}
body.authed .lan-cloud-hint {
  color: var(--muted-dim);
}

.auth-modal-dialog {
  max-width: 440px;
}
.auth-modal-header-content h3 {
  margin: 0;
  font-size: 18px;
}
.auth-modal-header-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}
.auth-modal-body {
  padding: 20px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.lang-switch--landing {
  margin: 0 !important;
}

.lang-switch--topbar {
  margin: 0 !important;
}

.lang-select {
  margin: 0 !important;
  width: auto;
  min-width: 0;
  flex-shrink: 0;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  box-shadow: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0 20px 0 8px;
  height: 24px;
  box-sizing: border-box;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%2394a3b8' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  line-height: normal;
  vertical-align: middle;
}

.lang-select:hover,
.lang-select:focus {
  color: #ffffff;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23ffffff' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
}

.lang-select option {
  background: #0f172a;
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
}

.lang-switch--topbar .lang-btn,
.lang-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted, #cbd5e1);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-switch--topbar .lang-btn:hover,
.lang-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.lang-switch--topbar .lang-btn.active,
.lang-btn.active {
  background: var(--accent1, #3b82f6);
  color: #fff;
  border-color: var(--accent1, #3b82f6);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* ====================================================
   LAYOUT SUPERIOR STICKY (ESTILO AWTRIX.DE)
   ==================================================== */

/* Disposición vertical para que el header quede arriba y el contenido debajo */
body,
body.authed,
body.locked {
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
}

/* Ocultar barra en la landing */
body.locked .app-header,
body.locked .site-header {
  display: none !important;
}

/* Expandir contenido principal quitando el margen lateral del antiguo sidebar */
.main-content {
  flex: 1 0 auto !important;
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 24px 20px 64px !important;
  box-sizing: border-box !important;
}

body.authed .main-content {
  margin-left: 0 !important;
  width: 100% !important;
}

/* Header superior fijo / sticky (2 filas) */
.app-header.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex !important;
  flex-direction: column !important;
  gap: 0;
  box-sizing: border-box;
}

/* Filas del Header */
.header-row {
  width: 100%;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.header-row--top {
  height: 44px;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 16px;
}

.header-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

.header-row--nav {
  height: 48px;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
}

/* Marca / Brand */
.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.site-brand:hover {
  opacity: 0.9;
}

.brand-matrix-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #60a5fa, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-transform: uppercase;
}

/* Enlaces de navegación principal (estrictamente horizontal) */
.site-nav,
body.authed .site-nav {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 6px !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.site-nav .nav-item,
body.authed .site-nav .nav-item,
body.authed .site-nav a {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #e2e8f0 !important;
  border-radius: 7px !important;
  text-decoration: none !important;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
  white-space: nowrap !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  flex-shrink: 0 !important;
  height: auto !important;
  cursor: pointer !important;
}

.site-nav .nav-item i,
body.authed .site-nav .nav-item i,
body.authed .site-nav a i {
  font-size: 13px !important;
  color: #94a3b8 !important;
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  border-radius: 0 !important;
  margin: 0 !important;
  transition: color 0.18s ease, transform 0.18s ease !important;
}

.site-nav .nav-item:hover,
body.authed .site-nav a:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
  transform: translateY(-1px);
}

.site-nav .nav-item:hover i,
body.authed .site-nav a:hover i {
  color: #60a5fa !important;
  transform: scale(1.08);
}

.site-nav .nav-item.active,
body.authed .site-nav a.active {
  color: #ffffff !important;
  background: rgba(59, 130, 246, 0.22) !important;
  border-color: rgba(59, 130, 246, 0.55) !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.28) !important;
}

.site-nav .nav-item.active i,
body.authed .site-nav a.active i {
  color: #60a5fa !important;
}

/* ====================================================
   BOTÓN DE WIDGETS (DESTACADO Y VISIBLE AL INSTANTE)
   ==================================================== */
#nav-widgets,
body.authed #nav-widgets,
.nav-item--widgets {
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: rgba(245, 158, 11, 0.4) !important;
  color: #fef08a !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.15) !important;
}

#nav-widgets i,
body.authed #nav-widgets i,
.nav-item--widgets i {
  color: #f59e0b !important;
  font-size: 13.5px !important;
}

#nav-widgets:hover,
body.authed #nav-widgets:hover,
.nav-item--widgets:hover {
  background: rgba(245, 158, 11, 0.22) !important;
  border-color: rgba(245, 158, 11, 0.75) !important;
  color: #ffffff !important;
  box-shadow: 0 3px 14px rgba(245, 158, 11, 0.35) !important;
  transform: translateY(-1px);
}

#nav-widgets:hover i,
body.authed #nav-widgets:hover i,
.nav-item--widgets:hover i {
  color: #fbbf24 !important;
  transform: scale(1.12);
}

#nav-widgets.active,
body.authed #nav-widgets.active,
.nav-item--widgets.active {
  background: rgba(245, 158, 11, 0.32) !important;
  border-color: #f59e0b !important;
  color: #ffffff !important;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.45) !important;
}

#nav-widgets.active i,
body.authed #nav-widgets.active i,
.nav-item--widgets.active i {
  color: #fbbf24 !important;
}

.site-header-spacer {
  flex: 1 1 auto;
}

/* Grupo derecho de navegación (Conexión + Dispositivo y Modo) */
.header-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Control del dispositivo y botón de modo */
.topbar-device-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 0 6px 0 4px;
  height: 34px;
  box-sizing: border-box;
  border-radius: 999px;
  transition: border-color 0.18s, box-shadow 0.18s;
  flex-shrink: 0;
}

.topbar-device-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.topbar-canvas-preview {
  display: none !important;
}

/* Botón único de modo: Icono + Modo LAN (verde) / Icono + Modo Nube (azul) */
.mode-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 26px;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  user-select: none;
}

.mode-toggle-btn i {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.mode-toggle-btn:hover {
  transform: translateY(-1px);
}

/* Modo LAN: verde */
.mode-toggle-btn.mode-lan {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.mode-toggle-btn.mode-lan i {
  color: #10b981;
}

.mode-toggle-btn.mode-lan:hover {
  background: rgba(16, 185, 129, 0.26);
  border-color: #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
}

/* Modo Nube: azul */
.mode-toggle-btn.mode-cloud {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.5);
  color: #60a5fa;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.mode-toggle-btn.mode-cloud i {
  color: #38bdf8;
}

.mode-toggle-btn.mode-cloud:hover {
  background: rgba(59, 130, 246, 0.26);
  border-color: #3b82f6;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.35);
}

/* Selector de dispositivo activo */
.topbar-device-select-wrap {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

.topbar-dev-select {
  margin: 0 !important;
  height: 26px;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  padding: 0 22px 0 8px;
  border-radius: 6px;
  cursor: pointer;
  max-width: 160px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2394a3b8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.topbar-dev-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

/* Responsive para el header en 2 filas */
@media (max-width: 960px) {
  .header-row--nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 10px;
  }
  .header-row--nav::-webkit-scrollbar {
    display: none;
  }
  .site-nav,
  .header-nav-right,
  .topbar-device-card {
    flex-shrink: 0 !important;
  }
}

@media (max-width: 640px) {
  .site-header-inner {
    padding: 0 12px;
  }
  .topbar-dev-select {
    max-width: 120px !important;
  }
  .topbar-auth-btn span {
    display: none;
  }
}

/* ====================================================
   BOTÓN DE ACCESO A WIDGETS EN PANEL DE STATUS
   ==================================================== */
.btn-status-widgets,
body.authed .btn-status-widgets {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100% !important;
  box-sizing: border-box;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
  color: #ffffff !important;
  border: 1px solid rgba(251, 191, 36, 0.45) !important;
  border-radius: 14px !important;
  padding: 18px 24px !important;
  font-size: 28px !important;
  font-weight: 800 !important;
  letter-spacing: 0.03em !important;
  text-transform: none !important;
  cursor: pointer;
  margin-bottom: 24px !important;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.35) !important;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-status-widgets:hover,
body.authed .btn-status-widgets:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(245, 158, 11, 0.55) !important;
  color: #ffffff !important;
}

.btn-status-widgets:active,
body.authed .btn-status-widgets:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.35) !important;
}

.btn-status-widgets i {
  font-size: 28px !important;
  color: #ffffff !important;
  transition: transform 0.22s ease;
}

.btn-status-widgets:hover i {
  transform: scale(1.12);
}

@media (max-width: 768px) {
  .btn-status-widgets,
  body.authed .btn-status-widgets {
    font-size: 22px !important;
    padding: 15px 18px !important;
  }
  .btn-status-widgets i {
    font-size: 22px !important;
  }
}

/* ============================================
   Widget Auto apagado
   ============================================ */
.sleep-section {
  margin: 16px 0;
  padding: 14px 16px;
  background: rgba(44, 90, 160, 0.04);
  border: 1px solid rgba(44, 90, 160, 0.15);
  border-radius: 12px;
}

body.authed .sleep-section {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

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

.sleep-preset-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sleep-chip-btn {
  background: rgba(44, 90, 160, 0.1);
  color: #2c5aa0;
  border: 1px solid rgba(44, 90, 160, 0.25);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.authed .sleep-chip-btn {
  background: rgba(96, 165, 250, 0.12);
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.25);
}

.sleep-chip-btn:hover {
  background: #2c5aa0;
  color: #ffffff;
  border-color: #2c5aa0;
  transform: translateY(-1px);
}

body.authed .sleep-chip-btn:hover {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
}

.sleep-range-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 14px 0;
}

.sleep-time-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sleep-time-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

body.authed .sleep-time-label {
  color: #94a3b8;
}

.sleep-time-inputs {
  margin: 0 !important;
}

.sleep-range-arrow {
  color: #94a3b8;
  font-size: 18px;
  margin-top: 18px;
}

.sleep-summary-badge {
  background: linear-gradient(135deg, rgba(44, 90, 160, 0.08), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.authed .sleep-summary-badge {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.12));
  border-color: rgba(139, 92, 246, 0.25);
}

.sleep-summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #2563eb;
  font-size: 13px;
  font-weight: 500;
}

body.authed .sleep-summary-item {
  color: #60a5fa;
}

.sleep-summary-item i {
  color: #f59e0b;
}

.sleep-summary-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #64748b;
}

body.authed .sleep-summary-sub {
  color: #cbd5e1;
}

.sleep-summary-sub i {
  color: #eab308;
}

@media (max-width: 600px) {
  .sleep-range-grid {
    flex-direction: column;
    gap: 8px;
  }
  .sleep-range-arrow {
    transform: rotate(90deg);
    margin: 4px 0;
  }
}

.sleep-overnight-badge {
  display: inline-block;
  color: #f59e0b;
  font-size: 11px;
  font-weight: 600;
  margin-left: 2px;
}

/* Selector de días: contraste nítido entre activo y desactivado */
.weekday-btn span {
  background: #f1f5f9 !important;
  border: 2px solid #cbd5e1 !important;
  color: #64748b !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
}

body.authed .weekday-btn span {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}

.weekday-btn:hover span {
  background: #e2e8f0 !important;
  border-color: #94a3b8 !important;
  color: #334155 !important;
  transform: scale(1.05) !important;
}

body.authed .weekday-btn:hover span {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

.weekday-btn input[type="checkbox"]:checked + span {
  background: #2563eb !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  transform: scale(1.1) !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4) !important;
}

body.authed .weekday-btn input[type="checkbox"]:checked + span {
  background: #3b82f6 !important;
  border-color: #60a5fa !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.55) !important;
}

/* ========================================================
   WIDGET: TARIFAS ELÉCTRICAS
   ======================================================== */
.tariff-modal {
  max-width: 960px !important;
}

.tariff-modal-sub {
  color: #64748b;
  font-size: 13.5px;
  margin: -4px 0 16px 0;
}

body.authed .tariff-modal-sub {
  color: #94a3b8;
}

.tariff-top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

body.authed .tariff-top-controls {
  background: #1e293b;
  border-color: #334155;
}

.tariff-name-field {
  flex: 1;
  min-width: 240px;
  margin: 0 !important;
}

.tariff-name-field input {
  margin-top: 4px;
}

.tariff-beep-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

body.authed .tariff-beep-toggle {
  color: #cbd5e1;
}

.tariff-beep-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  cursor: pointer;
}

.tariff-section {
  margin-bottom: 20px;
}

.tariff-section-title {
  font-size: 12px !important;
  font-weight: 800 !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #475569 !important;
  margin-bottom: 10px !important;
}

body.authed .tariff-section-title {
  color: #94a3b8 !important;
}

/* Tarjetas de tarifas (1 · ELIGE UNA TARIFA) */
.tariff-cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.tariff-card {
  position: relative;
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  border: 3px solid transparent;
}

.tariff-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.tariff-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tariff-card-name {
  font-size: 16px;
  font-weight: 800;
}

.tariff-brush-badge {
  background: #0f172a;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 9999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tariff-card-hours {
  font-size: 12.5px;
  line-height: 1.35;
  margin-bottom: 12px;
  opacity: 0.92;
  font-weight: 500;
}

.tariff-card-indicator {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
}

.tariff-card-indicator label {
  opacity: 0.85;
}

.tariff-indicator-select {
  width: 100%;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  color: #1e293b;
}

body.authed .tariff-indicator-select {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(255, 255, 255, 0.2);
  color: #f8fafc;
}

/* Colores específicos de las tarifas */
.tariff-card--valle {
  background: #bce1ee;
  color: #0c3340;
}
.tariff-card--valle.is-brush-active {
  border-color: #0c3340;
}

.tariff-card--llano {
  background: #e59a35;
  color: #1c1917;
}
.tariff-card--llano.is-brush-active {
  border-color: #1c1917;
}

.tariff-card--punta {
  background: #b8341b;
  color: #ffffff;
}
.tariff-card--punta.is-brush-active {
  border-color: #ffffff;
}

body.authed .tariff-card--valle {
  background: #0e3b4a;
  color: #e0f2fe;
}
body.authed .tariff-card--valle.is-brush-active {
  border-color: #38bdf8;
}

body.authed .tariff-card--llano {
  background: #b45309;
  color: #fef3c7;
}
body.authed .tariff-card--llano.is-brush-active {
  border-color: #fde68a;
}

body.authed .tariff-card--punta {
  background: #991b1b;
  color: #fee2e2;
}
body.authed .tariff-card--punta.is-brush-active {
  border-color: #fca5a5;
}

/* Sección de Rangos configurados */
.tariff-ranges-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

body.authed .tariff-ranges-section {
  background: #1e293b;
  border-color: #334155;
}

.tariff-ranges-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tariff-ranges-header h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: #334155;
  margin: 0;
}

body.authed .tariff-ranges-header h4 {
  color: #cbd5e1;
}

.tariff-count-badge {
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
}

body.authed .tariff-count-badge {
  background: #334155;
  color: #94a3b8;
}

.tariff-btn-secondary {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #2563eb;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

body.authed .tariff-btn-secondary {
  background: #0f172a;
  border-color: #475569;
  color: #60a5fa;
}

.tariff-btn-secondary:hover:not(:disabled) {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.tariff-btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tariff-ranges-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tariff-range-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.2s;
}

body.authed .tariff-range-item {
  background: #0f172a;
  border-color: #334155;
}

.tariff-range-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.tariff-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.tariff-range-title {
  color: #0f172a;
}

body.authed .tariff-range-title {
  color: #f8fafc;
}

.tariff-range-desc {
  color: #64748b;
  font-size: 12px;
}

body.authed .tariff-range-desc {
  color: #94a3b8;
}

.tariff-range-del-btn {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

body.authed .tariff-range-del-btn {
  background: rgba(220, 38, 38, 0.2);
  border-color: #ef4444;
  color: #f87171;
}

.tariff-range-del-btn:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
  transform: scale(1.05);
}

/* Caja para nuevo rango */
.tariff-new-range-box {
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

body.authed .tariff-new-range-box {
  background: #0f172a;
  border-color: #475569;
}

.tariff-new-range-box h5 {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin: 0 0 10px 0;
}

body.authed .tariff-new-range-box h5 {
  color: #e2e8f0;
}

.tariff-new-range-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.tariff-new-range-days {
  margin-bottom: 12px;
}

.tariff-new-range-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Cuadrícula visual del calendario (2 · PINTA LAS HORAS) */
.tariff-calendar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tariff-calendar-hint {
  font-size: 12px;
  color: #64748b;
  font-style: italic;
}

body.authed .tariff-calendar-hint {
  color: #94a3b8;
}

.tariff-calendar-grid {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  overflow-x: auto;
}

body.authed .tariff-calendar-grid {
  background: #0f172a;
  border-color: #334155;
}

.tariff-grid-header {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.tariff-grid-day-col--header {
  width: 90px;
  flex-shrink: 0;
}

.tariff-grid-hours-track {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 4px;
}

.tariff-hour-header-cell {
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
  text-align: left;
  user-select: none;
  white-space: nowrap;
  overflow: visible;
}

body.authed .tariff-hour-header-cell {
  color: #94a3b8;
}

.tariff-grid-row {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.tariff-grid-day-label {
  width: 90px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

body.authed .tariff-grid-day-label {
  color: #cbd5e1;
}

.tariff-grid-day-label:hover {
  color: #2563eb;
}

body.authed .tariff-grid-day-label:hover {
  color: #60a5fa;
}

.tariff-grid-cells-row {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 4px;
}

.tariff-cell {
  height: 24px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.tariff-cell:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  z-index: 5;
}

.tariff-cell.cell-valle {
  background-color: #bce1ee;
}
.tariff-cell.cell-llano {
  background-color: #e59a35;
}
.tariff-cell.cell-punta {
  background-color: #b8341b;
}
.tariff-cell.cell-empty {
  background-color: #f1f5f9;
}

body.authed .tariff-cell.cell-valle {
  background-color: #0e3b4a;
}
body.authed .tariff-cell.cell-llano {
  background-color: #b45309;
}
body.authed .tariff-cell.cell-punta {
  background-color: #991b1b;
}
body.authed .tariff-cell.cell-empty {
  background-color: #1e293b;
}

/* Barra de atajos */
.tariff-shortcuts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

body.authed .tariff-shortcuts {
  border-color: #1e293b;
}

.tariff-shortcuts-label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}

body.authed .tariff-shortcuts-label {
  color: #94a3b8;
}

.tariff-chip-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

body.authed .tariff-chip-btn {
  background: #1e293b;
  border-color: #475569;
  color: #cbd5e1;
}

.tariff-chip-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

body.authed .tariff-chip-btn:hover {
  background: #334155;
  color: #ffffff;
}

.tariff-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: 12px 0;
}

.tariff-holidays-link {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.authed .tariff-holidays-link {
  color: #60a5fa;
}

.tariff-holidays-textarea {
  width: 100%;
  font-family: inherit;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  margin-top: 8px;
}

body.authed .tariff-holidays-textarea {
  background: #0f172a;
  border-color: #475569;
  color: #f8fafc;
}

@media (max-width: 768px) {
  .tariff-cards-row {
    grid-template-columns: 1fr;
  }
  .tariff-new-range-row {
    grid-template-columns: 1fr;
  }
  .tariff-calendar-grid {
    padding: 10px;
  }
  .tariff-grid-day-label, .tariff-grid-day-col--header {
    width: 65px;
    font-size: 11.5px;
  }
  .tariff-cell {
    height: 20px;
  }
}

/* ========================================
   WIDGET CRIPTOMONEDAS (Binance Spot)
   ======================================== */
.crypto-modal {
  max-width: 760px;
}

.crypto-header-icon {
  color: #f59e0b;
}

.crypto-modal-sub {
  color: #64748b;
  font-size: 13.5px;
  margin-bottom: 16px;
}

body.authed .crypto-modal-sub {
  color: #94a3b8;
}

.crypto-pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.crypto-select-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crypto-select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

body.authed .crypto-select {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

.crypto-select:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.crypto-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.crypto-pill {
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

body.authed .crypto-pill {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

.crypto-pill:hover {
  background: #e2e8f0;
  color: #0f172a;
}

body.authed .crypto-pill:hover {
  background: #334155;
  color: #f8fafc;
}

.crypto-pill.active {
  background: #f59e0b;
  border-color: #d97706;
  color: #000000;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

body.authed .crypto-pill.active {
  background: #f59e0b;
  border-color: #fbbf24;
  color: #000000;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
}

.crypto-custom-row {
  margin-top: 6px;
}

.crypto-custom-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

body.authed .crypto-custom-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

/* Tarjeta de Cotización en vivo */
.crypto-price-card {
  background: linear-gradient(135deg, #0b1120 0%, #111a33 100%);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
}

.crypto-price-card::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.crypto-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.crypto-pair-title-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crypto-pair-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f59e0b;
  text-transform: uppercase;
}

.crypto-pair-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 0.5px;
}

.crypto-refresh-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s;
}

.crypto-refresh-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #ffffff;
}

.crypto-card-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.crypto-price-main {
  display: flex;
  align-items: baseline;
}

.crypto-price-val {
  font-size: 32px;
  font-weight: 800;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.crypto-change-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.crypto-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.crypto-badge--pos {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.crypto-badge--neg {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.crypto-change-label {
  font-size: 11px;
  color: #94a3b8;
}

.crypto-stats-bar {
  display: flex;
  gap: 24px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.crypto-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crypto-stat-label {
  color: #94a3b8;
}

.crypto-stat-val {
  color: #e2e8f0;
  font-weight: 600;
}

.crypto-preview-status {
  margin-top: 10px;
  font-size: 11.5px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crypto-preview-status.is-ok {
  color: #38bdf8;
}

.crypto-preview-status.is-loading {
  color: #fbbf24;
}

.crypto-preview-status.is-error {
  color: #f87171;
}

/* Simulador Matriz LED 32x8 */
.crypto-matrix-box {
  background: #07090e;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.crypto-matrix-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.crypto-matrix-title {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crypto-matrix-modes-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.crypto-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
}

.crypto-mode-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

.crypto-mode-btn.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #f59e0b;
  font-weight: 700;
}

.crypto-matrix-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #05070a;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid #0f172a;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

#crypto_matrix_canvas {
  image-rendering: pixelated;
  border-radius: 4px;
  background: #0a0d14;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.9);
  width: 100%;
  max-width: 480px;
  height: auto;
  aspect-ratio: 32 / 8;
  display: block;
}

.crypto-anim-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.crypto-anim-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #ffffff;
}

.crypto-anim-btn.is-paused {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.crypto-ticker-preview-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.crypto-strip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.crypto-strip-item:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.crypto-strip-item.active {
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 0 1px #f59e0b;
}

.crypto-strip-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crypto-strip-val {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.crypto-matrix-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
  font-size: 11.5px;
  color: #94a3b8;
}

.crypto-matrix-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Opciones de personalización */
.crypto-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.crypto-option-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crypto-color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crypto-color-input {
  width: 44px;
  height: 36px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  background: transparent;
}

body.authed .crypto-color-input {
  border-color: #334155;
}

.crypto-interval-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
}

body.authed .crypto-interval-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

.crypto-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.crypto-btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 600px) {
  .crypto-pair-grid {
    grid-template-columns: 1fr;
  }
  .crypto-options-grid {
    grid-template-columns: 1fr;
  }
  .crypto-card-price-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .crypto-change-wrap {
    align-items: flex-start;
  }
}

/* ==========================================================================
   Widget Redes Sociales (YouTube, Twitch, Kick)
   ========================================================================== */
.social-modal {
  max-width: 680px;
}

.social-header-icon {
  color: #ef4444;
  margin-right: 6px;
}

.social-modal-sub {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 16px;
}

body.authed .social-modal-sub {
  color: #94a3b8;
}

.social-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

body.authed .social-section-title {
  color: #cbd5e1;
}

.social-platforms-row,
.social-metrics-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.social-platform-btn,
.social-metric-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

body.authed .social-platform-btn,
body.authed .social-metric-btn {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

.social-platform-btn:hover,
.social-metric-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

body.authed .social-platform-btn:hover,
body.authed .social-metric-btn:hover {
  background: #334155;
  border-color: #475569;
}

.social-platform-btn.active,
.social-metric-btn.active {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
  font-weight: 700;
  box-shadow: 0 0 0 1px #ef4444;
}

.social-icon-yt { color: #ff0000; font-size: 16px; }
.social-icon-tw { color: #9146ff; font-size: 16px; }
.social-icon-kick { color: #53fc18; font-size: 16px; }

/* Logotipo Kick: círculo con la K verde */
.icon-kick {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.18em;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10.5' fill='%23000000' stroke='%2353fc18' stroke-width='2.2'/%3E%3Cpath d='M7 6h2.8v4.5L13.6 6H17l-4.5 5.5L17.2 18h-3.4l-4-5.4V18H7V6z' fill='%2353fc18'/%3E%3C/svg%3E");
}

.social-platform-btn .icon-kick {
  width: 16px;
  height: 16px;
  vertical-align: -2px;
  margin-right: 4px;
}

.app-card--script .icon-kick {
  width: 22px;
  height: 22px;
  vertical-align: middle;
}

.social-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.social-form-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.social-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
  background: #ffffff;
  color: #0f172a;
  transition: border-color 0.15s ease;
}

select.social-input {
  cursor: pointer;
}

body.authed .social-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

.social-input:focus {
  outline: none;
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Caja de Ayuda y Enlaces */
.social-help-card {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
}

body.authed .social-help-card {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
}

.social-help-title {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

body.authed .social-help-title {
  color: #60a5fa;
}

.social-help-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.social-help-link {
  font-size: 12px;
  color: #3b82f6;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s ease;
}

.social-help-link:hover {
  text-decoration: underline;
  color: #1d4ed8;
}

body.authed .social-help-link {
  color: #93c5fd;
}

body.authed .social-help-link:hover {
  color: #bfdbfe;
}

.social-help-link span {
  color: #64748b;
  font-size: 11px;
}

body.authed .social-help-link span {
  color: #94a3b8;
}

/* Tarjeta de Vista Previa */
.social-preview-card {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

body.authed .social-preview-card {
  background: #1e293b;
  border-color: #334155;
}

.social-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.social-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.social-channel-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px;
  margin: -4px -8px;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.social-channel-link:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.social-channel-link:hover .social-channel-title span {
  text-decoration: underline;
}

.social-channel-link.is-disabled {
  pointer-events: none;
  cursor: default;
}

.social-channel-link.is-disabled .social-ext-icon {
  display: none;
}

.social-ext-icon {
  font-size: 11px;
  opacity: 0.6;
  margin-left: 4px;
  vertical-align: middle;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.social-channel-link:hover .social-ext-icon {
  opacity: 1;
  color: var(--accent, #3b82f6);
}

.social-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.social-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.social-channel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

body.authed .social-channel-title {
  color: #f8fafc;
}

.social-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.social-card-metric-row {
  margin-top: 10px;
}

.social-metric-val-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.social-count-val {
  font-size: 28px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
}

body.authed .social-count-val {
  color: #f8fafc;
}

.social-count-sub {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

body.authed .social-count-sub {
  color: #94a3b8;
}

.social-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  margin-right: 4px;
  animation: socialPulse 1.4s infinite;
}

@keyframes socialPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.social-preview-status {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.social-preview-status.is-ok {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.social-preview-status.is-loading {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.social-preview-status.is-error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.social-preview-status.is-notice {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.social-preview-status.is-idle {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
}

/* Simulador Matriz LED */
.social-matrix-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid #1e293b;
}

.social-matrix-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.social-matrix-title {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.social-anim-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
}

.social-anim-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

.social-matrix-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #05070a;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid #0f172a;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

#social_matrix_canvas {
  image-rendering: pixelated;
  border-radius: 4px;
  width: 320px;
  height: 80px;
  max-width: 100%;
}

.social-matrix-legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: #94a3b8;
  flex-wrap: wrap;
}

.social-matrix-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.social-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.social-option-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.social-color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.social-color-input {
  width: 44px;
  height: 36px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  background: transparent;
}

body.authed .social-color-input {
  border-color: #334155;
}

.social-interval-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
}

body.authed .social-interval-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

/* ==========================================================================
   Script Viewer Modal & Widget "Ver Script" Buttons
   ========================================================================== */
#widget_script_modal {
  z-index: 12000;
}

.script-viewer-dialog {
  max-width: 680px !important;
  width: 92% !important;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.script-viewer-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.script-viewer-badge {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-family: 'Consolas', 'Fira Code', monospace;
  letter-spacing: 0.5px;
}

.script-viewer-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.script-viewer-intro p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted, #475569);
}

body.authed .script-viewer-intro p {
  color: var(--muted, #94a3b8);
}

.script-viewer-code-container {
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #0f172a;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

body.authed .script-viewer-code-container {
  border-color: rgba(255, 255, 255, 0.12);
}

.script-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.script-viewer-size {
  font-size: 12px;
  color: #94a3b8;
  font-family: 'Consolas', 'Fira Code', monospace;
}

.script-viewer-copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.script-viewer-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.script-viewer-copy-btn.btn-copied,
.modal-button.btn-copied {
  background: #10b981 !important;
  color: #fff !important;
  border-color: #059669 !important;
}

.script-viewer-textarea {
  width: 100%;
  min-height: 280px;
  max-height: 480px;
  padding: 14px 16px;
  font-family: 'Consolas', 'Fira Code', 'Monaco', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #f1f5f9;
  background: #0f172a;
  border: none;
  outline: none;
  resize: vertical;
  white-space: pre;
  tab-size: 2;
  box-sizing: border-box;
}

.script-viewer-textarea::selection {
  background: #3b82f6;
  color: #fff;
}

.script-viewer-textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.script-viewer-textarea::-webkit-scrollbar-track {
  background: #0f172a;
}
.script-viewer-textarea::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 5px;
}
.script-viewer-textarea::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Secondary "Ver script" buttons styling */
.widget-view-script-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 600;
  cursor: pointer;
}

body:not(.authed) .widget-inline-send-btn.widget-view-script-btn,
body:not(.authed) .draw-option-button.widget-view-script-btn {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1 !important;
}

body:not(.authed) .widget-inline-send-btn.widget-view-script-btn:hover,
body:not(.authed) .draw-option-button.widget-view-script-btn:hover {
  background: #e2e8f0;
}

body.authed .widget-inline-send-btn.widget-view-script-btn,
body.authed .draw-option-button.widget-view-script-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--ink) !important;
  border: 1px solid var(--card-border) !important;
}

body.authed .widget-inline-send-btn.widget-view-script-btn:hover,
body.authed .draw-option-button.widget-view-script-btn:hover {
  background: rgba(255, 255, 255, 0.16) !important;
}

.draw-actions-row {
  display: flex;
  gap: 8px;
  margin-top: auto;
  width: 100%;
}

.draw-actions-row .draw-option-button {
  flex: 1;
  margin-top: 0 !important;
}

@media (max-width: 600px) {
  .draw-actions-row {
    flex-direction: column;
  }
}

/* ====================================================
   BOTÓN DE CONMUTACIÓN DE TEMA (CLARO / OSCURO)
   ==================================================== */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  box-sizing: border-box;
  padding: 0;
  margin: 0 !important;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fbbf24;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  position: relative;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.theme-toggle-btn:active {
  transform: scale(0.94);
}

.theme-toggle-btn i {
  font-size: 13.5px;
  line-height: 1;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

/* En tema oscuro: SOLO mostramos icono de sol para invitar a pasar a claro (luna estrictamente oculta) */
.theme-toggle-btn .theme-icon-sun,
body:not(.theme-light) .theme-toggle-btn .theme-icon-sun,
body.theme-dark .theme-toggle-btn .theme-icon-sun,
[data-theme="dark"] .theme-toggle-btn .theme-icon-sun {
  display: inline-block !important;
  color: #facc15 !important;
}

.theme-toggle-btn .theme-icon-moon,
body:not(.theme-light) .theme-toggle-btn .theme-icon-moon,
body.theme-dark .theme-toggle-btn .theme-icon-moon,
[data-theme="dark"] .theme-toggle-btn .theme-icon-moon {
  display: none !important;
}

/* En tema claro: SOLO mostramos icono de luna para pasar a oscuro (sol estrictamente oculto) */
body.theme-light .theme-toggle-btn .theme-icon-sun,
[data-theme="light"] .theme-toggle-btn .theme-icon-sun {
  display: none !important;
}

body.theme-light .theme-toggle-btn .theme-icon-moon,
[data-theme="light"] .theme-toggle-btn .theme-icon-moon {
  display: inline-block !important;
  color: #4f46e5 !important;
}

body.theme-light .theme-toggle-btn,
[data-theme="light"] .theme-toggle-btn {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #4f46e5 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

body.theme-light .theme-toggle-btn:hover,
[data-theme="light"] .theme-toggle-btn:hover {
  background: #e2e8f0 !important;
  border-color: #94a3b8 !important;
  color: #3730a3 !important;
}

/* Corrección de indicadores en tema oscuro */
body:not(.theme-light) .canvas-indicator,
body.theme-dark .canvas-indicator {
  background: rgba(15, 23, 42, 0.6) !important;
  border-color: var(--card-border) !important;
}
body:not(.theme-light) .canvas-indicator:hover,
body.theme-dark .canvas-indicator:hover {
  background: rgba(30, 41, 59, 0.8) !important;
  border-color: var(--accent1) !important;
}

/* ====================================================
   TEMA CLARO — LANDING PAGE
   ==================================================== */
body.theme-light #view_landing,
body.theme-light .landing {
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(224, 238, 255, 0.7) 0%, transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, rgba(243, 232, 255, 0.6) 0%, transparent 55%),
    radial-gradient(800px 400px at 50% 100%, rgba(254, 243, 235, 0.4) 0%, transparent 60%),
    linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%) !important;
  color: #1e293b !important;
}

body.theme-light .landing-hero h1 {
  color: #1e293b !important;
}

body.theme-light .landing-sub {
  color: #475569 !important;
}

body.theme-light .landing-badge {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
}

body.theme-light .landing-feature {
  background: rgba(253, 254, 255, 0.92) !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(100, 116, 139, 0.05) !important;
  backdrop-filter: blur(8px) !important;
}

body.theme-light .landing-feature strong {
  color: #1e293b !important;
}

body.theme-light .landing-feature span {
  color: #475569 !important;
}

body.theme-light .landing-feature i {
  color: #3b82f6 !important;
}

body.theme-light .beta-banner {
  background: #fffbeb !important;
  border: 1px solid #fde68a !important;
  color: #92400e !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.08) !important;
}

body.theme-light .fw-banner {
  background: #fef2f2 !important;
  border: 1px solid #fecaca !important;
  color: #991b1b !important;
}

body.theme-light .landing-foot {
  color: #64748b !important;
}

body.theme-light .landing-foot a {
  color: #2563eb !important;
}

body.theme-light .landing-enter-hint {
  color: #64748b !important;
}

body.theme-light .landing-top-bar {
  border-bottom: 1px solid #e2e8f0 !important;
}

body.theme-light .landing-enter-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%) !important;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3) !important;
}

body.theme-light .landing-enter-btn:hover {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%) !important;
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.4) !important;
}

/* ====================================================
   TEMA CLARO — HEADER SUPERIOR Y NAVEGACIÓN
   ==================================================== */
body.theme-light .app-header.site-header {
  background: rgba(253, 254, 255, 0.94) !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 2px 10px rgba(100, 116, 139, 0.05) !important;
}

body.theme-light .header-row--top {
  border-bottom: 1px solid #f1f5f9 !important;
}

body.theme-light .site-brand {
  color: #1e293b !important;
}

body.theme-light .site-brand:hover {
  opacity: 0.85;
}

body.theme-light .brand-title {
  background: linear-gradient(90deg, #2563eb, #7c3aed, #db2777) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  color: transparent !important;
}

body.theme-light .site-nav .nav-item,
body.theme-light.authed .site-nav .nav-item,
body.theme-light.authed .site-nav a {
  color: #475569 !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

body.theme-light .site-nav .nav-item i,
body.theme-light.authed .site-nav .nav-item i,
body.theme-light.authed .site-nav a i {
  color: #64748b !important;
}

body.theme-light .site-nav .nav-item:hover,
body.theme-light.authed .site-nav a:hover {
  color: #1e293b !important;
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

body.theme-light .site-nav .nav-item:hover i,
body.theme-light.authed .site-nav a:hover i {
  color: #2563eb !important;
}

body.theme-light .site-nav .nav-item.active,
body.theme-light.authed .site-nav a.active {
  color: #1d4ed8 !important;
  background: #eff6ff !important;
  border-color: #93c5fd !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12) !important;
}

body.theme-light .site-nav .nav-item.active i,
body.theme-light.authed .site-nav a.active i {
  color: #2563eb !important;
}

body.theme-light #nav-widgets,
body.theme-light.authed #nav-widgets,
body.theme-light .nav-item--widgets {
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: rgba(245, 158, 11, 0.4) !important;
  color: #b45309 !important;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.1) !important;
}

body.theme-light #nav-widgets i,
body.theme-light.authed #nav-widgets i,
body.theme-light .nav-item--widgets i {
  color: #d97706 !important;
}

body.theme-light #nav-widgets:hover,
body.theme-light.authed #nav-widgets:hover,
body.theme-light .nav-item--widgets:hover {
  background: rgba(245, 158, 11, 0.2) !important;
  border-color: rgba(245, 158, 11, 0.6) !important;
  color: #92400e !important;
  box-shadow: 0 3px 14px rgba(245, 158, 11, 0.2) !important;
}

body.theme-light #nav-widgets:hover i,
body.theme-light.authed #nav-widgets:hover i,
body.theme-light .nav-item--widgets:hover i {
  color: #b45309 !important;
}

body.theme-light #nav-widgets.active,
body.theme-light.authed #nav-widgets.active,
body.theme-light .nav-item--widgets.active {
  background: rgba(245, 158, 11, 0.25) !important;
  border-color: #f59e0b !important;
  color: #92400e !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.3) !important;
}

body.theme-light #nav-widgets.active i,
body.theme-light.authed #nav-widgets.active i,
body.theme-light .nav-item--widgets.active i {
  color: #b45309 !important;
}

body.theme-light .lang-select {
  color: #475569 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23475569' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E") !important;
}

body.theme-light .lang-select:hover,
body.theme-light .lang-select:focus {
  color: #0f172a !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%230f172a' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E") !important;
}

body.theme-light .lang-select option {
  background: #ffffff !important;
  color: #0f172a !important;
}

body.theme-light .topbar-device-card {
  background: rgba(0, 0, 0, 0.04) !important;
  border: 1px solid rgba(0, 0, 0, 0.09) !important;
}

body.theme-light .topbar-device-card:hover {
  border-color: rgba(0, 0, 0, 0.18) !important;
}

body.theme-light .sidebar-dev-select,
body.theme-light .topbar-dev-select {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

body.theme-light .sidebar-dev-select option,
body.theme-light .topbar-dev-select option {
  background: #ffffff !important;
  color: #0f172a !important;
}

body.theme-light .topbar-user-trigger {
  background: rgba(0, 0, 0, 0.04) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #0f172a !important;
}

body.theme-light .topbar-user-trigger:hover {
  background: rgba(0, 0, 0, 0.08) !important;
}

body.theme-light .topbar-user-dropdown {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
}

body.theme-light .user-dropdown-header {
  color: #64748b !important;
}

body.theme-light .user-dropdown-email {
  color: #0f172a !important;
}

body.theme-light .user-dropdown-divider {
  border-top-color: #e2e8f0 !important;
}

body.theme-light .user-dropdown-item {
  color: #334155 !important;
}

body.theme-light .user-dropdown-item:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

/* ====================================================
   TEMA CLARO — CONTENEDORES, TARJETAS Y TIPOGRAFÍA
   ==================================================== */
body.theme-light.authed .header,
body.theme-light.authed .section-container,
body.theme-light.authed .status-container,
body.theme-light.authed .status-preview,
body.theme-light.authed .loop-controls,
body.theme-light.authed .moodlight-controls,
body.theme-light.authed .sub-section,
body.theme-light.authed .widget-card,
body.theme-light.authed .widgets-gallery-single .widget-card-inline-form,
body.theme-light.authed .modal-dialog {
  background: rgba(253, 254, 255, 0.92) !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
  border-radius: 16px;
  box-shadow: 0 4px 20px -2px rgba(100, 116, 139, 0.06), 0 2px 6px -1px rgba(100, 116, 139, 0.04) !important;
  backdrop-filter: blur(8px) !important;
  color: #1e293b !important;
}

body.theme-light.authed .section h3,
body.theme-light.authed .section-container h4,
body.theme-light.authed .sub-section h4,
body.theme-light.authed .loop-header h4,
body.theme-light.authed .moodlight-header h4 {
  color: #1e293b !important;
  border-bottom-color: #e2e8f0 !important;
}

body.theme-light.authed label {
  color: #334155 !important;
}

body.theme-light.authed small,
body.theme-light.authed .sound-description,
body.theme-light.authed .melody-description {
  color: #64748b !important;
}

body.theme-light.authed p {
  color: #475569 !important;
}

body.theme-light.authed strong {
  color: #1e293b !important;
}

/* ====================================================
   TEMA CLARO — FORMULARIOS, INPUTS Y BOTONES
   ==================================================== */
body.theme-light.authed input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
body.theme-light.authed select:not(.lang-select):not(.mode-toggle-select),
body.theme-light.authed textarea {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  border-radius: 8px;
}

body.theme-light.authed input::placeholder,
body.theme-light.authed textarea::placeholder {
  color: #94a3b8 !important;
}

body.theme-light.authed input:focus,
body.theme-light.authed select:not(.lang-select):not(.mode-toggle-select):focus,
body.theme-light.authed textarea:focus {
  outline: none !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18) !important;
}

body.theme-light.authed select:not(.lang-select) option {
  background: #ffffff !important;
  color: #1e293b !important;
}

/* Botones en Tema Claro */
body.theme-light.authed button:not(.text-preset):not(.theme-toggle-btn):not(.lang-btn):not(.modal-close):not(.modal-button--secondary):not(.widget-view-script-btn):not(.weekday-btn):not(.sleep-chip-btn):not(.tariff-chip-btn):not(.user-dropdown-item):not(.topbar-logout-btn):not(.cloud-only):not(#btn_reboot):not(#btn_sleep):not(.auto-brightness-btn):not(.setting-row-actions button):not(.colorbox button),
body.theme-light.authed .modal-button--primary,
body.theme-light.authed .widget-card-btn,
body.theme-light.authed .widget-inline-send-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%) !important;
  border: 1px solid rgba(37, 99, 235, 0.25) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.22) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease !important;
}

body.theme-light.authed button:not(.text-preset):not(.theme-toggle-btn):not(.lang-btn):not(.modal-close):not(.modal-button--secondary):not(.widget-view-script-btn):not(.weekday-btn):not(.sleep-chip-btn):not(.tariff-chip-btn):not(.user-dropdown-item):not(.topbar-logout-btn):not(.cloud-only):not(#btn_reboot):not(#btn_sleep):not(.auto-brightness-btn):not(.setting-row-actions button):not(.colorbox button):hover,
body.theme-light.authed .modal-button--primary:hover,
body.theme-light.authed .widget-card-btn:hover,
body.theme-light.authed .widget-inline-send-btn:hover {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%) !important;
  filter: brightness(1.05) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3) !important;
}

body.theme-light #btn_reboot,
body.theme-light #btn_sleep {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}
body.theme-light #btn_reboot:hover,
body.theme-light #btn_sleep:hover {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

body.theme-light.authed .modal-button--secondary {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-light.authed .modal-button--secondary:hover {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

body.theme-light.authed .result {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}

body.theme-light.authed .control-container,
body.theme-light.authed .power-toggle-container,
body.theme-light.authed .sound-toggle-container,
body.theme-light.authed .volume-control-container {
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
}

body.theme-light.authed .power-toggle-text {
  color: #1e293b !important;
  text-shadow: none !important;
}

body.theme-light.authed .volume-control-container i,
body.theme-light.authed #volume_value {
  color: #334155 !important;
}

body.theme-light.authed .status-preview .brightness-controls {
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
}

body.theme-light.authed .auto-brightness-btn {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-light.authed .auto-brightness-btn:hover {
  background: #f8fafc !important;
  color: #1e293b !important;
}

body.theme-light.authed .auto-brightness-btn.active {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  border-color: #fbbf24 !important;
  color: #fff !important;
}

body.theme-light.authed .brightness-slider-wrapper input[type="range"] {
  background: linear-gradient(to right, #cbd5e1 0%, #38bdf8 100%) !important;
}

/* Modales */
body.theme-light .modal-overlay {
  background: rgba(15, 23, 42, 0.4) !important;
  backdrop-filter: blur(6px) !important;
}

body.theme-light.authed .modal-dialog,
body.theme-light .modal-dialog {
  background: #fdfefe !important;
  color: #1e293b !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 16px 40px rgba(100, 116, 139, 0.12) !important;
}

body.theme-light .modal-header {
  background: #fdfefe !important;
  border-bottom: 1px solid #e2e8f0 !important;
  color: #1e293b !important;
  padding: 16px 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

body.theme-light .modal-header h3 {
  color: #1e293b !important;
  margin: 0 !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  border-bottom: none !important;
}

body.theme-light .modal-header h3 i {
  color: #2563eb !important;
}

body:not(.theme-light) .modal-header h3 {
  color: #ffffff !important;
  margin: 0 !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  border-bottom: none !important;
}

.modal-close {
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.7) !important;
  font-size: 22px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  padding: 0 !important;
  border-radius: 6px !important;
  transition: all 0.15s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 28px !important;
}

.modal-close:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.12) !important;
}

body.theme-light .modal-close {
  color: #64748b !important;
}

body.theme-light .modal-close:hover {
  color: #0f172a !important;
  background: rgba(0, 0, 0, 0.06) !important;
}

body.theme-light .modal-footer {
  background: #f8fafc !important;
  border-top: 1px solid #e2e8f0 !important;
}

body.theme-light .text-designer-box,
body.theme-light .widget-form-box,
body.theme-light fieldset.text-designer-box {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

body.theme-light .text-designer .widget-inline-color-label {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

body.theme-light .text-designer-label {
  color: #334155 !important;
}

body.theme-light .text-designer-count {
  color: #64748b !important;
}

body.theme-light .text-hex {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

/* Galería de Widgets en tema claro */
body.theme-light .widget-card {
  background: rgba(253, 254, 255, 0.95) !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(100, 116, 139, 0.05) !important;
}

body.theme-light .widget-card:hover {
  border-color: #93c5fd !important;
  box-shadow: 0 8px 24px rgba(100, 116, 139, 0.08) !important;
}

body.theme-light .widget-card h4 {
  color: #1e293b !important;
}

body.theme-light .widget-card p {
  color: #475569 !important;
}

/* Loop y scripts */
body.theme-light .loop-item {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #1e293b !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
}

body.theme-light .loop-item strong {
  color: #1e293b !important;
}

/* Sleep widget */
body.theme-light .sleep-section {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

body.theme-light .sleep-chip-btn {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-light .sleep-chip-btn:hover {
  background: #f1f5f9 !important;
  color: #1e293b !important;
}

body.theme-light .sleep-chip-btn.active {
  background: #3b82f6 !important;
  color: #ffffff !important;
  border-color: #3b82f6 !important;
}

body.theme-light .sleep-summary-item {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #1e293b !important;
}

body.theme-light .sleep-time-label,
body.theme-light .sleep-summary-sub {
  color: #64748b !important;
}

body.theme-light .weekday-btn span {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-light .weekday-btn:hover span {
  background: #f1f5f9 !important;
  color: #1e293b !important;
}

body.theme-light .weekday-btn input[type="checkbox"]:checked + span {
  background: #3b82f6 !important;
  color: #ffffff !important;
  border-color: #3b82f6 !important;
}

/* Tarifas */
body.theme-light .tariff-modal-sub {
  color: #64748b !important;
}

body.theme-light .tariff-ranges-section {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

body.theme-light .tariff-ranges-header h4 {
  color: #1e293b !important;
}

body.theme-light .tariff-card--valle {
  background: #f0f9ff !important;
  color: #0369a1 !important;
  border-color: #bae6fd !important;
}

body.theme-light .tariff-card--llano {
  background: #fefce8 !important;
  color: #854d0e !important;
  border-color: #fef08a !important;
}

body.theme-light .tariff-card--punta {
  background: #fef2f2 !important;
  color: #991b1b !important;
  border-color: #fecaca !important;
}

body.theme-light .tariff-chip-btn {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-light .tariff-chip-btn:hover {
  background: #f1f5f9 !important;
  color: #1e293b !important;
}

body.theme-light .tariff-holidays-textarea {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

/* Cripto widget */
body.theme-light .crypto-modal-sub {
  color: #64748b !important;
}

body.theme-light .crypto-select {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

body.theme-light .crypto-pill {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #475569 !important;
}

body.theme-light .crypto-pill:hover {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

/* ====================================================
   AJUSTES (SETTINGS) — TEMA OSCURO
   ==================================================== */
body:not(.theme-light) .setting-row,
body.theme-dark .setting-row,
[data-theme="dark"] .setting-row {
  background: rgba(255, 255, 255, 0.035) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #f1f5f9 !important;
  border-radius: 8px !important;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

body:not(.theme-light) .setting-row:hover,
body.theme-dark .setting-row:hover,
[data-theme="dark"] .setting-row:hover {
  background: rgba(255, 255, 255, 0.065) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
}

body:not(.theme-light) .setting-row-name,
body.theme-dark .setting-row-name,
[data-theme="dark"] .setting-row-name {
  color: #60a5fa !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  font-weight: 600 !important;
  font-size: 13px !important;
}

body:not(.theme-light) .setting-row-desc,
body.theme-dark .setting-row-desc,
[data-theme="dark"] .setting-row-desc {
  color: #94a3b8 !important;
}

body:not(.theme-light) .setting-row-check,
body.theme-dark .setting-row-check,
[data-theme="dark"] .setting-row-check {
  color: #cbd5e1 !important;
}

body:not(.theme-light) .setting-row-status,
body.theme-dark .setting-row-status,
[data-theme="dark"] .setting-row-status {
  color: #94a3b8 !important;
}

body:not(.theme-light) .setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
body:not(.theme-light) .setting-row-ctrl select,
body.theme-dark .setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
body.theme-dark .setting-row-ctrl select,
[data-theme="dark"] .setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
[data-theme="dark"] .setting-row-ctrl select {
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #f1f5f9 !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
}

body:not(.theme-light) .setting-row-ctrl input:focus,
body:not(.theme-light) .setting-row-ctrl select:focus,
body.theme-dark .setting-row-ctrl input:focus,
body.theme-dark .setting-row-ctrl select:focus,
[data-theme="dark"] .setting-row-ctrl input:focus,
[data-theme="dark"] .setting-row-ctrl select:focus {
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25) !important;
  outline: none !important;
}

body:not(.theme-light) .setting-row-actions button,
body.theme-dark .setting-row-actions button,
[data-theme="dark"] .setting-row-actions button {
  background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
  border-radius: 6px !important;
  padding: 5px 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

body:not(.theme-light) .setting-row-actions button:hover,
body.theme-dark .setting-row-actions button:hover,
[data-theme="dark"] .setting-row-actions button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35) !important;
}

body:not(.theme-light) .setting-row-actions button.cloud-only,
body.theme-dark .setting-row-actions button.cloud-only,
[data-theme="dark"] .setting-row-actions button.cloud-only {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #cbd5e1 !important;
}

body:not(.theme-light) .setting-row-actions button.cloud-only:hover,
body.theme-dark .setting-row-actions button.cloud-only:hover,
[data-theme="dark"] .setting-row-actions button.cloud-only:hover {
  background: rgba(255, 255, 255, 0.14) !important;
  color: #ffffff !important;
}

body:not(.theme-light) .colorbox button,
body.theme-dark .colorbox button,
[data-theme="dark"] .colorbox button {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #93c5fd !important;
  border-radius: 6px !important;
  padding: 4px 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  cursor: pointer;
}

body:not(.theme-light) .colpreview,
body.theme-dark .colpreview,
[data-theme="dark"] .colpreview {
  border: 2px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 6px !important;
}

/* ====================================================
   AJUSTES (SETTINGS) — TEMA CLARO
   ==================================================== */
body.theme-light .setting-row,
[data-theme="light"] .setting-row {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #1e293b !important;
  border-radius: 8px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02) !important;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

body.theme-light .setting-row:hover,
[data-theme="light"] .setting-row:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
}

body.theme-light .setting-row-name,
[data-theme="light"] .setting-row-name {
  color: #2563eb !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  font-weight: 600 !important;
  font-size: 13px !important;
}

body.theme-light .setting-row-desc,
[data-theme="light"] .setting-row-desc {
  color: #475569 !important;
}

body.theme-light .setting-row-check,
[data-theme="light"] .setting-row-check {
  color: #334155 !important;
}

body.theme-light .setting-row-status,
[data-theme="light"] .setting-row-status {
  color: #64748b !important;
}

body.theme-light .setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
body.theme-light .setting-row-ctrl select,
[data-theme="light"] .setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
[data-theme="light"] .setting-row-ctrl select {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
}

body.theme-light .setting-row-ctrl input:focus,
body.theme-light .setting-row-ctrl select:focus,
[data-theme="light"] .setting-row-ctrl input:focus,
[data-theme="light"] .setting-row-ctrl select:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
  outline: none !important;
}

body.theme-light .setting-row-actions button,
[data-theme="light"] .setting-row-actions button {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  border: 1px solid #2563eb !important;
  color: #ffffff !important;
  border-radius: 6px !important;
  padding: 5px 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

body.theme-light .setting-row-actions button:hover,
[data-theme="light"] .setting-row-actions button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3) !important;
}

body.theme-light .setting-row-actions button.cloud-only,
[data-theme="light"] .setting-row-actions button.cloud-only {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
  box-shadow: none !important;
}

body.theme-light .setting-row-actions button.cloud-only:hover,
[data-theme="light"] .setting-row-actions button.cloud-only:hover {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

body.theme-light .colorbox button,
[data-theme="light"] .colorbox button {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
  border-radius: 6px !important;
  padding: 4px 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  cursor: pointer;
}

body.theme-light .colpreview,
[data-theme="light"] .colpreview {
  border: 2px solid #cbd5e1 !important;
  border-radius: 6px !important;
}

/* Conexión */
body.theme-light .lan-ip-desc {
  color: #475569 !important;
}

body.theme-light .lan-ip-form-row label {
  color: #1e293b !important;
}

body.theme-light .lan-cloud-divider {
  color: #64748b !important;
}

body.theme-light .lan-cloud-hint {
  color: #64748b !important;
}

body.theme-light .conn-device-card {
  background: #fdfefe !important;
  border: 1px solid #e2e8f0 !important;
  color: #1e293b !important;
  box-shadow: 0 2px 8px rgba(100, 116, 139, 0.05) !important;
}

/* Viewer de scripts */
body.theme-light.authed .widget-inline-send-btn.widget-view-script-btn,
body.theme-light.authed .draw-option-button.widget-view-script-btn {
  background: #f1f5f9 !important;
  color: #334155 !important;
  border: 1px solid #cbd5e1 !important;
}

body.theme-light.authed .widget-inline-send-btn.widget-view-script-btn:hover,
body.theme-light.authed .draw-option-button.widget-view-script-btn:hover {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

/* Posiciones de presets de brillo, muestras crypto y filas de plantillas de dibujo (sin estilos inline) */
.brightness-preset-btn[data-arg="25"]  { left: calc(10px + (100% - 20px) * 0.098); }
.brightness-preset-btn[data-arg="75"]  { left: calc(10px + (100% - 20px) * 0.294); }
.brightness-preset-btn[data-arg="128"] { left: 50%; }
.brightness-preset-btn[data-arg="200"] { left: calc(10px + (100% - 20px) * 0.784); }
.brightness-preset-btn[data-arg="255"] { left: calc(100% - 10px); }

#crypto_strip_pair,
#crypto_legend_pair_dot { color: #F59E0B; }
#crypto_strip_price,
.u-color-white { color: #FFFFFF; }
#crypto_strip_change { color: #4ade80; }
.u-color-pos { color: #00E676; }
.u-color-neg { color: #FF5252; }

.text-preset[data-click="crypto-preset-color"][data-arg="#F59E0B"] { background: #F59E0B !important; }
.text-preset[data-click="crypto-preset-color"][data-arg="#00E5FF"] { background: #00E5FF !important; }
.text-preset[data-click="crypto-preset-color"][data-arg="#A855F7"] { background: #A855F7 !important; }
.text-preset[data-click="crypto-preset-color"][data-arg="#3B82F6"] { background: #3B82F6 !important; }
.text-preset[data-click="crypto-preset-color"][data-arg="#10B981"] { background: #10B981 !important; }
.text-preset[data-click="crypto-preset-color"][data-arg="#EC4899"] { background: #EC4899 !important; }

.draw-template-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--card-border, #eee);
}
.draw-template-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ============================================================================
   MODERN UI REDESIGN LAYER (2026-10)
   - Tipografía Inter + JetBrains Mono
   - Header unificado con navegación segmentada coherente
   - Status Dashboard: barra de controles unificada, marco LED realista,
     acceso rápido refinado a Widgets y tarjeta moderna para Apps en Loop
   - Galería de Widgets estilo App Store con iconos por categoría
   - Explorador de Ajustes con pestañas por categoría y buscador instantáneo
   - Tarjetas de dispositivos en Conexión con botón de copiar token
   ============================================================================ */

/* --- 1. LANDING HERO CTA & NOTICES --- */
.landing-hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 22px 0 18px;
}

.landing-enter-btn--hero {
  padding: 13px 26px;
  font-size: 15px;
  border-radius: 12px;
}

.landing-secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 22px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink, #f1f5f9);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.landing-secondary-btn:hover {
  background: rgba(96, 165, 250, 0.14);
  border-color: rgba(96, 165, 250, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
}

body.theme-light .landing-secondary-btn,
[data-theme="light"] .landing-secondary-btn {
  color: #1e293b;
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(148, 163, 184, 0.4);
}

body.theme-light .landing-secondary-btn:hover,
[data-theme="light"] .landing-secondary-btn:hover {
  background: #ffffff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.landing-notices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 680px;
  margin: 0 auto;
}

.landing-notices .beta-banner,
.landing-notices .fw-banner {
  margin: 0;
  font-size: 12.5px;
  padding: 9px 14px;
  border-radius: 10px;
}

/* --- 2. UNIFIED HEADER & SEGMENTED NAVIGATION --- */
.site-header {
  background: rgba(9, 13, 26, 0.84) !important;
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09) !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.28) !important;
}

body.theme-light .site-header,
[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.88) !important;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22) !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05) !important;
}

.site-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
}

body.theme-light .site-nav,
[data-theme="light"] .site-nav {
  background: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.25);
}

.site-nav .nav-item,
.site-nav .nav-item.nav-item--widgets {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px !important;
  border-radius: 9px !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  color: #94a3b8 !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease !important;
}

body.theme-light .site-nav .nav-item,
body.theme-light .site-nav .nav-item.nav-item--widgets,
[data-theme="light"] .site-nav .nav-item,
[data-theme="light"] .site-nav .nav-item.nav-item--widgets {
  color: #475569 !important;
}

.site-nav .nav-item:hover,
.site-nav .nav-item.nav-item--widgets:hover {
  color: #f8fafc !important;
  background: rgba(255, 255, 255, 0.06) !important;
  transform: none !important;
}

body.theme-light .site-nav .nav-item:hover,
body.theme-light .site-nav .nav-item.nav-item--widgets:hover,
[data-theme="light"] .site-nav .nav-item:hover,
[data-theme="light"] .site-nav .nav-item.nav-item--widgets:hover {
  color: #0f172a !important;
  background: rgba(255, 255, 255, 0.7) !important;
}

.site-nav .nav-item.active,
.site-nav .nav-item.nav-item--widgets.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  border-color: rgba(96, 165, 250, 0.4) !important;
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.35) !important;
}

body.theme-light .site-nav .nav-item.active,
body.theme-light .site-nav .nav-item.nav-item--widgets.active,
[data-theme="light"] .site-nav .nav-item.active,
[data-theme="light"] .site-nav .nav-item.nav-item--widgets.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.28) !important;
}

/* --- 3. STATUS DASHBOARD & HARDWARE MATRIX BEZEL --- */
.status-preview {
  background: linear-gradient(180deg, rgba(19, 28, 53, 0.85) 0%, rgba(12, 18, 36, 0.92) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 18px !important;
  padding: 18px 20px !important;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32) !important;
}

body.theme-light .status-preview,
[data-theme="light"] .status-preview {
  background: #ffffff !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06) !important;
}

.status-top-controls .power-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(9, 13, 26, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  margin-bottom: 14px;
}

body.theme-light .status-top-controls .power-buttons,
[data-theme="light"] .status-top-controls .power-buttons {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.power-toggle-container,
.sound-toggle-container,
.volume-control-container,
.sleep-control,
.reboot-button-container {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
  border-radius: 10px !important;
  box-shadow: none !important;
}

body.theme-light .power-toggle-container,
body.theme-light .sound-toggle-container,
body.theme-light .volume-control-container,
body.theme-light .sleep-control,
body.theme-light .reboot-button-container,
[data-theme="light"] .power-toggle-container,
[data-theme="light"] .sound-toggle-container,
[data-theme="light"] .volume-control-container,
[data-theme="light"] .sleep-control,
[data-theme="light"] .reboot-button-container {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
}

.canvas-screen-box {
  background: #05070d !important;
  border: 3px solid #1e293b !important;
  border-radius: 14px !important;
  padding: 10px !important;
  box-shadow:
    inset 0 2px 12px rgba(0, 0, 0, 0.85),
    0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

/* Quick-access Widgets Banner Card on Status */
.btn-status-widgets {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 14px !important;
  width: 100%;
  padding: 12px 18px !important;
  margin: 14px 0 !important;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.14) 0%, rgba(139, 92, 246, 0.14) 100%) !important;
  border: 1px solid rgba(96, 165, 250, 0.32) !important;
  border-radius: 14px !important;
  color: var(--ink, #f1f5f9) !important;
  text-align: left !important;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18) !important;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease !important;
}

.btn-status-widgets:hover {
  transform: translateY(-2px) !important;
  border-color: rgba(96, 165, 250, 0.65) !important;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22) 0%, rgba(139, 92, 246, 0.22) 100%) !important;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.22) !important;
}

body.theme-light .btn-status-widgets,
[data-theme="light"] .btn-status-widgets {
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%) !important;
  border-color: #bfdbfe !important;
  color: #0f172a !important;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.06) !important;
}

body.theme-light .btn-status-widgets:hover,
[data-theme="light"] .btn-status-widgets:hover {
  border-color: #60a5fa !important;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.14) !important;
}

.btn-status-widgets__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  color: #ffffff;
  font-size: 17px !important;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-status-widgets__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.btn-status-widgets__text strong {
  font-size: 14.5px;
  font-weight: 700;
  color: inherit;
  letter-spacing: -0.01em;
}

.btn-status-widgets__text small {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted-dim, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-light .btn-status-widgets__text small,
[data-theme="light"] .btn-status-widgets__text small {
  color: #475569;
}

.btn-status-widgets__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #93c5fd;
  font-size: 13px !important;
  transition: transform 0.18s ease, background 0.18s ease;
}

body.theme-light .btn-status-widgets__arrow,
[data-theme="light"] .btn-status-widgets__arrow {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.btn-status-widgets:hover .btn-status-widgets__arrow {
  transform: translateX(3px);
}

/* Loop Controls Modern Card */
.loop-controls {
  border-radius: 18px !important;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  background: rgba(15, 23, 42, 0.72) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.26) !important;
}

body.theme-light .loop-controls,
[data-theme="light"] .loop-controls {
  background: #ffffff !important;
  border-color: rgba(148, 163, 184, 0.25) !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05) !important;
}

.loop-header {
  background: rgba(255, 255, 255, 0.03) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 13px 18px !important;
}

body.theme-light .loop-header,
[data-theme="light"] .loop-header {
  background: #f8fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

.loop-header h4 {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--ink, #f1f5f9) !important;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.loop-header h4 i {
  color: #60a5fa !important;
}

body.theme-light .loop-header h4,
[data-theme="light"] .loop-header h4 {
  color: #0f172a !important;
}

body.theme-light .loop-header h4 i,
[data-theme="light"] .loop-header h4 i {
  color: #2563eb !important;
}

.loop-header .status-navigation button {
  width: 34px !important;
  height: 34px !important;
  border-radius: 9px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #e2e8f0 !important;
  transition: all 0.15s ease !important;
}

.loop-header .status-navigation button:hover {
  background: rgba(59, 130, 246, 0.22) !important;
  border-color: rgba(96, 165, 250, 0.5) !important;
  color: #ffffff !important;
  transform: translateY(-1px);
}

body.theme-light .loop-header .status-navigation button,
[data-theme="light"] .loop-header .status-navigation button {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-light .loop-header .status-navigation button:hover,
[data-theme="light"] .loop-header .status-navigation button:hover {
  background: #eff6ff !important;
  border-color: #60a5fa !important;
  color: #1d4ed8 !important;
}

/* --- 4. WIDGETS GALLERY (APP STORE BENTO CARDS) --- */
.widgets-gallery {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)) !important;
  gap: 16px !important;
}

.widget-card {
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  text-align: left !important;
  padding: 20px !important;
  border-radius: 16px !important;
  background: rgba(19, 28, 53, 0.72) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease !important;
}

.widget-card:hover {
  transform: translateY(-4px) !important;
  background: rgba(25, 37, 68, 0.9) !important;
  border-color: rgba(96, 165, 250, 0.45) !important;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(96, 165, 250, 0.18) !important;
}

body.theme-light .widget-card,
[data-theme="light"] .widget-card {
  background: #ffffff !important;
  border: 1px solid rgba(148, 163, 184, 0.26) !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04) !important;
}

body.theme-light .widget-card:hover,
[data-theme="light"] .widget-card:hover {
  background: #ffffff !important;
  border-color: #60a5fa !important;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.12) !important;
}

.widget-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 14px;
}

.widget-card-icon {
  width: 46px !important;
  height: 46px !important;
  min-width: 46px;
  border-radius: 12px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
  margin: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.2s ease;
}

.widget-card:hover .widget-card-icon {
  transform: scale(1.06);
}

.widget-card-icon--blue    { background: rgba(59, 130, 246, 0.18); color: #60a5fa; border-color: rgba(59, 130, 246, 0.35); }
.widget-card-icon--rose    { background: rgba(244, 63, 94, 0.18);  color: #fb7185; border-color: rgba(244, 63, 94, 0.35); }
.widget-card-icon--amber   { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border-color: rgba(245, 158, 11, 0.35); }
.widget-card-icon--cyan    { background: rgba(6, 182, 212, 0.18);  color: #22d3ee; border-color: rgba(6, 182, 212, 0.35); }
.widget-card-icon--emerald { background: rgba(16, 185, 129, 0.18); color: #34d399; border-color: rgba(16, 185, 129, 0.35); }
.widget-card-icon--orange  { background: rgba(249, 115, 22, 0.18); color: #fb923c; border-color: rgba(249, 115, 22, 0.35); }
.widget-card-icon--indigo  { background: rgba(99, 102, 241, 0.18); color: #818cf8; border-color: rgba(99, 102, 241, 0.35); }
.widget-card-icon--yellow  { background: rgba(234, 179, 8, 0.18);  color: #facc15; border-color: rgba(234, 179, 8, 0.35); }
.widget-card-icon--purple  { background: rgba(168, 85, 247, 0.18); color: #c084fc; border-color: rgba(168, 85, 247, 0.35); }

.widget-card-icon--social-trio {
  width: auto !important;
  min-width: 58px !important;
  height: 46px !important;
  padding: 0 10px !important;
  gap: 7px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.16) 0%, rgba(145, 70, 255, 0.16) 50%, rgba(83, 252, 24, 0.16) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 12px !important;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.widget-card-icon--social-trio .social-trio-yt {
  color: #ff0000;
  font-size: 16px;
  filter: drop-shadow(0 1px 2px rgba(255, 0, 0, 0.35));
  transition: transform 0.2s ease;
}

.widget-card-icon--social-trio .social-trio-tw {
  color: #a970ff;
  font-size: 15px;
  filter: drop-shadow(0 1px 2px rgba(145, 70, 255, 0.35));
  transition: transform 0.2s ease;
}

.widget-card-icon--social-trio .social-trio-kick {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(83, 252, 24, 0.35));
  transition: transform 0.2s ease;
}

.widget-card:hover .widget-card-icon--social-trio .social-trio-yt,
.widget-card:hover .widget-card-icon--social-trio .social-trio-tw,
.widget-card:hover .widget-card-icon--social-trio .social-trio-kick {
  transform: translateY(-1px) scale(1.12);
}

body.theme-light .widget-card-icon--blue    { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
body.theme-light .widget-card-icon--rose    { background: #fff1f2; color: #e11d48; border-color: #fecdd3; }
body.theme-light .widget-card-icon--amber   { background: #fffbeb; color: #d97706; border-color: #fde68a; }
body.theme-light .widget-card-icon--cyan    { background: #ecfeff; color: #0891b2; border-color: #a5f3fc; }
body.theme-light .widget-card-icon--emerald { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }
body.theme-light .widget-card-icon--orange  { background: #fff7ed; color: #ea580c; border-color: #fed7aa; }
body.theme-light .widget-card-icon--indigo  { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
body.theme-light .widget-card-icon--yellow  { background: #fefce8; color: #ca8a04; border-color: #fef08a; }
body.theme-light .widget-card-icon--purple  { background: #faf5ff; color: #9333ea; border-color: #e9d5ff; }
body.theme-light .widget-card-icon--social-trio {
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.08) 0%, rgba(145, 70, 255, 0.08) 50%, rgba(83, 252, 24, 0.08) 100%) !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

.widget-card-arrow {
  font-size: 13px;
  color: var(--muted-dim, #64748b);
  opacity: 0.55;
  transition: transform 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}

.widget-card:hover .widget-card-arrow {
  opacity: 1;
  color: #60a5fa;
  transform: translate(2px, -2px);
}

.widget-card h4 {
  font-size: 16px !important;
  font-weight: 700 !important;
  margin: 0 0 6px 0 !important;
  letter-spacing: -0.01em;
}

.widget-card p {
  font-size: 13px !important;
  line-height: 1.45 !important;
  margin: 0 0 16px 0 !important;
  flex: 1;
}

.widget-card-btn {
  width: 100%;
  padding: 9px 14px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  background: rgba(59, 130, 246, 0.14) !important;
  border: 1px solid rgba(96, 165, 250, 0.3) !important;
  color: #93c5fd !important;
  box-shadow: none !important;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease !important;
}

.widget-card:hover .widget-card-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
}

body.theme-light .widget-card-btn,
[data-theme="light"] .widget-card-btn {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

body.theme-light .widget-card:hover .widget-card-btn,
[data-theme="light"] .widget-card:hover .widget-card-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}

/* Compact hint-box in widget modals */
.modal-widget .hint-box {
  font-size: 12.5px !important;
  line-height: 1.45 !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
}

/* --- 5. SETTINGS EXPLORER (CATEGORY TABS + SEARCH + MODERN ROWS) --- */
.settings-explorer-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
}

body.theme-light .settings-explorer-bar,
[data-theme="light"] .settings-explorer-bar {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.settings-cat-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.settings-cat-tab {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.16s ease;
}

.settings-cat-tab:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}

.settings-cat-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}

body.theme-light .settings-cat-tab,
[data-theme="light"] .settings-cat-tab {
  color: #475569;
  background: #ffffff;
  border-color: #cbd5e1;
}

body.theme-light .settings-cat-tab:hover,
[data-theme="light"] .settings-cat-tab:hover {
  color: #0f172a;
  border-color: #94a3b8;
}

body.theme-light .settings-cat-tab.active,
[data-theme="light"] .settings-cat-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: #2563eb;
}

.settings-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
}

.settings-search-box i {
  position: absolute;
  left: 12px;
  color: #64748b;
  font-size: 13px;
  pointer-events: none;
}

.settings-search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px !important;
  border-radius: 10px !important;
  font-size: 13.5px !important;
  background: rgba(9, 13, 26, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: var(--ink, #f1f5f9) !important;
  margin: 0 !important;
}

.settings-search-box input:focus {
  outline: none !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18) !important;
}

body.theme-light .settings-search-box input,
[data-theme="light"] .settings-search-box input {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

.settings-read-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  background: rgba(59, 130, 246, 0.16) !important;
  border: 1px solid rgba(96, 165, 250, 0.35) !important;
  color: #93c5fd !important;
  cursor: pointer;
  transition: all 0.16s ease;
}

.settings-read-all-btn:hover {
  background: rgba(59, 130, 246, 0.28) !important;
  color: #ffffff !important;
}

body.theme-light .settings-read-all-btn,
[data-theme="light"] .settings-read-all-btn {
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
  color: #1d4ed8 !important;
}

/* Setting row hierarchy: Human description primary, technical key badge secondary */
.setting-row-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.setting-row-desc {
  font-size: 13.5px !important;
  font-weight: 600 !important;
  color: var(--ink, #f1f5f9) !important;
}

body.theme-light .setting-row-desc,
[data-theme="light"] .setting-row-desc {
  color: #0f172a !important;
}

code.setting-row-name {
  font-family: var(--font-mono) !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8 !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.theme-light code.setting-row-name,
[data-theme="light"] code.setting-row-name {
  background: #f1f5f9;
  color: #475569 !important;
  border-color: #e2e8f0;
}

/* Hide empty #result box so it doesn't leave an empty dark frame */
.result:empty {
  display: none !important;
}

/* --- 6. CONNECTION DEVICE CARDS --- */
.device-list-empty {
  display: block;
  margin-top: 8px;
  color: var(--muted-dim, #94a3b8);
}

.device-card-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.device-card-row.is-primary {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.15);
}

body.theme-light .device-card-row,
[data-theme="light"] .device-card-row {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

body.theme-light .device-card-row.is-primary,
[data-theme="light"] .device-card-row.is-primary {
  border-color: #3b82f6;
  background: #f8fbff;
}

.device-primary-radio {
  width: 16px !important;
  height: 16px !important;
  margin: 0 2px 0 0 !important;
  accent-color: #3b82f6;
  cursor: pointer;
}

.device-alias-input {
  width: 125px !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  margin: 0 !important;
}

.device-token-group {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 180px;
  gap: 4px;
}

.device-token-input {
  flex: 1;
  min-width: 120px;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  margin: 0 !important;
  opacity: 0.9;
}

.device-ip-field {
  width: 132px !important;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  margin: 0 !important;
}

.device-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0 !important;
  font-size: 12.5px !important;
  border-radius: 8px !important;
  margin: 0 !important;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
  transition: all 0.15s ease;
}

.device-action-btn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(96, 165, 250, 0.5);
  color: #ffffff;
}

.device-action-btn.is-copied {
  background: rgba(34, 197, 94, 0.2) !important;
  border-color: rgba(34, 197, 94, 0.5) !important;
  color: #4ade80 !important;
}

.device-action-btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: #f87171 !important;
}

body.theme-light .device-action-btn,
[data-theme="light"] .device-action-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

body.theme-light .device-action-btn:hover:not(:disabled),
[data-theme="light"] .device-action-btn:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.device-meta-row {
  flex-basis: 100%;
  font-size: 11.5px;
  color: var(--muted-dim, #94a3b8);
  padding-left: 24px;
}

@media (max-width: 640px) {
  .btn-status-widgets__text small {
    white-space: normal;
  }
  .device-meta-row {
    padding-left: 0;
  }
}

.landing-brand {
  cursor: default;
}

.landing-brand .beta-pill {
  margin-left: 6px;
  vertical-align: middle;
}

/* ============================================================================
   STATUS PASO 1: REDISEÑO DE «APPS EN LOOP»
   - Chips con icono + nombre visible + switch para Apps Nativas
   - Rejilla de 2 columnas para Scripts con insignias por categoría
   - Bloque de sistema (maestro) discreto y adaptado a tema oscuro/claro
   ============================================================================ */

.loop-body {
  padding: 16px 18px !important;
}

.loop-buttons {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  align-items: stretch !important;
}

/* --- 1. Apps Nativas (Chips modernos con etiqueta visible) --- */
.loop-buttons__row--native {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  gap: 10px !important;
  padding-bottom: 16px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.theme-light .loop-buttons__row--native,
[data-theme="light"] .loop-buttons__row--native {
  border-bottom-color: #e2e8f0 !important;
}

.app-card.app-card--native {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  min-height: 48px !important;
  padding: 6px 10px 6px 8px !important;
  border-radius: 12px !important;
  background: rgba(30, 41, 59, 0.65) !important;
  border: 1px solid rgba(96, 165, 250, 0.28) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18) !important;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease !important;
}

.app-card.app-card--native:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.55) !important;
  background: rgba(30, 41, 59, 0.9) !important;
}

.app-card.app-card--native.app-card--inactive {
  background: rgba(15, 23, 42, 0.45) !important;
  border-color: rgba(255, 255, 255, 0.07) !important;
  box-shadow: none !important;
  opacity: 0.68 !important;
}

body.theme-light .app-card.app-card--native,
[data-theme="light"] .app-card.app-card--native {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.06) !important;
}

body.theme-light .app-card.app-card--native:hover,
[data-theme="light"] .app-card.app-card--native:hover {
  background: #dbeafe !important;
  border-color: #60a5fa !important;
}

body.theme-light .app-card.app-card--native.app-card--inactive,
[data-theme="light"] .app-card.app-card--native.app-card--inactive {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  opacity: 0.72 !important;
}

.app-button.app-button--icon-native {
  flex: 1 !important;
  min-width: 0 !important;
  width: auto !important;
  height: 34px !important;
  padding: 0 4px 0 2px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 7px !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--ink, #f1f5f9) !important;
  cursor: pointer;
  text-align: left;
}

.app-button.app-button--icon-native:hover {
  transform: none !important;
  background: transparent !important;
}

.app-native-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.35);
  transition: transform 0.16s ease, background 0.16s ease;
}

.app-card--native:hover .app-native-ico {
  transform: scale(1.06);
  background: rgba(59, 130, 246, 0.32);
}

.app-card--native.app-card--inactive .app-native-ico {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.1);
}

body.theme-light .app-native-ico,
[data-theme="light"] .app-native-ico {
  background: #dbeafe;
  color: #2563eb;
  border-color: #93c5fd;
}

body.theme-light .app-card--native.app-card--inactive .app-native-ico,
[data-theme="light"] .app-card--native.app-card--inactive .app-native-ico {
  background: #e2e8f0;
  color: #64748b;
  border-color: #cbd5e1;
}

.app-native-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-card--native.app-card--inactive .app-native-name {
  color: #94a3b8;
}

body.theme-light .app-native-name,
[data-theme="light"] .app-native-name {
  color: #1e293b;
}

body.theme-light .app-card--native.app-card--inactive .app-native-name,
[data-theme="light"] .app-card--native.app-card--inactive .app-native-name {
  color: #64748b;
}

/* --- 1b. Apps Personalizadas (Pushed Apps) --- */
.loop-buttons__row--custom {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)) !important;
  gap: 12px !important;
  justify-content: stretch !important;
  margin-top: 4px !important;
  padding-bottom: 8px !important;
}

.app-card.app-card--custom {
  min-height: 54px !important;
  padding: 10px 14px !important;
  border-radius: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
}

.app-card--custom .app-card__label {
  flex: 1 !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.35 !important;
  overflow: visible !important;
  text-overflow: clip !important;
  padding: 0 4px !important;
}

/* --- 2. Sección de Scripts (Rejilla de 2 columnas + Insignias por tipo) --- */
.loop-buttons__row--scripts {
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: none !important;
}

.loop-buttons__row-title {
  font-size: 11.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8 !important;
  margin-bottom: 4px;
}

.loop-buttons__row-title i {
  color: #60a5fa;
}

body.theme-light .loop-buttons__row-title,
[data-theme="light"] .loop-buttons__row-title {
  color: #475569 !important;
}

.loop-buttons__row--script-cards {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)) !important;
  gap: 12px !important;
  justify-content: stretch !important;
  margin-top: 8px !important;
}

.loop-buttons__row--script-cards-disabled {
  margin-top: 6px !important;
  padding-top: 10px !important;
  border-top: 1px dashed rgba(255, 255, 255, 0.12) !important;
}

body.theme-light .loop-buttons__row--script-cards-disabled,
[data-theme="light"] .loop-buttons__row--script-cards-disabled {
  border-top-color: #cbd5e1 !important;
}

.app-card.app-card--script {
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  grid-template-rows: auto auto !important;
  grid-template-areas:
    "icon info"
    "actions actions" !important;
  column-gap: 12px !important;
  row-gap: 8px !important;
  align-items: center !important;
  min-width: 0 !important;
  min-height: 72px !important;
  padding: 12px 14px !important;
  border-radius: 14px !important;
}

.app-card.app-card--script:not(.app-card--maestro) {
  background: rgba(19, 28, 53, 0.78) !important;
  border: 1px solid rgba(255, 255, 255, 0.11) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22) !important;
  color: #f1f5f9 !important;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease !important;
}

.app-card.app-card--script:not(.app-card--maestro):hover {
  transform: translateY(-2px);
  border-color: rgba(96, 165, 250, 0.45) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3) !important;
}

.app-card.app-card--script.app-card--disabled:not(.app-card--maestro) {
  background: rgba(15, 23, 42, 0.45) !important;
  border-color: rgba(255, 255, 255, 0.07) !important;
  opacity: 0.65 !important;
  filter: none !important;
  box-shadow: none !important;
}

body.theme-light .app-card.app-card--script:not(.app-card--maestro),
[data-theme="light"] .app-card.app-card--script:not(.app-card--maestro) {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05) !important;
}

body.theme-light .app-card.app-card--script:not(.app-card--maestro):hover,
[data-theme="light"] .app-card.app-card--script:not(.app-card--maestro):hover {
  border-color: #60a5fa !important;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.1) !important;
}

body.theme-light .app-card.app-card--script.app-card--disabled:not(.app-card--maestro),
[data-theme="light"] .app-card.app-card--script.app-card--disabled:not(.app-card--maestro) {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

/* Icono de categoría en la tarjeta de script */
.app-card--script .app-button--icon-script,
.app-card--script .app-card--script__badge {
  grid-area: icon !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 10px !important;
  font-size: 16px !important;
  background: rgba(59, 130, 246, 0.18) !important;
  border: 1px solid rgba(96, 165, 250, 0.35) !important;
  color: #60a5fa !important;
  box-shadow: none !important;
  align-self: center !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
}

.app-card--script[data-widget-type="alarm"] .app-button--icon-script,
.app-card--script[data-widget-type="alarm"] .app-card--script__badge {
  background: rgba(244, 63, 94, 0.18) !important;
  border-color: rgba(244, 63, 94, 0.35) !important;
  color: #fb7185 !important;
}

.app-card--script[data-widget-type="timer"] .app-button--icon-script,
.app-card--script[data-widget-type="crypto"] .app-button--icon-script {
  background: rgba(245, 158, 11, 0.18) !important;
  border-color: rgba(245, 158, 11, 0.35) !important;
  color: #fbbf24 !important;
}

.app-card--script[data-widget-type="weather"] .app-button--icon-script {
  background: rgba(6, 182, 212, 0.18) !important;
  border-color: rgba(6, 182, 212, 0.35) !important;
  color: #22d3ee !important;
}

.app-card--script[data-widget-type="score"] .app-button--icon-script {
  background: rgba(16, 185, 129, 0.18) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
  color: #34d399 !important;
}

.app-card--script[data-widget-type="pizza"] .app-button--icon-script {
  background: rgba(249, 115, 22, 0.18) !important;
  border-color: rgba(249, 115, 22, 0.35) !important;
  color: #fb923c !important;
}

.app-card--script[data-widget-type="sleep"] .app-button--icon-script,
.app-card--script[data-widget-type="sleep"] .app-card--script__badge {
  background: rgba(99, 102, 241, 0.18) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
  color: #818cf8 !important;
}

.app-card--script[data-widget-type="tariff"] .app-button--icon-script,
.app-card--script[data-widget-type="tariff"] .app-card--script__badge {
  background: rgba(234, 179, 8, 0.18) !important;
  border-color: rgba(234, 179, 8, 0.35) !important;
  color: #facc15 !important;
}

.app-card--script[data-widget-type="drawing"] .app-button--icon-script {
  background: rgba(168, 85, 247, 0.18) !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
  color: #c084fc !important;
}

/* Trío de iconos de redes sociales en Status (Apps en Loop) */
.social-trio-icons {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.social-trio-icons .social-trio-yt {
  color: #ff0000;
  font-size: 13px;
  filter: drop-shadow(0 1px 2px rgba(255, 0, 0, 0.35));
}

.social-trio-icons .social-trio-tw {
  color: #a970ff;
  font-size: 12px;
  filter: drop-shadow(0 1px 2px rgba(145, 70, 255, 0.35));
}

.social-trio-icons .social-trio-kick {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(83, 252, 24, 0.35));
}

.app-card--social .app-button--icon-script,
.app-card--social .app-card--script__badge,
.app-card--script[data-widget-type="social"] .app-button--icon-script,
.app-card--script[data-widget-type="social"] .app-card--script__badge,
.app-card--script[data-widget-type="youtube"] .app-button--icon-script,
.app-card--script[data-widget-type="youtube"] .app-card--script__badge,
.app-card--script[data-widget-type="twitch"] .app-button--icon-script,
.app-card--script[data-widget-type="twitch"] .app-card--script__badge,
.app-card--script[data-widget-type="kick"] .app-button--icon-script,
.app-card--script[data-widget-type="kick"] .app-card--script__badge {
  width: auto !important;
  min-width: 52px !important;
  height: 40px !important;
  padding: 0 7px !important;
  gap: 4px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.16) 0%, rgba(145, 70, 255, 0.16) 50%, rgba(83, 252, 24, 0.16) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

body.theme-light .app-card--social .app-button--icon-script,
body.theme-light .app-card--social .app-card--script__badge,
[data-theme="light"] .app-card--social .app-button--icon-script,
[data-theme="light"] .app-card--social .app-card--script__badge {
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.08) 0%, rgba(145, 70, 255, 0.08) 50%, rgba(83, 252, 24, 0.08) 100%) !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
}

.app-card--script .app-card__info {
  grid-area: info !important;
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  padding: 0 !important;
  justify-content: center !important;
  gap: 2px !important;
}

.app-card--script .app-card__label {
  font-size: 13.5px !important;
  font-weight: 600 !important;
  color: var(--ink, #f1f5f9) !important;
  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.35 !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

body.theme-light .app-card--script .app-card__label,
[data-theme="light"] .app-card--script .app-card__label {
  color: #0f172a !important;
}

.app-card--script .app-card__kind {
  font-size: 10.5px !important;
  color: var(--muted-dim, #94a3b8) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
}

body.theme-light .app-card--script .app-card__kind,
[data-theme="light"] .app-card--script .app-card__kind {
  color: #64748b !important;
}

/* Barra de acciones en tarjetas de script (fila dedicada inferior) */
.app-card--script .app-card__actions {
  grid-area: actions !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  width: 100% !important;
  padding-top: 8px !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.theme-light .app-card--script .app-card__actions,
[data-theme="light"] .app-card--script .app-card__actions {
  border-top-color: rgba(0, 0, 0, 0.06) !important;
}

.app-card--script .app-button--toggle {
  flex: 0 0 auto !important;
  height: 30px !important;
  padding: 0 10px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  border-radius: 7px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  margin: 0 !important;
}

.app-card--script .app-button--delete {
  flex: 0 0 auto !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 7px !important;
  margin: 0 !important;
}

.app-card--script .app-button--toggle-on {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #cbd5e1 !important;
}

.app-card--script .app-button--toggle-on:hover {
  background: rgba(245, 158, 11, 0.18) !important;
  border-color: rgba(245, 158, 11, 0.45) !important;
  color: #fbbf24 !important;
}

.app-card--script .app-button--toggle-off {
  background: rgba(34, 197, 94, 0.18) !important;
  border: 1px solid rgba(34, 197, 94, 0.45) !important;
  color: #4ade80 !important;
}

.app-card--script .app-button--toggle-off:hover {
  background: rgba(34, 197, 94, 0.3) !important;
  color: #ffffff !important;
}

body.theme-light .app-card--script .app-button--toggle-on,
[data-theme="light"] .app-card--script .app-button--toggle-on {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #475569 !important;
}

body.theme-light .app-card--script .app-button--toggle-off,
[data-theme="light"] .app-card--script .app-button--toggle-off {
  background: #dcfce7 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}

/* --- 3. Bloque de Sistema (Maestro) adaptado a tema oscuro/claro --- */
.loop-buttons__system {
  margin-top: 12px !important;
  padding-top: 12px !important;
  border-top: 1px dashed rgba(255, 255, 255, 0.12) !important;
}

body.theme-light .loop-buttons__system,
[data-theme="light"] .loop-buttons__system {
  border-top-color: #cbd5e1 !important;
}

.app-card--script.app-card--maestro {
  background: rgba(15, 23, 42, 0.5) !important;
  border: 1px dashed rgba(148, 163, 184, 0.28) !important;
  border-radius: 12px !important;
  padding: 8px 12px !important;
}

body.theme-light .app-card--script.app-card--maestro,
[data-theme="light"] .app-card--script.app-card--maestro {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

.app-card--script.app-card--maestro .app-card__label {
  color: #cbd5e1 !important;
}

body.theme-light .app-card--script.app-card--maestro .app-card__label,
[data-theme="light"] .app-card--script.app-card--maestro .app-card__label {
  color: #334155 !important;
}

.app-card--maestro__badge {
  background: rgba(96, 165, 250, 0.12) !important;
  border: 1px dashed rgba(96, 165, 250, 0.35) !important;
  color: #60a5fa !important;
}

/* ============================================================================
   STATUS PASO 3: CONSOLA SUPERIOR, BRILLO E INDICADORES LED 1-2-3
   - Controles superiores proporcionados (Matriz LED, Sonido, Volumen, Sleep, Reboot)
   - Cápsulas de Indicadores LED 1-2-3 adaptadas a tema oscuro y claro
   - Barra de brillo refinada con insignia numérica monoespaciada
   ============================================================================ */

/* --- 1. Consola Superior (.power-buttons) --- */
.status-top-controls .power-buttons {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  padding: 8px 10px !important;
  border-radius: 14px !important;
}

.power-toggle-container,
.sound-toggle-container,
.volume-control-container,
.sleep-control,
.reboot-button-container {
  height: 40px !important;
  padding: 4px 10px !important;
  border-radius: 10px !important;
  display: inline-flex !important;
  align-items: center !important;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease !important;
}

.power-toggle-container:hover,
.sound-toggle-container:hover,
.sleep-control:hover {
  transform: none !important;
  border-color: rgba(96, 165, 250, 0.35) !important;
}

.power-toggle-text {
  font-size: 13px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em;
  text-shadow: none !important;
}

/* Modern compact toggle switches (48x26) for Power & Sound */
.power-toggle,
.sound-toggle {
  width: 48px !important;
  height: 26px !important;
}

.power-toggle-slider,
.sound-toggle-slider {
  background: rgba(148, 163, 184, 0.28) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  border-radius: 999px !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35) !important;
}

body.theme-light .power-toggle-slider,
body.theme-light .sound-toggle-slider,
[data-theme="light"] .power-toggle-slider,
[data-theme="light"] .sound-toggle-slider {
  background: #cbd5e1 !important;
  border-color: #94a3b8 !important;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12) !important;
}

.power-toggle-slider:before,
.sound-toggle-slider::before {
  width: 20px !important;
  height: 20px !important;
  left: 2px !important;
  bottom: 2px !important;
  background: #ffffff !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3) !important;
}

.power-toggle input:checked + .power-toggle-slider,
.sound-toggle input:checked + .sound-toggle-slider {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border-color: rgba(52, 211, 153, 0.5) !important;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.35) !important;
}

.power-toggle input:checked + .power-toggle-slider:before,
.sound-toggle input:checked + .sound-toggle-slider::before {
  transform: translateX(22px) !important;
}

/* Volume slider & badge */
.volume-control-container {
  flex: 1 1 150px;
  min-width: 135px;
  gap: 8px !important;
}

.volume-control-container .vol-ico {
  font-size: 13.5px;
  color: #60a5fa !important;
}

.volume-control-container input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  accent-color: #3b82f6;
  cursor: pointer;
}

#volume_value {
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  min-width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sleep control with 'min' unit */
.sleep-control {
  gap: 5px !important;
  padding: 4px 6px 4px 10px !important;
}

.sleep-control input {
  width: 44px !important;
  height: 28px !important;
  font-family: var(--font-mono) !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  background: rgba(15, 23, 42, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #f1f5f9 !important;
}

.sleep-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-dim, #94a3b8);
  margin-right: 2px;
  user-select: none;
}

.sleep-control button,
.reboot-button-container button {
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  background: rgba(255, 255, 255, 0.07) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #e2e8f0 !important;
}

.sleep-control button:hover {
  background: rgba(99, 102, 241, 0.25) !important;
  border-color: rgba(129, 140, 248, 0.55) !important;
  color: #c7d2fe !important;
  transform: none !important;
}

.reboot-button-container {
  padding: 4px 5px !important;
}

.reboot-button-container:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  box-shadow: none !important;
  transform: none !important;
}

.reboot-button-container button:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: rgba(248, 113, 113, 0.6) !important;
  color: #fecaca !important;
}

/* --- 2. Indicadores LED de Esquina (.canvas-indicators) centrados con el panel LED --- */
.canvas-main-col {
  width: 100% !important;
  max-width: 720px !important;
}

.canvas-screen-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 14px !important;
  width: 100% !important;
}

.canvas-screen-row .canvas-screen-box {
  flex: 1 1 auto;
  min-width: 0;
}

.canvas-indicators {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 10px !important;
  height: auto !important;
  margin-top: 0 !important;
  align-self: center !important;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .canvas-screen-row {
    flex-direction: column;
    gap: 12px;
  }
  .canvas-indicators {
    flex-direction: row !important;
    justify-content: center !important;
  }
}

.canvas-indicator {
  position: relative;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 7px 10px !important;
  background: rgba(9, 13, 26, 0.72) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 11px !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4) !important;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease !important;
}

.canvas-indicator:hover {
  transform: translateY(-1px) !important;
  border-color: rgba(96, 165, 250, 0.45) !important;
  background: rgba(15, 23, 42, 0.9) !important;
}

.canvas-indicator.active {
  background: rgba(30, 58, 138, 0.45) !important;
  border-color: rgba(96, 165, 250, 0.65) !important;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.28) !important;
}

body.theme-light .canvas-indicator,
[data-theme="light"] .canvas-indicator {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
}

body.theme-light .canvas-indicator:hover,
[data-theme="light"] .canvas-indicator:hover {
  background: #ffffff !important;
  border-color: #60a5fa !important;
}

body.theme-light .canvas-indicator.active,
[data-theme="light"] .canvas-indicator.active {
  background: #eff6ff !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.2) !important;
}

.canvas-indicator-led {
  width: 22px !important;
  height: 22px !important;
  border: 2px solid rgba(255, 255, 255, 0.35) !important;
}

body.theme-light .canvas-indicator-led,
[data-theme="light"] .canvas-indicator-led {
  border-color: #94a3b8 !important;
}

.canvas-indicator input[type="color"] {
  width: 24px !important;
  height: 22px !important;
  padding: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 6px !important;
  background: transparent !important;
  cursor: pointer;
}

/* --- 3. Barra de Brillo bajo el lienzo (.brightness-controls) --- */
.status-preview .brightness-controls {
  margin-top: 10px !important;
  padding: 7px 12px !important;
  border-radius: 12px !important;
  background: rgba(9, 13, 26, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.theme-light .status-preview .brightness-controls,
[data-theme="light"] .status-preview .brightness-controls {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

.brightness-val-badge {
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  min-width: 38px;
  padding: 4px 8px;
  border-radius: 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

body.theme-light .brightness-val-badge,
[data-theme="light"] .brightness-val-badge {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0284c7 !important;
}

/* ============================================================================
   STATUS PASO 2: BARRA DE «TRANSICIÓN ENTRE APPS»
   - Sustituye el fondo verde pastel fijo por una barra integrada en el tema
   - Píldoras rápidas (5s / 7s / 10s / 15s) + campo numérico monoespaciado
   ============================================================================ */

.loop-transition-control {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  padding: 10px 14px !important;
  margin-bottom: 16px !important;
  background: rgba(9, 13, 26, 0.55) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 12px !important;
}

body.theme-light .loop-transition-control,
[data-theme="light"] .loop-transition-control {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

.loop-transition-control__label {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--ink, #f1f5f9) !important;
  gap: 8px !important;
}

.loop-transition-control__label i {
  color: #60a5fa !important;
}

body.theme-light .loop-transition-control__label,
[data-theme="light"] .loop-transition-control__label {
  color: #1e293b !important;
}

body.theme-light .loop-transition-control__label i,
[data-theme="light"] .loop-transition-control__label i {
  color: #2563eb !important;
}

.loop-transition-control__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.loop-preset-pills {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.theme-light .loop-preset-pills,
[data-theme="light"] .loop-preset-pills {
  background: #ffffff;
  border-color: #cbd5e1;
}

.loop-preset-pill {
  padding: 4px 9px !important;
  height: 26px !important;
  border-radius: 6px !important;
  font-family: var(--font-mono) !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  color: #94a3b8 !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: all 0.15s ease !important;
}

.loop-preset-pill:hover {
  color: #f8fafc !important;
  background: rgba(255, 255, 255, 0.08) !important;
  transform: none !important;
}

.loop-preset-pill.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  border-color: rgba(96, 165, 250, 0.45) !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
}

body.theme-light .loop-preset-pill,
[data-theme="light"] .loop-preset-pill {
  color: #475569 !important;
}

body.theme-light .loop-preset-pill:hover,
[data-theme="light"] .loop-preset-pill:hover {
  color: #0f172a !important;
  background: #f1f5f9 !important;
}

body.theme-light .loop-preset-pill.active,
[data-theme="light"] .loop-preset-pill.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
}

.loop-transition-control__input input {
  width: 62px !important;
  height: 32px !important;
  padding: 4px 8px !important;
  font-family: var(--font-mono) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #f1f5f9 !important;
}

.loop-transition-control__input input:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22) !important;
}

.loop-transition-control__unit {
  font-size: 12px !important;
  font-weight: 600;
  color: var(--muted-dim, #94a3b8) !important;
}

.loop-transition-control__apply {
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  border: 1px solid rgba(96, 165, 250, 0.4) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28) !important;
}

.loop-transition-control__apply:hover {
  filter: brightness(1.08);
  transform: translateY(-1px) !important;
}

/* ============================================================================
   STATUS PASO 4: BARRA DE COMANDOS CLOUD Y VELO DEL LIENZO EN MODO NUBE
   - Adaptación completa a tema oscuro y claro (sustituye el fondo #eef4ff fijo)
   - Modo compacto cuando hay 0 comandos en cola y expansión al acumular cambios
   ============================================================================ */

/* Velo sobre la matriz en modo Cloud (solo selector de clase para respetar .is-hidden) */
.cloud-screen-veil {
  background: rgba(5, 8, 15, 0.72) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 10px !important;
}

.cloud-screen-veil span {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #e2e8f0 !important;
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(96, 165, 250, 0.35) !important;
  padding: 7px 15px !important;
  border-radius: 999px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.cloud-screen-veil span i {
  color: #60a5fa;
}

/* Barra de Comandos Cloud (.cloud-cmd-bar) */
.cloud-cmd-bar {
  margin-top: 14px !important;
  border-radius: 16px !important;
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1px solid rgba(96, 165, 250, 0.25) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24) !important;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cloud-cmd-bar.has-queued {
  border-color: rgba(96, 165, 250, 0.55) !important;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.22) !important;
}

body.theme-light .cloud-cmd-bar,
[data-theme="light"] .cloud-cmd-bar {
  background: #ffffff !important;
  border: 1px solid #bfdbfe !important;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.06) !important;
}

body.theme-light .cloud-cmd-bar.has-queued,
[data-theme="light"] .cloud-cmd-bar.has-queued {
  border-color: #3b82f6 !important;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.14) !important;
}

.cloud-cmd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 16px !important;
  background: rgba(59, 130, 246, 0.1) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
}

body.theme-light .cloud-cmd-header,
[data-theme="light"] .cloud-cmd-header {
  background: #eff6ff !important;
  border-bottom: 1px solid #dbeafe !important;
}

.cloud-cmd-header h4 {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: var(--ink, #f1f5f9) !important;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cloud-cmd-header h4 i {
  color: #60a5fa !important;
  margin: 0 !important;
}

body.theme-light .cloud-cmd-header h4,
[data-theme="light"] .cloud-cmd-header h4 {
  color: #0f172a !important;
}

body.theme-light .cloud-cmd-header h4 i,
[data-theme="light"] .cloud-cmd-header h4 i {
  color: #2563eb !important;
}

.cloud-cmd-count {
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  padding: 2px 8px !important;
  border-radius: 999px !important;
  background: rgba(59, 130, 246, 0.22) !important;
  color: #93c5fd !important;
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.cloud-cmd-bar.has-queued .cloud-cmd-count {
  background: #3b82f6 !important;
  color: #ffffff !important;
}

body.theme-light .cloud-cmd-count,
[data-theme="light"] .cloud-cmd-count {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
  border-color: #93c5fd;
}

.cloud-cmd-actions {
  display: flex;
  align-items: center;
  gap: 6px !important;
}

.cloud-cmd-actions button {
  padding: 6px 12px !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: 9px !important;
  background: rgba(255, 255, 255, 0.07) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #e2e8f0 !important;
  transition: all 0.15s ease !important;
}

.cloud-cmd-actions button:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.22) !important;
  border-color: rgba(96, 165, 250, 0.5) !important;
  color: #ffffff !important;
}

.cloud-cmd-bar.has-queued #btn_send_cloud_cmds {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  border-color: rgba(96, 165, 250, 0.5) !important;
  color: #ffffff !important;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35) !important;
}

/* Cuando la cola está vacía (0 comandos), ocultar el botón Descartar y el aviso largo */
.cloud-cmd-bar:not(.has-queued) .cloud-cmd-discard,
.cloud-cmd-bar:not(.has-queued) .cloud-cmd-hint {
  display: none !important;
}

.cloud-cmd-actions .cloud-cmd-discard:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(248, 113, 113, 0.5) !important;
  color: #fca5a5 !important;
}

.cloud-cmd-list {
  padding: 10px 16px 4px !important;
}

.cloud-cmd-item {
  background: rgba(9, 13, 26, 0.65) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px !important;
  padding: 6px 12px !important;
  font-size: 12.5px !important;
  color: #e2e8f0 !important;
}

body.theme-light .cloud-cmd-item,
[data-theme="light"] .cloud-cmd-item {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}

.cloud-cmd-item button {
  color: #f87171 !important;
}

.cloud-cmd-ts {
  padding: 8px 16px !important;
  font-size: 12px !important;
  color: var(--muted-dim, #94a3b8) !important;
}

.cloud-cmd-ts span#cloud_status_ts {
  font-family: var(--font-mono);
  color: #60a5fa !important;
}

body.theme-light .cloud-cmd-ts span#cloud_status_ts,
[data-theme="light"] .cloud-cmd-ts span#cloud_status_ts {
  color: #2563eb !important;
}

.cloud-cmd-hint {
  padding: 0 16px 12px !important;
  font-size: 12px !important;
  color: var(--muted-dim, #94a3b8) !important;
}

/* ==========================================================================
   Sistema Dual Calibrado — Warm Stone & Amber (Modo Claro y Modo Oscuro)
   Variables nativas definidas en base.css:
     --bg-canvas      : #FAFAF9 (Claro) | #121110 (Oscuro)
     --bg-surface     : #FFFFFF (Claro) | #1C1A18 (Oscuro)
     --bg-subtle      : #F5F5F4 (Claro) | #262320 (Oscuro)
     --border-subtle  : #E7E5E4 (Claro) | #332F2C (Oscuro)
     --text-primary   : #1C1917 (Claro) | #F5F5F4 (Oscuro)
     --text-secondary : #57534E (Claro) | #A8A29E (Oscuro)
     --brand-primary  : #D97706 (Claro) | #F59E0B (Oscuro)
     --brand-hover    : #B45309 (Claro) | #FBBF24 (Oscuro)
     --brand-tint     : #FEF3C7 (Claro) | #451A03 (Oscuro)
     --text-on-brand  : #FFFFFF (Claro) | #121110 (Oscuro)
   ========================================================================== */

body,
body.authed,
body.theme-light,
body.theme-dark,
body.theme-light.authed,
body.theme-dark.authed,
:root[data-theme="light"] body,
:root[data-theme="dark"] body {
  background: var(--bg-canvas) !important;
  color: var(--text-primary) !important;
}

/* Landing */
#view_landing,
.landing,
body.theme-light #view_landing,
body.theme-light .landing,
body.theme-dark #view_landing,
body.theme-dark .landing {
  background: var(--bg-canvas) !important;
  color: var(--text-primary) !important;
}

.landing-top-bar,
body.theme-light .landing-top-bar {
  border-bottom: 1px solid var(--border-subtle) !important;
}

.landing-hero h1,
.landing-feature strong,
body.theme-light .landing-hero h1,
body.theme-light .landing-feature strong {
  color: var(--text-primary) !important;
}

.landing-hero h1 em {
  color: var(--brand-primary) !important;
  background: none !important;
  -webkit-text-fill-color: var(--brand-primary) !important;
}

.landing-sub,
.landing-feature span,
.landing-foot,
.landing-enter-hint,
body.theme-light .landing-sub,
body.theme-light .landing-feature span,
body.theme-light .landing-foot,
body.theme-light .landing-enter-hint {
  color: var(--text-secondary) !important;
}

.landing-feature,
body.theme-light .landing-feature {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: var(--shadow-sm) !important;
}

.landing-feature i,
.landing-foot a,
body.theme-light .landing-feature i,
body.theme-light .landing-foot a {
  color: var(--brand-primary) !important;
}

.landing-badge,
body.theme-light .landing-badge,
.beta-pill {
  background: var(--brand-tint) !important;
  border: 1px solid var(--brand-primary) !important;
  color: var(--brand-primary) !important;
}

.beta-banner,
body.theme-light .beta-banner {
  background: var(--brand-tint) !important;
  border: 1px solid var(--brand-primary) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-sm) !important;
}

body.theme-light .fw-banner {
  background: #FEF2F2 !important;
  border: 1px solid #FCA5A5 !important;
  color: #991B1B !important;
}

body.theme-dark .fw-banner,
:root[data-theme="dark"] .fw-banner {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
  color: #FCA5A5 !important;
}

.landing-secondary-btn,
body.theme-light .landing-secondary-btn,
[data-theme="light"] .landing-secondary-btn {
  color: var(--text-primary) !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: var(--shadow-sm) !important;
}

.landing-secondary-btn:hover,
body.theme-light .landing-secondary-btn:hover,
[data-theme="light"] .landing-secondary-btn:hover {
  background: var(--bg-subtle) !important;
  border-color: var(--brand-primary) !important;
  color: var(--brand-primary) !important;
}

/* Header y navegación segmentada */
.app-header.site-header,
.site-header,
body.theme-light .app-header.site-header,
[data-theme="light"] .site-header,
[data-theme="dark"] .site-header {
  background: var(--header-bg) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  box-shadow: var(--shadow-sm) !important;
}

.header-row--top,
body.theme-light .header-row--top {
  border-bottom: 1px solid var(--border-subtle) !important;
}

.site-brand,
body.theme-light .site-brand {
  color: var(--text-primary) !important;
}

.brand-title,
body.theme-light .brand-title,
body.authed .sidebar-header h1 {
  background: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}

.site-nav,
body.theme-light .site-nav,
[data-theme="light"] .site-nav,
[data-theme="dark"] .site-nav {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
}

.site-nav .nav-item,
.site-nav .nav-item.nav-item--widgets,
body.theme-light .site-nav .nav-item,
body.theme-light .site-nav .nav-item.nav-item--widgets,
body.theme-light.authed .site-nav a,
[data-theme="light"] .site-nav .nav-item,
[data-theme="light"] .site-nav .nav-item.nav-item--widgets,
[data-theme="dark"] .site-nav .nav-item,
[data-theme="dark"] .site-nav .nav-item.nav-item--widgets,
body.theme-light #nav-widgets,
body.theme-light.authed #nav-widgets {
  color: var(--text-secondary) !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
}

.site-nav .nav-item i,
.site-nav .nav-item.nav-item--widgets i,
body.theme-light .site-nav .nav-item i,
body.theme-light.authed .site-nav a i,
body.theme-light #nav-widgets i,
body.theme-light.authed #nav-widgets i {
  color: var(--text-secondary) !important;
}

.site-nav .nav-item:hover,
.site-nav .nav-item.nav-item--widgets:hover,
body.theme-light .site-nav .nav-item:hover,
body.theme-light .site-nav .nav-item.nav-item--widgets:hover,
body.theme-light.authed .site-nav a:hover,
[data-theme="light"] .site-nav .nav-item:hover,
[data-theme="light"] .site-nav .nav-item.nav-item--widgets:hover,
body.theme-light #nav-widgets:hover,
body.theme-light.authed #nav-widgets:hover {
  color: var(--text-primary) !important;
  background: var(--bg-surface) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: none !important;
}

.site-nav .nav-item:hover i,
.site-nav .nav-item.nav-item--widgets:hover i,
body.theme-light .site-nav .nav-item:hover i,
body.theme-light.authed .site-nav a:hover i,
body.theme-light #nav-widgets:hover i {
  color: var(--brand-primary) !important;
}

.site-nav .nav-item.active,
.site-nav .nav-item.nav-item--widgets.active,
body.theme-light .site-nav .nav-item.active,
body.theme-light .site-nav .nav-item.nav-item--widgets.active,
body.theme-light.authed .site-nav a.active,
[data-theme="light"] .site-nav .nav-item.active,
[data-theme="light"] .site-nav .nav-item.nav-item--widgets.active,
[data-theme="dark"] .site-nav .nav-item.active,
[data-theme="dark"] .site-nav .nav-item.nav-item--widgets.active,
body.theme-light #nav-widgets.active,
body.theme-light.authed #nav-widgets.active {
  color: var(--text-on-brand) !important;
  background: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  box-shadow: var(--shadow-sm) !important;
}

.site-nav .nav-item.active i,
.site-nav .nav-item.nav-item--widgets.active i,
body.theme-light .site-nav .nav-item.active i,
body.theme-light.authed .site-nav a.active i,
body.theme-light #nav-widgets.active i,
body.theme-light.authed #nav-widgets.active i {
  color: var(--text-on-brand) !important;
}

/* Controles de cabecera (idioma, tema, usuario, selector de dispositivo) */
.theme-toggle-btn,
body.theme-light .theme-toggle-btn,
[data-theme="light"] .theme-toggle-btn,
[data-theme="dark"] .theme-toggle-btn {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--brand-primary) !important;
  box-shadow: none !important;
}

.theme-toggle-btn:hover,
body.theme-light .theme-toggle-btn:hover,
[data-theme="light"] .theme-toggle-btn:hover,
[data-theme="dark"] .theme-toggle-btn:hover {
  background: var(--brand-tint) !important;
  border-color: var(--brand-primary) !important;
  color: var(--brand-hover) !important;
}

body.theme-light .theme-toggle-btn .theme-icon-moon,
[data-theme="light"] .theme-toggle-btn .theme-icon-moon {
  color: var(--brand-primary) !important;
}

body.theme-dark .theme-toggle-btn .theme-icon-sun,
[data-theme="dark"] .theme-toggle-btn .theme-icon-sun {
  color: var(--brand-primary) !important;
}

.lang-select,
body.theme-light .lang-select {
  background-color: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
}

.lang-select:hover,
.lang-select:focus,
body.theme-light .lang-select:hover,
body.theme-light .lang-select:focus {
  background-color: var(--brand-tint) !important;
  border-color: var(--brand-primary) !important;
  color: var(--text-primary) !important;
}

.topbar-device-card,
body.theme-light .topbar-device-card {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
}

.topbar-device-card:hover,
body.theme-light .topbar-device-card:hover {
  border-color: var(--brand-primary) !important;
}

.topbar-user-trigger,
.topbar-auth-btn,
body.theme-light .topbar-user-trigger {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
}

.topbar-user-trigger:hover,
.topbar-auth-btn:hover,
body.theme-light .topbar-user-trigger:hover {
  background: var(--brand-tint) !important;
  border-color: var(--brand-primary) !important;
  color: var(--text-primary) !important;
}

.topbar-user-dropdown,
body.theme-light .topbar-user-dropdown {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary) !important;
}

.user-dropdown-header,
body.theme-light .user-dropdown-header {
  color: var(--text-secondary) !important;
}

.user-dropdown-email,
body.theme-light .user-dropdown-email {
  color: var(--text-primary) !important;
}

.user-dropdown-divider,
body.theme-light .user-dropdown-divider {
  border-top-color: var(--border-subtle) !important;
}

.user-dropdown-item,
body.theme-light .user-dropdown-item {
  color: var(--text-primary) !important;
}

.user-dropdown-item:hover,
body.theme-light .user-dropdown-item:hover {
  background: var(--bg-subtle) !important;
  color: var(--brand-primary) !important;
}

/* Superficie principal: Tarjetas, contenedores y modales
   Claro: #FFFFFF con sombra suave | Oscuro: #1C1A18 sobre #121110 sin sombra */
body.authed .header,
body.authed .section-container,
body.authed .status-container,
body.authed .status-preview,
.status-preview,
body.theme-light .status-preview,
[data-theme="light"] .status-preview,
body.authed .loop-controls,
.loop-controls,
body.theme-light .loop-controls,
[data-theme="light"] .loop-controls,
body.authed .moodlight-controls,
body.authed .sub-section,
body.authed .widget-card,
.widget-card,
body.theme-light .widget-card,
[data-theme="light"] .widget-card,
body.authed .widgets-gallery-single .widget-card-inline-form,
body.authed .modal-dialog,
.modal-dialog,
body.theme-light .modal-dialog,
.conn-device-card,
body.theme-light .conn-device-card,
.cloud-cmd-bar,
body.theme-light .cloud-cmd-bar,
[data-theme="light"] .cloud-cmd-bar {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-md) !important;
}

.widget-card:hover,
body.theme-light .widget-card:hover,
[data-theme="light"] .widget-card:hover {
  background: var(--bg-surface) !important;
  border-color: var(--brand-primary) !important;
  box-shadow: var(--shadow-md) !important;
}

.modal-header,
.modal-footer,
.loop-header,
body.theme-light .modal-header,
body.theme-light .modal-footer,
body.theme-light .loop-header,
[data-theme="light"] .loop-header {
  background: var(--bg-subtle) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-primary) !important;
}

.cloud-cmd-header,
body.theme-light .cloud-cmd-header,
[data-theme="light"] .cloud-cmd-header {
  background: var(--brand-tint) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

.cloud-cmd-count,
.cloud-cmd-bar.has-queued .cloud-cmd-count,
body.theme-light .cloud-cmd-count,
[data-theme="light"] .cloud-cmd-count {
  background: var(--brand-primary) !important;
  color: var(--text-on-brand) !important;
  border-color: var(--brand-primary) !important;
}

.cloud-cmd-bar.has-queued,
body.theme-light .cloud-cmd-bar.has-queued,
[data-theme="light"] .cloud-cmd-bar.has-queued {
  border-color: var(--brand-primary) !important;
}

/* Superficie secundaria: Recesos, barras de herramientas, filas y chips (#F5F5F4 / #262320) */
.status-top-controls .power-buttons,
body.theme-light .status-top-controls .power-buttons,
[data-theme="light"] .status-top-controls .power-buttons,
body.authed .status-preview .brightness-controls,
body.theme-light .status-preview .brightness-controls,
[data-theme="light"] .status-preview .brightness-controls,
.loop-transition-control,
body.theme-light .loop-transition-control,
[data-theme="light"] .loop-transition-control,
.settings-explorer-bar,
body.theme-light .settings-explorer-bar,
[data-theme="light"] .settings-explorer-bar,
.text-designer-box,
.widget-form-box,
fieldset.text-designer-box,
body.theme-light .text-designer-box,
body.theme-light .widget-form-box,
body.theme-light fieldset.text-designer-box,
.sleep-section,
.tariff-ranges-section,
body.theme-light .sleep-section,
body.theme-light .tariff-ranges-section {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
}

.power-toggle-container,
.sound-toggle-container,
.volume-control-container,
.sleep-control,
.reboot-button-container,
body.theme-light .power-toggle-container,
body.theme-light .sound-toggle-container,
body.theme-light .volume-control-container,
body.theme-light .sleep-control,
body.theme-light .reboot-button-container,
[data-theme="light"] .power-toggle-container,
[data-theme="light"] .sound-toggle-container,
[data-theme="light"] .volume-control-container,
[data-theme="light"] .sleep-control,
[data-theme="light"] .reboot-button-container,
.canvas-indicator,
body:not(.theme-light) .canvas-indicator,
body.theme-dark .canvas-indicator,
body.theme-light .canvas-indicator,
[data-theme="light"] .canvas-indicator,
.loop-preset-pills,
body.theme-light .loop-preset-pills,
[data-theme="light"] .loop-preset-pills,
.loop-item,
body.theme-light .loop-item,
.setting-row,
body.theme-light .setting-row,
[data-theme="light"] .setting-row,
.cloud-cmd-item,
body.theme-light .cloud-cmd-item,
[data-theme="light"] .cloud-cmd-item,
.maestro-panel,
.maestro-card,
.app-chip,
.script-card {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
}

.setting-row:hover,
body.theme-light .setting-row:hover,
[data-theme="light"] .setting-row:hover,
.canvas-indicator:hover,
body:not(.theme-light) .canvas-indicator:hover,
body.theme-dark .canvas-indicator:hover,
body.theme-light .canvas-indicator:hover,
[data-theme="light"] .canvas-indicator:hover {
  background: var(--bg-surface) !important;
  border-color: var(--brand-primary) !important;
}

/* Tipografía y jerarquía de texto */
body.authed h3,
body.authed h4,
body.authed strong,
.widget-card h4,
.loop-header h4,
.loop-transition-control__label,
body.theme-light.authed h3,
body.theme-light.authed h4,
body.theme-light.authed strong,
body.theme-light .widget-card h4,
body.theme-light .loop-header h4,
[data-theme="light"] .loop-header h4,
body.theme-light .loop-transition-control__label,
[data-theme="light"] .loop-transition-control__label {
  color: var(--text-primary) !important;
}

body.authed .section h3,
body.authed .section-container h4,
body.authed .sub-section h4,
body.authed .loop-header h4,
body.authed .moodlight-header h4 {
  border-bottom-color: var(--border-subtle) !important;
}

body.authed label,
body.authed p,
.widget-card p,
.setting-row-desc,
.setting-row-check,
body.theme-light.authed label,
body.theme-light.authed p,
body.theme-light .widget-card p,
body.theme-light .setting-row-desc,
[data-theme="light"] .setting-row-desc,
body.theme-light .setting-row-check,
[data-theme="light"] .setting-row-check,
body.authed small,
body.authed .sound-description,
body.authed .melody-description,
.setting-row-status,
.cloud-cmd-ts,
.cloud-cmd-hint,
.sleep-unit,
.loop-transition-control__unit,
.btn-status-widgets__text small,
body.theme-light.authed small,
body.theme-light.authed .sound-description,
body.theme-light.authed .melody-description,
body.theme-light .setting-row-status,
[data-theme="light"] .setting-row-status,
body.theme-light .cloud-cmd-ts,
body.theme-light .cloud-cmd-hint,
body.theme-light .sleep-unit,
body.theme-light .loop-transition-control__unit,
body.theme-light .btn-status-widgets__text small,
[data-theme="light"] .btn-status-widgets__text small {
  color: var(--text-secondary) !important;
}

.setting-row-name,
.loop-header h4 i,
.loop-transition-control__label i,
.cloud-cmd-header h4 i,
.cloud-cmd-ts span#cloud_status_ts,
.brightness-val-badge,
body.theme-light .setting-row-name,
[data-theme="light"] .setting-row-name,
body.theme-light .loop-header h4 i,
[data-theme="light"] .loop-header h4 i,
body.theme-light .loop-transition-control__label i,
[data-theme="light"] .loop-transition-control__label i,
body.theme-light .cloud-cmd-header h4 i,
[data-theme="light"] .cloud-cmd-header h4 i,
body.theme-light .cloud-cmd-ts span#cloud_status_ts,
[data-theme="light"] .cloud-cmd-ts span#cloud_status_ts,
body.theme-light .brightness-val-badge,
[data-theme="light"] .brightness-val-badge {
  color: var(--brand-primary) !important;
}

.brightness-val-badge {
  background: var(--brand-tint) !important;
  border-color: var(--border-subtle) !important;
}

/* Inputs, selects y textareas */
body.authed input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
body.authed select:not(.lang-select):not(.mode-toggle-select),
body.authed textarea,
body.theme-light.authed input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
body.theme-light.authed select:not(.lang-select):not(.mode-toggle-select),
body.theme-light.authed textarea,
.sidebar-dev-select,
.topbar-dev-select,
body.theme-light .sidebar-dev-select,
body.theme-light .topbar-dev-select,
.sleep-control input,
body.theme-light .sleep-control input,
.loop-transition-control__input input,
body.theme-light .loop-transition-control__input input,
.setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
.setting-row-ctrl select,
body.theme-light .setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
body.theme-light .setting-row-ctrl select,
[data-theme="light"] .setting-row-ctrl input:not([type="checkbox"]):not([type="color"]),
[data-theme="light"] .setting-row-ctrl select,
.crypto-select,
.tariff-holidays-textarea,
body.theme-light .crypto-select,
body.theme-light .tariff-holidays-textarea {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
}

body.authed select option,
.sidebar-dev-select option,
.topbar-dev-select option,
.lang-select option {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
}

body.authed input::placeholder,
body.authed textarea::placeholder,
body.theme-light.authed input::placeholder,
body.theme-light.authed textarea::placeholder {
  color: var(--text-secondary) !important;
  opacity: 0.85;
}

body.authed input:focus,
body.authed select:not(.lang-select):not(.mode-toggle-select):focus,
body.authed textarea:focus,
body.theme-light.authed input:focus,
body.theme-light.authed select:not(.lang-select):not(.mode-toggle-select):focus,
body.theme-light.authed textarea:focus,
.setting-row-ctrl input:focus,
.setting-row-ctrl select:focus,
.loop-transition-control__input input:focus {
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3px var(--focus-ring) !important;
}

/* Botones primarios (CTA): Ámbar con texto de máximo contraste (#FFFFFF en claro / #121110 en oscuro) */
.landing-enter-btn,
body.theme-light .landing-enter-btn,
body.authed button:not(.text-preset):not(.theme-toggle-btn):not(.lang-btn):not(.modal-close):not(.modal-button--secondary):not(.widget-view-script-btn):not(.weekday-btn):not(.sleep-chip-btn):not(.tariff-chip-btn):not(.user-dropdown-item):not(.topbar-logout-btn):not(.cloud-only):not(#btn_reboot):not(#btn_sleep):not(.auto-brightness-btn):not(.setting-row-actions button):not(.colorbox button):not(.settings-cat-tab):not(.loop-preset-pill):not(.brightness-preset-btn):not(.btn-status-widgets):not(.mode-toggle-btn):not(.topbar-lan-ip-btn):not(.topbar-user-trigger):not(.topbar-auth-btn):not(.topbar-dev-add-btn):not(.landing-secondary-btn):not(.widget-card-btn):not(.cloud-cmd-discard),
body.theme-light.authed button:not(.text-preset):not(.theme-toggle-btn):not(.lang-btn):not(.modal-close):not(.modal-button--secondary):not(.widget-view-script-btn):not(.weekday-btn):not(.sleep-chip-btn):not(.tariff-chip-btn):not(.user-dropdown-item):not(.topbar-logout-btn):not(.cloud-only):not(#btn_reboot):not(#btn_sleep):not(.auto-brightness-btn):not(.setting-row-actions button):not(.colorbox button):not(.settings-cat-tab):not(.loop-preset-pill):not(.brightness-preset-btn):not(.btn-status-widgets):not(.mode-toggle-btn):not(.topbar-lan-ip-btn):not(.topbar-user-trigger):not(.topbar-auth-btn):not(.topbar-dev-add-btn):not(.landing-secondary-btn):not(.widget-card-btn):not(.cloud-cmd-discard),
body.authed .modal-button--primary,
body.theme-light.authed .modal-button--primary,
body.authed .widget-inline-send-btn,
body.theme-light.authed .widget-inline-send-btn,
.setting-row-actions button:not(.cloud-only),
body.theme-light .setting-row-actions button:not(.cloud-only),
[data-theme="light"] .setting-row-actions button:not(.cloud-only),
.loop-transition-control__apply,
body.theme-light .loop-transition-control__apply,
.cloud-cmd-bar.has-queued #btn_send_cloud_cmds {
  background: var(--brand-primary) !important;
  border: 1px solid var(--brand-primary) !important;
  color: var(--text-on-brand) !important;
  box-shadow: var(--shadow-sm) !important;
}

.landing-enter-btn:hover,
body.theme-light .landing-enter-btn:hover,
body.authed .modal-button--primary:hover,
body.theme-light.authed .modal-button--primary:hover,
body.authed .widget-inline-send-btn:hover,
body.theme-light.authed .widget-inline-send-btn:hover,
.setting-row-actions button:not(.cloud-only):hover,
body.theme-light .setting-row-actions button:not(.cloud-only):hover,
[data-theme="light"] .setting-row-actions button:not(.cloud-only):hover,
.loop-transition-control__apply:hover,
.cloud-cmd-bar.has-queued #btn_send_cloud_cmds:hover {
  background: var(--brand-hover) !important;
  border-color: var(--brand-hover) !important;
  color: var(--text-on-brand) !important;
}

/* Botones secundarios, chips, pestañas y navegación de loop */
body.authed .modal-button--secondary,
body.theme-light.authed .modal-button--secondary,
#btn_reboot,
#btn_sleep,
body.theme-light #btn_reboot,
body.theme-light #btn_sleep,
body.authed .auto-brightness-btn:not(.active),
body.theme-light.authed .auto-brightness-btn:not(.active),
.loop-header .status-navigation button,
body.theme-light .loop-header .status-navigation button,
[data-theme="light"] .loop-header .status-navigation button,
.widget-card-btn,
body.theme-light .widget-card-btn,
[data-theme="light"] .widget-card-btn,
.settings-cat-tab:not(.active),
body.theme-light .settings-cat-tab:not(.active),
[data-theme="light"] .settings-cat-tab:not(.active),
.sleep-chip-btn:not(.active),
body.theme-light .sleep-chip-btn:not(.active),
.tariff-chip-btn,
body.theme-light .tariff-chip-btn,
.weekday-btn span,
body.theme-light .weekday-btn span,
.setting-row-actions button.cloud-only,
body.theme-light .setting-row-actions button.cloud-only,
[data-theme="light"] .setting-row-actions button.cloud-only,
.cloud-cmd-actions button:not(#btn_send_cloud_cmds),
body.theme-light .cloud-cmd-actions button:not(#btn_send_cloud_cmds) {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
}

body.authed .modal-button--secondary:hover,
body.theme-light.authed .modal-button--secondary:hover,
#btn_reboot:hover,
#btn_sleep:hover,
body.theme-light #btn_reboot:hover,
body.theme-light #btn_sleep:hover,
body.authed .auto-brightness-btn:not(.active):hover,
body.theme-light.authed .auto-brightness-btn:not(.active):hover,
.loop-header .status-navigation button:hover,
body.theme-light .loop-header .status-navigation button:hover,
[data-theme="light"] .loop-header .status-navigation button:hover,
.settings-cat-tab:not(.active):hover,
body.theme-light .settings-cat-tab:not(.active):hover,
[data-theme="light"] .settings-cat-tab:not(.active):hover,
.sleep-chip-btn:not(.active):hover,
body.theme-light .sleep-chip-btn:not(.active):hover,
.tariff-chip-btn:hover,
body.theme-light .tariff-chip-btn:hover,
.weekday-btn:hover span,
body.theme-light .weekday-btn:hover span {
  background: var(--brand-tint) !important;
  border-color: var(--brand-primary) !important;
  color: var(--text-primary) !important;
}

.widget-card:hover .widget-card-btn,
body.theme-light .widget-card:hover .widget-card-btn,
[data-theme="light"] .widget-card:hover .widget-card-btn,
.settings-cat-tab.active,
body.theme-light .settings-cat-tab.active,
[data-theme="light"] .settings-cat-tab.active,
.loop-preset-pill.active,
body.theme-light .loop-preset-pill.active,
[data-theme="light"] .loop-preset-pill.active,
.sleep-chip-btn.active,
body.theme-light .sleep-chip-btn.active,
.weekday-btn input[type="checkbox"]:checked + span,
body.theme-light .weekday-btn input[type="checkbox"]:checked + span,
body.authed .auto-brightness-btn.active,
.brightness-preset-btn.active {
  background: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: var(--text-on-brand) !important;
}

.loop-preset-pill,
body.theme-light .loop-preset-pill,
[data-theme="light"] .loop-preset-pill,
.brightness-preset-btn {
  color: var(--text-secondary) !important;
}

.loop-preset-pill:hover,
body.theme-light .loop-preset-pill:hover,
[data-theme="light"] .loop-preset-pill:hover,
.brightness-preset-btn:hover {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
}

/* Slider de brillo en tono ámbar */
body.authed .brightness-slider-wrapper input[type="range"] {
  background: linear-gradient(to right, var(--border-subtle) 0%, var(--brand-primary) 100%) !important;
}

body.authed .brightness-slider-wrapper input[type="range"]::-webkit-slider-thumb {
  background: var(--brand-primary) !important;
  border: 2px solid var(--bg-surface) !important;
}

/* Acceso rápido a Widgets en Status */
.btn-status-widgets,
body.theme-light .btn-status-widgets,
[data-theme="light"] .btn-status-widgets {
  background: var(--brand-tint) !important;
  border: 1px solid var(--brand-primary) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-sm) !important;
}

.btn-status-widgets:hover,
body.theme-light .btn-status-widgets:hover,
[data-theme="light"] .btn-status-widgets:hover {
  border-color: var(--brand-hover) !important;
  background: var(--brand-tint) !important;
}

.btn-status-widgets__arrow,
body.theme-light .btn-status-widgets__arrow,
[data-theme="light"] .btn-status-widgets__arrow {
  background: var(--brand-primary) !important;
  color: var(--text-on-brand) !important;
}

/* Iconos de categorías en Galería de Widgets */
body.theme-light .widget-card-icon--blue    { background: #DBEAFE; color: #1E40AF; border-color: #93C5FD; }
body.theme-light .widget-card-icon--rose    { background: #FFE4E6; color: #9F1239; border-color: #FDA4AF; }
body.theme-light .widget-card-icon--amber   { background: #FEF3C7; color: #92400E; border-color: #F59E0B; }
body.theme-light .widget-card-icon--cyan    { background: #CFFAFE; color: #155E75; border-color: #67E8F9; }
body.theme-light .widget-card-icon--emerald { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
body.theme-light .widget-card-icon--orange  { background: #FFEDD5; color: #9A3412; border-color: #FDBA74; }
body.theme-light .widget-card-icon--indigo  { background: #E0E7FF; color: #3730A3; border-color: #A5B4FC; }
body.theme-light .widget-card-icon--yellow  { background: #FEF9C3; color: #854D0E; border-color: #FDE047; }
body.theme-light .widget-card-icon--purple  { background: #F3E8FF; color: #6B21A8; border-color: #D8B4FE; }

.topbar-dev-add-btn,
body.theme-light .topbar-dev-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
  height: 26px;
  padding: 0 10px !important;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.topbar-dev-add-btn i {
  font-size: 11px;
  color: var(--brand-primary) !important;
}

.topbar-dev-add-btn:hover,
body.theme-light .topbar-dev-add-btn:hover {
  background: var(--brand-tint) !important;
  border-color: var(--brand-primary) !important;
  color: var(--text-primary) !important;
}

/* Tarjetas de dispositivos y bloques de la pestaña Conexión */
#cloud_token_box,
body.theme-light #cloud_token_box,
body.theme-dark #cloud_token_box {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

.conn-step,
body.theme-light .conn-step {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
}

.conn-step .n {
  background: var(--brand-primary) !important;
  color: var(--text-on-brand) !important;
}

.conn-step strong {
  color: var(--text-primary) !important;
}

.conn-step span {
  color: var(--text-secondary) !important;
}

.conn-hint,
body.theme-light .conn-hint {
  background: var(--brand-tint) !important;
  border: 1px solid var(--brand-primary) !important;
  color: var(--text-primary) !important;
}

.conn-hint i {
  color: var(--brand-primary) !important;
}

.device-card-row,
body.theme-light .device-card-row,
[data-theme="light"] .device-card-row {
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: none !important;
  color: var(--text-primary) !important;
}

.device-card-row.is-primary,
body.theme-light .device-card-row.is-primary,
[data-theme="light"] .device-card-row.is-primary {
  background: var(--bg-subtle) !important;
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 1px var(--brand-primary) !important;
}

.device-primary-radio {
  accent-color: var(--brand-primary) !important;
}

.device-action-btn,
body.theme-light .device-action-btn,
[data-theme="light"] .device-action-btn {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-secondary) !important;
}

.device-action-btn:hover:not(:disabled),
body.theme-light .device-action-btn:hover:not(:disabled),
[data-theme="light"] .device-action-btn:hover:not(:disabled) {
  background: var(--brand-tint) !important;
  border-color: var(--brand-primary) !important;
  color: var(--brand-primary) !important;
}

/* Refuerzo adicional para usuarios con prefers-contrast: more */
@media (prefers-contrast: more) {
  :root[data-theme="light"],
  body.theme-light {
    --border-subtle: #57534E;
    --text-secondary: #1C1917;
  }

  :root[data-theme="dark"],
  body.theme-dark {
    --border-subtle: #A8A29E;
    --text-secondary: #F5F5F4;
  }
}

/* ==========================================================================
   Modern Web Guidance: <dialog> nativo, :focus-visible y prefers-reduced-motion
   ========================================================================== */

/* Native modal <dialog> (#custom_modal): nunca fijar display fuera de [open] */
dialog.native-modal-dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  max-width: min(480px, calc(100vw - 32px));
  width: 100%;
  overflow: visible;
}

dialog.native-modal-dialog .modal-dialog {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

/* Bloquea el scroll de la página bajo el modal sin tocar overflow en html/body */
dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--backdrop-bg, rgba(18, 17, 16, 0.72));
  backdrop-filter: blur(5px);
}

/* Indicador de foco accesible para navegación por teclado (:focus-visible) */
:where(a:any-link, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--brand-primary, #D97706) !important;
  outline-offset: 2px !important;
}

@media (forced-colors: active) {
  :where(a:any-link, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 2px solid Highlight !important;
    outline-offset: 2px !important;
  }
}

/* Respeto por prefers-reduced-motion (selectivo, sin global 0.01ms) */
@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-dialog,
  .topbar-user-dropdown,
  .fa-spin {
    animation: none !important;
  }

  .power-buttons button,
  .canvas-indicator,
  .widget-card,
  .btn-status-widgets {
    transition-property: color, background-color, border-color, opacity !important;
  }
}

/* ====================================================
   SECCIÓN "¿QUÉ ES ESTO?" Y PIE FIJO GLOBAL
   ==================================================== */
.about-container {
  margin: 0 auto;
  padding: 8px 0 16px;
}

.about-block {
  margin-top: 28px;
}

.about-block-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.about-block-title i {
  color: var(--brand-primary);
}

.about-block-desc {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.about-block-desc a {
  color: var(--brand-primary);
  text-decoration: underline;
}

.about-req-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.about-req-card {
  margin: 0 !important;
  max-width: none !important;
}

.lan-firefox-warn {
  margin: 8px 0 12px !important;
  max-width: none !important;
  text-align: left;
}

.about-req-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.about-req-info i {
  color: var(--brand-primary);
  font-size: 18px;
  margin-top: 2px;
  flex-shrink: 0;
}

.about-req-info b {
  color: var(--text-primary);
}

.about-devices-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 720px) {
  .about-devices-grid {
    grid-template-columns: 1fr;
  }
}

.about-res-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--brand-tint);
  border: 1px solid var(--brand-primary);
  color: var(--brand-primary);
  vertical-align: middle;
}

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  padding: 10px 20px;
  text-align: center;
  font-size: 12px;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary, #94a3b8);
}

body.theme-light .app-footer,
[data-theme="light"] .app-footer {
  background: rgba(253, 254, 255, 0.94);
  border-top: 1px solid var(--border-subtle, #e2e8f0);
  color: var(--text-secondary, #64748b);
}

.app-footer .legal-links {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

.app-footer .legal-links a {
  color: var(--brand-primary, #3b82f6);
  text-decoration: none;
}

.app-footer .legal-links a:hover {
  text-decoration: underline;
}

.app-footer .legal-links span {
  opacity: 0.6;
  margin: 0 6px;
}

/* ====================================================
   DESPLEGABLE DE MODO (LAN / NUBE) Y BOTÓN IP LOCAL
   ==================================================== */
.mode-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 26px;
  box-sizing: border-box;
  padding: 0 2px 0 8px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.mode-select-wrap i {
  font-size: 12px;
  pointer-events: none;
  margin-right: 5px;
  flex-shrink: 0;
}

.mode-select-wrap.mode-lan {
  color: #34d399;
}

.mode-select-wrap.mode-lan i {
  color: #10b981;
}

.mode-select-wrap.mode-cloud {
  color: #60a5fa;
}

.mode-select-wrap.mode-cloud i {
  color: #38bdf8;
}

body.theme-light .mode-select-wrap.mode-lan,
[data-theme="light"] .mode-select-wrap.mode-lan {
  color: #065f46;
}

body.theme-light .mode-select-wrap.mode-cloud,
[data-theme="light"] .mode-select-wrap.mode-cloud {
  color: #1e40af;
}

.mode-toggle-select,
body.authed .mode-toggle-select,
body.theme-light.authed .mode-toggle-select {
  width: auto !important;
  min-width: 0 !important;
  flex-shrink: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  background-color: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  color: inherit !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em;
  line-height: 24px !important;
  height: 24px !important;
  margin: 0 !important;
  padding: 0 20px 0 2px !important;
  cursor: pointer;
  outline: none !important;
  box-shadow: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='5' viewBox='0 0 9 5'%3E%3Cpath fill='%2394a3b8' d='M0 0l4.5 5L9 0z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 4px center !important;
}

.mode-toggle-select option {
  background: var(--bg-surface, #1e293b);
  color: var(--text-primary, #f1f5f9);
  font-weight: 600;
}

.topbar-lan-ip-btn,
body.theme-light .topbar-lan-ip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
  height: 26px;
  padding: 0 10px !important;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  cursor: pointer;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.topbar-lan-ip-btn:hover,
body.theme-light .topbar-lan-ip-btn:hover {
  border-color: var(--brand-primary) !important;
}

.topbar-lan-ip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.topbar-lan-ip-edit {
  font-size: 10px;
  opacity: 0.65;
}

/* Fondo verde cuando hay conexión LAN activa */
.topbar-lan-ip-btn.is-connected {
  background: rgba(16, 185, 129, 0.24) !important;
  border-color: #10b981 !important;
  color: #ecfdf5 !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.22) !important;
}

body.theme-light .topbar-lan-ip-btn.is-connected,
[data-theme="light"] .topbar-lan-ip-btn.is-connected {
  background: #dcfce7 !important;
  border-color: #16a34a !important;
  color: #14532d !important;
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.18) !important;
}

.topbar-lan-ip-btn.is-connected .topbar-lan-ip-dot {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

body.theme-light .topbar-lan-ip-btn.is-connected .topbar-lan-ip-dot,
[data-theme="light"] .topbar-lan-ip-btn.is-connected .topbar-lan-ip-dot {
  background: #16a34a;
  box-shadow: 0 0 4px rgba(22, 163, 74, 0.6);
}
