/* =========================================================
   ATLAS - SITE.CSS LIMPIO
   Tema claro/oscuro, sidebar colapsable, UI compacta y fina
========================================================= */

/* ====== DESIGN TOKENS / THEME ====== */
:root {
    --atlas-bg: #f4f6f8;
    --atlas-surface: #ffffff;
    --atlas-surface-soft: #f8fafc;
    --atlas-ink: #0d1b2a;
    --atlas-muted: #6c757d;
    --atlas-brand: #0f4c75;
    --atlas-brand-light: #1b6ca8;
    --atlas-sidebar-bg-1: #0d1b2a;
    --atlas-sidebar-bg-2: #1a3550;
    --atlas-sidebar-text: #9fb3c8;
    --atlas-sidebar-active: #7bc8f6;
    --atlas-border: #e8edf2;
    --atlas-radius: 10px;
    --atlas-shadow: 0 4px 16px rgba(13,27,42,.08);
    --atlas-station-kpi: #1b6ca8;
    --atlas-station-button-bg: #0f172a;
    --atlas-station-button-hover: #172033;
    --atlas-station-button-border: #0f172a;
    --atlas-station-pill-bg: #0f172a;
    --atlas-station-pill-border: #0f172a;
}

html[data-theme="dark"] {
    --atlas-bg: #0b1220;
    --atlas-surface: #111827;
    --atlas-surface-soft: #172033;
    --atlas-ink: #e5e7eb;
    --atlas-muted: #9ca3af;
    --atlas-sidebar-bg-1: #020617;
    --atlas-sidebar-bg-2: #0f172a;
    --atlas-sidebar-text: #cbd5e1;
    --atlas-sidebar-active: #60c8f8;
    --atlas-border: #243244;
    --atlas-shadow: 0 4px 18px rgba(0,0,0,.35);
    --atlas-station-kpi: #3b82f6;
    --atlas-station-button-bg: #0f172a;
    --atlas-station-button-hover: #1e293b;
    --atlas-station-button-border: #334155;
    --atlas-station-pill-bg: #0f172a;
    --atlas-station-pill-border: #334155;
}

/* Evita brinco visual del sidebar al cambiar de página */
html.sidebar-collapsed-start .sidebar-atlas {
    width: 70px;
    min-width: 70px;
    padding-left: 9px;
    padding-right: 9px;
}

html.sidebar-collapsed-start .sidebar-text,
html.sidebar-collapsed-start .sidebar-logo-text,
html.sidebar-collapsed-start .sidebar-role,
html.sidebar-collapsed-start .sidebar-section {
    display: none !important;
}

/* ====== GLOBAL ====== */
body {
    font-family: 'Outfit', sans-serif;
    background: var(--atlas-bg);
    color: var(--atlas-ink);
    transition: background .2s ease, color .2s ease;
}

a {
    color: var(--atlas-brand-light);
}

h1, h2, h3, h4, h5 {
    font-weight: 600;
    letter-spacing: -0.3px;
}

/* ====== LAYOUT ====== */
.layout-main {
    display: flex;
    min-height: 100vh;
}

.content-atlas {
    flex: 1;
    background: var(--atlas-bg);
    color: var(--atlas-ink);
    padding: 25px;
    transition: background .2s ease, color .2s ease;
}

/* ====== SIDEBAR ====== */
.sidebar-atlas {
    width: 240px;
    min-width: 240px;
    background: linear-gradient(180deg, var(--atlas-sidebar-bg-1) 0%, var(--atlas-sidebar-bg-2) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    z-index: 999;
    transition: width .25s ease, min-width .25s ease, padding .25s ease;
}

    .sidebar-atlas.collapsed {
        width: 70px;
        min-width: 70px;
        padding-left: 9px;
        padding-right: 9px;
    }

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 18px;
    letter-spacing: -0.5px;
}

.sidebar-toggle {
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.22);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, border-color .15s ease;
}

    .sidebar-toggle:hover {
        background: rgba(255,255,255,.10);
        border-color: rgba(255,255,255,.35);
    }

.sidebar-menu {
    flex: 0 0 auto;
    max-height: calc(100vh - 210px);
    overflow-y: auto;
    padding-right: 2px;
}

