/* cte home · Control energético — portado del prototipo Control_Energetico_dc.html */

:root {
	--bg: #F7F6F5;
	--card: #FFFFFF;
	--ink: #111112;
	--accent: #76232F;
	--accent-2: #EB5C5F;
	--accent-soft: #F6E7E8;
	--accent-border: #E7CDD0;
	--muted: #A09A98;
	--muted-2: #98918F;
	--muted-3: #77716F;
	--border: #EAE6E4;
	--border-2: #E2DEDC;
	--divider: #F3F0EE;
	--head-bg: #FAF8F7;
	--ok: #22A06B;
	--off: #C9C3C1;
	--mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
	background: var(--bg);
	color: var(--ink);
	font-family: Manrope, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
input, button { font-family: inherit; }
input::placeholder { color: #A8A2A5; }

@keyframes pulseDot { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.85); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
	* { animation: none !important; transition: none !important; }
}

/* Contenedor tipo app: a ancho completo en móvil, centrado en escritorio */
.app {
	max-width: 430px;
	margin: 0 auto;
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
}
.screen {
	flex: 1;
	overflow-y: auto;
	padding: 18px 20px 24px;
	padding-bottom: calc(24px + 90px);	/* hueco para la nav inferior */
}
.screen--login { padding-bottom: 24px; display: flex; flex-direction: column; justify-content: center; }

/* Tipos recurrentes */
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .1em; /*text-transform: uppercase;color: var(--muted);*/ display: flex;align-items: flex-end;     gap: 4px; }
.microlabel { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: var(--ink); margin-top: 4px; }
.mono { font-family: var(--mono); }
.powered {
	margin-top: 26px; text-align: center; font-size: 10.5px; font-weight: 600;
	letter-spacing: .08em; text-transform: uppercase; color: #C4BEBC;
}
.powered strong { color: var(--accent); font-weight: 800; }

/* ---------- Login ---------- */
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 28px; }
.brand__mark {
	width: 44px; height: 44px; border-radius: 14px; /*background: var(--accent);*/
	display: flex; align-items: center; justify-content: center; flex: none;
}
.brand__mark i { /*width: 13px; height: 13px; background: var(--accent-2); border-radius: 3px; transform: rotate(45deg);*/     color: var(--accent-2); }
.brand__name { font-size: 19px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.brand__sub { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.login-title { font-size: 31px; line-height: 1.08; font-weight: 800; letter-spacing: -.03em; }
.login-lede { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--muted-3); max-width: 260px; text-wrap: pretty; }
.login-error {
	margin-top: 18px; background: #FDF4F4; border: 1px solid var(--accent-border);
	color: var(--accent); border-radius: 12px; padding: 11px 14px; font-size: 13.5px; font-weight: 600;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); }
.field input {
	height: 52px; border: 1px solid var(--border-2); background: var(--card);
	border-radius: 14px; padding: 0 16px; font-size: 15px; color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--accent); }
