/* Portal Reporte Eléctrico — centro de mando. Autónomo, no hereda estilos del tema. */

:root {
    --dvpe-accent: #2b7de9;
    --dvpe-bg: #0f1522;
    --dvpe-panel: #141d2f;
    --dvpe-inset: #0f1522;
    --dvpe-border: rgba(120, 150, 200, .14);
    --dvpe-text: #e6edf7;
    --dvpe-text-strong: #f2f6fc;
    --dvpe-muted: #93a3bd;
    --dvpe-soft: #b9c6da;
    --dvpe-danger: #f0687f;
    --dvpe-danger-soft: #f19aab;
    --dvpe-ok: #4ade80;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--dvpe-bg);
    color: var(--dvpe-text);
    font-family: 'Instrument Sans', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: #5ea3f2; }
a:hover { color: #8cc0f7; }

@keyframes dvpe-ring { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes dvpe-tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes dvpe-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* --- Estructura ------------------------------------------------------- */

.dvpe-app { position: relative; min-height: 100dvh; }

.dvpe-mapwrap { position: relative; height: 52dvh; z-index: 1; }
.dvpe-map { position: absolute; inset: 0; }

.dvpe-rail { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 12px; padding: 12px 12px 0; }
.dvpe-rail--right { padding-bottom: 56px; }

/* Desktop: mapa de fondo, paneles flotantes */
@media (min-width: 980px) {
    .dvpe-app { height: 100dvh; overflow: hidden; }
    .dvpe-mapwrap { position: absolute; inset: 0 0 38px 0; height: auto; }
    .dvpe-rail { position: absolute; top: 80px; bottom: 54px; padding: 0; z-index: 850; }
    .dvpe-rail--left { left: 16px; width: 372px; }
    .dvpe-rail--right { right: 16px; width: 312px; padding-bottom: 0; }
    .dvpe-card--live { flex: 1; min-height: 260px; }
    .dvpe-card--rank { max-height: 100%; }
}

/* --- Cabecera ---------------------------------------------------------- */

.dvpe-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(11, 16, 26, .94), rgba(11, 16, 26, .6) 75%, transparent);
    pointer-events: none;
}
.dvpe-header > * { pointer-events: auto; }

.dvpe-header__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dvpe-header__mascot { width: 46px; height: 46px; flex: none; object-fit: contain; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .4)); }

.dvpe-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--dvpe-text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dvpe-subtitle { margin: 0; font-size: 12px; color: var(--dvpe-muted); }

.dvpe-header__status { display: flex; align-items: center; gap: 12px; flex: none; }
.dvpe-clock { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--dvpe-soft); font-variant-numeric: tabular-nums; }

