/* ══════════════════════════════════════════════
   PTAR System — "Deep Water"
   Azul profundo, superficies de vidrio y acento aguamarina.
   Movimiento: rápido, sobrio, con propósito.
   ══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    color-scheme: dark;

    /* Core */
    --bg-deep: #0A1624;
    --bg-surface: #0F1F33;
    --bg-card: #13263C;
    --bg-card-hover: #183050;
    --bg-elevated: #1D3754;
    --bg-glass: rgba(19, 38, 60, 0.72);

    /* Accent — aguamarina */
    --accent: #2EE6C1;
    --accent-glow: rgba(46, 230, 193, 0.18);
    --accent-muted: #1FBF9F;
    --accent-subtle: rgba(46, 230, 193, 0.07);
    --accent-strong: #6FFFE2;
    --accent-deep: #0B8F7E;

    /* Semantic */
    --success: #3DDBA4;
    --warning: #FFD166;
    --danger: #FF6B6B;
    --info: #74B9FF;

    /* Text */
    --text-primary: #EEF3F8;
    --text-secondary: #9AABC0;
    --text-muted: #67798F;
    --text-inverse: #06131F;

    /* Borders */
    --border: rgba(148, 170, 200, 0.10);
    --border-accent: rgba(46, 230, 193, 0.32);
    --border-light: rgba(148, 170, 200, 0.18);
    --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.045);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.22), 0 12px 32px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5);

    /* Type */
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    /* Motion */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
    --dur-press: 140ms;
    --dur-fast: 180ms;
    --dur-base: 240ms;
    --dur-enter: 420ms;

    /* Sidebar */
    --sidebar-width: 264px;
}

/* ── RESET & BASE ──────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(1200px 600px at 85% -10%, rgba(46, 230, 193, 0.06), transparent 60%),
        radial-gradient(900px 500px at 10% 110%, rgba(116, 185, 255, 0.05), transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

::selection {
    background: rgba(46, 230, 193, 0.28);
    color: var(--text-primary);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--dur-fast) ease;
}

a:hover {
    color: var(--accent-strong);
}

input,
select,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ── SCROLLBAR ─────────────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 170, 200, 0.25) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 170, 200, 0.22);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 170, 200, 0.4);
    background-clip: padding-box;
}

/* ── LAYOUT ────────────────────────────────── */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────── */
.sidebar {
    background:
        linear-gradient(180deg, rgba(46, 230, 193, 0.035), transparent 220px),
        linear-gradient(180deg, #0E1D30 0%, #0A1624 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 100;
    transition: transform 420ms var(--ease-drawer);
}

.sidebar-brand {
    padding: 1.4rem 1.3rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeSlideIn var(--dur-enter) var(--ease-out) backwards;
}

.sidebar-brand-icon {
    width: 80px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-muted) 45%, var(--accent-deep) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    letter-spacing: 0.06em;
    color: var(--text-inverse);
    font-weight: 800;
    box-shadow: 0 4px 16px rgba(46, 230, 193, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    position: relative;
    overflow: hidden;
}

/* Con logo cargado: placa clara y el logo conserva su proporción */
.sidebar-brand-icon.has-logo,
.login-brand-icon.has-logo {
    background: #FFFFFF;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.sidebar-brand-icon.has-logo {
    width: auto;
    min-width: 44px;
    max-width: 104px;
    height: 44px;
    padding: 4px 8px;
    flex-shrink: 0;
}

.login-brand-icon.has-logo {
    width: auto;
    min-width: 96px;
    max-width: 260px;
    height: 96px;
    padding: 10px 16px;
}

.sidebar-brand-icon img,
.login-brand-icon img {
    display: block;
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Brillo que recorre el logo una vez al cargar */
.sidebar-brand-icon::after,
.login-brand-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
    transform: translateX(-120%);
    animation: sheen 1.4s var(--ease-in-out) 0.5s both;
}

.sidebar-brand-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-brand-text span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.64rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 0.6rem 0.7rem;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    padding: 1.1rem 0.75rem 0.4rem;
    font-weight: 700;
    transition: color var(--dur-fast) ease;
}

.nav-section-label:hover {
    color: var(--accent-muted);
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0.55rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    margin: 2px 0;
    transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    bottom: 25%;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(46, 230, 193, 0.6);
    transform: scaleY(0.4);
    opacity: 0;
    transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-fast) ease;
}