.sidebar-section {
    margin: 13px 10px 6px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--atlas-sidebar-active);
}

.sidebar-link {
    position: relative;
    display: flex !important;
    align-items: center;
    gap: 11px;
    padding: 7px 11px;
    border-radius: 8px;
    color: var(--atlas-sidebar-text);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.25;
    margin-bottom: 2px;
    transition: background .15s ease, color .15s ease, border .15s ease;
}

    .sidebar-link:hover {
        background: color-mix(in srgb, var(--atlas-brand-light) 18%, transparent);
        color: #ffffff;
    }

    .sidebar-link.active {
        background: color-mix(in srgb, var(--atlas-brand-light) 14%, transparent);
        border: 1px solid color-mix(in srgb, var(--atlas-brand-light) 22%, transparent);
        color: var(--atlas-sidebar-active);
    }

        .sidebar-link.active::before,
        .sidebar-link:hover::before {
            content: "";
            position: absolute;
            left: -7px;
            top: 24%;
            height: 52%;
            width: 3px;
            background: var(--atlas-brand-light);
            border-radius: 999px;
        }

.sidebar-icon {
    min-width: 19px;
    font-size: 15px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 12px;
    padding-top: 12px;
}

.sidebar-user,
.sidebar-logout {
    display: flex !important;
    align-items: center;
    gap: 9px;
}

.sidebar-user {
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 7px;
    border-radius: 8px;
    padding: 6px 8px;
}

.sidebar-user:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar-role {
    font-size: 10px;
    color: var(--atlas-sidebar-active);
    background: rgba(123,200,246,0.1);
    padding: 2px 6px;
    border-radius: 999px;
}

.sidebar-logout {
    font-size: 12px;
    color: #f87171;
    text-decoration: none;
}

    .sidebar-logout:hover {
        color: #fb7185;
        text-decoration: none;
    }

.sidebar-atlas.collapsed .sidebar-text,
.sidebar-atlas.collapsed .sidebar-logo-text,
.sidebar-atlas.collapsed .sidebar-role,
.sidebar-atlas.collapsed .sidebar-section {
    display: none !important;
}

.sidebar-atlas.collapsed .sidebar-logo,
.sidebar-atlas.collapsed .sidebar-link,
.sidebar-atlas.collapsed .sidebar-user,
.sidebar-atlas.collapsed .sidebar-logout {
    justify-content: center;
}

.sidebar-atlas.collapsed .sidebar-link {
    padding-left: 0;
    padding-right: 0;
    height: 34px;
}

.sidebar-atlas.collapsed .sidebar-toggle {
    margin: auto;
}

/* ====== THEME SELECTOR ====== */
.sidebar-theme-selector {
    display: flex;
    gap: 7px;
    margin-bottom: 12px;
}

.theme-btn {
    flex: 1;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.04);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

    .theme-btn:hover {
        background: rgba(255,255,255,.12);
        border-color: rgba(255,255,255,.26);
        color: #ffffff;
    }

.sidebar-atlas.collapsed .sidebar-theme-selector {
    flex-direction: column;
    align-items: center;
}

    .sidebar-atlas.collapsed .sidebar-theme-selector .theme-btn {
        width: 34px;
        flex: none;
    }

.theme-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.accent-dot {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255,255,255,.65);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0,0,0,.12);
}

    .accent-dot[data-color="#0f4c75"] {
        background: #0f4c75;
    }

    .accent-dot[data-color="#2563eb"] {
        background: #2563eb;
    }

    .accent-dot[data-color="#16a34a"] {
        background: #16a34a;
    }

    .accent-dot[data-color="#9333ea"] {
        background: #9333ea;
    }

    .accent-dot[data-color="#dc2626"] {
        background: #dc2626;
    }

    .accent-dot[data-color="#ea580c"] {
        background: #ea580c;
    }

/* ====== CARDS ====== */
.card,
.card-atlas {
    background: var(--atlas-surface);
    color: var(--atlas-ink);
    border-radius: var(--atlas-radius);
    border: 1px solid var(--atlas-border);
    box-shadow: var(--atlas-shadow);
}

.card-header {
    background: var(--atlas-surface-soft);
    color: var(--atlas-ink);
    border-bottom-color: var(--atlas-border);
}