.dvpe-live { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.dvpe-live__dot { width: 7px; height: 7px; border-radius: 50%; }
.dvpe-live[data-state="ok"] { color: var(--dvpe-ok); background: rgba(74, 222, 128, .1); }
.dvpe-live[data-state="ok"] .dvpe-live__dot { background: var(--dvpe-ok); animation: dvpe-blink 1.8s ease-in-out infinite; }
.dvpe-live[data-state="loading"] { color: var(--dvpe-soft); background: rgba(147, 163, 189, .12); }
.dvpe-live[data-state="loading"] .dvpe-live__dot { background: var(--dvpe-soft); }
.dvpe-live[data-state="error"] { color: var(--dvpe-danger); background: rgba(232, 83, 107, .12); }
.dvpe-live[data-state="error"] .dvpe-live__dot { background: var(--dvpe-danger); }

/* --- CTA de WhatsApp ------------------------------------------------------ */

.dvpe-cta {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex: none;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease;
}
.dvpe-cta:hover { transform: translateY(-3px); }

.dvpe-cta__mascot {
    width: 58px;
    height: 58px;
    object-fit: contain;
    flex: none;
    margin-bottom: -4px;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .45));
}
.dvpe-cta__bubble {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 10px 30px rgba(5, 10, 20, .45);
}
.dvpe-cta__tail {
    position: absolute;
    left: -6px;
    bottom: 12px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-radius: 2px;
}
.dvpe-cta__wa {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    background: #25d366;
    display: grid;
    place-items: center;
}
.dvpe-cta__wa svg { width: 19px; height: 19px; fill: #fff; }
.dvpe-cta__text strong { display: block; font-size: 13.5px; font-weight: 700; color: #17253c; line-height: 1.25; }
.dvpe-cta__text span { display: block; font-size: 12px; color: #5b6b85; }

/* --- Tarjetas ----------------------------------------------------------- */

.dvpe-card {
    background: var(--dvpe-panel);
    border: 1px solid var(--dvpe-border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(5, 10, 20, .4);
    padding: 12px;
}
.dvpe-card__title { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--dvpe-text-strong); }

.dvpe-card--live { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 6px; }
.dvpe-card--rank { display: flex; flex-direction: column; overflow: hidden; }

.dvpe-alert {
    background: rgba(232, 83, 107, .1);
    border: 1px solid rgba(232, 83, 107, .3);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
}

/* --- Controles segmentados ---------------------------------------------- */

.dvpe-seg { display: flex; gap: 6px; margin-bottom: 10px; background: var(--dvpe-inset); border-radius: 10px; padding: 4px; }
.dvpe-seg__btn {
    flex: 1;
    padding: 7px 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--dvpe-muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
}
.dvpe-seg__btn.is-active { background: var(--dvpe-accent); color: #fff; }

/* --- Estadísticas -------------------------------------------------------- */

.dvpe-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; transition: opacity .18s ease; }
.dvpe-stats.is-fading { opacity: 0; }

.dvpe-stat { background: var(--dvpe-inset); border-radius: 10px; padding: 9px 12px; position: relative; }
.dvpe-stat__label { display: block; font-size: 11.5px; color: var(--dvpe-muted); }
.dvpe-stat__value { font-size: 20px; line-height: 1.15; font-weight: 700; color: var(--dvpe-text-strong); font-variant-numeric: tabular-nums; }
.dvpe-stat__value--small { font-size: 14.5px; line-height: 1.2; white-space: nowrap; }

.dvpe-stat--accent { background: rgba(232, 83, 107, .09); }
.dvpe-stat--accent .dvpe-stat__label { color: var(--dvpe-danger-soft); font-weight: 600; }
.dvpe-stat--accent .dvpe-stat__value { font-size: 24px; color: var(--dvpe-danger); }

#dvpe-spark { position: absolute; right: 10px; bottom: 8px; width: 58px; height: 26px; }

/* --- Lista de fallas ------------------------------------------------------ */

.dvpe-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.dvpe-list__item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 6px;
    border-bottom: 1px solid rgba(120, 150, 200, .09);
    border-radius: 8px;
    cursor: pointer;
}
.dvpe-list__item:hover, .dvpe-list__item:focus-visible { background: rgba(43, 125, 233, .08); outline: none; }
.dvpe-list__zone { display: block; font-weight: 600; font-size: 13.5px; color: var(--dvpe-text); }
.dvpe-list__addr { display: block; font-size: 12px; color: var(--dvpe-muted); }
.dvpe-list__time { flex: none; font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600; color: var(--dvpe-danger); font-variant-numeric: tabular-nums; }

.dvpe-empty { padding: 12px 4px; font-size: 13px; color: var(--dvpe-muted); }

/* --- Ranking -------------------------------------------------------------- */

.dvpe-rank { list-style: none; margin: 0; padding: 0; overflow-y: auto; transition: opacity .18s ease; }
.dvpe-rank.is-fading { opacity: 0; }
.dvpe-rank__item { padding: 9px 2px; border-bottom: 1px solid rgba(120, 150, 200, .09); }
.dvpe-rank__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dvpe-rank__name { font-weight: 600; font-size: 13px; color: var(--dvpe-text); min-width: 0; overflow-wrap: anywhere; }
.dvpe-rank__parent { display: block; font-weight: 400; font-size: 11.5px; color: var(--dvpe-muted); }
.dvpe-rank__value { flex: none; font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; font-weight: 600; color: var(--dvpe-soft); font-variant-numeric: tabular-nums; }
.dvpe-rank__bar { display: block; height: 4px; border-radius: 2px; background: var(--dvpe-accent); opacity: .85; margin-top: 7px; transition: width .5s ease; }

.dvpe-note { margin: 10px 0 0; font-size: 11px; line-height: 1.5; color: var(--dvpe-muted); }

/* --- Leyenda del mapa ------------------------------------------------------ */

.dvpe-legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 800;
    display: flex;
    gap: 16px;
    align-items: center;
    background: var(--dvpe-panel);
    border: 1px solid var(--dvpe-border);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--dvpe-muted);
}
.dvpe-legend > span { display: flex; align-items: center; gap: 7px; }
.dvpe-legend__dot { width: 10px; height: 10px; border-radius: 50%; }
.dvpe-legend__dot--gps { background: #e8536b; }
.dvpe-legend__dot--approx { background: var(--dvpe-accent); }

/* --- Marcadores ------------------------------------------------------------ */

.dvpe-pin { position: relative; display: block; width: 14px; height: 14px; }
.dvpe-pin i { position: absolute; inset: 2px; border-radius: 50%; border: 2px solid #fff; }
.dvpe-pin b { position: absolute; inset: 0; border-radius: 50%; animation: dvpe-ring 2.4s ease-out infinite; }
.dvpe-pin--gps i { background: #e8536b; }
.dvpe-pin--gps b { background: rgba(232, 83, 107, .5); }
.dvpe-pin--approx i { background: var(--dvpe-accent); }
.dvpe-pin--approx b { background: rgba(43, 125, 233, .4); animation-duration: 3.4s; }

.leaflet-container { background: var(--dvpe-bg); font-family: 'Instrument Sans', sans-serif; }
.leaflet-tooltip { background: #fff; border: 0; color: #22304a; font-family: 'Instrument Sans', sans-serif; font-size: 12px; font-weight: 600; border-radius: 8px; box-shadow: 0 4px 14px rgba(10, 20, 40, .25); }
.leaflet-tooltip-top:before { border-top-color: #fff; }
.leaflet-control-zoom a { background: #fff; color: #22304a; border-color: rgba(30, 50, 80, .12); }
.leaflet-control-attribution { background: rgba(15, 21, 34, .7); color: #64748f; }
.leaflet-control-attribution a { color: #8296b3; }

/* --- Ticker ------------------------------------------------------------------ */

.dvpe-ticker {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 38px;
    z-index: 950;
    display: flex;
    align-items: stretch;
    background: var(--dvpe-panel);
    border-top: 1px solid var(--dvpe-border);
    overflow: hidden;
}
@media (min-width: 980px) { .dvpe-ticker { position: absolute; } }

.dvpe-ticker__label {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 700;
    color: var(--dvpe-text-strong);
    border-right: 1px solid var(--dvpe-border);
    background: var(--dvpe-panel);
    z-index: 2;
}
.dvpe-ticker__label img { width: 22px; height: 22px; object-fit: contain; }
.dvpe-ticker__viewport { flex: 1; overflow: hidden; display: flex; align-items: center; }
.dvpe-ticker__row { display: flex; gap: 42px; white-space: nowrap; padding-left: 42px; animation: dvpe-tick 40s linear infinite; }
.dvpe-ticker__item { font-size: 12.5px; color: var(--dvpe-muted); }
.dvpe-ticker__item time { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; }
.dvpe-ticker__item strong { color: var(--dvpe-text); font-weight: 600; }
.dvpe-ticker__item em { font-style: normal; color: var(--dvpe-danger); }

/* --- Detalle ------------------------------------------------------------------ */

.dvpe-detail {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 18, .7);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.dvpe-detail__panel {
    position: relative;
    background: var(--dvpe-panel);
    border: 1px solid rgba(120, 150, 200, .18);
    border-radius: 16px;
    padding: 24px;
    max-width: 440px;
    width: 100%;
    max-height: 86dvh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.dvpe-detail__close {
    position: absolute;
    top: 12px; right: 14px;
    background: none;
    border: 0;
    font-size: 24px;
    line-height: 1;
    color: var(--dvpe-muted);
    cursor: pointer;
}
.dvpe-detail__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dvpe-detail__head img { width: 44px; height: 44px; object-fit: contain; flex: none; }
.dvpe-detail__kicker { display: block; font-size: 12px; font-weight: 600; color: var(--dvpe-danger-soft); }
.dvpe-detail__panel h2 { margin: 2px 0 0; font-size: 19px; font-weight: 700; color: var(--dvpe-text-strong); }
.dvpe-detail__panel dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13.5px; }
.dvpe-detail__panel dt { color: var(--dvpe-muted); }
.dvpe-detail__panel dd { margin: 0; color: var(--dvpe-text); font-weight: 600; }
.dvpe-detail__photo { display: block; width: 100%; border-radius: 10px; margin-top: 14px; }

.dvpe-detail[hidden], .dvpe-ticker[hidden], #dvpe-spark[hidden] { display: none; }

/* --- Movimiento reducido -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .dvpe-pin b, .dvpe-ticker__row, .dvpe-live__dot { animation: none !important; }
}