.nav-link:active {
    transform: scale(0.98);
}

.nav-link.active {
    color: var(--text-primary);
    background: linear-gradient(90deg, rgba(46, 230, 193, 0.14), rgba(46, 230, 193, 0.04));
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(46, 230, 193, 0.12);
}

.nav-link.active::before {
    transform: scaleY(1);
    opacity: 1;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.55;
    transition: opacity var(--dur-fast) ease, color var(--dur-fast) ease;
}

.nav-link.active svg {
    opacity: 1;
    color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
    .nav-link:hover {
        color: var(--text-primary);
        background: rgba(148, 170, 200, 0.06);
    }

    .nav-link.active:hover {
        background: linear-gradient(90deg, rgba(46, 230, 193, 0.16), rgba(46, 230, 193, 0.05));
    }

    .nav-link:hover svg {
        opacity: 0.9;
    }
}

.sidebar-footer {
    padding: 1rem 1.1rem 1.1rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.18);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.35rem;
    border-radius: var(--radius-md);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-elevated), var(--bg-card));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    border: 1.5px solid var(--border-accent);
    box-shadow: 0 0 0 3px rgba(46, 230, 193, 0.06);
    flex-shrink: 0;
}

.user-info-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.user-info-role {
    font-size: 0.68rem;
    color: var(--accent-muted);
    font-weight: 500;
}

.sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 0.7rem;
}

.btn-account {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}

.btn-account svg {
    width: 13px;
    height: 13px;
}

.btn-account:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .btn-account:hover {
        border-color: var(--border-accent);
        color: var(--accent);
        background: var(--accent-subtle);
    }
}

.sidebar-actions .btn-logout {
    margin-top: 0;
}

.btn-logout {
    margin-top: 0.7rem;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}

.btn-logout:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .btn-logout:hover {
        border-color: rgba(255, 107, 107, 0.6);
        color: var(--danger);
        background: rgba(255, 107, 107, 0.06);
    }
}

/* ── MAIN CONTENT ──────────────────────────── */
.main-content {
    grid-column: 2;
    padding: 1.75rem 2.25rem 3rem;
    max-width: 1600px;
    width: 100%;
    overflow-x: hidden;
}

/* Entrada de página: cada bloque nuevo aparece en cascada */
.main-content > * {
    animation: fadeSlideIn var(--dur-enter) var(--ease-out) backwards;
}

.main-content > *:nth-child(2) { animation-delay: 50ms; }
.main-content > *:nth-child(3) { animation-delay: 100ms; }
.main-content > *:nth-child(4) { animation-delay: 150ms; }
.main-content > *:nth-child(5) { animation-delay: 200ms; }
.main-content > *:nth-child(n+6) { animation-delay: 240ms; }

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 4rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(46, 230, 193, 0.18);
    border-top-color: var(--accent);
    animation: spin 0.7s linear infinite;
}

/* ── PAGE HEADER ───────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1.5rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.page-header::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 64px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
    transform-origin: left;
    animation: growX 700ms var(--ease-out) 150ms backwards;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.2;
    background: linear-gradient(180deg, #FFFFFF 20%, #B9C8D8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── BUTTONS ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-light);
    background: var(--bg-elevated);
    color: var(--text-primary);
    letter-spacing: 0.01em;
    box-shadow: var(--highlight), var(--shadow-sm);
    transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: var(--text-inverse);
    border-color: transparent;
    font-weight: 700;
    box-shadow: 0 2px 12px rgba(46, 230, 193, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-danger {
    border-color: rgba(255, 107, 107, 0.4);
    color: var(--danger);
    background: rgba(255, 107, 107, 0.08);
    box-shadow: none;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.74rem;
    border-radius: 7px;
    min-width: 62px;
    justify-content: center;
}

/* Contenedor de acciones en tabla — botones en linea */
.action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

/* Boton Editar — azul claro */
.btn-edit,
.btn-del {
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    font-size: 0.74rem;
    border-radius: 7px;
    min-width: 62px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}

.btn-edit {
    background: rgba(116, 185, 255, 0.1);
    border: 1px solid rgba(116, 185, 255, 0.28);
    color: var(--info);
}

