:root {
  --navy: #0d1b3e; --ink: #1c2434; --muted: #6b7380; --line: #e8ebf1; --bg: #f5f6f9;
  --green: #2e9e5b; --red: #d64545; --amber: #e0a526; --gray: #7a828e;
  --radius: 14px; --sidebar: 232px;
}
html, body { background: var(--bg); color: var(--ink); }
body { font-size: .93rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.min-w-0 { min-width: 0; }
.pre-wrap { white-space: pre-wrap; }

/* ---------- Layout ---------- */
.content { padding: 1.5rem 1.75rem 2rem; margin-left: var(--sidebar); max-width: 1500px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: #fff; border-right: 1px solid var(--line); padding: 1.1rem .8rem; z-index: 1020; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--ink); font-size: 1.02rem; margin: 0 .4rem 1.4rem; }
.brand-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--navy); color: #f5c542; display: inline-flex; align-items: center; justify-content: center; }
.side-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; color: #4a5160; margin-bottom: 2px; font-weight: 500; }
.side-link i { font-size: 1.05rem; }
.side-link:hover { background: var(--bg); color: var(--ink); }
.side-link.active { background: #eaf6ef; color: #1d7a43; }
.side-link .count, .menu-link .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45rem; font-weight: 600; }
.side-foot { border-top: 1px solid var(--line); padding: .9rem .4rem 0; color: var(--muted); font-size: .85rem; }
.side-foot a { color: var(--muted); }
.btn-sync { background: var(--bg); border: 1px solid var(--line); color: var(--ink); }
.btn-sync:hover { background: #eceff4; }

.topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .25rem; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: .55rem .9rem; padding-top: max(.55rem, env(safe-area-inset-top)); }
.topbar .brand { margin: 0; }
.topbar-btn { position: relative; border: 0; background: transparent; font-size: 1.35rem; color: var(--ink); padding: .2rem .45rem; }
.dot-count { position: absolute; top: -2px; right: -2px; background: var(--red); color: #fff; font-size: .62rem; font-weight: 700; min-width: 17px; height: 17px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; padding: .45rem 0 .4rem; color: var(--muted); font-size: .68rem; font-weight: 500; }
.bottomnav a i { font-size: 1.25rem; line-height: 1.2; }
.bottomnav a.active { color: var(--green); }
.bottomnav .dot-count { top: 2px; right: calc(50% - 20px); }
.menu-link { display: flex; align-items: center; gap: .7rem; padding: .7rem .5rem; color: var(--ink); border-bottom: 1px solid var(--line); }
.menu-link.active { color: var(--green); font-weight: 600; }

@media (max-width: 991.98px) {
  .content { margin-left: 0; padding: 1rem .85rem calc(76px + env(safe-area-inset-bottom)); }
}

/* ---------- Encabezados y paneles ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--muted); font-size: .85rem; }
.panel, .card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
.card-header { background: #fff; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0 !important; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.panel-head a { font-weight: 500; font-size: .85rem; }
.list-row { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); font-size: .87rem; min-width: 0; }
.list-row:last-child { border-bottom: 0; }

/* ---------- Franja de estado ---------- */
.status-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.6fr); gap: .75rem; }
.stat { position: relative; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; overflow: hidden; }
button.stat { cursor: pointer; transition: transform .1s, box-shadow .1s; }
button.stat:hover { box-shadow: 0 4px 14px rgba(20, 30, 60, .08); }
.stat .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat .n small { font-size: .95rem; font-weight: 600; color: var(--muted); }
.stat .l { color: var(--muted); font-size: .8rem; }
.stat-ok .n { color: var(--green); } .stat-alarm .n { color: var(--red); } .stat-offline .n { color: var(--gray); }
.stat-ok { border-top: 3px solid var(--green); } .stat-alarm { border-top: 3px solid var(--red); } .stat-offline { border-top: 3px solid var(--gray); } .stat-power { border-top: 3px solid var(--amber); }
.stat .spark { position: absolute; right: 0; bottom: 0; width: 55% !important; height: 70% !important; opacity: .9; }
@media (max-width: 767.98px) {
  .status-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-power { grid-column: 1 / -1; }
  .stat { padding: .7rem .8rem; } .stat .n { font-size: 1.55rem; }
}

