/* BK EMS — sistema visual. Misma identidad que BK Storage Analytics (estructura Horizon UI
   con la paleta BK: marino #16283a, verde #12a468; FV naranja, red azul, batería verde). */
:root {
  --bg: #f4f7f6; --surface: #ffffff; --surface-2: #f4f7f6; --surface-3: #eaf0ee;
  --text-primary: #16283a; --text-secondary: #56677a; --text-tertiary: #8796a7;
  --border: rgba(22,40,58,0.07); --separator: rgba(22,40,58,0.08);
  --shadow: 0 18px 40px rgba(22,40,58,0.07); --shadow-sm: 0 6px 18px rgba(22,40,58,0.06);
  --brand: #12a468; --brand-hover: #0f8f5a; --brand-soft: #e7f6ef; --navy: #16283a; --teal: #0ea89b;
  --c-fv: #d4811d; --c-grid: #2d6cdf; --c-bess: #12a468; --c-load: #7a5af8; --c-price: #16283a;
  --ok: #12a468; --warn: #d4811d; --bad: #d64545; --info: #2d6cdf; --idle: #8796a7;
  --r: 20px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #0e0f0f; --surface-2: #161818; --surface-3: #1f2222;
    --text-primary: #f2f4f3; --text-secondary: #a9b3bb; --text-tertiary: #7a858f;
    --border: rgba(255,255,255,0.08); --separator: rgba(255,255,255,0.09);
    --shadow: 0 18px 40px rgba(0,0,0,0.6); --shadow-sm: 0 6px 18px rgba(0,0,0,0.5);
    --brand-soft: rgba(18,164,104,0.16); --c-fv: #e08a22; --c-grid: #5585e6; --c-bess: #1fb072; --c-price: #f2f4f3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #000000; --surface: #0e0f0f; --surface-2: #161818; --surface-3: #1f2222;
    --text-primary: #f2f4f3; --text-secondary: #a9b3bb; --text-tertiary: #7a858f;
    --border: rgba(255,255,255,0.08); --separator: rgba(255,255,255,0.09);
    --shadow: 0 18px 40px rgba(0,0,0,0.6); --shadow-sm: 0 6px 18px rgba(0,0,0,0.5);
    --brand-soft: rgba(18,164,104,0.16); --c-fv: #e08a22; --c-grid: #5585e6; --c-bess: #1fb072; --c-price: #f2f4f3;
    color-scheme: dark;
  }
* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
html { height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text-primary);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
a { color: inherit; text-decoration: none; }
a, button, input, select, textarea { transition: all 150ms ease-out; }
[hidden], .hidden { display: none !important; }
::selection { background: rgba(18,164,104,0.25); }
.num, .tab { font-variant-numeric: tabular-nums; }