/* Boton Eliminar — rojo, mismo tamano que Editar */
.btn-del {
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.25);
    color: var(--danger);
}

.btn-edit:active,
.btn-del:active {
    transform: scale(0.96);
}

@media (hover: hover) and (pointer: fine) {
    .btn:hover {
        background: var(--bg-card-hover);
        border-color: rgba(148, 170, 200, 0.32);
    }

    .btn-primary:hover {
        background: linear-gradient(135deg, var(--accent-strong), var(--accent));
        border-color: transparent;
        box-shadow: 0 4px 20px rgba(46, 230, 193, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }

    .btn-danger:hover {
        background: rgba(255, 107, 107, 0.15);
        border-color: var(--danger);
    }

    .btn-edit:hover {
        background: rgba(116, 185, 255, 0.2);
        border-color: var(--info);
        color: #A5D8FF;
    }

    .btn-del:hover {
        background: rgba(255, 107, 107, 0.18);
        border-color: var(--danger);
    }
}

/* ── KPI GRID ──────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 14px;
    margin-bottom: 1.8rem;
}

.kpi-card {
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(46, 230, 193, 0.05), transparent 55%),
        linear-gradient(160deg, var(--bg-card), var(--bg-surface));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--highlight), var(--shadow-sm);
    transition: border-color var(--dur-base) ease, box-shadow var(--dur-base) ease, transform var(--dur-base) var(--ease-out);
    animation: fadeSlideIn var(--dur-enter) var(--ease-out) backwards;
}

/* Cascada de tarjetas KPI */
.kpi-card:nth-child(2) { animation-delay: 40ms; }
.kpi-card:nth-child(3) { animation-delay: 80ms; }
.kpi-card:nth-child(4) { animation-delay: 120ms; }
.kpi-card:nth-child(5) { animation-delay: 160ms; }
.kpi-card:nth-child(6) { animation-delay: 200ms; }
.kpi-card:nth-child(7) { animation-delay: 240ms; }
.kpi-card:nth-child(n+8) { animation-delay: 280ms; }

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent 80%);
    opacity: 0.35;
    transition: opacity var(--dur-base) ease;
}

.kpi-warn::before {
    background: linear-gradient(90deg, var(--warning), transparent 80%);
}

.kpi-danger::before {
    background: linear-gradient(90deg, var(--danger), transparent 80%);
}

@media (hover: hover) and (pointer: fine) {
    .kpi-card:hover {
        border-color: var(--border-accent);
        transform: translateY(-2px);
        box-shadow: var(--highlight), 0 10px 30px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(46, 230, 193, 0.04);
    }

    .kpi-card:hover::before {
        opacity: 1;
    }
}

.kpi-label {
    font-size: 0.66rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 8px;
    font-weight: 700;
}

.kpi-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.035em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 500;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    margin-top: 8px;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 600;
}

.kpi-trend.up {
    color: var(--success);
    background: rgba(61, 219, 164, 0.12);
}

.kpi-trend.down {
    color: var(--danger);
    background: rgba(255, 107, 107, 0.12);
}

.kpi-accent .kpi-value {
    color: var(--accent);
    text-shadow: 0 0 24px rgba(46, 230, 193, 0.25);
}

.kpi-warn .kpi-value {
    color: var(--warning);
}

.kpi-danger .kpi-value {
    color: var(--danger);
}

/* ── PROGRESS BAR ──────────────────────────── */
.progress-bar {
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 170, 200, 0.1);
    margin-top: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-muted), var(--accent-strong));
    box-shadow: 0 0 10px rgba(46, 230, 193, 0.45);
    transform-origin: left;
    animation: growX 900ms var(--ease-out) 300ms backwards;
}

/* ── CARDS & SECTIONS ──────────────────────── */
.section-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 1.8rem 0 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.005em;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-light), transparent);
}

.card {
    background: linear-gradient(170deg, rgba(23, 44, 68, 0.9), rgba(17, 34, 54, 0.9));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.3rem;
    margin-bottom: 1rem;
    box-shadow: var(--highlight), var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.card-title::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(46, 230, 193, 0.6);
}

.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 14px;
    margin-bottom: 1.5rem;
}

.charts-row > .card {
    animation: fadeSlideIn var(--dur-enter) var(--ease-out) 120ms backwards;
}

.charts-row > .card:nth-child(2) {
    animation-delay: 180ms;
}