/* ---------- Requieren atención ---------- */
.attention-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.attention { display: flex; align-items: center; gap: .7rem; padding: .65rem 1rem; color: var(--ink); border-bottom: 1px solid var(--line); }
.attention:hover { background: #fafbfc; }

/* ---------- Filtros ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar .search { position: relative; flex: 1 1 240px; }
.toolbar .search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .45rem .75rem .45rem 2.1rem; outline: none; }
.toolbar .search input:focus { border-color: #9cc9ae; }
.toolbar select { width: auto; border-radius: 10px; border-color: var(--line); }
.pills { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; }
.pill { border: 1px solid var(--line); background: #fff; color: #4a5160; border-radius: 999px; padding: .3rem .8rem; font-size: .82rem; white-space: nowrap; }
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (max-width: 767.98px) {
  .toolbar .search { flex-basis: 100%; }
  .pills { flex-basis: 100%; }
  .toolbar select { flex: 1; }
}

/* ---------- Tarjetas de planta ---------- */
.plant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: .75rem; }
.plant-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem .95rem; color: var(--ink); border-left: 4px solid var(--green); transition: box-shadow .12s, transform .12s; }
.plant-card:hover { box-shadow: 0 6px 18px rgba(20, 30, 60, .08); transform: translateY(-1px); color: var(--ink); }
.plant-card.st-alarm { border-left-color: var(--red); }
.plant-card.st-warning { border-left-color: var(--amber); }
.plant-card.st-offline { border-left-color: var(--gray); background: #fafafb; }
.plant-card.st-unknown { border-left-color: #c5cad3; }
.plant-card .name { font-weight: 600; }
.plant-card .meta { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.plant-card .power { margin-top: .65rem; color: var(--muted); font-size: .85rem; }
.plant-card .power .v { font-size: 1.45rem; font-weight: 700; color: var(--ink); }
.plant-card .power .pct { float: right; margin-top: .55rem; }
.plant-card .bar { height: 6px; border-radius: 999px; background: #eef0f4; overflow: hidden; margin: .3rem 0 .6rem; }
.plant-card .bar div { height: 100%; background: var(--green); border-radius: 999px; }
.plant-card.st-offline .bar div { background: var(--gray); }
.plant-card .foot { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .78rem; }
@media (max-width: 575.98px) { .plant-grid { grid-template-columns: 1fr; gap: .55rem; } }

.provider-chip { display: inline-block; font-size: .68rem; font-weight: 600; letter-spacing: .02em; color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, white); border-radius: 6px; padding: .05rem .4rem; margin-right: .2rem; vertical-align: 1px; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; }
.badge.status-ok { background: #e6f5ec; color: #1d7a43; }
.badge.status-warning { background: #fff4d6; color: #9a6b00; }
.badge.status-alarm { background: #fde4e4; color: #b42332; }
.badge.status-offline { background: #eceef1; color: #444b55; }
.badge.status-unknown { background: #eef1f6; color: var(--muted); }
.badge.degree-1 { background: #fff4d6; color: #9a6b00; }
.badge.degree-2 { background: #ffe3c8; color: #a14c00; }
.badge.degree-3 { background: var(--red); color: #fff; }
.badge.maint-completado { background: #e6f5ec; color: #1d7a43; }
.badge.maint-programado { background: #e3edff; color: #1d4f9a; }
.badge.maint-en-curso { background: #fff4d6; color: #9a6b00; }
.badge.maint-cancelado { background: #eceef1; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #adb5bd; flex-shrink: 0; }
.dot-success { background: var(--green); } .dot-danger { background: var(--red); } .dot-warning { background: var(--amber); } .dot-info { background: #3b82c4; }

/* ---------- KPIs (detalle de planta) ---------- */
.kpi { display: block; background: #fff; border-radius: var(--radius); padding: .8rem .95rem; border: 1px solid var(--line); color: inherit; height: 100%; }
.kpi-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.kpi-value.sm { font-size: 1.25rem; }
.kpi-sub { font-size: .76rem; color: var(--muted); }
.plant-pic { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.chart-box { position: relative; height: 260px; }
.nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border-bottom-color: var(--line); }
.nav-tabs .nav-link { white-space: nowrap; color: #4a5160; }
.nav-tabs .nav-link.active { font-weight: 600; }
.card-tabbed { border-top-left-radius: 0; border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.device-dtu { background: var(--bg); padding: .5rem .75rem; border-radius: 10px; margin-top: .75rem; }
.micro-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .5rem; margin: .5rem 0 0 1rem; }
.micro { border-radius: 10px; padding: .45rem .6rem; font-size: .8rem; border: 1px solid var(--line); background: #fff; }
.micro.m-ok { border-left: 4px solid var(--green); }
.micro.m-off { border-left: 4px solid var(--gray); background: #f6f7f8; }
.micro.m-alarm { border-left: 4px solid var(--red); background: #fff6f6; }
.note { background: #fffdf3; border: 1px solid #f1e6b8; border-radius: 12px; padding: .6rem .75rem; height: 100%; }
.note-pinned { border-color: #f5c542; box-shadow: 0 0 0 1px #f5c542 inset; }
@media (max-width: 575.98px) {
  .kpi-value.sm { font-size: 1.05rem; }
  .chart-box { height: 220px; }
  .micro-grid { margin-left: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { font-size: .8rem; }
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: radial-gradient(circle at 30% 20%, #1f4b7a, var(--navy)); }
.login-card { background: #fff; padding: 2rem; border-radius: 18px; width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }

.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0; }

/* =================== v3: prioridad de alarmas, proveedores, frescura =================== */
.page-head { flex-wrap: wrap; align-items: center; }

/* Barra de sincronización */
.sync-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.sync-item { display: inline-flex; align-items: center; gap: .35rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .65rem; font-size: .78rem; color: #4a5160; white-space: nowrap; }
.sync-item > .bi-circle-fill { color: var(--pc, #999); font-size: .5rem; }
.sync-item.sync-err { border-color: #f3b4b4; background: #fff5f5; }
.sync-bar .btn { border-radius: 999px; border: 1px solid var(--line); background: #fff; }

/* Requieren atención */
.attention-panel { background: #fff; border: 1px solid #f3c7c7; border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 10px rgba(214, 69, 69, .06); }
.attention-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; background: linear-gradient(90deg, #fdecec, #fff6f6); color: #9b1c1c; font-weight: 700; }
.attention-head a { font-weight: 500; font-size: .85rem; color: #9b1c1c; }
.att-row { display: flex; gap: .85rem; align-items: flex-start; padding: .8rem 1rem; border-top: 1px solid #f6dede; color: var(--ink); border-left: 4px solid transparent; }
.att-row:hover { background: #fffafa; color: var(--ink); }
.att-row.att-offline { border-left-color: var(--gray); }
.att-row.att-alarm { border-left-color: var(--red); }
.att-row.att-warning { border-left-color: var(--amber); }
.att-title { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1rem; min-width: 0; }
.att-reason { color: #6b3b3b; font-size: .86rem; margin-top: 1px; }
.att-alarms { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .35rem; font-size: .8rem; color: #4a5160; }
.att-alarm code { font-size: .75rem; }
.att-side { text-align: right; flex-shrink: 0; }
.att-dur { font-weight: 700; font-size: .95rem; color: #6b3b3b; white-space: nowrap; }
.st-icon { flex-shrink: 0; width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.st-icon-alarm { background: #fde4e4; color: #b42332; }
.st-icon-offline { background: #e9ebef; color: #444b55; }
.st-icon-warning { background: #fff1cc; color: #9a6b00; }
.st-icon-ok { background: #e6f5ec; color: #1d7a43; }
.st-icon-unknown { background: #eef1f6; color: var(--muted); }
.all-good { background: #eaf6ef; color: #1d7a43; border: 1px solid #cfe9da; border-radius: var(--radius); padding: .7rem 1rem; font-weight: 600; }
@media (max-width: 575.98px) {
  .att-row { flex-wrap: wrap; gap: .6rem; padding: .75rem .8rem; }
  .att-side { width: 100%; text-align: left; display: flex; gap: .8rem; padding-left: calc(38px + .6rem); }
  .st-icon { width: 34px; height: 34px; }
}

/* Proveedores */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.provider-card { text-align: left; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--pc); border-radius: var(--radius); padding: .75rem 1rem; color: var(--ink); transition: box-shadow .12s; }
.provider-card:hover { box-shadow: 0 4px 14px rgba(20, 30, 60, .08); }
.provider-card.active { box-shadow: 0 0 0 2px var(--pc) inset; }
.provider-card .pv-name { font-weight: 700; color: var(--pc); }
.provider-card .pv-stats { display: flex; gap: .9rem; font-size: .84rem; margin-top: .3rem; }
.provider-card .pv-power { font-size: .8rem; color: var(--muted); margin-top: .15rem; }

/* Filtros */
.pill span { opacity: .65; margin-left: .2rem; font-weight: 600; }
.pill.pill-alarm:not(.active) span { color: var(--red); opacity: 1; }
.pill-prov i { color: var(--pc); font-size: .5rem; vertical-align: 2px; }
.pill-prov.active { background: var(--pc); border-color: var(--pc); }
.pill-prov.active i { color: #fff; }
a.pill { display: inline-block; }
.view-toggle .btn { border: 1px solid var(--line); background: #fff; }
.view-toggle .btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
#sortBy { max-width: 190px; }

/* Tarjetas */
.plant-card .meta-top { display: flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .74rem; min-width: 0; }
.plant-card .name { margin-top: 2px; }
.plant-card .reason { font-size: .78rem; color: #9b1c1c; margin-top: .3rem; }
.plant-card.st-offline .reason { color: #555c66; }
.plant-card.st-alarm { background: linear-gradient(180deg, #fff7f7, #fff 45%); }

/* Tabla de plantas */
.plant-table td, .plant-table th { padding: .55rem .75rem; }
.plant-table tr.st-alarm td:first-child { box-shadow: 3px 0 0 var(--red) inset; }
.plant-table tr.st-offline td:first-child { box-shadow: 3px 0 0 var(--gray) inset; }
tr.clickable { cursor: pointer; }
.table-danger-soft td { background: #fff7f7 !important; }

.hidden-plants summary { cursor: pointer; color: var(--muted); font-size: .88rem; }

/* Frescura de datos en la ficha */
.freshness { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .82rem; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .85rem; }
.freshness strong { color: var(--ink); }

/* Inversores (Growatt) */
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .65rem; }
.inv { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; background: #fff; border-left: 4px solid var(--green); }
.inv.m-alarm { border-left-color: var(--red); background: #fff7f7; }
.inv.m-off { border-left-color: var(--gray); background: #f6f7f8; }
.inv.m-idle { border-left-color: #c5cad3; }
.plant-card .name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; }

/* =================== v4: look & feel, inicio con gráficos, plantas por proveedor =================== */
:root { --bg: #f4f6fa; --line: #e6e9f0; --radius: 16px; --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06); }
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .92rem; letter-spacing: -.005em; }
.panel, .card, .stat, .plant-card, .kpi, .provider-card { box-shadow: var(--shadow); border-color: var(--line); }
.page-head h1 { font-weight: 800; letter-spacing: -.02em; }
.panel-title { font-weight: 700; font-size: .95rem; margin-bottom: .6rem; color: var(--ink); }
.side-link { font-weight: 500; }
.side-link.active { background: #e8f5ee; color: #17703c; font-weight: 600; }
.side-sub { display: flex; align-items: center; gap: .55rem; padding: .35rem .75rem .35rem 2.35rem; border-radius: 9px; color: #5b6270; font-size: .86rem; margin-bottom: 1px; }
.side-sub i { color: var(--pc); font-size: .5rem; }
.side-sub:hover, .side-sub.active { background: var(--bg); color: var(--ink); }
.side-sub .count, .menu-sub .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .45rem; font-weight: 700; min-width: 20px; text-align: center; }
.count-ok { margin-left: auto; color: var(--muted); font-size: .75rem; }
.menu-sub { padding-left: 2rem; font-size: .9rem; }
.menu-sub i { color: var(--pc); font-size: .5rem; }

/* Burbuja de aviso (numerito) */
.bubble { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1; margin-left: .35rem; vertical-align: 2px; box-shadow: 0 0 0 2px #fff; }
.bubble-info { background: #3b82c4; }

/* Punto de estado */
.sdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; background: #cfd4dc; }
.sdot-ok { background: var(--green); box-shadow: 0 0 0 3px #e3f4ea; }
.sdot-alarm { background: var(--red); box-shadow: 0 0 0 3px #fde4e4; animation: pulse 1.8s infinite; }
.sdot-warning { background: var(--amber); box-shadow: 0 0 0 3px #fff1cc; }
.sdot-offline { background: #8a919c; box-shadow: 0 0 0 3px #eceef1; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(214, 69, 69, .15); } }

/* Inicio: estado + producción */
.dash-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: .9rem; }
.donut-wrap { display: flex; align-items: center; gap: 1.5rem; }
.donut { position: relative; flex-shrink: 0; }
.donut-lg { width: 170px; height: 170px; }
.donut-sm { width: 64px; height: 64px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center b { font-size: 2rem; font-weight: 800; line-height: 1; }
.donut-sm .donut-center b { font-size: 1rem; }
.donut-center span { font-size: .75rem; color: var(--muted); }
.legend { flex: 1; display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: 10px; color: var(--ink); }
.legend-row:hover { background: var(--bg); color: var(--ink); }
.legend-row .sw { width: 12px; height: 12px; border-radius: 4px; }
.legend-row b { font-size: 1.05rem; }
.legend-row .pct { color: var(--muted); font-size: .78rem; width: 38px; text-align: right; }
.prod-kpis { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.prod-kpis .v { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; display: block; line-height: 1.1; }
.prod-kpis .u { font-size: .78rem; color: var(--muted); }
.fleet-chart { position: relative; height: 120px; margin-top: .6rem; }
@media (max-width: 991.98px) { .dash-top { grid-template-columns: 1fr; } }
@media (max-width: 575.98px) {
  .donut-wrap { gap: 1rem; }
  .donut-lg { width: 130px; height: 130px; }
  .donut-center b { font-size: 1.6rem; }
  .prod-kpis { gap: 1rem; } .prod-kpis .v { font-size: 1.35rem; }
}

/* Inicio: proveedores */
.prov-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .9rem; }
.prov-tile { display: flex; align-items: center; gap: .9rem; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--pc); border-radius: var(--radius); padding: .8rem 1rem; color: var(--ink); box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s; }
.prov-tile:hover { color: var(--ink); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20, 30, 60, .08); }
.prov-name { font-weight: 800; color: var(--pc); font-size: 1.02rem; }
.prov-line { display: flex; gap: .7rem; font-size: .82rem; font-weight: 600; margin-top: .1rem; flex-wrap: wrap; }
.prov-sub { font-size: .76rem; color: var(--muted); margin-top: .1rem; }
.list-link { color: var(--ink); }
.list-link:hover { background: #fafbfc; color: var(--ink); }
.attention-head .bubble { box-shadow: none; }

/* Plantas: grupos por proveedor */
.pgroup { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: .9rem; overflow: hidden; }
.pgroup-head { width: 100%; display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; background: #fff; border: 0; border-left: 5px solid var(--pc); text-align: left; color: var(--ink); }
.pgroup-head:hover { background: #fafbfc; }
.pgroup-head .chev { transition: transform .15s; color: var(--muted); }
.pgroup.collapsed .chev { transform: rotate(-90deg); }
.pgroup.collapsed .pgroup-body { display: none; }
.pgroup-name { font-weight: 800; font-size: 1.08rem; color: var(--pc); }
.pgroup-meta { display: inline-flex; gap: .8rem; font-size: .8rem; font-weight: 600; margin-left: .6rem; }
.pgroup-right { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.pgroup-body { border-top: 1px solid var(--line); padding: .9rem; background: #fbfcfd; }
.pgroup-body .pc-table { margin: -.9rem; background: #fff; }
.empty-group { padding: .5rem; }

/* Tarjeta simple */
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .65rem; }
.pc { display: flex; flex-direction: column; gap: .35rem; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .75rem .85rem; color: var(--ink); transition: box-shadow .12s, transform .12s; }
.pc:hover { color: var(--ink); box-shadow: 0 6px 16px rgba(20, 30, 60, .08); transform: translateY(-1px); }
.pc.st-alarm { border-color: #f4c4c4; background: #fffafa; }
.pc.st-warning { border-color: #f3dc9b; }
.pc.st-offline { background: #f8f9fa; }
.pc-top { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.pc-name { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.pc-top .bubble { margin-left: 0; }
.pc-mid { font-size: .82rem; color: var(--muted); }
.pc-mid b { font-size: 1.3rem; color: var(--ink); font-weight: 800; letter-spacing: -.02em; }
.pc.st-offline .pc-mid b { color: #9aa1ab; }
.pc-bar { height: 5px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.pc-bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.pc-foot { display: flex; justify-content: space-between; gap: .5rem; font-size: .74rem; color: var(--muted); min-width: 0; }
.pc-reason { color: #b42332; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc.st-offline .pc-reason { color: #555c66; }
@media (max-width: 575.98px) {
  .pc-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .pc { padding: .6rem .65rem; }
  .pc-today { display: none; }
  .pc-mid b { font-size: 1.1rem; }
  .pgroup-body { padding: .6rem; }
  .pgroup-body .pc-table { margin: -.6rem; }
  #sortBy, #catFilter { max-width: none; }
}
.pc { min-width: 0; }
.pc-grid { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
@media (max-width: 575.98px) { .pc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pc-foot > span:last-child { display: none; } .pc-foot .pc-reason { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } }

/* v6: mantenimientos por vencer */
.count-amber, .bubble-amber { background: #e08a00 !important; }
.menu-link .count { margin-left: auto; }
.due-pill { font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; white-space: nowrap; }
.due-over { background: #fde4e4; color: #b42332; }
.due-soon { background: #ffe9cc; color: #a14c00; }
.due-ok { background: #e6f5ec; color: #1d7a43; }

/* v7: equipos agrupados por planta */
.dgroup { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: .55rem; overflow: hidden; }
.dgroup-head { width: 100%; display: flex; align-items: center; gap: .55rem; padding: .7rem .9rem; background: #fff; border: 0; border-left: 4px solid var(--pc); text-align: left; color: var(--ink); }
.dgroup-head:hover { background: #fafbfc; }
.dgroup .chev { color: var(--muted); transition: transform .15s; }
.dgroup.collapsed .chev { transform: rotate(-90deg); }
.dgroup.collapsed .dgroup-body { display: none; }
.dgroup[data-problem="1"] { border-color: #f4c4c4; }
.dgroup-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dgroup-meta { display: inline-flex; gap: .7rem; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.dgroup-link { color: var(--muted); padding: 0 .2rem; }
.dgroup-link:hover { color: var(--ink); }
.dgroup-body { border-top: 1px solid var(--line); background: #fbfcfd; padding: .6rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: .45rem; }
.dev { display: flex; align-items: center; gap: .6rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .65rem; min-width: 0; }
.dev-ico { font-size: 1.15rem; color: var(--green); flex-shrink: 0; }
.dev-sn { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; font-weight: 600; }
.dev-model { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-alarm-text { font-size: .74rem; color: #b42332; font-weight: 600; }
.dev-state { font-size: .7rem; font-weight: 700; padding: .12rem .45rem; border-radius: 999px; background: #e6f5ec; color: #1d7a43; white-space: nowrap; }
.dev-time { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.dev-alarm { border-color: #f4c4c4; background: #fff7f7; } .dev-alarm .dev-ico { color: var(--red); } .dev-alarm .dev-state { background: #fde4e4; color: #b42332; }
.dev-off { background: #f6f7f8; } .dev-off .dev-ico { color: #8a919c; } .dev-off .dev-state { background: #e9ebef; color: #444b55; }
.dev-idle .dev-ico { color: #b0b6bf; } .dev-idle .dev-state { background: #eef1f6; color: var(--muted); }
@media (max-width: 575.98px) { .dgroup-meta { display: none; } }

/* v8 — roles y usuarios */
.role-tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .68rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; line-height: 1.5; }
.role-admin { background: #fde8e8; color: #b42318; }
.role-operator { background: #e6effd; color: #1d4ed8; }
.role-auditor { background: #eef0f3; color: #475467; }
.role-card { border: 1px solid var(--bs-border-color); border-radius: .75rem; padding: .75rem .9rem; height: 100%; }
.role-card h6 { margin: 0 0 .25rem; display: flex; align-items: center; gap: .4rem; }
.urow { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; border-top: 1px solid var(--bs-border-color); }
.urow:first-child { border-top: 0; }
.urow.inactive { opacity: .55; }
.uavatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex-shrink: 0; }
.uavatar.role-admin { background: #d64545; } .uavatar.role-operator { background: #3b6fd8; } .uavatar.role-auditor { background: #8a919c; }
.uedit { background: var(--bs-tertiary-bg, #f7f8fa); padding: .9rem 1rem; border-top: 1px dashed var(--bs-border-color); }
.perm-table td, .perm-table th { text-align: center; } .perm-table td:first-child, .perm-table th:first-child { text-align: left; }