/* ====== TITLES ====== */
.title-atlas {
    font-weight: 700;
    letter-spacing: -0.3px;
}

.subtitle-atlas {
    font-size: 13px;
    color: var(--atlas-muted);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ====== INPUTS / FORMS ====== */
.input-atlas,
.form-control,
.form-select,
input,
select,
textarea {
    background-color: var(--atlas-surface);
    color: var(--atlas-ink);
    border-color: var(--atlas-border);
    border-radius: 8px;
}

.input-atlas {
    font-size: 14px;
    padding: 9px 10px;
    border: 1px solid var(--atlas-border);
}

    .input-atlas:focus,
    .form-control:focus,
    .form-select:focus,
    input:focus,
    select:focus,
    textarea:focus {
        background-color: var(--atlas-surface);
        color: var(--atlas-ink);
        border-color: var(--atlas-brand-light);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--atlas-brand-light) 20%, transparent);
    }

.form-atlas .form-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.form-atlas .form-control {
    font-size: 14px;
    padding: 9px 10px;
    border: 1px solid var(--atlas-border);
}

.form-check-input {
    width: 18px;
    height: 18px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* ====== BUTTONS ====== */
.btn-atlas,
.btn-primary {
    background: linear-gradient(135deg, var(--atlas-brand), var(--atlas-brand-light));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
}

.btn-atlas {
    font-size: 14px;
    padding: 9px 12px;
}

    .btn-atlas:hover {
        opacity: .92;
        color: #fff;
    }

.btn-sm-atlas {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-outline-secondary {
    color: var(--atlas-muted);
    border-color: var(--atlas-border);
}

.btn-outline-primary {
    color: var(--atlas-brand-light);
    border-color: var(--atlas-brand-light);
}

/* ====== AUTH ====== */
.auth-container {
    min-height: 100vh;
}

.auth-card {
    width: 380px;
}

/* ====== TOPBAR MOBILE ====== */
.topbar-atlas {
    display: none;
    width: 100%;
    background: var(--atlas-surface);
    color: var(--atlas-ink);
    border-bottom: 1px solid var(--atlas-border);
    padding: 12px 16px;
    align-items: center;
    gap: 12px;
    box-shadow: var(--atlas-shadow);
}

.topbar-title {
    font-weight: 600;
    font-size: 15px;
}

.hamburger-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--atlas-border);
    border-radius: 8px;
    background: var(--atlas-surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    cursor: pointer;
}

    .hamburger-btn span {
        height: 2px;
        background: var(--atlas-ink);
        border-radius: 2px;
        display: block;
    }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 998;
}

/* ====== TABLES ====== */
.table-responsive {
    overflow-x: auto;
}

.table {
    color: var(--atlas-ink);
}

    .table th,
    .table td {
        border-color: var(--atlas-border);
    }

.table-hover tbody tr:hover {
    background-color: var(--atlas-surface-soft);
}

.table-atlas {
    font-size: 12px;
    margin-bottom: 0;
    white-space: nowrap;
}

    .table-atlas thead {
        background: var(--atlas-surface-soft);
    }

    .table-atlas th {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .08em;
        color: var(--atlas-muted);
        border-bottom: 2px solid var(--atlas-border);
    }

    .table-atlas th,
    .table-atlas td {
        padding: 6px 8px;
        vertical-align: middle;
    }

    .table-atlas tbody tr {
        transition: background .2s ease;
    }

        .table-atlas tbody tr:hover {
            background: color-mix(in srgb, var(--atlas-brand-light) 5%, transparent);
        }

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* ====== BADGES / INFO ====== */
.badge-atlas {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.info-box {
    background: var(--atlas-surface-soft);
    border: 1px solid var(--atlas-border);
    border-radius: var(--atlas-radius);
}

.text-muted {
    color: var(--atlas-muted) !important;
}

/* ====== ESTACIONES CARD KPI ====== */
.station-card-title {
    font-size: 17px;
    min-height: 48px;
    font-weight: 700;
    color: var(--atlas-ink);
    line-height: 1.3;
}

.station-kpi {
    border-top: 1px solid var(--atlas-border);
    margin-top: 16px;
    padding-top: 22px;
    margin-bottom: 22px;
    text-align: center;
}

.station-kpi-number {
    font-size: 38px;
    line-height: 1;
    font-weight: 750;
    color: var(--atlas-station-kpi);
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.station-kpi-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--atlas-muted);
    text-transform: uppercase;
    letter-spacing: .12em;
    margin-bottom: 16px;
}