/* ── TABLES ────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

table.dt {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82rem;
}

table.dt thead {
    background: var(--bg-surface);
}

table.dt th {
    padding: 0.75rem 1rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-surface);
}

table.dt th:first-child {
    border-top-left-radius: var(--radius-sm);
}

table.dt th:last-child {
    border-top-right-radius: var(--radius-sm);
}

table.dt td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
    transition: color var(--dur-fast) ease;
}

table.dt tbody tr {
    transition: background-color var(--dur-fast) ease;
}

table.dt tbody tr:last-child td {
    border-bottom: none;
}

table.dt tbody tr:nth-child(even) {
    background: rgba(148, 170, 200, 0.018);
}

@media (hover: hover) and (pointer: fine) {
    table.dt tbody tr:hover {
        background: rgba(46, 230, 193, 0.045);
    }

    table.dt tbody tr:hover td {
        color: var(--text-primary);
    }
}

/* ── BADGES ────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.67rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    line-height: 1.5;
}

.badge-ok {
    background: rgba(61, 219, 164, 0.12);
    color: var(--success);
    border: 1px solid rgba(61, 219, 164, 0.22);
}

.badge-warn {
    background: rgba(255, 209, 102, 0.12);
    color: var(--warning);
    border: 1px solid rgba(255, 209, 102, 0.22);
}

.badge-danger {
    background: rgba(255, 107, 107, 0.12);
    color: var(--danger);
    border: 1px solid rgba(255, 107, 107, 0.22);
}

.badge-info {
    background: rgba(116, 185, 255, 0.12);
    color: var(--info);
    border: 1px solid rgba(116, 185, 255, 0.22);
}

.badge-prev {
    background: rgba(167, 139, 250, 0.12);
    color: #B9A5FF;
    border: 1px solid rgba(167, 139, 250, 0.22);
}

.badge-corr {
    background: rgba(251, 146, 60, 0.12);
    color: #FDA35E;
    border: 1px solid rgba(251, 146, 60, 0.22);
}

/* ── STATUS DOTS ───────────────────────────── */
.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    position: relative;
    vertical-align: 1px;
}

.dot-ok {
    background: var(--success);
    box-shadow: 0 0 8px rgba(61, 219, 164, 0.55);
}

.dot-warn {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(255, 209, 102, 0.55);
}

.dot-off {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.55);
}

/* Pulso suave solo en estados que piden atención */
.dot-warn::after,
.dot-off::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: pulseRing 2.2s var(--ease-out) infinite;
}

/* ── PLANT CARDS ───────────────────────────── */
.plant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}

.plant-card {
    background: linear-gradient(165deg, var(--bg-card), var(--bg-surface));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    cursor: pointer;
    box-shadow: var(--highlight);
    transition: border-color var(--dur-base) ease, box-shadow var(--dur-base) ease, transform var(--dur-base) var(--ease-out);
    animation: fadeSlideIn var(--dur-enter) var(--ease-out) backwards;
}

.plant-card:nth-child(2) { animation-delay: 30ms; }
.plant-card:nth-child(3) { animation-delay: 60ms; }
.plant-card:nth-child(4) { animation-delay: 90ms; }
.plant-card:nth-child(5) { animation-delay: 120ms; }
.plant-card:nth-child(6) { animation-delay: 150ms; }
.plant-card:nth-child(7) { animation-delay: 180ms; }
.plant-card:nth-child(8) { animation-delay: 210ms; }
.plant-card:nth-child(n+9) { animation-delay: 240ms; }

.plant-card:active {
    transform: scale(0.98);
}

@media (hover: hover) and (pointer: fine) {
    .plant-card:hover {
        border-color: var(--border-accent);
        transform: translateY(-3px);
        box-shadow: var(--highlight), 0 12px 28px rgba(0, 0, 0, 0.28);
    }

    .plant-card:active {
        transform: translateY(-1px) scale(0.98);
    }
}

.plant-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
}

.plant-stat {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── FORMS ─────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.form-control {
    width: 100%;
    padding: 0.62rem 0.9rem;
    background: rgba(8, 18, 30, 0.7);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.86rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, background-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
    .form-control:hover {
        border-color: rgba(148, 170, 200, 0.3);
    }
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), inset 0 1px 2px rgba(0, 0, 0, 0.2);
    background: rgba(8, 18, 30, 0.9);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}

