/*
 * Web de gestión (`gestion.js`): lo que le falta a `docs.css`, cuya base (colores, cabecera, botones) comparte. El MISMO
 * archivo en las tres apps (ListenUnify/public/gestion, WatchUnify/site/gestion y GasUnify/public/gestion): si cambia uno,
 * se copia a los otros.
 */
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; max-width: 420px; margin: 24px auto; display: flex; flex-direction: column; gap: 12px; }
.login-box h1 { margin: 0; }
input, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.button.danger { background: #c62828; color: #fff; }
.button[aria-busy='true'] { opacity: .75; cursor: progress; }
.button[aria-busy='true']::before, .spinner { content: ''; display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: gestion-spin .8s linear infinite; }
@keyframes gestion-spin { to { transform: rotate(360deg); } }
.busy { display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.error-text { color: #ff6b6b; margin: 0; }
.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.grow { flex: 1; min-width: 0; }
.toc-inline { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.toc-inline a { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.toc-inline a[hidden] { display: none; }
section[hidden] { display: none; }
/* Aviso flotante abajo: la cabecera fija cambia de alto según el ancho y un aviso arriba quedaba tapado en el móvil. */
.notice-area { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 5; max-width: 680px; margin: 0 auto; }
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); box-shadow: 0 6px 24px #0006; overflow-wrap: anywhere; }
.notice.error { border-left-color: #ff6b6b; }
.icon-close { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); margin-left: 6px; vertical-align: middle; }
.badge.danger { background: #c62828; color: #fff; }
.badge.warn { background: #f9a825; color: #15171c; }
details.user { padding: 0; }
details.user > summary { padding: 10px 14px; list-style-position: inside; }
.user-name { font-weight: 700; }
.user-meta { display: block; font-weight: 400; margin-top: 2px; }
.user-body { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.user-body h3 { font-size: 16px; margin: 14px 0 4px; }
.plain-list { list-style: none; padding: 0; margin: 8px 0; }
.plain-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { font: inherit; padding: 6px 12px; border-radius: 999px; background: var(--surface); color: var(--text); border: 1px solid var(--line); cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
details.log-error summary { font-weight: 400; }
details.log-error pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); padding: 10px; border-radius: 8px; font-size: 13px; }
.meter { display: inline-block; width: 120px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.meter-fill { display: block; height: 100%; background: #2ebd85; }
.meter.warn .meter-fill { background: #f9a825; }
.meter.danger .meter-fill { background: #c62828; }
/* Mi configuración (config.js, WatchUnify) */
.config-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.config-card[data-disabled='true'] { opacity: .6; }
.config-card .row { margin: 6px 0; }
.form-grid { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 8px 12px; align-items: center; margin: 10px 0; }
.form-grid label { color: var(--muted); }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; box-sizing: border-box; }
textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 70px; }
.sticky-save[hidden] { display: none; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); z-index: 2; }
.schedule-list li { align-items: baseline; }
.schedule-list time { font-variant-numeric: tabular-nums; min-width: 90px; color: var(--muted); }
.schedule-list li.now { border-left: 4px solid var(--accent); padding-left: 8px; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .row input, .row select { flex: 1 1 100%; }
}

/* Caja de contraseña con el ojito para ver lo escrito (gestion.js › passwordField). */
.input-with-eye { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.input-with-eye input { flex: 1; min-width: 0; }
.login-box .input-with-eye { display: flex; }
.eye-toggle { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.eye-toggle:hover { color: var(--text); }
.link-button { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; font: inherit; text-align: left; }
.link-button:hover { text-decoration: underline; }
.form-grid .input-with-eye { display: flex; }

/* Pestañas «Mi usuario» / «Administración» (solo administradores; 2026-11-26) */
.tabs { display: flex; gap: 4px; margin: 16px 0 4px; border-bottom: 1px solid var(--line); }
.tab { font: inherit; font-weight: 600; padding: 10px 16px; background: none; color: var(--muted); border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Ventana de confirmación propia (confirmDialog en gestion.js): nunca la del navegador. */
.dialog-backdrop { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; background: #000a; }
.dialog { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 12px 40px #0008; }
.dialog h2 { margin: 0 0 8px; padding: 0; border: 0; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.dialog p { margin: 0 0 18px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
/* Historial de cambios de plan de un usuario (2026-11-28): cuándo, de qué a qué, quién y el motivo. */
.user-body h4 { margin: 14px 0 6px; font-size: 14px; }
.plan-history { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.plan-change { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.plan-reason { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Bloques de «Mi configuración» con los mismos controles que Ajustes de la app (2026-11-28): colores, interruptores y desplegables. */
.settings-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.settings-panel h3 { margin: 0 0 2px; }
.settings-panel > div > h3 { margin-top: 0; }
.settings-panel .field { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.settings-panel .field > small { flex-basis: 100%; }
.settings-panel .field > .row { margin: 0; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.active { border-color: var(--text); }
.switch-field { padding: 4px 0; cursor: pointer; flex-wrap: nowrap; }
.switch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 2px solid var(--line); transition: background .18s; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #cfd3dc; transition: transform .18s, background .18s; box-shadow: 0 1px 3px #0006; }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(22px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Foto de los perfiles (config.js, como en la app): círculo encuadrado con CSS, editor con zoom y arrastre. */
.profile-avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%; background-color: var(--surface-2); background-repeat: no-repeat; color: var(--text); font-weight: 700; overflow: hidden; }
.avatar-editor { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.avatar-editor h4 { margin: 4px 0; }
.avatar-preview { align-self: flex-start; cursor: grab; touch-action: none; user-select: none; box-shadow: 0 0 0 3px var(--accent); }
.avatar-preview:active { cursor: grabbing; }
.avatar-editor input[type=range] { flex: 1; min-width: 140px; }