.station-years {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
}

.station-year-badge {
    background: var(--atlas-station-pill-bg);
    color: #fff;
    border: 1px solid var(--atlas-station-pill-border);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.25;
}

.btn-station-details {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    background: var(--atlas-station-button-bg);
    color: #fff;
    border: 1px solid var(--atlas-station-button-border);
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

    .btn-station-details:hover {
        background: var(--atlas-station-button-hover);
        border-color: var(--atlas-brand-light);
        color: #fff;
        transform: translateY(-1px);
    }

.station-card .btn-dark,
.card .btn-station-details {
    border-radius: 10px;
}

/* ====== DARK MODE FIXES - BOOTSTRAP / VISTAS INTERNAS ====== */
html[data-theme="dark"] .table,
html[data-theme="dark"] .table tbody,
html[data-theme="dark"] .table tr,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th {
    color: var(--atlas-ink) !important;
    border-color: var(--atlas-border) !important;
}

    html[data-theme="dark"] .table thead,
    html[data-theme="dark"] .table thead tr,
    html[data-theme="dark"] .table thead th,
    html[data-theme="dark"] .table-light,
    html[data-theme="dark"] thead.table-light,
    html[data-theme="dark"] .table > :not(caption) > * > * {
        background-color: var(--atlas-surface) !important;
        color: var(--atlas-ink) !important;
        border-color: var(--atlas-border) !important;
    }

        html[data-theme="dark"] .table thead th,
        html[data-theme="dark"] thead.table-light th {
            background-color: var(--atlas-surface-soft) !important;
            color: var(--atlas-ink) !important;
        }

html[data-theme="dark"] .table-hover tbody tr:hover,
html[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: var(--atlas-surface-soft) !important;
    color: var(--atlas-ink) !important;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .toast {
    background-color: var(--atlas-surface) !important;
    color: var(--atlas-ink) !important;
    border-color: var(--atlas-border) !important;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .card-atlas,
html[data-theme="dark"] .info-box,
html[data-theme="dark"] .station-card,
html[data-theme="dark"] .xml-card,
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-top {
    border-color: var(--atlas-border) !important;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .card-atlas,
html[data-theme="dark"] .station-card,
html[data-theme="dark"] .xml-card,
html[data-theme="dark"] .info-box {
    background-color: var(--atlas-surface) !important;
    color: var(--atlas-ink) !important;
}

html[data-theme="dark"] .xml-month-card,
html[data-theme="dark"] .station-summary,
html[data-theme="dark"] .station-metric,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .report-card {
    background-color: var(--atlas-surface-soft) !important;
    color: var(--atlas-ink) !important;
    border-color: var(--atlas-border) !important;
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-body,
html[data-theme="dark"] .text-black {
    color: var(--atlas-ink) !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] small.text-muted {
    color: var(--atlas-muted) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] option {
    background-color: var(--atlas-surface) !important;
    color: var(--atlas-ink) !important;
    border-color: var(--atlas-border) !important;
}

    html[data-theme="dark"] .form-control::placeholder,
    html[data-theme="dark"] input::placeholder,
    html[data-theme="dark"] textarea::placeholder {
        color: var(--atlas-muted) !important;
    }

html[data-theme="dark"] .btn-outline-secondary {
    color: #cbd5e1 !important;
    border-color: #475569 !important;
}

    html[data-theme="dark"] .btn-outline-secondary:hover {
        background-color: #475569 !important;
        color: #ffffff !important;
    }

html[data-theme="dark"] .btn-outline-primary {
    color: var(--atlas-sidebar-active) !important;
    border-color: var(--atlas-brand-light) !important;
}

    html[data-theme="dark"] .btn-outline-primary:hover {
        background-color: var(--atlas-brand-light) !important;
        color: #ffffff !important;
    }

html[data-theme="dark"] .btn:disabled,
html[data-theme="dark"] .btn.disabled,
html[data-theme="dark"] a.disabled {
    opacity: .45;
    color: var(--atlas-muted) !important;
}

html[data-theme="dark"] .badge.bg-warning {
    color: #111827 !important;
}

html[data-theme="dark"] .badge.bg-danger,
html[data-theme="dark"] .badge.bg-success,
html[data-theme="dark"] .badge.bg-primary {
    color: #ffffff !important;
}

/* ====== MOBILE ====== */
@media (max-width: 768px) {
    .layout-main {
        flex-direction: column;
    }

    .topbar-atlas {
        display: flex;
    }

    .content-atlas {
        width: 100%;
        padding: 15px;
    }

    .sidebar-atlas {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }

        .sidebar-atlas.open {
            transform: translateX(0);
        }

    .sidebar-overlay.show {
        display: block;
    }
}
/* ====== ACCORDION ATLAS / DARK MODE ====== */
.accordion-item {
    background-color: var(--atlas-surface);
    color: var(--atlas-ink);
    border: 1px solid var(--atlas-border);
    border-radius: var(--atlas-radius);
    overflow: hidden;
}

.accordion-button {
    background-color: var(--atlas-surface);
    color: var(--atlas-ink);
    font-weight: 600;
    box-shadow: none;
}

    .accordion-button:not(.collapsed) {
        background-color: color-mix(in srgb, var(--atlas-brand-light) 12%, var(--atlas-surface));
        color: var(--atlas-brand-light);
        box-shadow: none;
    }

    .accordion-button:focus {
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--atlas-brand-light) 20%, transparent);
        border-color: var(--atlas-brand-light);
    }

.accordion-body {
    background-color: var(--atlas-surface);
    color: var(--atlas-ink);
}

html[data-theme="dark"] .accordion-button::after {
    filter: invert(1);
}

/* ====== TABLAS RESPONSIVAS INTERNAS ====== */
.table-atlas-wrap,
.table-bitacoras-fixed,
.table-detalle-fixed {
    width: 100%;
    table-layout: fixed;
}

    .table-bitacoras-fixed th,
    .table-bitacoras-fixed td,
    .table-detalle-fixed th,
    .table-detalle-fixed td {
        white-space: normal !important;
        word-break: break-word;
        overflow-wrap: anywhere;
        vertical-align: top;
    }

.descripcion-bitacora,
.detalle-cfdi {
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.xml-modal-body {
    overflow-x: hidden;
}

.xml-detail-view .table-responsive {
    overflow-x: visible;
}

.xml-detail-view .table-atlas {
    width: 100%;
}

.xml-detail-view .table-detalle-fixed,
.xml-detail-view .table-bitacoras-fixed {
    table-layout: fixed;
    white-space: normal;
}

.table-cfdi-detalle .col-rfc {
    width: 16%;
}

.table-cfdi-detalle .col-nombre {
    width: 24%;
}

.table-cfdi-detalle .col-permiso {
    width: 18%;
}

.table-cfdi-detalle .col-detalle {
    width: 42%;
}

.table-bitacoras-fixed .col-numero {
    width: 8%;
}

.table-bitacoras-fixed .col-fecha {
    width: 18%;
}

.table-bitacoras-fixed .col-tipo {
    width: 14%;
}

.table-bitacoras-fixed .col-descripcion {
    width: 60%;
}

.descripcion-bitacora {
    display: -webkit-box;
    line-height: 1.35;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.detalle-cfdi {
    line-height: 1.45;
}

/* ====== SUBIDA XML / DROP ZONE ====== */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    padding: 34px 20px;
    border: 2px dashed var(--atlas-border);
    border-radius: 14px;
    background: var(--atlas-surface-soft);
    color: var(--atlas-muted);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}

    .drop-zone:hover {
        border-color: var(--atlas-brand-light);
        color: var(--atlas-ink);
    }

    .drop-zone.dragging {
        border-color: var(--atlas-brand-light);
        background: color-mix(in srgb, var(--atlas-brand-light) 12%, var(--atlas-surface));
        color: var(--atlas-brand-light);
        transform: translateY(-2px);
    }

.drop-zone-icon {
    font-size: 40px;
    line-height: 1;
    color: var(--atlas-brand-light);
}

.drop-zone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--atlas-ink);
}

.drop-zone-hint {
    font-size: 12px;
}

/* Lista de archivos seleccionados */
.upload-file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
}

.upload-file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--atlas-border);
    border-radius: 10px;
    background: var(--atlas-surface);
}

    .upload-file-row .file-name {
        font-size: 13px;
        font-weight: 600;
        word-break: break-all;
    }

    .upload-file-row .file-size {
        font-size: 11px;
        color: var(--atlas-muted);
        white-space: nowrap;
    }