select.form-control option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

input[type="date"].form-control::-webkit-calendar-picker-indicator {
    filter: invert(0.75);
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

/* ── MODAL ─────────────────────────────────── */
/* Entrada y salida animadas con transiciones (interrumpibles).
   En navegadores sin @starting-style simplemente aparece al instante. */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 12, 22, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 500;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 200ms ease, display 200ms allow-discrete;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal {
    background:
        radial-gradient(120% 60% at 50% 0%, rgba(46, 230, 193, 0.06), transparent 60%),
        linear-gradient(165deg, #183049, var(--bg-card));
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.6rem;
    box-shadow: var(--shadow-lg), var(--highlight), 0 0 0 1px rgba(46, 230, 193, 0.05);
    transform: translateY(8px) scale(0.97);
    opacity: 0;
    transition: transform 180ms var(--ease-out), opacity 160ms ease;
}

.modal-overlay.show .modal {
    transform: translateY(0) scale(1);
    opacity: 1;
    transition: transform 320ms var(--ease-out), opacity 220ms ease;
}

@starting-style {
    .modal-overlay.show {
        opacity: 0;
    }

    .modal-overlay.show .modal {
        transform: translateY(12px) scale(0.96);
        opacity: 0;
    }
}

/* Contenido del modal en cascada */
.modal > * {
    animation: fadeIn 300ms var(--ease-out) backwards;
}

.modal > *:nth-child(2) { animation-delay: 50ms; }
.modal > *:nth-child(n+3) { animation-delay: 90ms; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.3rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.modal-close {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-base) var(--ease-out);
}

.modal-close:active {
    transform: scale(0.92);
}

@media (hover: hover) and (pointer: fine) {
    .modal-close:hover {
        color: var(--danger);
        border-color: rgba(255, 107, 107, 0.6);
        background: rgba(255, 107, 107, 0.1);
        transform: rotate(90deg);
    }

    .modal-close:hover:active {
        transform: rotate(90deg) scale(0.92);
    }
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ── TABS ──────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 3px;
    background: rgba(8, 18, 30, 0.55);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 1.4rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
    scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 0.5rem 1.05rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}

.tab-btn:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .tab-btn:hover {
        color: var(--text-primary);
        background: rgba(148, 170, 200, 0.07);
    }
}

.tab-btn.active,
.tab-btn.active:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: var(--text-inverse);
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(46, 230, 193, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.tab-panel {
    display: none;
}

.tab-panel.visible {
    display: block;
    animation: fadeSlideIn 300ms var(--ease-out);
}

/* ── TIMELINE ──────────────────────────────── */
.timeline {
    padding-left: 26px;
    border-left: 2px solid var(--border-light);
    margin-left: 6px;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.3rem;
    padding-left: 18px;
    animation: fadeSlideIn var(--dur-enter) var(--ease-out) backwards;
}

.timeline-item:nth-child(2) { animation-delay: 50ms; }
.timeline-item:nth-child(3) { animation-delay: 100ms; }
.timeline-item:nth-child(4) { animation-delay: 150ms; }
.timeline-item:nth-child(n+5) { animation-delay: 200ms; }

.timeline-item::before {
    content: '';
    position: absolute;
    left: -33px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2.5px solid var(--bg-card);
    box-shadow: 0 0 0 1px rgba(46, 230, 193, 0.35), 0 0 10px rgba(46, 230, 193, 0.35);
}

.timeline-item.danger::before {
    background: var(--danger);
    box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.35), 0 0 10px rgba(255, 107, 107, 0.35);
}

.timeline-item.warn::before {
    background: var(--warning);
    box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.35), 0 0 10px rgba(255, 209, 102, 0.35);
}

.timeline-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.timeline-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-top: 3px;
    font-weight: 500;
}

.timeline-loc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── TOAST ─────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0.8rem 1rem 0.8rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    min-width: 290px;
    max-width: min(420px, calc(100vw - 2rem));
    background: rgba(29, 55, 84, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    box-shadow: var(--shadow-md), var(--highlight);
    transform: translateX(calc(100% + 1.5rem));
    opacity: 0;
    transition: transform 300ms var(--ease-out), opacity 240ms ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
    .toast button:hover {
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.08);
    }
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--danger);
}