.login-form .fields { display: flex; flex-direction: column; gap: 12px; margin-top: 30px; }
.login-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.remember { display: flex; align-items: center; gap: 8px; color: var(--muted-3); cursor: pointer; }
.remember input { position: absolute; opacity: 0; width: 0; height: 0; }
.remember .box {
	width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--accent);
	display: inline-flex; align-items: center; justify-content: center;
	color: #FFF; font-size: 10px; font-weight: 800; background: var(--card);
}
.remember input:checked + .box { background: var(--accent); }
.remember input:focus-visible + .box { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn-primary {
	margin-top: 26px; width: 100%; height: 56px; border: none; border-radius: 16px;
	background: var(--accent); color: #FFF; font-size: 16px; font-weight: 700;
	letter-spacing: -.01em; cursor: pointer; transition: background .18s ease;
}
.btn-primary:hover { background: #8E2B39; }
.btn-primary:active { background: #611C26; }

/* ---------- Cabecera del panel ---------- */
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.avatar-btn {
	width: 40px; height: 40px; flex: none; border-radius: 12px; border: 1px solid var(--border-2);
	background: var(--card); color: var(--accent); font-size: 14px; font-weight: 700; cursor: pointer;
}
.avatar-btn:hover { border-color: var(--accent); }
.chips { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12px; font-weight: 600; color: var(--muted-2); flex-wrap: wrap; }
.chip { background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; display: flex; align-items: center; gap: 6px; }
.chip .dot-ok { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

/* ---------- Grupos y cards de dispositivo ---------- */
.group { margin-top: 24px; }
.group__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.group__title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.group__title::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.group__kwh { font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
.cards { display: flex; flex-direction: column; gap: 10px; }
.dev-card {
	display: block; width: 100%; text-align: left; background: var(--card);
	border: 1px solid var(--border); border-radius: 18px; padding: 15px 16px;
	cursor: pointer; transition: border-color .18s ease, transform .18s ease; color: inherit;
}
.dev-card:hover { border-color: var(--accent); transform: translateY(-1px); color: inherit; }
.dev-card__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dev-card__id { display: flex; align-items: center; gap: 9px; min-width: 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot--on { background: var(--ok); animation: pulseDot 2s ease-in-out infinite; }
.dot--off { background: var(--off); }
.dev-card__name {
	font-size: 14.5px; font-weight: 700; letter-spacing: -.01em;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.state { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; flex: none; }
.state--on { color: var(--ok); }
.state--off { color: var(--muted); }
.dev-card__stats { display: flex; align-items: flex-end; gap: 20px; margin-top: 14px; }
.stat-num { font-family: var(--mono); font-size: 21px; font-weight: 600; letter-spacing: -.03em; margin-top: 2px; }
.stat-num small { font-size: 12px; font-weight: 500; color: var(--muted-3); margin-left: 3px; font-family: Manrope, sans-serif; }
.stat-num--kwh { color: var(--accent); }
/* Equipos que solo conmutan: sin potencia ni sparkline, el estado del relé
   ocupa la fila entera y no compite en tamaño con las cifras de consumo. */
.dev-card__stats--sw { gap: 0; }
.stat-num--sw {
	font-family: Manrope, sans-serif; font-size: 15px; font-weight: 800;
	letter-spacing: -.01em; color: var(--ink, #111112);
}
.dev-card--sw .dev-card__stats { margin-top: 10px; }
.spark { flex: 1; display: flex; align-items: flex-end; justify-content: flex-end; gap: 2px; height: 30px; }
/*
.spark span { width: 3px; border-radius: 2px; background: #F0DDDF; }
*/
.spark span { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: #F0DDDF; }

/* ---------- Selector de dispositivo (botón + hoja) ---------- */
.picker-btn {
	margin-top: 10px; width: 100%; background: var(--card); border: 1px solid var(--border);
	border-radius: 18px; padding: 13px 15px; display: flex; align-items: center; gap: 12px;
	cursor: pointer; text-align: left;
}
.picker-btn:hover { border-color: var(--accent); }
.picker-btn__icon {
	width: 34px; height: 34px; flex: none; border-radius: 11px; background: var(--accent-soft);
	display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 13px;
}
.picker-btn__txt { flex: 1; min-width: 0; }
.picker-btn__name {
	display: block; font-size: 16px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.picker-btn__cta { flex: none; font-size: 12px; color: var(--muted-2); font-weight: 700; }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: none; flex-direction: column; justify-content: flex-end; }
.sheet-wrap.open { display: flex; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(17,17,18,.45); animation: fadeIn .18s ease; border: none; }
.sheet {
	position: relative; background: var(--bg); border-radius: 28px 28px 0 0; max-height: 72%;
	display: flex; flex-direction: column; animation: sheetUp .26s cubic-bezier(.2,.8,.2,1);
	max-width: 430px; margin: 0 auto; width: 100%;
}
.sheet__head {
	flex: none; padding: 16px 20px 12px; display: flex; align-items: center;
	justify-content: space-between; border-bottom: 1px solid var(--border);
}
.sheet__title { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.sheet__close {
	width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border-2);
	background: var(--card); color: var(--muted-3); font-size: 13px; cursor: pointer;
}
.sheet__body { flex: 1; overflow-y: auto; padding: 6px 20px 30px; }
.sheet-group { margin-top: 14px; }
.sheet-group__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sheet-group__name { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.sheet-group__rule { flex: 1; height: 1px; background: var(--border); }
.sheet-group__count { font-family: var(--mono); font-size: 11px; color: #B4AEAC; }
.sheet-list { display: flex; flex-direction: column; gap: 6px; }
.sheet-item {
	width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
	border: 1px solid var(--border); background: var(--card); border-radius: 14px; padding: 12px 13px; color: inherit;
}
.sheet-item:hover { border-color: var(--accent); color: inherit; }
.sheet-item__name {
	flex: 1; min-width: 0; font-size: 14px; font-weight: 700; letter-spacing: -.01em;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-item__w { flex: none; font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
.sheet-item__check { flex: none; font-size: 12px; font-weight: 800; width: 12px; text-align: right; }
.sheet-item.sel { background: var(--accent); border-color: var(--accent); color: #FFF; }
.sheet-item.sel .sheet-item__w { color: rgba(255,255,255,.72); }

/* ---------- Historial ---------- */
.card { margin-top: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 18px 16px; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; }
.card__title { font-size: 13.5px; font-weight: 700; }
.card__meta { font-family: var(--mono); font-size: 12.5px; color: var(--muted-2); }
.card__meta--accent { color: var(--accent); font-weight: 600; }
.filters {
	margin-top: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 18px;
	padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.filters__date { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.filters__date input {
	border: none; outline: none; background: transparent; font-size: 15px;
	font-weight: 600; color: var(--ink); padding: 0; width: 100%;
}
.seg { display: flex; background: #F2EEEC; border-radius: 11px; padding: 3px; }
.seg button {
	height: 30px; padding: 0 12px; border: none; border-radius: 9px;
	font-size: 12.5px; font-weight: 700; cursor: pointer; background: transparent; color: #8E8886;
}
.seg button.sel { background: var(--card); color: var(--accent); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 132px; margin-top: 16px; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bars__bar { width: 100%; border-radius: 3px 3px 1px 1px; background: var(--accent); min-height: 2px; }
.bars__bar--peak { background: var(--accent-2); }
.bars__tick { font-family: var(--mono); font-size: 8px; color: #B4AEAC; }
.line-chart { margin-top: 14px; }
.btn-ghost {
	margin-top: 14px; width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--border-2);
	background: var(--card); color: var(--accent); font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); }
.table { margin-top: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.table__row { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 11px 16px; border-bottom: 1px solid var(--divider); font-family: var(--mono); font-size: 12.5px; }
.table__row span:nth-child(2) { text-align: right; color: var(--muted-3); }
.table__row span:nth-child(3) { text-align: right; font-weight: 600; }
.table__head {
	display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 12px 16px; background: var(--head-bg);
	border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 700;
	letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.table__head span:nth-child(n+2) { text-align: right; }

/* ---------- Tiempo real ---------- */
.live-head { display: flex; align-items: center; justify-content: space-between; }
.live-badge {
	display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
	letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
	background: var(--accent-soft); padding: 7px 10px; border-radius: 9px;
}
.live-badge .dot { width: 6px; height: 6px; background: var(--accent-2); animation: pulseDot 1.4s ease-in-out infinite; }
.live-badge.stale { color: var(--muted-2); background: #F2EEEC; }
.live-badge.stale .dot { background: var(--off); animation: none; }
.inst-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.inst-tag {
	font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
	color: var(--accent); border: 1px solid var(--accent-border); background: #FDF4F4;
	border-radius: 8px; padding: 5px 9px;
}
.inst-serial { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.live-hero { margin-top: 14px; border-radius: 22px; background: var(--ink); color: #FFF; padding: 20px; overflow: hidden; }
.live-hero__label { font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; opacity: .55; }
.live-hero__num { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.live-hero__num strong { font-family: var(--mono); font-size: 46px; font-weight: 600; letter-spacing: -.045em; line-height: .9; }
.live-hero__num small { font-size: 15px; font-weight: 600; opacity: .6; padding-bottom: 5px; }
.live-hero__spark { margin-top: 14px; }
.live-hero__cells { display: flex; gap: 8px; margin-top: 16px; }
.live-cell { flex: 1; background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 12px; }
.live-cell__label { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; opacity: .5; }
.live-cell__val { font-family: var(--mono); font-size: 16px; font-weight: 600; margin-top: 3px; }
.section-label { margin-top: 22px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.phase-table { margin-top: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.phase-row { display: grid; grid-template-columns: 44px 1fr 1fr 1fr; padding: 12px 14px; border-bottom: 1px solid var(--divider); font-family: var(--mono); font-size: 13px; }
.phase-row span:first-child { font-weight: 600; color: var(--accent); }
.phase-row span:nth-child(n+2) { text-align: right; }
.phase-row span:nth-child(4) { font-weight: 600; }
.phase-row--head {
	background: var(--head-bg); border-bottom: 1px solid var(--border); padding: 11px 14px;
	font-family: Manrope, sans-serif; font-size: 10.5px; font-weight: 700;
	letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.phase-row--head span:first-child { color: var(--muted); font-weight: 700; }
.phase-row--sum { background: var(--head-bg); border-bottom: none; }
.phase-row--sum span:first-child { font-family: Manrope, sans-serif; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.imbalance { margin-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted-2); }
.imbalance::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); }
.params { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.param { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 13px 14px; }
.param__val { display: flex; align-items: baseline; gap: 4px; margin-top: 6px; }
.param__val strong { font-family: var(--mono); font-size: 19px; font-weight: 600; letter-spacing: -.02em; }
.param__val small { font-size: 11px; font-weight: 600; color: var(--muted-3); }

/* ---------- Opciones ---------- */
.loc-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 14px 15px; margin-top: 12px; }
.loc-card .field input {
	height: 40px; border-radius: 11px; padding: 0 12px; font-size: 15px;
	font-weight: 700; background: var(--head-bg); letter-spacing: -.01em;
}
.loc-card .field input:focus { background: var(--card); }
.dev-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--divider); }
.dev-row { display: flex; align-items: center; gap: 10px; }
.dev-row input {
	flex: 1; min-width: 0; height: 38px; border: 1px solid var(--border); background: var(--card);
	border-radius: 10px; padding: 0 11px; font-size: 14px; font-weight: 600; color: var(--ink); outline: none;
}
.dev-row input:focus { border-color: var(--accent); }
.dev-row .tag { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.prefs { margin-top: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.pref { display: flex; align-items: center; gap: 12px; padding: 14px 15px; border-bottom: 1px solid var(--divider); cursor: pointer; }
.pref:last-child { border-bottom: none; }
.pref__txt { flex: 1; }
.pref__label { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.pref__hint { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.toggle { width: 44px; height: 26px; flex: none; border-radius: 13px; padding: 3px; background: #DDD8D6; transition: background .2s ease; display: flex; justify-content: flex-start; border: none; cursor: pointer; }
.toggle.on { background: var(--accent); justify-content: flex-end; }
.toggle span { width: 20px; height: 20px; border-radius: 50%; background: #FFF; }
.tariff-box {
	display: flex; align-items: center; gap: 4px; background: var(--head-bg);
	border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px;
}
.tariff-box input {
	width: 52px; border: none; background: transparent; outline: none;
	font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--ink); text-align: right;
}
.tariff-box small { font-size: 11.5px; font-weight: 600; color: var(--muted-3); }
.btn-danger-soft {
	margin-top: 20px; width: 100%; height: 48px; border-radius: 14px; border: 1px solid var(--accent-border);
	background: #FDF4F4; color: var(--accent); font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-danger-soft:hover { background: var(--accent-soft); }
.save-note { margin-top: 8px; font-size: 12px; color: var(--muted-2); text-align: center; min-height: 16px; }

/* ---------- Nav inferior ---------- */
.bottom-nav {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
	max-width: 430px; margin: 0 auto;
	background: rgba(247,246,245,.92); backdrop-filter: blur(14px);
	border-top: 1px solid #E7E3E1;
	padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 14px));
	display: flex; gap: 3px;
}
.bottom-nav a {
	flex: 1; border: none; background: transparent; border-radius: 14px; padding: 9px 2px 8px;
	display: flex; flex-direction: column; align-items: center; gap: 5px; color: #8E8886;
}
.bottom-nav a.sel { background: #F0E4E5; color: var(--accent); }
.bottom-nav a:hover { color: var(--accent); }
.bottom-nav .glyph { font-size: 15px; line-height: 1; }
.bottom-nav .lbl { font-size: 10px; font-weight: 700; letter-spacing: -.01em; }

/* ---- Historial: gráficos Chart.js ---- */
.chart-box {
	position: relative;
	height: 210px;
	margin-top: 10px;
}
.card__sub {
	font-family: var(--mono, 'IBM Plex Mono', monospace);
	font-size: 10px;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--muted, #8A8786);
	margin-top: 2px;
}

/* ---- Historial: tabla de 4 columnas (vista de día) ---- */
.table__head.table--4,
.table__row.table--4 { grid-template-columns: 1.1fr 1fr 1fr 1fr; }
.table__row.table--4 span:nth-child(2),
.table__row.table--4 span:nth-child(3) { text-align: right; color: var(--muted-3); font-weight: 400; }
.table__row.table--4 span:nth-child(4) { text-align: right; font-weight: 600; }

/* ---- Historial: tabla de 5 columnas (media, mín, máx, consumo) ---- */
.table__head.table--5,
.table__row.table--5 {
	grid-template-columns: 1fr .85fr .85fr .85fr 1.05fr;
	padding-left: 13px; padding-right: 13px;
}
.table__row.table--5 { font-size: 11.5px; }
.table__head.table--5 { font-size: 9.5px; letter-spacing: .04em; }
.table__row.table--5 span:nth-child(n+2) { text-align: right; }
.table__row.table--5 span:nth-child(2),
.table__row.table--5 span:nth-child(3),
.table__row.table--5 span:nth-child(4) { color: var(--muted-3); font-weight: 400; }
.table__row.table--5 span:nth-child(5) { font-weight: 600; }

/* ---- Tiempo real: badge de estado y aviso de offline ---- */
.live-badge.on { color: var(--ok, #22A06B); background: rgba(34,160,107,.1); }
.live-badge.on .dot { background: var(--ok, #22A06B); }
.live-badge.off { color: var(--muted-2, #8A8786); background: #F2EEEC; }
.live-badge.off .dot { background: var(--off, #C9C4C1); animation: none; }

.offline-note {
	margin-top: 14px;
	background: var(--card, #FFF);
	border: 1px solid var(--border, #E9E5E2);
	border-radius: 20px;
	padding: 30px 20px;
	text-align: center;
}
.offline-note__icon {
	width: 46px; height: 46px; margin: 0 auto;
	display: flex; align-items: center; justify-content: center;
	border-radius: 14px; background: #F2EEEC;
	font-size: 20px; color: var(--muted-2, #8A8786);
}
.offline-note__title { margin-top: 12px; font-weight: 800; font-size: 15.5px; }
.offline-note__txt {
	margin: 8px auto 0; max-width: 300px;
	font-size: 12.5px; line-height: 1.55; color: var(--muted-2, #8A8786);
}
.offline-note__txt strong { color: var(--ink, #111112); font-weight: 700; }
.offline-note__btn { margin-top: 16px; }

/* ---- Icono de sitio en cabeceras ---- */
.site-ico {
	width: 22px; height: 22px; border-radius: 7px;
	vertical-align: -5px; margin-right: 7px;
}

.site-ico--fa {
	display: inline-flex; align-items: center; justify-content: center;
	background: linear-gradient(135deg, #A63A47, #5E1B25);
	color: #FFF; font-size: 11px;
}
.site-ico--fa i { transform: rotate(45deg); }

/* ---- Recuperar contraseña ---- */
.login-back {
	display: block; text-align: center; margin-top: 16px;
	font-size: 13px; font-weight: 600; color: var(--muted-2, #8A8786);
	text-decoration: none;
}

/* ==================== OPCIONES v1.1 ==================== */
.section-hint {
	margin: -6px 0 12px;
	font-size: 11.5px; color: var(--muted-2, #8A8786);
}
.drag-ico { font-size: 12px; }
.drag {
	cursor: grab; user-select: none; touch-action: none;
	color: var(--muted-3, #C9C4C1); font-size: 15px;
	padding: 4px 6px; margin-left: -6px;
}
.drag:active { cursor: grabbing; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { background: #FBF3F1; border-radius: 12px; }

.loc-card__head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.loc-card__name {
	flex: 1; text-align: left; background: none; border: 0; cursor: pointer;
	font: inherit; font-weight: 800; font-size: 15px; color: var(--ink, #111112);
	display: flex; flex-direction: column; gap: 2px; padding: 4px 0;
}
.loc-card__name small {
	font-family: var(--mono, 'IBM Plex Mono', monospace);
	font-size: 10.5px; font-weight: 500; color: var(--muted-2, #8A8786);
}
.dev-row__name {
	flex: 1; text-align: left; background: none; border: 0; cursor: pointer;
	font: inherit; font-weight: 600; font-size: 13.5px; color: var(--ink, #111112);
	padding: 8px 0;
}
.tag--alert { color: var(--accent2, #EB5C5F); border-color: rgba(235,92,95,.35); }
.tag--owner { color: var(--accent, #76232F); border-color: rgba(118,35,47,.3); font-weight: 700; }

/* ---- Usuarios ---- */
.users-card {
	background: var(--card, #FFF); border: 1px solid var(--border, #E9E5E2);
	border-radius: 20px; padding: 8px 16px; margin-bottom: 18px;
}
.user-row {
	display: flex; align-items: center; gap: 12px;
	padding: 12px 0; border-bottom: 1px solid var(--border, #EFEBE8);
}
.user-row:last-of-type { border-bottom: 0; }
.user-row__avatar {
	width: 36px; height: 36px; border-radius: 12px; flex: none;
	display: flex; align-items: center; justify-content: center;
	background: #F2EEEC; font-weight: 800; font-size: 13px; color: var(--accent, #76232F);
}
.user-row__txt {
	flex: 1; min-width: 0; text-align: left; background: none; border: 0;
	font: inherit; cursor: pointer; padding: 0;
	display: flex; flex-direction: column; gap: 1px;
}
.user-row__txt:disabled { cursor: default; }
.user-row__name { font-weight: 700; font-size: 13.5px; color: var(--ink, #111112); }
.user-row__name small { font-weight: 500; color: var(--muted-2, #8A8786); }
.user-row__mail {
	font-size: 11.5px; color: var(--muted-2, #8A8786);
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-row--pending { opacity: .75; }
.link-danger {
	background: none; border: 0; cursor: pointer; font: inherit;
	font-size: 12px; font-weight: 700; color: var(--accent2, #EB5C5F);
}
.users-card__add { width: 100%; margin: 10px 0 12px; }

/* ---- Modales ---- */
body.modal-open { overflow: hidden; }
.modal {
	position: fixed; inset: 0; z-index: 60;
	background: rgba(17,17,18,.45);
	display: flex; align-items: flex-end; justify-content: center;
	animation: fadeIn .18s ease;
}
.modal[hidden] { display: none !important; }
[hidden] { display: none !important; }
.modal__card {
	background: var(--bg, #F7F6F5); width: 100%; max-width: 430px;
	border-radius: 24px 24px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
	max-height: 86vh; overflow-y: auto;
	animation: sheetUp .22s ease;
}
.modal__head {
	display: flex; align-items: center; justify-content: space-between;
	margin-bottom: 16px;
}
.modal__title { font-weight: 800; font-size: 16.5px; }
.modal__x {
	width: 34px; height: 34px; border-radius: 12px; border: 1px solid var(--border, #E9E5E2);
	background: var(--card, #FFF); font-size: 18px; cursor: pointer; color: var(--muted-2, #8A8786);
}
.modal__hint { font-size: 11.5px; color: var(--muted-2, #8A8786); margin: 2px 0 16px; }
.modal__sub {
	font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
	color: var(--muted-2, #8A8786); margin: 14px 0 8px;
}
.modal__err {
	background: rgba(235,92,95,.1); color: var(--accent2, #EB5C5F);
	border-radius: 12px; padding: 10px 14px; font-size: 12.5px; font-weight: 600;
	margin-bottom: 12px;
}
.modal__remove { width: 100%; margin-top: 10px; }
.modal .btn-primary { width: 100%; margin-top: 6px; }
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field select {
	width: 100%; border: 1px solid var(--border, #E9E5E2); border-radius: 14px;
	background: var(--card, #FFF); padding: 13px 12px; font: inherit; font-size: 14px;
}
.pref--inmodal {
	background: var(--card, #FFF); border: 1px solid var(--border, #E9E5E2);
	border-radius: 14px; padding: 12px 14px; margin: 4px 0 12px;
}
.check-list {
	background: var(--card, #FFF); border: 1px solid var(--border, #E9E5E2);
	border-radius: 14px; padding: 6px 14px; max-height: 34vh; overflow-y: auto;
	margin-bottom: 12px;
}
.check-list__group {
	font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
	color: var(--muted-2, #8A8786); margin: 10px 0 2px;
}
.check {
	display: flex; align-items: center; gap: 10px; padding: 8px 0;
	font-size: 13.5px; font-weight: 600; cursor: pointer;
	border-bottom: 1px solid var(--border, #F1EDEA);
}
.check:last-child { border-bottom: 0; }
.check input { width: 17px; height: 17px; accent-color: var(--accent, #76232F); }
.pref__btn { padding: 9px 16px; font-size: 12.5px; white-space: nowrap; }

/* ---- Banner instalar PWA (panel) ---- */
.install-banner {
	display: flex; align-items: center; gap: 12px;
	background: var(--card, #FFF); border: 1px solid var(--border, #E9E5E2);
	border-radius: 18px; padding: 12px 14px; margin-bottom: 16px;
	animation: fadeIn .3s ease;
}
.install-banner img { width: 38px; height: 38px; border-radius: 11px; }
.install-banner__txt { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.install-banner__txt strong { font-size: 13.5px; }
.install-banner__txt span { font-size: 11.5px; color: var(--muted-2, #8A8786); }
.install-banner__go {
	border: 0; background: var(--accent, #76232F); color: #FFF; cursor: pointer;
	font: inherit; font-weight: 700; font-size: 12.5px; padding: 9px 16px; border-radius: 12px;
}
.install-banner__x {
	border: 0; background: none; cursor: pointer; color: var(--muted-3, #C9C4C1);
	font-size: 20px; padding: 2px 4px;
}

/* ---- Instrucciones iOS ---- */
.install-ios {
	position: fixed; inset: 0; z-index: 70; background: rgba(17,17,18,.45);
	display: flex; align-items: center; justify-content: center; padding: 24px;
}
.install-ios__card {
	background: var(--card, #FFF); border-radius: 20px; padding: 24px;
	max-width: 320px; text-align: center;
}
.install-ios__title { font-weight: 800; font-size: 16px; margin-bottom: 8px; }
.install-ios__card p { font-size: 13.5px; line-height: 1.6; color: var(--muted-2, #555); margin: 0 0 18px; }
.install-ios__share { color: var(--accent, #76232F); font-weight: 800; }
.install-ios[hidden] { display: none !important; }

.group__eur { font-weight: 600; color: var(--muted-2); }
.group__eur::before { content: "·"; margin: 0 5px; color: var(--muted-3); }

.tag--general { color: var(--accent); border-color: rgba(118,35,47,.3); font-weight: 700; font-size:10px;}
.dev-card--general { border-color: rgba(118,35,47,.25); }

/* ==================== CONTROL ON/OFF ==================== */
.switch {
	position: relative; width: 52px; height: 30px; flex: none;
	border: 0; border-radius: 999px; cursor: pointer; padding: 0;
	background: #D9D4D1; transition: background .18s ease;
}
.switch span {
	position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
	border-radius: 50%; background: #FFF; transition: transform .18s ease;
	box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on { background: var(--ok, #22A06B); }
.switch.on span { transform: translateX(22px); }
.switch.pending { opacity: .55; }
.switch.pending span { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.switch--mini { width: 40px; height: 23px; }
.switch--mini span { width: 19px; height: 19px; top: 2px; left: 2px; }
.switch--mini.on span { transform: translateX(17px); }

.switch-card {
	display: flex; align-items: center; justify-content: space-between; gap: 14px;
	background: var(--card, #FFF); border: 1px solid var(--border, #E9E5E2);
	border-radius: 18px; padding: 14px 16px; margin-bottom: 14px; margin-top: 14px;
}
.switch-card__label {
	font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
	text-transform: uppercase; color: var(--muted-2, #8A8786);
}
.switch-card__state { font-size: 15px; font-weight: 800; margin-top: 2px; }
.tag--ctrl { color: var(--ok, #22A06B); border-color: rgba(34,160,107,.35); font-weight: 700; }

/* ==================== PROGRAMACIONES ==================== */
.sched__add { padding: 7px 14px; font-size: 12px; }
.sched__empty { font-size: 9.5px; color: var(--muted-2, #8A8786); line-height: 1.5; padding: 6px 0 2px; }
.sched-row {
	display: flex; align-items: center; gap: 10px;
	padding: 11px 0; border-bottom: 1px solid var(--border, #F1EDEA);
}
.sched-row:last-child { border-bottom: 0; }
.sched-row--off { opacity: .5; }
.sched-row__ico {
	width: 8px; height: 8px; border-radius: 50%; flex: none;
	background: var(--ok, #22A06B);
}
.sched-row__ico--off { background: var(--muted-3, #C9C4C1); }
.sched-row__txt {
	flex: 1; text-align: left; background: none; border: 0; cursor: pointer;
	font: inherit; font-size: 13.5px; font-weight: 600; padding: 0;
	display: flex; flex-direction: column; gap: 2px;
}
.sched-row__warn { font-size: 10.5px; font-weight: 500; color: var(--accent2, #EB5C5F); }
.toggle--sm { transform: scale(.8); transform-origin: right center; }

.seg {
	display: flex; gap: 4px; background: #F0ECE9; border-radius: 12px; padding: 3px;
}
.seg__btn {
	flex: 1; border: 0; background: none; cursor: pointer; font: inherit;
	font-size: 12.5px; font-weight: 700; color: var(--muted-2, #8A8786);
	padding: 9px 4px; border-radius: 10px;
}
.seg__btn.on { background: var(--card, #FFF); color: var(--ink, #111112); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.days { display: flex; gap: 6px; margin-bottom: 12px; }
.day {
	flex: 1; aspect-ratio: 1; border-radius: 50%; cursor: pointer; font: inherit;
	font-size: 12px; font-weight: 700; border: 1px solid var(--border, #E9E5E2);
	background: var(--card, #FFF); color: var(--muted-2, #8A8786);
}
.day.on { background: var(--accent, #76232F); border-color: var(--accent, #76232F); color: #FFF; }


/* ==================== REGISTRO DE SUCESOS ==================== */
.ev-day {
	font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
	color: var(--muted-2, #8A8786); margin: 14px 0 4px;
}
.ev-day:first-child { margin-top: 2px; }
.ev {
	display: flex; align-items: flex-start; gap: 10px;
	padding: 10px 0; border-bottom: 1px solid var(--border, #F1EDEA);
}
.ev:last-child { border-bottom: 0; }
.ev__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; }
.ev--ok   { background: var(--ok, #22A06B); }
.ev--off  { background: var(--accent2, #EB5C5F); }
.ev--warn { background: #E8A33D; }
.ev--mute { background: var(--muted-3, #C9C4C1); }
.ev__txt { flex: 1; min-width: 0; }
.ev__main { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.ev__meta { font-size: 11px; color: var(--muted-2, #8A8786); margin-top: 1px; }
.ev__hora {
	font-family: var(--mono, 'IBM Plex Mono', monospace);
	font-size: 11px; color: var(--muted-2, #8A8786); flex: none; margin-top: 2px;
}
.pager { display: flex; gap: 8px; margin-bottom: 12px; }
.pager .btn-ghost {flex: 1;text-align: center;display: flex;align-items: center;justify-content: center; }

/* ---- Filtro desplegable del registro ---- */
.filters__date select {
	-webkit-appearance: none; appearance: none;
	border: none; outline: none; background: transparent;
	font-family: inherit; font-size: 15px; font-weight: 600;
	color: var(--ink); padding: 0 22px 0 0; width: 100%;
	cursor: pointer; line-height: 1.3;
	/* Flecha dibujada, para que sea igual en todos los navegadores */
	background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2376232F' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right center;
	background-size: 11px;
}
.filters:focus-within { border-color: var(--accent); }

/* ==================== COSTE POR PERIODOS ==================== */
.periodos { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.periodo {
	display: grid; grid-template-columns: 1fr auto auto; align-items: center;
	gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border, #F1EDEA);
}
.periodo:last-child { border-bottom: 0; }
.periodo__nom {
	font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 7px;
}
.periodo__nom::before {
	content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-3, #C9C4C1);
}
.periodo--punta .periodo__nom::before { background: var(--accent2, #EB5C5F); }
.periodo--llana .periodo__nom::before { background: #E8A33D; }
.periodo--valle .periodo__nom::before { background: var(--ok, #22A06B); }
.periodo__kwh {
	font-family: var(--mono, 'IBM Plex Mono', monospace);
	font-size: 11.5px; color: var(--muted-2, #8A8786);
}
.periodo__eur { font-size: 13.5px; font-weight: 800; min-width: 62px; text-align: right; }