.upload-summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
}

.upload-loading-host {
    position: relative;
}

.upload-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    border-radius: inherit;
    background: rgba(248, 250, 252, .82);
    backdrop-filter: blur(3px);
}

html[data-theme="dark"] .upload-loading-overlay {
    background: rgba(15, 23, 42, .78);
}

.upload-loading-box {
    min-width: min(280px, 100%);
    padding: 18px 20px;
    border: 1px solid var(--atlas-border);
    border-radius: 10px;
    background: var(--atlas-surface);
    box-shadow: 0 16px 40px rgba(15, 23, 42, .18);
    text-align: center;
}

.upload-loading-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 10px;
    border: 3px solid color-mix(in srgb, var(--atlas-brand-light) 20%, transparent);
    border-top-color: var(--atlas-brand-light);
    border-radius: 50%;
    animation: atlas-spin .8s linear infinite;
}

.upload-loading-title {
    color: var(--atlas-ink);
    font-size: 15px;
    font-weight: 800;
}

.upload-loading-message {
    color: var(--atlas-muted);
    font-size: 12px;
    margin-top: 4px;
}

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

/* ====== USUARIOS DASHBOARD ====== */
.user-kpi-card {
    display: block;
    height: 100%;
    padding: 16px;
    text-decoration: none;
}