/* ---------------- barra lateral (como Storage Analytics) ---------------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 40; background: var(--surface);
  display: flex; flex-direction: column; box-shadow: var(--shadow); overflow-y: auto; transition: transform 250ms ease; }
.side-brand { padding: 30px 32px 22px; border-bottom: 1px solid var(--separator); }
.side-brand img { height: 40px; width: auto; display: block; }
.side-brand .sub { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; letter-spacing: .12em; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side-brand img { background: #fff; border-radius: 10px; padding: 4px 8px; height: 46px; } }
:root[data-theme="dark"] .side-brand img { background: #fff; border-radius: 10px; padding: 4px 8px; height: 46px; }
.side-nav { padding: 12px 0 10px; flex: 1 0 auto; }
.side-sec { font-size: 10.5px; letter-spacing: .14em; color: var(--text-tertiary); padding: 14px 30px 6px; font-weight: 700; }
.side-link { display: flex; align-items: center; gap: 14px; padding: 8px 0 8px 30px; margin: 1px 0; color: var(--text-tertiary);
  font-weight: 500; font-size: 15px; position: relative; }
.side-link svg { width: 22px; height: 22px; flex-shrink: 0; }
.side-link:hover { color: var(--text-primary); }
.side-link.active { color: var(--text-primary); font-weight: 700; }
.side-link.active svg { color: var(--brand); }
.side-link.active::after { content: ''; position: absolute; right: 0; top: 6px; bottom: 6px; width: 4px; border-radius: 4px; background: var(--brand); }
.side-link .cnt { margin-left: auto; margin-right: 22px; font-size: 11px; font-weight: 700; min-width: 20px; text-align: center;
  padding: 1px 7px; border-radius: 99px; background: var(--bad); color: #fff; }
.side-card { margin: 18px; padding: 18px; border-radius: 20px; color: #fff;
  background: linear-gradient(135deg, #12a468 0%, #0e7a53 45%, #16283a 100%); }
.side-card .t { font-weight: 700; font-size: 15px; }
.side-card .s { font-size: 12px; color: rgba(255,255,255,.8); margin-top: 2px; line-height: 1.45; }
.side-card .row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.side-card .btn-w { display: block; text-align: center; margin-top: 14px; background: #fff; color: #16283a; border-radius: 12px;
  padding: 8px; font-weight: 600; font-size: 13px; }

/* ---------------- principal y cabecera de vidrio ---------------- */
.main-wrap { margin-left: 272px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; padding: 16px 32px 8px; }
.topbar-glass { background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px); border-radius: 20px; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.crumb { font-size: 12px; color: var(--text-tertiary); }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; background: var(--surface);
  box-shadow: var(--shadow); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip svg { width: 16px; height: 16px; }
.chip .sep { width: 1px; height: 14px; background: var(--separator); }
.chip .muted { color: var(--text-tertiary); font-weight: 500; }
.state-chip { color: #fff; }
.state-chip.ok { background: var(--ok); } .state-chip.warn { background: var(--warn); } .state-chip.bad { background: var(--bad); }
.state-chip.info { background: var(--info); } .state-chip.idle { background: var(--idle); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: livepulse 1.6s ease-in-out infinite; }
.state-chip .live-dot { background: #fff; }
@keyframes livepulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(18,164,104,.5); } 50% { opacity: .65; box-shadow: 0 0 0 5px rgba(18,164,104,0); } }
.menu-btn { display: none !important; }
main { padding: 8px 32px 32px; max-width: 1640px; }
footer { padding: 0 32px 36px; font-size: 12px; color: var(--text-tertiary); max-width: 1640px; }
@media (max-width: 1279px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: none; }
  .main-wrap { margin-left: 0; } .menu-btn { display: inline-flex !important; }
}
@media (max-width: 640px) { .topbar, main, footer { padding-left: 14px; padding-right: 14px; } .page-title { font-size: 20px; } .top-right .hide-sm { display: none; } .crumb { display: none; }
  .topbar-glass { flex-wrap: wrap; } .top-right { width: 100%; justify-content: flex-start; } .topbar { position: static; } }

/* ---------------- pestañas de la sección y barra inferior (móvil) ---------------- */
.sec-tabs { display: flex; gap: 6px; padding: 4px 32px 10px; overflow-x: auto; scrollbar-width: none; max-width: 1640px; }
.sec-tabs::-webkit-scrollbar { display: none; }
.sec-tabs a { flex: 0 0 auto; padding: 7px 15px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  background: var(--surface); box-shadow: var(--shadow-sm); white-space: nowrap; }
.sec-tabs a:hover { color: var(--text-primary); }
.sec-tabs a.on { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sec-tabs a.on { background: var(--brand); } }
:root[data-theme="dark"] .sec-tabs a.on { background: var(--brand); }
.bottom-nav { display: none; }