.toast-info {
    border-left: 3px solid var(--info);
}

.toast-warning {
    border-left: 3px solid var(--warning);
}

/* ── LOGIN PAGE ────────────────────────────── */
.login-page {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 120%, #0E2A3E 0%, var(--bg-deep) 55%, #060E19 100%);
    padding: 1rem;
    overflow: hidden;
    isolation: isolate;
}

/* Retícula técnica que se desvanece hacia los bordes */
.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(148, 170, 200, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 170, 200, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
    mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
}

/* Luces ambientales flotando lentamente (decorativo) */
.login-orb {
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.55;
    pointer-events: none;
    will-change: transform;
}

.login-orb-1 {
    width: 460px;
    height: 460px;
    top: -140px;
    left: -120px;
    background: radial-gradient(circle, rgba(46, 230, 193, 0.35), transparent 70%);
    animation: drift1 22s ease-in-out infinite alternate;
}

.login-orb-2 {
    width: 520px;
    height: 520px;
    bottom: -200px;
    right: -160px;
    background: radial-gradient(circle, rgba(116, 185, 255, 0.28), transparent 70%);
    animation: drift2 26s ease-in-out infinite alternate;
}

.login-orb-3 {
    width: 300px;
    height: 300px;
    top: 55%;
    left: 60%;
    background: radial-gradient(circle, rgba(46, 230, 193, 0.18), transparent 70%);
    animation: drift1 30s ease-in-out infinite alternate-reverse;
}

/* Ondas de agua en la base */
.login-waves {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 180px;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
    opacity: 0.6;
}

.login-waves svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 100%;
}

.login-waves .wave-a {
    animation: waveShift 18s linear infinite;
}

.login-waves .wave-b {
    animation: waveShift 26s linear infinite reverse;
    opacity: 0.7;
}

.login-container {
    width: 100%;
    max-width: 420px;
    position: relative;
}

.login-card {
    background:
        radial-gradient(120% 60% at 50% 0%, rgba(46, 230, 193, 0.07), transparent 60%),
        linear-gradient(165deg, rgba(23, 44, 68, 0.82), rgba(15, 31, 51, 0.82));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2.2rem 2rem;
    box-shadow: var(--shadow-lg), var(--highlight), 0 0 0 1px rgba(46, 230, 193, 0.04);
    animation: cardIn 700ms var(--ease-out) backwards;
}

.login-card > * {
    animation: fadeSlideIn 500ms var(--ease-out) backwards;
}

.login-card > *:nth-child(1) { animation-delay: 150ms; }
.login-card > *:nth-child(2) { animation-delay: 200ms; }
.login-card > *:nth-child(3) { animation-delay: 240ms; }
.login-card > *:nth-child(4) { animation-delay: 290ms; }
.login-card > *:nth-child(5) { animation-delay: 340ms; }
.login-card > *:nth-child(n+6) { animation-delay: 400ms; }

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand-icon {
    width: 96px;
    height: 96px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-muted) 45%, var(--accent-deep) 100%);
    border-radius: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    letter-spacing: 0.06em;
    color: var(--text-inverse);
    font-weight: 800;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(46, 230, 193, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    animation: float 6s ease-in-out 1s infinite;
}

.login-brand h2 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(180deg, #FFFFFF 30%, #A9BCD0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-brand p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.login-error {
    display: none;
    padding: 0.65rem 0.9rem;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.25);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.login-card > .login-error.show {
    display: block;
    animation: shake 380ms var(--ease-out);
}

.login-btn {
    width: 100%;
    padding: 0.8rem;
    margin-top: 0.4rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(46, 230, 193, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: box-shadow var(--dur-base) ease, transform var(--dur-press) var(--ease-out), opacity var(--dur-fast) ease;
}

.login-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
    transform: translateX(-120%);
    transition: transform 700ms var(--ease-out);
}

.login-btn:active {
    transform: scale(0.98);
}

@media (hover: hover) and (pointer: fine) {
    .login-btn:hover {
        box-shadow: 0 8px 28px rgba(46, 230, 193, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }

    .login-btn:hover::after {
        transform: translateX(120%);
    }
}

.login-btn:disabled {
    opacity: 0.55;
    cursor: progress;
    transform: none;
    box-shadow: none;
}

.login-footer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border);
}