.user-kpi-link {
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

    .user-kpi-link:hover,
    .user-kpi-link.active {
        border-color: var(--atlas-brand-light);
        color: var(--atlas-ink);
        transform: translateY(-1px);
        text-decoration: none;
    }

.user-kpi-label {
    color: var(--atlas-muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.user-kpi-value {
    color: var(--atlas-ink);
    font-size: 34px;
    font-weight: 750;
    line-height: 1;
    margin-top: 10px;
}

.user-kpi-meta {
    color: var(--atlas-muted);
    font-size: 12px;
    margin-top: 8px;
}

.user-activity-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-activity-item {
    display: grid;
    grid-template-columns: 12px 1fr;
    gap: 12px;
}

.user-activity-dot {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--atlas-brand-light);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--atlas-brand-light) 14%, transparent);
}

.user-activity-content {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--atlas-border);
}

.user-activity-item:last-child .user-activity-content {
    padding-bottom: 0;
    border-bottom: 0;
}

.user-activity-text {
    color: var(--atlas-muted);
    font-size: 13px;
    margin-top: 3px;
    white-space: normal;
}

/* ====== ESTACIONES DASHBOARD ====== */
.station-dashboard-kpi {
    height: 100%;
    padding: 16px;
}

.station-dashboard-label {
    color: var(--atlas-muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.station-dashboard-value {
    color: var(--atlas-ink);
    font-size: 34px;
    font-weight: 750;
    line-height: 1;
    margin-top: 10px;
}

.station-dashboard-period {
    font-size: 26px;
}

.station-dashboard-meta {
    color: var(--atlas-muted);
    font-size: 12px;
    margin-top: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.station-list,
.recent-report-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.station-list-row,
.recent-report-row {
    display: grid;
    gap: 14px;
    align-items: center;
    padding: 13px 0;
    border-bottom: 1px solid var(--atlas-border);
}

.station-list-row {
    grid-template-columns: minmax(0, 1.4fr) minmax(180px, .9fr) auto;
}

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

.station-list-row:last-child,
.recent-report-row:last-child {
    border-bottom: 0;
}

.station-list-title {
    color: var(--atlas-ink);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
}

.station-list-years {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.station-year-link {
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

    .station-year-link:hover {
        border-color: var(--atlas-brand-light);
        color: #fff;
        transform: translateY(-1px);
        text-decoration: none;
    }

.station-list-actions,
.recent-report-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}

@media (max-width: 992px) {
    .station-list-row,
    .recent-report-row {
        grid-template-columns: 1fr;
    }

    .station-list-actions,
    .recent-report-actions {
        justify-content: flex-start;
    }
}

.station-detail-report-row {
    min-height: 82px;
}

.station-data-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 992px) {
    .station-data-grid {
        grid-template-columns: 1fr;
    }
}

/* ====== MERMAS ====== */
.merma-kpi-card {
    height: 100%;
    padding: 8px 10px;
    border-radius: 7px;
}

.merma-kpi-label {
    color: var(--atlas-muted);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.merma-kpi-value {
    color: var(--atlas-ink);
    font-size: 16px;
    font-weight: 750;
    line-height: 1.1;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.merma-kpi-meta {
    color: var(--atlas-muted);
    font-size: 10px;
    margin-top: 3px;
}

.notification-card {
    border: 1px solid var(--atlas-border);
    border-left: 3px solid var(--atlas-brand);
    border-radius: 8px;
    padding: 12px;
    height: 100%;
    background: var(--atlas-surface);
}

.merma-initial-card {
    border: 1px solid rgba(245, 158, 11, .28);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    color: var(--atlas-ink);
}

.merma-initial-form {
    background: var(--atlas-surface);
    border: 1px solid var(--atlas-border);
    border-radius: 8px;
    padding: 8px 10px;
}

.merma-chart-card {
    min-height: 380px;
}

    .merma-chart-card .card-body {
        height: 320px;
    }

.merma-table-wrap {
    max-height: none;
    overflow-x: visible !important;
}

    .merma-table-wrap table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    .merma-table-wrap th,
    .merma-table-wrap td {
        white-space: normal;
        overflow-wrap: anywhere;
        vertical-align: middle;
    }

    .merma-table-wrap th {
        font-size: 11px;
        line-height: 1.2;
    }

    .merma-table-wrap td {
        font-size: 12px;
    }

.merma-alert-card {
    height: 100%;
    padding: 10px 12px;
    border-left: 3px solid var(--atlas-border);
}

.merma-alert-ok {
    border-left-color: #16a34a;
}

.merma-alert-warning {
    border-left-color: #f59e0b;
}

.merma-alert-danger {
    border-left-color: #dc2626;
}

.merma-alert-critical {
    border-left-color: #111827;
    background: linear-gradient(90deg, rgba(17, 24, 39, .10), var(--atlas-surface) 48%);
    box-shadow: 0 0 0 1px rgba(17, 24, 39, .14), 0 10px 24px rgba(17, 24, 39, .10);
}

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

.merma-ticket-month-list {
    display: grid;
    gap: 14px;
}

.merma-ticket-month-title {
    color: var(--atlas-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    margin-bottom: 7px;
    text-transform: uppercase;
}

.merma-ticket-grid-products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.merma-ticket-grid-analysis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.merma-ticket {
    min-height: 96px;
    padding: 9px 10px;
    border: 1px solid var(--atlas-border);
    border-left: 3px solid var(--atlas-border);
    border-radius: 8px;
    background: var(--atlas-surface);
}

.merma-ticket-ok {
    border-left-color: #16a34a;
}

.merma-ticket-warning {
    border-left-color: #f59e0b;
}

.merma-ticket-danger {
    border-left-color: #dc2626;
}

.merma-ticket-critical {
    border-left-color: #111827;
    background: linear-gradient(90deg, rgba(17, 24, 39, .12), var(--atlas-surface) 55%);
    box-shadow: 0 0 0 1px rgba(17, 24, 39, .16);
}

.merma-ticket-value {
    margin-top: 7px;
    color: var(--atlas-ink);
    font-size: 16px;
    font-weight: 750;
    line-height: 1;
}

@media (max-width: 768px) {
    .merma-kpi-value {
        font-size: 16px;
    }

    .merma-chart-card .card-body {
        height: 280px;
    }

    .merma-ticket-grid-products,
    .merma-ticket-grid-analysis {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .merma-ticket-grid-analysis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
