/* =====================================================================
   Grafico comun (WmsChart) y Administracion > Configuracion Graficos.
   ===================================================================== */

.wms-chart {
    container-type: inline-size;
    position: relative;
    min-width: 0;
}

.wms-chart.is-echarts .wms-chart-canvas {
    width: 100%;
    height: var(--chart-h, 280px);
}

.wms-chart.is-basic { min-height: 0; }

.wms-chart-png {
    position: absolute;
    top: -6px;
    right: -4px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: #35506f;
    cursor: pointer;
    opacity: 0;
    transition: opacity 160ms ease;
    z-index: 2;
}

.wms-chart:hover .wms-chart-png,
.wms-chart-png:focus-visible { opacity: 1; }

.wms-chart-png svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Sin animaciones (configuracion, modo Basica o "reducir movimiento"). */
.eq-static *,
.eq-static *::before,
.eq-static *::after {
    animation: none !important;
    transition: none !important;
}

.eq-static .eq-line { stroke-dashoffset: 0; }
.eq-static .eq-area,
.eq-static .eq-dot { opacity: 1; }

.wms-basic-gauge { display: grid; place-items: center; padding: 8px 0; }

.wms-basic-heat { overflow-x: auto; }

.wms-basic-heat table { border-collapse: separate; border-spacing: 2px; font-size: 0.72rem; width: 100%; }

.wms-basic-heat th { color: #5b6b83; font-weight: 700; padding: 2px 4px; white-space: nowrap; text-align: left; }
.wms-basic-heat thead th { text-align: center; }

.wms-basic-heat td {
    --i: 0;
    height: 18px;
    min-width: 14px;
    border-radius: 3px;
    background: color-mix(in srgb, #2563eb calc(var(--i) * 1%), #f1f5fb);
}

/* ---------- Pantalla de configuracion ---------- */

.cg-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 1fr);
    align-items: start;
}

@media (max-width: 1100px) {
    .cg-grid { grid-template-columns: 1fr; }
}

.cg-modes {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.cg-mode {
    --c: #2563eb;
    position: relative;
    display: grid;
    gap: 4px;
    align-content: start;
    padding: 14px;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    background: #ffffff;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.cg-mode:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -16px rgba(15, 34, 62, 0.5); }
.cg-mode:disabled { cursor: not-allowed; opacity: 0.55; transform: none; box-shadow: none; }

.cg-mode.is-active {
    border-color: var(--c);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent), 0 12px 24px -16px var(--c);
    background: linear-gradient(160deg, color-mix(in srgb, var(--c) 8%, #ffffff), #ffffff 65%);
}

.cg-mode.is-active::after {
    content: "✓";
    position: absolute;
    top: 10px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--c);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
}

.cg-mode-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--c);
    margin-bottom: 4px;
}