/* ── HAMBURGER (mobile) ────────────────────── */
.hamburger {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur-press) var(--ease-out);
}

.hamburger:active {
    transform: scale(0.94);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 8, 15, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    transition: opacity 300ms ease, display 300ms allow-discrete;
}

/* ── RESPONSIVE ────────────────────────────── */
@media (min-width: 2500px) {
    html {
        font-size: 18px;
    }

    .main-content {
        padding: 2rem 3rem;
        max-width: 2200px;
    }

    .kpi-grid {
        grid-template-columns: repeat(8, 1fr);
    }

    .kpi-value {
        font-size: 2.2rem;
    }

    .charts-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .plant-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 1920px) and (max-width: 2499px) {
    html {
        font-size: 16px;
    }

    .kpi-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 24px 0 64px rgba(0, 0, 0, 0.45);
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    @starting-style {
        .sidebar-overlay.show {
            opacity: 0;
        }
    }

    .main-content {
        grid-column: 1;
        padding: 1rem;
        padding-top: 4rem;
    }

    .hamburger {
        display: flex;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    html {
        font-size: 14px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .plant-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal {
        width: 95%;
        padding: 1.2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tab-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .login-card {
        padding: 2rem 1.4rem 1.6rem;
    }

    .brand-form {
        grid-template-columns: 1fr !important;
    }

    .charts-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ── CHART CONTAINERS ──────────────────────── */
.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
}

@media (min-width: 2500px) {
    .chart-container {
        height: 360px;
    }
}

/* ── LOADING SKELETON ──────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
    border-radius: var(--radius-sm);
}

/* ── EMPTY STATE ───────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ── LEAFLET (mapas) armonizado con el tema ── */
.leaflet-container {
    background: var(--bg-surface);
    font-family: var(--font-main);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.leaflet-bar a {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom-color: var(--border-light);
}

/* Sidebar expandible */
.nav-section-label { cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.nav-section-label::after { content: '▾'; font-size: 0.7rem; transition: transform var(--dur-base) var(--ease-out); }
.nav-section-label.collapsed::after { transform: rotate(-90deg); }
.nav-section-group { overflow: hidden; max-height: 500px; transition: max-height 0.3s var(--ease-in-out); }
.nav-section-group.collapsed { max-height: 0; }

/* ══════════════════════════════════════════════
   KEYFRAMES
   ══════════════════════════════════════════════ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
}

@keyframes growX {
    from {
        transform: scaleX(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes sheen {
    to {
        transform: translateX(120%);
    }
}

@keyframes pulseRing {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    80%,
    100% {
        transform: scale(2.6);
        opacity: 0;
    }
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(2px);
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@keyframes drift1 {
    to {
        transform: translate(120px, 80px) scale(1.15);
    }
}

@keyframes drift2 {
    to {
        transform: translate(-140px, -60px) scale(1.1);
    }
}

@keyframes waveShift {
    to {
        transform: translateX(-50%);
    }
}

/* ── MOVIMIENTO REDUCIDO ───────────────────── */
/* Menos y más suave, no cero: se conservan fundidos, se quita el desplazamiento. */
@media (prefers-reduced-motion: reduce) {
    .main-content > *,
    .sidebar-brand,
    .kpi-card,
    .plant-card,
    .charts-row > .card,
    .timeline-item,
    .tab-panel.visible,
    .modal > *,
    .login-card,
    .login-card > * {
        animation: fadeIn 200ms ease backwards !important;
    }

    .progress-fill,
    .page-header::after,
    .login-brand-icon,
    .login-card > .login-error.show {
        animation: none !important;
    }

    .login-orb,
    .login-waves svg,
    .dot-warn::after,
    .dot-off::after,
    .sidebar-brand-icon::after,
    .login-brand-icon::after,
    .login-btn::after {
        animation: none !important;
    }

    .sidebar-brand-icon::after,
    .login-brand-icon::after,
    .dot-warn::after,
    .dot-off::after {
        display: none;
    }

    .modal,
    .modal-overlay.show .modal,
    .toast,
    .sidebar {
        transition-property: opacity !important;
    }

    .modal {
        transform: none;
    }

    @media (hover: hover) and (pointer: fine) {
        .kpi-card:hover,
        .plant-card:hover,
        .modal-close:hover {
            transform: none;
        }
    }
}