/* ---------------- Inicio: anomalías, ajustes rápidos, bloques personalizables; flujo pulsable ---------------- */
.flow .hot { fill: transparent; cursor: pointer; stroke: transparent; stroke-width: 2; transition: stroke .15s; }
.flow .hot:hover { stroke: var(--brand); }
.anom { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; margin-bottom: 14px; font-size: 13.5px;
  background: #fff4e5; color: #7a4a00; }
.anom.bad { background: #fdecec; color: #8f1f1f; }
.anom .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; color: #fff; background: var(--warn); }
.anom.bad .ic { background: var(--bad); }
.anom a { color: inherit; font-weight: 700; margin-left: auto; white-space: nowrap; }
.anom button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; opacity: .6; padding: 0 2px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .anom { background: #3a2a10; color: #f6c88a; } :root:not([data-theme="light"]) .anom.bad { background: #3a1616; color: #ffb3b3; } }
:root[data-theme="dark"] .anom { background: #3a2a10; color: #f6c88a; } :root[data-theme="dark"] .anom.bad { background: #3a1616; color: #ffb3b3; }
.qs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.qs a { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm);
  color: inherit; position: relative; transition: transform .15s; }
.qs a:hover { transform: translateY(-1px); }
.qs .l { font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.qs .l svg { width: 16px; height: 16px; color: var(--brand); }
.qs .v { font-size: 15px; font-weight: 700; }
.qs .s { font-size: 11.5px; color: var(--text-tertiary); }
.blk-bar { display: flex; justify-content: flex-end; margin-top: 18px; }
.blk-edit { display: grid; gap: 8px; }
.blk-edit .row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); }
.blk-edit .row .n { flex: 1; font-weight: 600; font-size: 13.5px; }
.blk-edit .row .n small { display: block; font-weight: 400; color: var(--text-tertiary); font-size: 12px; }
.blk-edit .row button { border: 0; background: var(--surface); border-radius: 10px; width: 30px; height: 30px; cursor: pointer; color: var(--text-secondary); font: inherit; }
.blk-edit .row button:disabled { opacity: .35; cursor: default; }
/* Modo de energía y editor de franjas */
.modo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.modo-card { text-align: left; border: 2px solid transparent; background: var(--surface); box-shadow: var(--shadow-sm); border-radius: 18px;
  padding: 14px 16px; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; }
.modo-card:hover:not(:disabled) { border-color: var(--separator); }
.modo-card.on { border-color: var(--brand); }
.modo-card:disabled { opacity: .55; cursor: not-allowed; }
.modo-card .t { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.modo-card .s { font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; }
.modo-como { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }
.fr-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.fr-tabs button { border: 0; background: var(--surface-2); font: inherit; font-weight: 600; font-size: 12.5px; padding: 6px 13px; border-radius: 99px; cursor: pointer; color: var(--text-secondary); }
.fr-tabs button.on { background: var(--navy); color: #fff; }
.fr-season { background: var(--surface-2); border-radius: 16px; padding: 14px; }
.fr-meses { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.fr-meses button { border: 0; padding: 6px 0; border-radius: 9px; font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; background: var(--surface); color: var(--text-secondary); }
.fr-meses button.on { background: var(--brand); color: #fff; }
.fr-meses button:disabled { opacity: .35; cursor: not-allowed; }
@media (max-width: 640px) { .fr-meses { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.fr-bars { margin: 14px 0 8px; display: grid; gap: 8px; }
.fr-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; }
@media (max-width: 640px) { .fr-row { grid-template-columns: 1fr; gap: 4px; } }
.fr-lbl { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.fr-lbl i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.fr-track { position: relative; height: 38px; border-radius: 10px; background: var(--surface); cursor: copy; overflow: hidden; touch-action: none; }
.fr-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--separator); }
.fr-blk { position: absolute; top: 4px; bottom: 4px; border-radius: 8px; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 6px; }
.fr-blk.sel { box-shadow: 0 0 0 2px var(--text-primary); }
.fr-t { font-size: 11px; font-weight: 700; white-space: nowrap; padding: 0 10px; pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.fr-blk.corta .fr-t { display: none; }
.fr-h { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; z-index: 2; }
.fr-h.l { left: 0; } .fr-h.r { right: 0; }
.fr-h::after { content: ''; position: absolute; top: 25%; bottom: 25%; left: 4px; width: 2px; border-radius: 2px; background: rgba(255,255,255,.8); }
.fr-scale { position: relative; height: 14px; font-size: 10.5px; color: var(--text-tertiary); }
.fr-scale span { position: absolute; transform: translateX(-50%); }
.fr-panel { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface); }
.fr-panel > b { align-self: center; font-size: 13px; }
.fr-hoy { position: relative; height: 26px; border-radius: 8px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.fr-hoy .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text-primary); }
/* Puesta en marcha: pasos del asistente */
.pm-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1100px) { .pm-steps { grid-template-columns: 1fr; } }
.pm-step { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 2px solid transparent; background: var(--surface-2); border-radius: 14px;
  padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; }
.pm-step.on { border-color: var(--brand); background: var(--surface); }
.pm-step b { display: block; font-size: 13px; }
.pm-step small { display: block; font-size: 11.5px; color: var(--text-tertiary); line-height: 1.35; margin-top: 2px; }
/* Ajustes › Planta */
.set-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.set-ej { font-size: 12.5px; color: var(--text-secondary); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin: 10px 0 14px; line-height: 1.5; }
.set-ej b { color: var(--text-primary); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13.5px; }
.dl dt { color: var(--text-tertiary); } .dl dd { margin: 0; font-weight: 600; }
.tar-per { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
@media (max-width: 760px) {
  .sec-tabs { padding-left: 14px; padding-right: 14px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); box-shadow: 0 -1px 0 var(--separator); }
  .bottom-nav a { position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
    font-size: 10.5px; font-weight: 600; color: var(--text-tertiary); min-width: 0; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav .cnt { position: absolute; top: 0; left: calc(50% + 6px); font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; }
  body { padding-bottom: 64px; }
}

/* ---------------- rejillas y tarjetas ---------------- */
.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-hero { grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.span-2 { grid-column: span 2; }
@media (max-width: 1400px) { .g-4, .g-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .g-hero, .g-21, .g-12, .g-3, .g-2 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
@media (max-width: 560px) { .g-4, .g-5 { grid-template-columns: 1fr; } }
.mt { margin-top: 20px; } .mt-s { margin-top: 10px; }
.surface { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; min-width: 0; position: relative; }
.surface.tight { padding: 16px 18px; }
.card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-t { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.card-s { font-size: 12.5px; color: var(--text-tertiary); margin-top: 2px; }
.muted { color: var(--text-secondary); } .faint { color: var(--text-tertiary); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; color: var(--text-tertiary); }
.b { font-weight: 700; }

/* KPI */
.kpi { display: flex; align-items: center; gap: 14px; }
.kpi-ic { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); }
.kpi-ic svg { width: 26px; height: 26px; }
.kpi-l { font-size: 13px; color: var(--text-tertiary); }
.kpi-v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-v small { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; }
.kpi-d { font-size: 12px; color: var(--text-tertiary); }
.delta-up { color: var(--ok); font-weight: 700; } .delta-dn { color: var(--bad); font-weight: 700; }

/* insignias y botones */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: 11.5px; font-weight: 600; padding: .2rem .65rem; border-radius: 999px; white-space: nowrap; }
.badge-neutral { background: var(--surface-2); color: var(--text-secondary); }
.badge-green { background: rgba(18,164,104,.12); color: #0d8a57; } .badge-amber { background: rgba(212,129,29,.14); color: #a15c00; }
.badge-red { background: rgba(214,69,69,.12); color: #c03636; } .badge-blue { background: rgba(45,108,223,.12); color: #2457b8; }
.badge-navy { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-green { color: #4fd59a; } :root:not([data-theme="light"]) .badge-amber { color: #f0b46a; } :root:not([data-theme="light"]) .badge-red { color: #ff8f8f; } :root:not([data-theme="light"]) .badge-blue { color: #9bbcff; } }
:root[data-theme="dark"] .badge-green { color: #4fd59a; } :root[data-theme="dark"] .badge-amber { color: #f0b46a; } :root[data-theme="dark"] .badge-red { color: #ff8f8f; } :root[data-theme="dark"] .badge-blue { color: #9bbcff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-size: 13px; font-weight: 600;
  border-radius: 12px; padding: .55rem 1.05rem; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; } .btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text-primary); border-color: var(--border); } .btn-secondary:hover { background: var(--surface-3); }
.btn-danger { background: var(--bad); color: #fff; }
.btn svg { width: 16px; height: 16px; }
.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--surface-2); gap: 2px; }
.seg > * { padding: .28rem .85rem; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; border: 0; background: none; font-family: inherit; }
.seg > .on { background: var(--brand); color: #fff; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-secondary); }

/* tablas */
.tbl { width: 100%; font-size: 13px; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-tertiary); padding: .5rem 1rem .5rem 0; white-space: nowrap; }
.tbl td { padding: .55rem 1rem .55rem 0; border-top: 1px solid var(--separator); vertical-align: top; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl tr.hl td { background: var(--brand-soft); } .tbl tr.hl-warn td { background: rgba(212,129,29,.10); }
.scroll { overflow-x: auto; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* formularios */
.input { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 12px; padding: .5rem .8rem; font: inherit; font-size: 13.5px; min-width: 0; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18,164,104,.18); }
.input:disabled { opacity: .55; }
.input.inline { width: 96px; text-align: right; padding: .35rem .6rem; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-secondary); }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; font-size: 13px; user-select: none; }
.toggle input { appearance: none; width: 40px; height: 23px; border-radius: 99px; background: var(--surface-3); position: relative; cursor: pointer; margin: 0; flex-shrink: 0; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left 150ms; }
.toggle input:checked { background: var(--brand); } .toggle input:checked::after { left: 20px; }
.toggle input:disabled { opacity: .5; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

/* ---------------- modo sencillo / experto ---------------- */
.expert-toggle { gap: 8px; cursor: pointer; user-select: none; }
.expert-toggle .toggle { margin: 0; }
body:not(.expert) .expert-toggle { color: var(--text-secondary); }
.big-status { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: none; color: #fff; }
.big-status.ok { background: var(--ok); } .big-status.warn { background: var(--warn); } .big-status.bad { background: var(--bad); } .big-status.idle { background: var(--idle); }
a.simple-link { display: block; color: inherit; text-decoration: none; position: relative; transition: box-shadow .15s, transform .15s; }
a.simple-link:hover { transform: translateY(-1px); }
a.simple-link .go { position: absolute; right: 18px; top: 18px; font-size: 12px; font-weight: 600; color: var(--brand); display: inline-flex; align-items: center; gap: 4px; }
a.simple-link .go svg { width: 14px; height: 14px; }
.surface.aviso { border-left: 4px solid var(--warn); }
.surface.aviso.bad { border-left-color: var(--bad); }

/* ---------------- flujo de energía ---------------- */
.flow-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.flow-card .flow { flex: 1; display: flex; align-items: center; }
.flow-foot { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding: 12px 22px 18px; border-top: 1px solid var(--surface-2); font-size: 12px; color: var(--text-tertiary); }
.flow-foot i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.flow-foot .sp { margin-left: auto; }
.flow-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 22px 0; gap: 10px; flex-wrap: wrap; }
.flow svg { width: 100%; height: auto; display: block; }
.flow .wire { fill: none; stroke: var(--surface-3); stroke-width: 8; stroke-linecap: round; }
.flow .wire-on { fill: none; stroke-width: 3; stroke-linecap: round; opacity: .45; }
.flow .lbl { font-size: 13px; fill: var(--text-tertiary); font-weight: 600; letter-spacing: .02em; }
.flow .val { font-size: 23px; font-weight: 700; fill: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.flow .val-u { font-size: 13px; font-weight: 500; fill: var(--text-secondary); }
.flow .sub { font-size: 12px; font-weight: 700; }
.flow .card-bg { fill: var(--surface); stroke: var(--border); }
.flow .shadow { filter: drop-shadow(0 10px 18px rgba(22,40,58,.10)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flow .shadow { filter: drop-shadow(0 10px 18px rgba(0,0,0,.35)); } }
:root[data-theme="dark"] .flow .shadow { filter: drop-shadow(0 10px 18px rgba(0,0,0,.35)); }

/* indicadores */
.gauge-wrap { display: flex; align-items: center; justify-content: center; position: relative; }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.gauge-center .v { font-size: 30px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.gauge-center .l { font-size: 12px; color: var(--text-tertiary); }

/* envolvente de control */
.env-track { position: relative; height: 44px; margin: 6px 0 2px; }
.env-axis { position: absolute; left: 0; right: 0; top: 19px; height: 6px; background: var(--surface-2); border-radius: 6px; }
.env-ok { position: absolute; top: 14px; height: 16px; background: var(--brand-soft); border: 1.5px solid var(--brand); border-radius: 8px; transition: all .6s; }
.env-zero { position: absolute; top: 6px; width: 1px; height: 32px; background: var(--text-tertiary); left: 50%; }
.env-mark { position: absolute; top: 4px; width: 4px; height: 36px; border-radius: 3px; transform: translateX(-2px); transition: left .6s; }
.env-mark.t { background: var(--text-tertiary); } .env-mark.s { background: var(--navy); box-shadow: 0 0 0 3px var(--surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .env-mark.s { background: #fff; } }
:root[data-theme="dark"] .env-mark.s { background: #fff; }
.env-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-tertiary); }
.why { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; line-height: 1.5; font-size: 13px; color: var(--text-secondary); }
.why b { color: var(--text-primary); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: baseline; margin: 0; }
.kv dt { color: var(--text-tertiary); font-size: 12.5px; } .kv dd { margin: 0; font-weight: 600; }

/* ---------------- baterías y celdas ---------------- */
.cab { display: flex; gap: 20px; align-items: center; }
.cab svg { flex-shrink: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.mini .l { font-size: 11.5px; color: var(--text-tertiary); } .mini .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.heat { display: grid; gap: 4px; }
.heat-row { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; }
.heat-row .m { font-size: 11px; color: var(--text-tertiary); text-align: right; font-weight: 600; }
.heat-cells { display: grid; gap: 3px; }
.cell { height: 22px; border-radius: 4px; cursor: crosshair; position: relative; transition: transform 120ms, box-shadow 120ms; }
.cell:hover { transform: scale(1.45); z-index: 2; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.cell.mark-min { outline: 2px solid var(--info); outline-offset: 1px; }
.cell.mark-max { outline: 2px solid var(--bad); outline-offset: 1px; }
.scale-bar { height: 10px; border-radius: 6px; }
.scale-lbl { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-tertiary); margin-top: 4px; font-variant-numeric: tabular-nums; }
.tip { position: fixed; z-index: 60; pointer-events: none; background: rgba(22,40,58,.96); color: #fff; padding: 10px 12px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.5; box-shadow: 0 12px 30px rgba(0,0,0,.25); min-width: 150px; }

/* ---------------- proyecto ---------------- */
.defs { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.def h4 { margin: 0 0 4px; font-size: 15px; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.def .id { font-size: 11.5px; color: var(--text-tertiary); font-weight: 600; letter-spacing: .03em; }
.def p { margin: 7px 0; color: var(--text-secondary); line-height: 1.5; font-size: 13px; }
.def pre { white-space: pre-wrap; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 12px; margin: 8px 0; font-family: ui-monospace, Consolas, monospace; }
.def ul { margin: 6px 0; padding-left: 18px; color: var(--text-secondary); font-size: 13px; }

/* ---------------- informe imprimible ---------------- */
.report { max-width: 1100px; }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 3px solid var(--brand); padding-bottom: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.report-head img { height: 44px; }
@media print {
  @page { margin: 12mm; }
  .sidebar, .topbar, footer, .no-print, .toast, .bottom-nav { display: none !important; }
  .main-wrap { margin: 0; } main { padding: 0; max-width: none; }
  body { background: #fff; font-size: 12px; }
  .surface { box-shadow: none; border: 1px solid #e3e9e7; break-inside: avoid; padding: 14px; }
}

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); max-width: 440px; z-index: 70; font-size: 13.5px; }
.toast.err { background: var(--bad); }
.empty { color: var(--text-tertiary); padding: 26px; text-align: center; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; } .chart-box.short { height: 220px; } .chart-box.xs { height: 120px; }
.pulse-bad { animation: pb 1.4s infinite; } @keyframes pb { 50% { opacity: .55; } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { border: 0; background: var(--surface); box-shadow: var(--shadow-sm); font: inherit; font-weight: 600; font-size: 13px; padding: 8px 16px; border-radius: 99px; cursor: pointer; color: var(--text-secondary); }
.tabs button.on { background: var(--navy); color: #fff; }
.hero-num { font-size: 40px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.hero-num small { font-size: 18px; font-weight: 500; color: var(--text-secondary); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: var(--brand); transition: width .6s; }

/* ---------------- guía de puesta en marcha (planta en solo lectura) ---------------- */
.guide-bar { margin: 0 32px 10px; padding: 10px 16px; border-radius: 16px; background: #fff4e5; color: #6b4300; font-size: 13px;
  display: flex; gap: 8px 18px; flex-wrap: wrap; align-items: center; }
.guide-bar .gb-step { color: #8a6a3a; } .guide-bar .gb-step.ok { color: #0d8a57; } .guide-bar .gb-step.cur { font-weight: 700; color: #6b4300; }
.guide-bar a { text-decoration: underline; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .guide-bar { background: rgba(212,129,29,.16); color: #f0c58a; } :root:not([data-theme="light"]) .guide-bar .gb-step.cur { color: #f0c58a; } }
:root[data-theme="dark"] .guide-bar { background: rgba(212,129,29,.16); color: #f0c58a; } :root[data-theme="dark"] .guide-bar .gb-step.cur { color: #f0c58a; }
@media (max-width: 640px) { .guide-bar { margin: 0 14px 10px; } }

/* ---------------- técnico ---------------- */
.tec-devs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.tec-dev { text-align: left; border: 1.5px solid transparent; background: var(--surface); box-shadow: var(--shadow-sm); border-radius: 16px;
  padding: 12px 14px; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tec-dev:hover { border-color: var(--separator); }
.tec-dev.on { border-color: var(--brand); background: var(--brand-soft); }
.tec-dev .t { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.tec-dev .s { font-size: 11.5px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(18,164,104,.18); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(214,69,69,.18); }
.tec-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); gap: 16px; align-items: start; }
.tec-tbl td { padding: .4rem .6rem .4rem 0; vertical-align: middle; }
.tec-tbl tr:first-child td { border-top: 0; }
.tec-tbl .v { text-align: right; white-space: nowrap; }
.tec-tbl .v-num { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.tec-tbl .u { color: var(--text-tertiary); font-size: 12px; width: 44px; padding-right: 0; }
.tec-tbl .act { width: 30px; padding-right: 0; }
.pid { font-size: 10.5px; color: var(--text-tertiary); font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--text-tertiary); padding: 4px; border-radius: 8px; display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--brand); background: var(--brand-soft); }
.icon-btn.on { color: #fff; background: var(--brand); }
.icon-btn svg { width: 16px; height: 16px; }
.flash td { animation: fl 1.2s ease-out; } @keyframes fl { from { background: rgba(18,164,104,.20); } to { background: transparent; } }
.alarm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 6px 12px; }
.alarm-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--surface-2); font-size: 12.5px; }
.alarm-item.on { background: rgba(214,69,69,.12); font-weight: 600; }
.tec-chart { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .tec-chart { grid-template-columns: 1fr; } }
.picker-list { max-height: 600px; overflow: auto; margin-top: 10px; border-top: 1px solid var(--separator); }
.picker-dev { position: sticky; top: 0; background: var(--surface); font-size: 12.5px; font-weight: 700; padding: 10px 0 4px; z-index: 1; }
.picker-grp { font-size: 10.5px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .07em; margin: 6px 0 2px; font-weight: 600; }
.picker-item { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-size: 12.5px; line-height: 1.35; }
.picker-item:hover { background: var(--surface-2); }
.picker-item input { margin-top: 2px; accent-color: var(--brand); flex-shrink: 0; }
.sel-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sel-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px; font-weight: 600; max-width: 100%; }
.sel-chip button { border: 0; background: none; cursor: pointer; color: var(--text-tertiary); font-size: 15px; line-height: 1; padding: 0 5px; border-radius: 50%; }
.sel-chip button:hover { color: var(--bad); }
.chart-big { position: relative; height: 470px; user-select: none; }
.zoom-box { position: absolute; top: 0; bottom: 30px; background: rgba(18,164,104,.12); border-left: 1px solid var(--brand); border-right: 1px solid var(--brand); pointer-events: none; }

/* Régimen retributivo: barra de horas equivalentes y comprobaciones trimestrales */
.hb { position: relative; padding: 34px 0 6px; }
.hb-track { position: relative; height: 18px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hb-real { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c-bess); border-radius: 99px 0 0 99px; }
.hb-prev { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(18,164,104,.45) 0 6px, rgba(18,164,104,.2) 6px 12px); }
.hb-sb { position: absolute; top: 2px; bottom: 2px; width: 3px; margin-left: -1px; background: var(--c-fv); border-radius: 2px; }
.hb-mark { position: absolute; top: 30px; bottom: 2px; width: 0; border-left: 2px dashed currentColor; }
.hb-mark span { position: absolute; top: -31px; transform: translateX(-50%); font-size: 11px; white-space: nowrap; color: currentColor; font-weight: 600; text-align: center; line-height: 1.15; }
.hb-mark span b { display: block; font-weight: 700; }
.hb-mark.u { color: var(--bad); } .hb-mark.m { color: #7a5af8; }
.hb-leg { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--text-secondary); margin-top: 10px; }
.hb-leg .sw { display: inline-block; width: 12px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hb-leg .sw.real { background: var(--c-bess); } .hb-leg .sw.prev { background: rgba(18,164,104,.35); } .hb-leg .sw.sb { background: var(--c-fv); width: 4px; }
.hitos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .hitos { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hito { border-radius: 14px; padding: 12px 14px; background: var(--surface-2); border-top: 3px solid var(--idle); }
.hito.ok { border-top-color: var(--ok); } .hito.warn { border-top-color: var(--warn); } .hito.bad { border-top-color: var(--bad); } .hito.prev { border-top-color: var(--info); }
.hito-h { display: flex; align-items: center; gap: 8px; font-size: 13px; } .hito-h .tiny { margin-left: auto; }
.hito-ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--idle); }
.hito.ok .hito-ic { background: var(--ok); } .hito.warn .hito-ic { background: var(--warn); } .hito.bad .hito-ic { background: var(--bad); } .hito.prev .hito-ic { background: var(--info); }
.hito-v { font-size: 22px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.reg-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
@media (max-width: 800px) { .reg-form { grid-template-columns: 1fr; } }
.reg-form .full { grid-column: 1 / -1; }
.reg-form .field small { color: var(--text-tertiary); font-weight: 400; }