.cg-mode-icon svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.cg-mode strong { color: #0f223e; font-size: 0.95rem; }
.cg-mode small { color: #5b6b83; font-size: 0.76rem; line-height: 1.35; }

.cg-toggles { display: grid; gap: 8px; }

.cg-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e3eaf3;
    border-radius: 12px;
    background: #fbfcfe;
}

.cg-toggle-text { display: grid; gap: 2px; }
.cg-toggle-text b { color: #0f223e; font-size: 0.86rem; }
.cg-toggle-text span { color: #64748b; font-size: 0.76rem; }

.cg-switch { position: relative; width: 44px; height: 24px; flex: 0 0 auto; }
.cg-switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.cg-switch i {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 160ms ease;
}
.cg-switch i::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 160ms ease;
}
.cg-switch input:checked + i { background: #16a34a; }
.cg-switch input:checked + i::after { transform: translateX(20px); }
.cg-switch input:disabled + i { opacity: 0.5; }

.cg-interval { display: flex; align-items: center; gap: 8px; }
.cg-interval input { width: 90px; }

.cg-device {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    background: linear-gradient(120deg, #0f223e, #183f78);
    color: #ffffff;
}

.cg-device b, .cg-device strong, .cg-device span { color: #ffffff; }
.cg-device b { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }
.cg-device strong { font-size: 1.05rem; }
.cg-device span { font-size: 0.78rem; opacity: 0.85; }

.cg-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.cg-note {
    padding: 8px 12px;
    border-radius: 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-size: 0.8rem;
}

.cg-ok {
    padding: 8px 12px;
    border-radius: 10px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    font-size: 0.82rem;
    font-weight: 600;
}

.cg-preview { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Boton de la barra superior (mis graficos) */
.chart-pref-action {
    align-items: center;
    background: #ffffff;
    border: 1px solid #bfcbdb;
    border-radius: 6px;
    color: #163456;
    cursor: pointer;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    padding: 0;
    width: 38px;
    transition: background 140ms ease, border-color 140ms ease;
}

.chart-pref-action:hover { background: #eff6ff; border-color: #93c5fd; }

.chart-pref-action svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chart-pref-modal { width: min(720px, calc(100vw - 32px)); }

.chart-pref-body { display: grid; gap: 14px; padding: 4px 18px 6px; max-height: 70vh; overflow-y: auto; overflow-x: hidden; }
.chart-pref-body .cg-modes { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }

/* ---------- Variacion vs periodo anterior ---------- */
.kpi-delta {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    width: fit-content;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.kpi-delta small { font-weight: 600; opacity: 0.75; font-size: 0.66rem; }
.kpi-delta.is-good { background: #dcfce7; color: #166534; }
.kpi-delta.is-bad { background: #fee2e2; color: #991b1b; }
.kpi-delta.is-flat { background: #f1f5f9; color: #475569; }

/* ---------- En vivo ---------- */
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
}
.live-pill i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: live-pulse 1.6s ease-out infinite;
}
.live-pill small { font-weight: 600; opacity: 0.8; }
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    80% { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ---------- Encabezados de color adicionales ---------- */
.eq-hero-amber { background: linear-gradient(120deg, #0f223e 0%, #7c2d12 55%, #ea580c 100%); }
.eq-hero-rose { background: linear-gradient(120deg, #0f223e 0%, #831843 55%, #db2777 100%); }
.eq-hero-emerald { background: linear-gradient(120deg, #0f223e 0%, #065f46 55%, #059669 100%); }

/* ---------- Ordenes en riesgo ---------- */
.risk-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.risk-card {
    --c: #f59e0b;
    position: relative;
    display: grid;
    gap: 3px;
    padding: 10px 12px 10px 14px;
    border: 1px solid #e3eaf3;
    border-radius: 12px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--c) 10%, #ffffff), #ffffff 70%);
    overflow: hidden;
}
.risk-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.risk-card.is-late { --c: #dc2626; }
.risk-card strong { color: #0f223e; font-size: 0.88rem; }
.risk-card span { color: #5b6b83; font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.risk-chip {
    position: absolute;
    top: 9px;
    right: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--c);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 800;
}
.risk-bar { height: 5px; border-radius: 999px; background: #eef2f8; overflow: hidden; margin-top: 3px; }
.risk-bar > i { display: block; height: 100%; background: var(--c); border-radius: 999px; }

.eq-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

/* Tarjeta que ocupa 2 de 3 columnas en pantallas anchas. */
@media (min-width: 1100px) {
    .eq-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .eq-wide { grid-column: span 2; }
}

/* =====================================================================
   Torre de Control
   ===================================================================== */
.tc-hero { background: radial-gradient(120% 140% at 85% 20%, #1e3a8a 0%, #0f223e 45%, #050b16 100%); }

.tc-radar { position: absolute; right: 36px; top: 50%; width: 120px; height: 120px; transform: translateY(-50%); z-index: -1; }
.tc-radar i {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(147, 197, 253, 0.35);
    border-radius: 50%;
    animation: tc-ping 3.6s ease-out infinite;
}
.tc-radar i:nth-child(2) { animation-delay: 1.2s; }
.tc-radar i:nth-child(3) { animation-delay: 2.4s; }
@keyframes tc-ping {
    from { transform: scale(0.2); opacity: 0.9; }
    to { transform: scale(1.4); opacity: 0; }
}

.tc-tiles {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}

.tc-tile {
    --c: #2563eb;
    position: relative;
    overflow: hidden;
    display: grid;
    align-content: start;
    gap: 4px;
    padding: 14px 16px 0;
    min-height: 150px;
    border: 1px solid #dbe4ef;
    border-radius: 16px;
    background: linear-gradient(165deg, color-mix(in srgb, var(--c) 9%, #ffffff) 0%, #ffffff 55%);
    box-shadow: 0 1px 2px rgba(15, 34, 62, 0.06);
    animation: eq-rise 420ms ease both;
    transition: transform 180ms ease, box-shadow 180ms ease;
}
.tc-tile:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -18px var(--c); }
.tc-tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c); }

.tc-label { color: #5b6b83; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.tc-value { color: #0f223e; font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tc-value em { font-style: normal; font-size: 0.9rem; color: #64748b; font-weight: 700; }
.tc-tile small { color: #64748b; font-size: 0.74rem; }

.tc-tile .sparkline { display: block; width: calc(100% + 32px); height: 38px; margin: auto -16px 0; }

.tc-alerts { list-style: none; margin: 0; padding: 0 4px 0 0; display: grid; gap: 8px; max-height: 330px; overflow-y: auto; overflow-x: hidden; }
.tc-alert {
    --c: #64748b;
    display: grid;
    grid-template-columns: 12px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid #e3eaf3;
    border-left: 4px solid var(--c);
    border-radius: 10px;
    background: color-mix(in srgb, var(--c) 6%, #ffffff);
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease;
}
.tc-alert:hover { transform: translateX(3px); box-shadow: 0 6px 16px -12px var(--c); }
.tc-alert.is-alta { --c: #dc2626; }
.tc-alert.is-media { --c: #f59e0b; }
.tc-alert.is-baja { --c: #0ea5e9; }
.tc-alert div { display: grid; gap: 1px; min-width: 0; }
.tc-alert strong { color: #0f223e; font-size: 0.84rem; }
.tc-alert span { color: #5b6b83; font-size: 0.74rem; }
.tc-alert b { color: var(--c); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.tc-alert-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 0 var(--c); }
.tc-alert.is-alta .tc-alert-dot { animation: live-pulse 1.6s ease-out infinite; }

/* ---------- Calidad de los planos 3D (v2.20.0) ---------- */
.cg-subtitle {
    display: grid;
    gap: 2px;
    margin: 6px 0 -2px;
    padding-top: 12px;
    border-top: 1px dashed #d9e2ef;
}
.cg-subtitle b { color: #0f172a; font-size: 0.9rem; }
.cg-subtitle span { color: #5b6b83; font-size: 0.78rem; }
.cg-modes-3d .cg-mode { padding: 10px 12px; }
