/* ============================================
   VolControl - Premium UI Styles v2.0
   Modern, vibrant, professional SaaS design
   ============================================ */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 40px -5px rgba(0,0,0,0.08), 0 8px 16px -8px rgba(0,0,0,0.04);
    --shadow-color-emerald: 0 4px 14px -3px rgba(16, 185, 129, 0.2);
    --shadow-color-orange: 0 4px 14px -3px rgba(249, 115, 22, 0.2);
    --shadow-color-blue: 0 4px 14px -3px rgba(59, 130, 246, 0.2);
    --shadow-color-red: 0 4px 14px -3px rgba(239, 68, 68, 0.15);
    --shadow-color-amber: 0 4px 14px -3px rgba(245, 158, 11, 0.2);
    --shadow-color-purple: 0 4px 14px -3px rgba(139, 92, 246, 0.2);
    --radius-card: 16px;
    --radius-section: 20px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Body — clean flat background */

/* ============================================
   LANDING PAGE — WeTransfer-style layout
   ============================================ */

.landing-page {
    display: grid;
    grid-template-columns: 45% 55%;
    min-height: 100vh;
    gap: 0;
    margin: -1.5rem;
    animation: fadeIn 0.6s ease-out forwards;
}

.landing-left {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 3rem 3rem 4rem;
    background: white;
    border-radius: 0 0 2rem 0;
    position: relative;
    z-index: 2;
    box-shadow: 4px 4px 30px rgba(0, 0, 0, 0.04);
}

.landing-left-inner {
    max-width: 420px;
    width: 100%;
}

.landing-dropzone {
    border-color: #e5e7eb !important;
    background: #f8f9fb !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.landing-dropzone:hover {
    border-color: #449ed3 !important;
    box-shadow: 0 12px 35px rgba(44, 127, 184, 0.1);
    transform: translateY(-3px);
}
.landing-dropzone:hover .fa-cloud-upload-alt {
    animation: floatIcon 2s ease-in-out infinite;
}
@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.landing-right {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #0e2a42 0%, #143758 30%, #19527d 70%, #2c7fb8 100%);
    display: flex;
    align-items: center;
    padding: 3rem 4rem;
    border-radius: 2rem 0 0 2rem;
}

.landing-right-inner {
    position: relative;
    max-width: 440px;
}

.landing-right-glow {
    position: absolute;
    top: -20%;
    right: -30%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(68, 158, 211, 0.2) 0%, transparent 70%);
    pointer-events: none;
    animation: glowPulse 6s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Floating orbs */
.landing-float {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.15;
}
.landing-float-1 {
    width: 200px; height: 200px;
    background: radial-gradient(circle, #449ed3, transparent);
    top: 10%; right: 5%;
    animation: floatOrb 8s ease-in-out infinite;
}
.landing-float-2 {
    width: 120px; height: 120px;
    background: radial-gradient(circle, #7cbce3, transparent);
    bottom: 15%; left: 5%;
    animation: floatOrb 10s ease-in-out infinite reverse;
}
.landing-float-3 {
    width: 80px; height: 80px;
    background: radial-gradient(circle, #34d399, transparent);
    top: 50%; right: 25%;
    animation: floatOrb 7s ease-in-out infinite 2s;
}

@keyframes floatOrb {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(15px, -20px); }
    50% { transform: translate(-10px, 15px); }
    75% { transform: translate(20px, 10px); }
}

/* Mini dashboard mockup */
.landing-mockup {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Feature cards */
.landing-feature-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.25s ease;
}
.landing-feature-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateX(4px);
}

/* Login bar — white curved shape at top of right panel */
.landing-login-bar {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 20;
    background: white;
    padding: 0.75rem 2rem 0.75rem 2.5rem;
    border-radius: 0 0 0 2rem;
    box-shadow: -4px 4px 20px rgba(0, 0, 0, 0.06);
}
.landing-login-bar a {
    text-decoration: none;
}

/* Fade-up animation for landing elements */
.landing-fade-up {
    opacity: 0;
    transform: translateY(20px);
    animation: landingFadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes landingFadeUp {
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive: landing page tablet & mobile — handled in SUPER RESPONSIVE section at end */

/* ============================================
   NAV SIDEBAR — Refined
   ============================================ */

.nav-sidebar {
    width: 270px;
    min-width: 270px;
    height: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #f7f8fb 50%, #f3f4f8 100%);
    border-right: 1px solid #e8eaef;
    display: flex;
    flex-direction: column;
    z-index: 30;
    animation: sidebarSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.02);
}
.nav-sidebar.hidden {
    display: none !important;
}

@keyframes sidebarSlideIn {
    from { opacity: 0; transform: translateX(-24px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Sidebar header */
.sidebar-header {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 1.25rem;
    border-bottom: 1px solid #eaecf0;
    flex-shrink: 0;
    background: #ffffff;
}
.sidebar-rename-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.sidebar-rename-btn:hover {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}
html.dark .sidebar-rename-btn {
    background: #1e293b;
    border-color: #334155;
    color: #64748b;
}
html.dark .sidebar-rename-btn:hover {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

/* Sidebar navigation area */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.625rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Nav buttons */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.575rem 0.875rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: #6b7280;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
}
.sidebar-nav-item:hover {
    background: #eef3f9;
    color: #1d4e6e;
    border-color: #e0e8f0;
    transform: translateX(2px);
}
.sidebar-nav-item.active {
    background: linear-gradient(135deg, #1a5f91 0%, #2879ad 100%);
    color: #ffffff;
    font-weight: 600;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(29, 102, 155, 0.28), 0 1px 3px rgba(29, 102, 155, 0.12);
}
.sidebar-nav-item.active i {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

/* Section divider */
.sidebar-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.875rem 0.5rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #b0b5bc;
    border-top: 1px solid #eef0f3;
    margin-top: 0.375rem;
}

/* Refresh button */
.sidebar-refresh-btn {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #b0b5bc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}
.sidebar-refresh-btn:hover {
    background: #e8ecf1;
    color: #6b7280;
    transform: rotate(90deg);
}

/* ---- Sidebar filter bar (search + chips) ---- */
.sidebar-filter-bar {
    padding: 0.375rem 0.625rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.sidebar-search-wrap {
    position: relative;
}
.sidebar-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.55rem;
    color: #b0b5bc;
    pointer-events: none;
}
.sidebar-search-input {
    width: 100%;
    height: 28px;
    padding: 0 8px 0 24px;
    border-radius: 7px;
    border: 1px solid #e5e7eb;
    background: #f8f9fb;
    font-size: 0.65rem;
    font-family: 'Inter', sans-serif;
    color: #374151;
    outline: none;
    transition: all 0.2s ease;
}
.sidebar-search-input::placeholder {
    color: #c4c9d0;
}
.sidebar-search-input:focus {
    border-color: #2c7fb8;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(44, 127, 184, 0.1);
}
.sidebar-type-chips {
    display: flex;
    gap: 4px;
}
.sidebar-chip {
    flex: 1;
    height: 22px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: transparent;
    font-size: 0.55rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
}
.sidebar-chip:hover {
    border-color: #d1d5db;
    color: #6b7280;
    background: #f8f9fb;
}
.sidebar-chip.active {
    background: #1e293b;
    border-color: #1e293b;
    color: #ffffff;
}

/* Custom scrollbar for file list */
.sidebar-file-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 2px 0;
    scrollbar-width: thin;
    scrollbar-color: #d4d8de transparent;
}
.sidebar-file-list::-webkit-scrollbar {
    width: 4px;
}
.sidebar-file-list::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-file-list::-webkit-scrollbar-thumb {
    background: #d4d8de;
    border-radius: 4px;
}
.sidebar-file-list::-webkit-scrollbar-thumb:hover {
    background: #b0b5bc;
}

/* File item card */
/* ---- File item card ---- */
.sidebar-file-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
}
.sidebar-file-item:hover {
    background: #ffffff;
    border-color: #e2e5ea;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}
.sidebar-file-item.active {
    background: #ffffff;
    border-color: #c5d9e8;
    box-shadow: 0 2px 8px rgba(29, 102, 155, 0.07);
}
.sidebar-file-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, #1d669b, #2c7fb8);
}
.sidebar-file-item.active .file-name {
    color: #1d669b;
}

/* ---- Mini calendar icon ---- */
.sidebar-file-item .file-cal-icon {
    width: 36px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    transition: all 0.2s ease;
}
.sidebar-file-item:hover .file-cal-icon {
    transform: scale(1.04);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.sidebar-file-item .file-cal-icon__month {
    font-size: 0.45rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #ffffff;
    width: 100%;
    text-align: center;
    padding: 1.5px 0;
    line-height: 1.1;
}
.sidebar-file-item .file-cal-icon__day {
    font-size: 0.85rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1;
    padding-top: 2px;
}
.sidebar-file-item .file-cal-icon.diario {
    border-color: #bfdbfe;
}
.sidebar-file-item .file-cal-icon.diario .file-cal-icon__month {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.sidebar-file-item .file-cal-icon.mensual {
    border-color: #ddd6fe;
}
.sidebar-file-item .file-cal-icon.mensual .file-cal-icon__month {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* Fallback generic icon */
.sidebar-file-item .file-icon {
    width: 36px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}
.sidebar-file-item:hover .file-icon {
    transform: scale(1.04);
}
.sidebar-file-item .file-icon.diario {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #3b82f6;
}
.sidebar-file-item .file-icon.mensual {
    background: linear-gradient(135deg, #faf5ff, #f3e8ff);
    color: #8b5cf6;
}

/* ---- File info container ---- */
.sidebar-file-item .file-info {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}

/* ---- Name row: filename + type badge inline ---- */
.sidebar-file-item .file-name-row {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}
.sidebar-file-item .file-name {
    font-size: 0.675rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    letter-spacing: -0.01em;
    min-width: 0;
}

/* ---- Type badge (inline with name) ---- */
.sidebar-file-item .file-badge {
    font-size: 0.5rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    white-space: nowrap;
}
.sidebar-file-item .file-badge--type.diario {
    background: #eff6ff;
    color: #2563eb;
}
.sidebar-file-item .file-badge--type.mensual {
    background: #f5f3ff;
    color: #7c3aed;
}

/* ---- Dates row: side by side ---- */
.sidebar-file-item .file-dates {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    line-height: 1.2;
}
.sidebar-file-item .file-date {
    font-size: 0.55rem;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}
.sidebar-file-item .file-date--upload {
    color: #9ca3af;
}
.sidebar-file-item .file-date-sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #d1d5db;
    flex-shrink: 0;
}
.sidebar-file-item .file-meta-icon {
    font-size: 0.45rem;
    opacity: 0.55;
}

/* ---- File delete button ---- */
.sidebar-file-item .file-delete-btn {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: none;
    background: transparent;
    color: #d1d5db;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.55rem;
    opacity: 0;
    transition: all 0.15s ease;
    margin-top: 2px;
}
.sidebar-file-item:hover .file-delete-btn {
    opacity: 0.6;
}
.sidebar-file-item .file-delete-btn:hover {
    opacity: 1;
    background: #fef2f2;
    color: #ef4444;
}

/* Delete confirmation modal */
.delete-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0);
    backdrop-filter: blur(0px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease, backdrop-filter 0.25s ease;
}
.delete-modal-backdrop.show {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
}
.delete-modal-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 2rem 2rem 1.5rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.delete-modal-backdrop.show .delete-modal-card {
    transform: scale(1);
    opacity: 1;
}
.delete-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fef2f2, #fecaca);
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.25rem;
}
.delete-modal-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.5rem;
}
.delete-modal-text {
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.6;
    margin: 0 0 1.5rem;
}
.delete-modal-text strong {
    color: #1e293b;
    word-break: break-all;
}
.delete-modal-actions {
    display: flex;
    gap: 0.625rem;
    justify-content: center;
}
.delete-modal-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}
.delete-modal-btn--cancel {
    background: #f1f5f9;
    color: #64748b;
}
.delete-modal-btn--cancel:hover {
    background: #e2e8f0;
    color: #334155;
}
.delete-modal-btn--confirm {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.delete-modal-btn--confirm:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.sidebar-file-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #d1d5db;
}
.sidebar-file-empty i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}
.sidebar-file-empty p {
    font-size: 0.6875rem;
    color: #9ca3af;
}

.sidebar-file-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    color: #d1d5db;
    font-size: 0.6875rem;
}

/* Sidebar footer */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-top: 1px solid #eaecf0;
    flex-shrink: 0;
    background: #ffffff;
    gap: 0.5rem;
}

.sidebar-logout-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: #f3f4f6;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}
.sidebar-logout-btn:hover {
    background: #fef2f2;
    color: #ef4444;
    transform: scale(1.05);
}

/* When sidebar is active, adjust landing layout */
#app.sidebar-active .landing-right {
    display: none;
}
#app.sidebar-active .landing-page {
    grid-template-columns: 1fr;
    min-height: calc(100vh + 3rem);
    margin: -1.5rem;
}
#app.sidebar-active .landing-left {
    border-radius: 0;
    box-shadow: none;
    padding: 3rem;
    background: white;
    min-height: 100%;
}
html.dark #app.sidebar-active .landing-left {
    background: #0f172a;
    box-shadow: none;
}
#app.sidebar-active .landing-left-inner {
    max-width: 480px;
    margin: 0 auto;
}

/* Hide top-bar branding when sidebar has it */
#app.sidebar-active #topbar-branding {
    display: none;
}

/* Historial file table rows */
.historial-file-row:hover td {
    color: #1d669b;
}

/* Responsive: sidebar becomes drawer on mobile (handled in SUPER RESPONSIVE section below) */

/* --- Base & Scrollbar --- */
html, body {
    overflow: hidden;
    height: 100%;
    margin: 0;
    padding: 0;
}
* {
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}
*::-webkit-scrollbar { width: 5px; height: 5px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }
*::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* --- Drop Zone --- */
#drop-zone {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
#drop-zone.drag-over {
    border-color: #2c7fb8 !important;
    border-style: solid !important;
    background: rgba(44, 127, 184, 0.03) !important;
    transform: scale(1.02) translateY(-4px);
    box-shadow: 0 0 0 4px rgba(44, 127, 184, 0.1), 0 25px 50px -12px rgba(44, 127, 184, 0.15);
}

/* --- Animations --- */
@keyframes pulse-soft {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}
.animate-pulse-soft { animation: pulse-soft 2.5s ease-in-out infinite; }

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}
.animate-shimmer { animation: shimmer 2s ease-in-out infinite; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up { animation: fadeInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }

/* Stagger children */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.stagger-children > *:nth-child(1) { animation-delay: 0s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.03s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.06s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.09s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.12s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.18s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.21s; }

/* ============================================
   KPI CARDS — Minimal Clean v3
   ============================================ */

.kpi-card {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    padding: 1.125rem 1.25rem;
    border: 1px solid #eef0f3;
    transition: all 0.2s ease;
    overflow: hidden;
}

.kpi-card:hover {
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* KPI Card — all icons use same muted style */
.kpi-card .kpi-card__icon { background: #f5f7fa; color: #94a3b8; }

/* Variant overrides removed — unified muted look */
.kpi-card--emerald .kpi-card__icon { background: #f5f7fa; color: #94a3b8; }
.kpi-card--orange .kpi-card__icon  { background: #f5f7fa; color: #94a3b8; }
.kpi-card--blue .kpi-card__icon    { background: #f5f7fa; color: #94a3b8; }

.kpi-card--red .kpi-card__icon     { background: #f5f7fa; color: #94a3b8; }
.kpi-card--amber .kpi-card__icon   { background: #f5f7fa; color: #94a3b8; }
.kpi-card--purple .kpi-card__icon  { background: #f5f7fa; color: #94a3b8; }
.kpi-card--gray .kpi-card__icon    { background: #f5f7fa; color: #94a3b8; }
.kpi-card--primary .kpi-card__icon { background: #f5f7fa; color: #94a3b8; }

/* KPI Card Inner Elements */
.kpi-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.kpi-card__icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
}

.kpi-card__label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    line-height: 1.2;
}

.kpi-card__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b !important;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: 0.125rem;
}

.kpi-card__sub {
    font-size: 0.6875rem;
    color: #b0b5bc;
    margin-top: 0.25rem;
    font-weight: 400;
}

/* Tier classes — neutralized (no visual difference) */
.kpi-card--tier-info,
.kpi-card--tier-metric { background: #ffffff; border: 1px solid #eef0f3; }
.kpi-card--tier-metric::after { display: none; }

/* Section label — minimal */
.section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.section-label__text {
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #b0b5bc;
    white-space: nowrap;
}
.section-label__line {
    flex: 1;
    height: 1px;
    background: #eef0f3;
}

/* Section break — just spacing */
.dashboard-section-break {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}
.dashboard-section-break::before { display: none; }

/* Card hover — subtle */
.card-hover {
    transition: all 0.2s ease;
}
.card-hover:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ============================================
   CHART CONTAINERS — Enhanced
   ============================================ */

.chart-container {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #eef0f3;
    overflow: hidden;
    transition: all 0.2s ease;
}

.chart-container::before { display: none; }

.chart-container:hover {
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chart-container__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f5f6f8;
    background: #fafbfc;
}

.chart-container__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container__title-icon {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    flex-shrink: 0;
}

.chart-container__badge {
    font-size: 0.6875rem;
    font-weight: 500;
    color: #94a3b8;
}

.chart-container__body {
    padding: 1.25rem;
    min-height: 200px;
}
/* Skeleton pulse while chart canvas is empty */
.chart-container__body canvas:not([width]) {
    background: linear-gradient(90deg, transparent 25%, rgba(148,163,184,0.05) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease infinite;
    border-radius: 8px;
}
@keyframes skeletonPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Ficha Tecnica toggle enhancement */
#ficha-toggle {
    position: relative;
    border-left: 3px solid transparent;
    transition: all 0.25s ease;
}
#ficha-toggle:hover {
    border-left-color: #2c7fb8;
    background: #fafbfd;
}
#ficha-chevron {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Section Divider --- */
.section-divider {
    position: relative;
    padding-top: 0.5rem;
}
.section-divider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
}

/* ============================================
   SECTION HEADERS — Refined
   ============================================ */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.section-header__left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header__icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.section-header__title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.025em;
}

.section-header__subtitle {
    font-size: 0.8125rem;
    color: #94a3b8;
    margin-top: 0.125rem;
    font-weight: 400;
}

/* ============================================
   TAB NAVIGATION — Premium Pill Style
   ============================================ */

.tab-nav-container {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: linear-gradient(180deg, #f5f7fa 0%, #eef1f5 100%);
    border-radius: 14px;
    padding: 5px 6px;
    border: 1px solid #e5e8ed;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.tab-btn {
    padding: 0.5rem 1.125rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: #94a3b8;
    cursor: pointer;
    border: none;
    background: transparent;
    white-space: nowrap;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}
.tab-btn i {
    transition: color 0.25s ease, transform 0.25s ease;
}
.tab-btn:hover {
    color: #475569;
    background: rgba(255, 255, 255, 0.6);
}
.tab-btn:hover i {
    transform: scale(1.15);
}
.tab-btn.tab-active {
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0px 1px rgba(0,0,0,0.04);
}
.tab-btn.tab-active i {
    color: #2c7fb8;
}
/* Active indicator bar */
.tab-btn.tab-active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2.5px;
    border-radius: 2px;
    background: linear-gradient(90deg, #2c7fb8, #449ed3);
}

/* Tab panel transitions */
.tab-panel {
    animation: tabFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.tab-panel.hidden {
    display: none;
}

/* ============================================
   HISTORIAL SECTION — Premium BI Dashboard
   ============================================ */

.historial-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 1.25rem;
    background: #1e293b;
    border-radius: 14px;
    margin-bottom: 0.5rem;
}

.historial-header::before,
.historial-header::after { display: none; }

.historial-header__left {}

.historial-header__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.historial-header__subtitle {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 0.125rem;
}

.historial-header__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.historial-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.historial-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.875rem;
    border-radius: 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: #2c7fb8;
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.historial-ai-btn:hover {
    background: #1d669b;
}

/* ============================================
   FILE SUMMARY TABLE — Enhanced
   ============================================ */

.file-table-container {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #eef0f3;
    overflow: hidden;
    transition: all 0.2s ease;
}
.file-table-container::before { display: none; }
.file-table-container:hover {
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.file-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f5f6f8;
    background: #fafbfc;
}

/* Tank inventory stats */
#hist-tanques-section .grid > div {
    padding: 0.75rem;
    border-radius: 8px;
    background: #f8f9fb;
    border: 1px solid #eef0f3;
}

/* ============================================
   PROGRESS MODAL
   ============================================ */

#progress-card {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
#progress-card.show {
    opacity: 1 !important;
    transform: scale(1) !important;
}

/* Backdrop */
.progress-backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Animated accent bar at top of card */
.progress-accent-bar {
    height: 3px;
    background: linear-gradient(90deg, #19527d, #2c7fb8, #449ed3, #7cbce3, #449ed3, #2c7fb8, #19527d);
    background-size: 300% 100%;
    animation: accentSlide 3s linear infinite;
}
@keyframes accentSlide {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* Circular progress indicator */
.progress-circle-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
}
.progress-circle-svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}
.progress-circle-track {
    fill: none;
    stroke: #f0f7fc;
    stroke-width: 4;
}
.progress-circle-fill {
    fill: none;
    stroke: #2c7fb8;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 326.7;
    stroke-dashoffset: 326.7;
    transition: stroke-dashoffset 0.7s ease-out, stroke 0.5s ease;
}
.progress-circle-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Enhanced progress bar with glow */
.progress-bar-enhanced {
    background: linear-gradient(90deg, #1d669b, #2c7fb8, #449ed3);
    box-shadow: 0 0 8px rgba(44, 127, 184, 0.25);
}

/* --- DataTables Premium Overrides --- */
.dataTables_wrapper {
    font-family: 'Inter', system-ui, sans-serif !important;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid #e5e7eb !important;
    border-radius: 10px !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.8125rem !important;
    outline: none !important;
    transition: all 0.2s !important;
    background: #fafafa !important;
    margin-left: 0.5rem !important;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: #2c7fb8 !important;
    box-shadow: 0 0 0 3px rgba(44, 127, 184, 0.08) !important;
    background: white !important;
}

.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid #e5e7eb !important;
    border-radius: 10px !important;
    padding: 0.375rem 2rem 0.375rem 0.75rem !important;
    font-size: 0.8125rem !important;
    background: #fafafa !important;
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.75rem !important;
    color: #94a3b8 !important;
    padding-top: 1rem !important;
}

.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label {
    font-size: 0.8125rem !important;
    color: #94a3b8 !important;
}

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

table.dataTable thead th {
    background-color: #fafbfc !important;
    color: #64748b !important;
    font-weight: 600 !important;
    font-size: 0.6875rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 0.875rem 1rem !important;
    white-space: nowrap;
}

table.dataTable thead th:first-child { border-radius: 8px 0 0 0; }
table.dataTable thead th:last-child { border-radius: 0 8px 0 0; }

table.dataTable tbody td {
    padding: 0.75rem 1rem !important;
    font-size: 0.8125rem !important;
    border-bottom: 1px solid #f8fafc !important;
    vertical-align: middle !important;
}

table.dataTable tbody tr {
    transition: background-color 0.15s ease;
}
table.dataTable tbody tr:hover {
    background-color: #f8faff !important;
}
table.dataTable tbody tr:last-child td { border-bottom: none !important; }

/* Pagination */
.dataTables_wrapper .dataTables_paginate { padding-top: 1rem !important; }

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: none !important;
    border-radius: 8px !important;
    padding: 0.375rem 0.75rem !important;
    margin: 0 2px !important;
    font-size: 0.8125rem !important;
    transition: all 0.15s !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #18181b !important;
    color: white !important;
    font-weight: 600 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
    background: #f4f4f5 !important;
    color: #18181b !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: 0.3 !important; }

table.dataTable.no-footer { border-bottom: none !important; }

/* --- Toast Notifications --- */
.toast {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    padding: 0.875rem 1.25rem;
    border-radius: 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    transform: translateX(120%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    max-width: 380px;
    backdrop-filter: blur(12px);
}
.toast.show { transform: translateX(0); }
.toast-success {
    background: rgba(240, 253, 244, 0.95);
    color: #166534;
    border: 1px solid rgba(134, 239, 172, 0.4);
}
.toast-error {
    background: rgba(254, 242, 242, 0.95);
    color: #991b1b;
    border: 1px solid rgba(252, 165, 165, 0.4);
}
.toast-info {
    background: rgba(238, 242, 255, 0.95);
    color: #184469;
    border: 1px solid rgba(124, 188, 227, 0.4);
}

/* --- KPI Number Animation --- */
@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.kpi-value {
    animation: countUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ============================================
   OPERATIONS TABLE SECTION — Enhanced
   ============================================ */

.operations-section {
    margin-top: 2rem;
}

.operations-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-top: 1.5rem;
    border-top: none;
    position: relative;
}
.operations-section__header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #e2e8f0 15%, #cbd5e1 50%, #e2e8f0 85%, transparent 100%);
}

.operations-section__title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.operations-section__title-bar {
    width: 4px;
    height: 22px;
    border-radius: 2px;
    background: linear-gradient(180deg, #2c7fb8, #1d669b);
}

.operations-section__title h2 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.operations-section__title span {
    font-size: 0.6875rem;
    color: #94a3b8;
    font-weight: 500;
}

.operations-section__actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.filter-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #64748b;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.filter-btn:hover {
    background: #f8f9fb;
    border-color: #d1d5db;
    color: #1e293b;
}
.filter-btn.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.export-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.2);
}
.export-btn:hover {
    background: linear-gradient(135deg, #047857, #059669);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

/* Operations summary strip */
.ops-summary-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #eef0f3;
}
.ops-summary-card__label {
    font-size: 0.5625rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ops-summary-card__value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1e293b;
    margin-top: 1px;
}
html.dark .ops-summary-card {
    background: #1e293b;
    border-color: transparent;
}
html.dark .ops-summary-card__value {
    color: #f1f5f9;
}

.operations-table-card {
    background: #ffffff;
    border-radius: var(--radius-card);
    border: 1px solid #f0f1f4;
    padding: 0;
    overflow: hidden;
}

.operations-table-card > .overflow-x-auto {
    padding: 1rem 1.25rem;
}

/* Table summary footer */
.table-summary-footer td {
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
    color: #1e293b;
    font-size: 11px;
}

/* ============================================
   CHATBOT PANEL
   ============================================ */

.chatbot-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 0;
    background: #ffffff;
    border-left: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    z-index: 35;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0);
}

.chatbot-panel.open {
    width: 33.333%;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
}

/* Main content shrinks when chat is open */
#main-content {
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#main-content.chatbot-active {
    margin-right: 33.333%;
}

/* Chat messages */
.chat-msg-enter {
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Typing dots animation */
.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7cbce3;
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick action buttons */
.chatbot-quick-btn {
    padding: 0.3125rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.chatbot-quick-btn:hover {
    border-color: #d1d5db;
    color: #111827;
    background: #f9fafb;
}

/* ============================================
   CHATBOT MARKDOWN — Minimal Professional Style
   ============================================ */
.chatbot-markdown {
    font-size: 0.8125rem;
    line-height: 1.8;
    color: #374151;
    letter-spacing: -0.006em;
}
.chatbot-markdown p { margin-bottom: 0.75rem; }
.chatbot-markdown p:last-child { margin-bottom: 0; }
.chatbot-markdown strong { font-weight: 600; color: #111827; }
.chatbot-markdown em { color: #475569; font-style: italic; }
.chatbot-markdown code {
    background: #f3f4f6;
    color: #1f2937;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

/* --- Headings --- */
.chatbot-markdown h2 {
    font-weight: 700;
    font-size: 0.8125rem;
    margin: 1.25rem 0 0.5rem;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.chatbot-markdown h3 {
    font-weight: 600;
    font-size: 0.8125rem;
    margin: 1rem 0 0.375rem;
    color: #1e293b;
}
.chatbot-markdown h4 {
    font-weight: 600;
    font-size: 0.8125rem;
    margin: 0.75rem 0 0.3rem;
    color: #374151;
}
.chatbot-markdown hr {
    border: none;
    height: 1px;
    background: #e5e7eb;
    margin: 0.75rem 0;
}

/* --- Lists --- */
.chatbot-markdown ul {
    padding-left: 0;
    margin-bottom: 0.75rem;
    list-style: none;
}
.chatbot-markdown ul li {
    position: relative;
    padding-left: 1rem;
    margin-bottom: 0.5rem;
}
.chatbot-markdown ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #9ca3af;
}
.chatbot-markdown ul ul li::before {
    width: 3px;
    height: 3px;
    background: #d1d5db;
    border-radius: 1px;
}
.chatbot-markdown ol {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}
.chatbot-markdown ol li {
    margin-bottom: 0.5rem;
    padding-left: 0.125rem;
}
.chatbot-markdown ol li::marker {
    color: #6b7280;
    font-weight: 600;
    font-size: 0.75rem;
}

/* --- Blockquote --- */
.chatbot-markdown blockquote {
    border-left: 2px solid #d1d5db;
    padding: 0.5rem 0.875rem;
    margin: 0.75rem 0;
    background: transparent;
    color: #6b7280;
    font-style: normal;
    font-size: 0.7875rem;
}

/* --- Inline values --- */
.cm-val {
    font-weight: 600;
    color: #111827;
    font-variant-numeric: tabular-nums;
    background: rgba(99, 102, 241, 0.06);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
}
.cm-neg {
    font-weight: 700;
    color: #dc2626;
    font-variant-numeric: tabular-nums;
    background: rgba(220, 38, 38, 0.06);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
}
.cm-pos {
    font-weight: 700;
    color: #059669;
    font-variant-numeric: tabular-nums;
    background: rgba(5, 150, 105, 0.06);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
}

/* --- Cards --- */
.cm-card {
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    margin: 0.625rem 0;
    font-size: 0.8rem;
    line-height: 1.6;
    border-left: 3px solid;
    border: 1px solid #e5e7eb;
    border-left-width: 3px;
}
.cm-card--ok {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
}
.cm-card--tip {
    border-left-color: #6366f1;
    background: linear-gradient(135deg, #eef2ff 0%, #f0f4ff 100%);
}
.cm-card--warn {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 40%, #fffbeb 100%);
}
.cm-card strong {
    display: inline-block;
    margin-bottom: 0.15rem;
}
.cm-card p { margin-bottom: 0.2rem; }
.cm-card p:last-child { margin-bottom: 0; }

/* --- KV Grid --- */
.cm-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
    margin: 0.5rem 0;
    background: #f3f4f6;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.cm-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.45rem 0.75rem;
    background: #fff;
    font-size: 0.8125rem;
    line-height: 1.5;
}
.cm-kv-k {
    color: #6b7280;
    font-weight: 500;
    flex-shrink: 0;
    max-width: 55%;
}
.cm-kv-v {
    color: #111827;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

/* --- Stat Cards --- */
.cm-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    margin: 0.5rem 0;
}
.cm-stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    transition: box-shadow 0.15s ease;
}
.cm-stat-card:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.cm-stat-card-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    margin-bottom: 0.35rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #f3f4f6;
}
.cm-stat-card .cm-kv {
    padding: 0.2rem 0;
    background: transparent;
    font-size: 0.78rem;
}
.cm-stat-card .cm-kv-k { font-size: 0.73rem; }
.cm-stat-card .cm-kv-v { font-size: 0.78rem; }
.cm-card-text {
    font-size: 0.8rem;
    color: #374151;
    margin: 0.15rem 0;
    line-height: 1.5;
}

/* --- Section Title --- */
.cm-section-title {
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin: 0.875rem 0 0.375rem !important;
    padding: 0.35rem 0.5rem 0.35rem 0.625rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 3px solid #6366f1;
    border-bottom: none;
    border-radius: 0 6px 6px 0;
    letter-spacing: -0.01em;
}
.cm-section-title:first-child { margin-top: 0 !important; }
.cm-section-title strong { font-weight: 700; }

/* --- Tables --- */
.chatbot-markdown .cm-table-wrap {
    margin: 0.625rem 0;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    background: #fff;
}
.chatbot-markdown table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}
.chatbot-markdown thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.625rem;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.chatbot-markdown tbody td {
    padding: 0.5rem 0.625rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}
.chatbot-markdown tbody tr:last-child td { border-bottom: none; }
.chatbot-markdown tbody tr:hover td { background: #f8fafc; }
.chatbot-markdown td:nth-child(n+2),
.chatbot-markdown th:nth-child(n+2) { text-align: right; }
/* First column (product names) bold */
.chatbot-markdown tbody td:first-child {
    font-weight: 600;
    color: #1e293b;
}
/* Product color indicators in first column */
.chatbot-markdown tbody td:first-child .cm-product-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
/* Negative values in tables */
.chatbot-markdown td .cm-neg {
    color: #dc2626;
    font-weight: 600;
}
/* Positive values in tables */
.chatbot-markdown td .cm-pos {
    color: #059669;
    font-weight: 600;
}

/* Toggle button shifts when panel is open */
#chatbot-toggle {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chatbot-toggle-shifted {
    right: calc(33.333% + 1.5rem) !important;
}

/* Responsive: full width on smaller screens */
@media (max-width: 1024px) {
    .chatbot-panel.open {
        width: 100%;
    }
    #main-content.chatbot-active {
        margin-right: 0;
    }
    .chatbot-toggle-shifted {
        right: 1.5rem !important;
        bottom: auto !important;
        top: 1rem !important;
    }
}

@media (min-width: 1025px) and (max-width: 1400px) {
    .chatbot-panel.open {
        width: 40%;
    }
    #main-content.chatbot-active {
        margin-right: 40%;
    }
    .chatbot-toggle-shifted {
        right: calc(40% + 1.5rem) !important;
    }
}

/* --- Follow-up Suggestion Buttons --- */
.chatbot-followup-btn {
    display: block;
    padding: 0.375rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: normal;
    text-align: left;
    line-height: 1.4;
    max-width: 100%;
}
.chatbot-followup-btn:hover {
    background: #f9fafb;
    color: #111827;
    border-color: #d1d5db;
}
.chatbot-followup-btn:active {
    background: #f3f4f6;
}

/* Follow-up suggestions container */
.chatbot-followups-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.375rem 0 0.25rem;
    animation: fadeIn 0.3s ease-out forwards;
}

/* --- Streaming dots --- */
.streaming-cursor {
    display: inline-flex;
    gap: 3px;
    margin-left: 5px;
    vertical-align: middle;
}
.streaming-cursor .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #6366f1;
    animation: dot-bounce 1.2s ease-in-out infinite;
}
.streaming-cursor .dot:nth-child(2) { animation-delay: 0.15s; }
.streaming-cursor .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-4px); opacity: 1; }
}
html.dark .streaming-cursor .dot { background: #818cf8; }

/* --- Chatbot Filter Action Buttons --- */
.chatbot-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0 0.25rem;
    animation: fadeIn 0.3s ease-out forwards;
}
.chatbot-filter-label {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 2px;
}
.chatbot-filter-btn {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.chatbot-filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.chatbot-filter-btn.active {
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.chatbot-filter-btn--green { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.chatbot-filter-btn--green:hover, .chatbot-filter-btn--green.active { background: #16a34a; color: white; border-color: #16a34a; }
.chatbot-filter-btn--red { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.chatbot-filter-btn--red:hover, .chatbot-filter-btn--red.active { background: #dc2626; color: white; border-color: #dc2626; }
.chatbot-filter-btn--amber { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.chatbot-filter-btn--amber:hover, .chatbot-filter-btn--amber.active { background: #d97706; color: white; border-color: #d97706; }
.chatbot-filter-btn--clear { border-color: #e2e8f0; color: #94a3b8; font-size: 10px; }
.chatbot-filter-btn--clear:hover { background: #f1f5f9; color: #64748b; }
.chatbot-filter-btn--outline { background: transparent; border-style: dashed; font-size: 10px; opacity: 0.8; }
.chatbot-filter-btn--outline:hover { opacity: 1; border-style: solid; }
.chatbot-filter-sep { color: #e2e8f0; font-size: 14px; margin: 0 2px; user-select: none; }

/* --- Interactive Chart Filter Chips --- */
.chart-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 10px 8px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}
.chart-filter-bar:empty { display: none; }
.chart-chip {
    font-size: 10px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    padding: 2px 8px;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: line-through;
    opacity: 0.5;
}
.chart-chip.active {
    color: #334155;
    text-decoration: none;
    opacity: 1;
    border-color: #cbd5e1;
    background: #f8fafc;
}
.chart-chip:hover {
    border-color: #94a3b8;
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chart-chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.chart-chip:not(.active) .chart-chip-dot { opacity: 0.3; }

/* --- Quick Action Button variants --- */
.chatbot-quick-btn i {
    opacity: 0.7;
    transition: opacity 0.15s;
}
.chatbot-quick-btn:hover i {
    opacity: 1;
}

/* ============================================
   AUTH MODAL
   ============================================ */

.auth-backdrop {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.25s ease;
}
.auth-backdrop.fade-out {
    opacity: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#auth-card {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#auth-card.show {
    transform: scale(1);
    opacity: 1;
}

.auth-tab-active {
    background: white;
    color: #111827;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.auth-tab-inactive {
    background: transparent;
    color: #9ca3af;
}
.auth-tab-inactive:hover {
    color: #6b7280;
}

/* ============================================
   PREVIEW MODE — Locked content overlays
   ============================================ */

.preview-mode .kpi-locked {
    position: relative;
    overflow: hidden;
}
.preview-mode .kpi-locked::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 5;
    border-radius: inherit;
}
.preview-mode .kpi-locked::before {
    content: '\f023';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    color: #d1d5db;
    font-size: 1.25rem;
}

.preview-mode .tab-locked {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
}
.preview-mode .tab-locked::after {
    content: '\f023';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: 0.375rem;
    font-size: 0.625rem;
    color: #d1d5db;
}

.preview-mode .table-preview-wrapper {
    position: relative;
    max-height: 220px;
    overflow: hidden;
}
.preview-mode .table-preview-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, transparent 0%, rgba(255,255,255,0.95) 70%, white 100%);
    z-index: 5;
    pointer-events: none;
}

.preview-mode .table-preview-overlay {
    text-align: center;
    padding: 1rem;
    position: relative;
    z-index: 6;
    margin-top: -2rem;
}

.preview-mode #chatbot-toggle {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================
   GLOBAL HELPERS
   ============================================ */

/* Gradient text helper */
.text-gradient {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glass effect */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Subtle pulse for live indicators */
@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.live-dot {
    animation: livePulse 2s ease-in-out infinite;
}

/* ============================================
   PROACTIVE ALERTS
   ============================================ */
.proactive-alert-chip {
    opacity: 0;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.proactive-alert-chip:nth-child(1) { animation-delay: 0.1s; }
.proactive-alert-chip:nth-child(2) { animation-delay: 0.15s; }
.proactive-alert-chip:nth-child(3) { animation-delay: 0.2s; }
.proactive-alert-chip:nth-child(4) { animation-delay: 0.25s; }
.proactive-alert-chip:nth-child(5) { animation-delay: 0.3s; }

.proactive-alert-in-chat button {
    opacity: 0;
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.proactive-alert-in-chat button:nth-child(1) { animation-delay: 0.1s; }
.proactive-alert-in-chat button:nth-child(2) { animation-delay: 0.2s; }
.proactive-alert-in-chat button:nth-child(3) { animation-delay: 0.3s; }
.proactive-alert-in-chat button:nth-child(4) { animation-delay: 0.4s; }
.proactive-alert-in-chat button:nth-child(5) { animation-delay: 0.5s; }

/* Filter badge */
#hist-filter-badge {
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Filter Bar */
.hist-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #eef0f3;
}
.hist-filter-bar__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #f5f7fa;
    color: #94a3b8;
    font-size: 11px;
    flex-shrink: 0;
}
.hist-filter-bar__controls {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex: 1;
    flex-wrap: wrap;
}
.hist-filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.hist-filter-group__label {
    font-size: 10px;
    font-weight: 500;
    color: #b0b5bc;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-left: 2px;
}
.hist-filter-select,
.hist-filter-input {
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.hist-filter-select {
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.hist-filter-input {
    min-width: 130px;
}
.hist-filter-select:hover,
.hist-filter-input:hover {
    border-color: #cbd5e1;
    background: #ffffff;
}
.hist-filter-select:focus,
.hist-filter-input:focus {
    border-color: #2c7fb8;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(44, 127, 184, 0.1);
}
.hist-filter-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.hist-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.hist-filter-btn--apply {
    background: #1e293b;
    color: #ffffff;
}
.hist-filter-btn--apply:hover {
    background: #334155;
}
.hist-filter-btn--reset {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.hist-filter-btn--reset:hover {
    background: #e2e8f0;
    color: #475569;
}
.hist-filter-btn--reset.hidden {
    display: none;
}

/* Responsive: stack on small screens */
@media (max-width: 768px) {
    .hist-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .hist-filter-bar__icon { display: none; }
    .hist-filter-bar__controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    .hist-filter-group { width: 100%; }
    .hist-filter-select,
    .hist-filter-input { width: 100%; }
    .hist-filter-bar__actions {
        justify-content: flex-end;
    }
}

/* Historial entrance — simple fade */
#historial-content .kpi-card,
#historial-content .chart-container,
#historial-content .file-table-container {
    animation: fadeIn 0.3s ease forwards;
}

/* ============================================
   ANOMALY CARDS (F3)
   ============================================ */
.anomaly-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid #eef0f3;
    cursor: default;
    opacity: 0;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.anomaly-card:hover {
    box-shadow: var(--shadow-md);
}
.anomaly-card--danger {
    border-left: 3px solid #ef4444;
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 40%);
}
.anomaly-card--warning {
    border-left: 3px solid #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 40%);
}
.anomaly-card__action {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

/* ============================================
   SAT AUDIT (F4)
   ============================================ */
.sat-audit-panel {
    background: #ffffff;
    border-radius: var(--radius-card);
    border: 1px solid #eef0f3;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.sat-progress-bar {
    height: 6px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0;
}
.sat-progress-bar__fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.sat-check-v2 {
    opacity: 0;
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.sat-check-v2:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* ============================================
   HEALTH SCORE GAUGE (F5)
   ============================================ */
.health-gauge-container {
    display: flex;
    align-items: center;
    gap: 32px;
    background: #ffffff;
    border-radius: var(--radius-card);
    border: 1px solid #eef0f3;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.health-gauge {
    position: relative;
    width: 140px; height: 140px;
    flex-shrink: 0;
}
.health-gauge__svg {
    transform: rotate(-90deg);
    width: 140px; height: 140px;
}
.health-gauge__bg {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 10;
}
.health-gauge__fill {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.health-gauge__label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.health-gauge__score {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}
.health-gauge__grade {
    font-size: 13px;
    font-weight: 700;
    margin-top: 2px;
}
.health-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.health-bar__label {
    width: 120px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}
.health-bar__track {
    flex: 1;
    height: 6px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
}
.health-bar__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.health-bar__pts {
    font-size: 11px;
    font-weight: 700;
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* ============================================
   PROJECTION CARD (F6)
   ============================================ */
.projection-card {
    background: linear-gradient(135deg, #f0f4ff 0%, #ffffff 50%);
    border-radius: var(--radius-card);
    border: 1px solid #e0e7ff;
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.projection-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}
.projection-item:last-child { border-bottom: none; }
.confidence-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}
.confidence-indicator--high { background: #dcfce7; color: #16a34a; }
.confidence-indicator--medium { background: #fef3c7; color: #d97706; }
.confidence-indicator--low { background: #fee2e2; color: #dc2626; }

/* ============================================
   PERIOD COMPARISON (F8)
   ============================================ */
.comparison-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #eef0f3;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}
.comparison-card:hover { box-shadow: var(--shadow-md); }
.comparison-card--global {
    background: linear-gradient(135deg, #f8fafc 0%, #f0f4ff 100%);
    border: 1px solid #e0e7ff;
}
.delta-positive { color: #16a34a; }
.delta-negative { color: #dc2626; }
.mini-bar {
    height: 6px;
    border-radius: 3px;
    background: #f1f5f9;
    overflow: hidden;
}
.mini-bar__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* Comparison toggle button */
.comparison-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
    padding: 6px 0;
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.comparison-toggle-btn:hover {
    background: #f8fafc;
    color: #334155;
    border-color: #cbd5e1;
}
html.dark .comparison-toggle-btn {
    border-color: #334155;
    color: #64748b;
}
html.dark .comparison-toggle-btn:hover {
    background: #1e293b;
    color: #94a3b8;
    border-color: #475569;
}

/* ============================================
   REPORT & NOTIFICATION BUTTONS (F7, F9)
   ============================================ */
.historial-report-btn,
.historial-notif-btn {
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}
.historial-report-btn:hover,
.historial-notif-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #ffffff;
}

/* Toast notification */
.petrol-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 100;
    opacity: 0;
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.petrol-toast--out {
    animation: toastOut 0.3s ease forwards;
}
@keyframes toastIn {
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* Bell shake animation (F9) */
@keyframes bellShake {
    0%, 100% { transform: rotate(0); }
    15% { transform: rotate(14deg); }
    30% { transform: rotate(-14deg); }
    45% { transform: rotate(10deg); }
    60% { transform: rotate(-8deg); }
    75% { transform: rotate(4deg); }
}
.bell-shake i { animation: bellShake 0.6s ease; }

/* Responsive health gauge */
@media (max-width: 640px) {
    .health-gauge-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* ============================================
   DARK MODE
   ============================================ */

/* Theme toggle button in sidebar */
.sidebar-theme-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}
.sidebar-theme-btn:hover {
    background: #e8ecf1;
    color: #475569;
}

/* === DARK MODE OVERRIDES === */

/* Body / root */
.dark body,
html.dark body {
    background: #0f172a !important;
    color: #e2e8f0;
}
html.dark #app {
    background: #0f172a;
}

/* Sidebar */
html.dark .nav-sidebar {
    background: #111827;
    border-right-color: #1e293b;
}
html.dark .sidebar-header {
    background: #111827;
    border-bottom-color: #1e293b;
}
html.dark .sidebar-header h1 { color: #e2e8f0; }
html.dark .sidebar-header p { color: #64748b; }

html.dark .sidebar-nav-item {
    color: #94a3b8;
}
html.dark .sidebar-nav-item:hover {
    background: #1e293b;
    color: #e2e8f0;
    border-color: transparent;
}
html.dark .sidebar-nav-item.active {
    background: linear-gradient(135deg, #1d669b 0%, #2879ad 100%);
    color: #ffffff;
}
html.dark .sidebar-section-title {
    color: #94a3b8;
    border-top-color: #1e293b;
}
html.dark .sidebar-filter-bar { background: transparent; }
html.dark .sidebar-search-input {
    background: #1e293b;
    border-color: transparent;
    color: #e2e8f0;
}
html.dark .sidebar-search-input::placeholder { color: #64748b; }
html.dark .sidebar-chip {
    background: transparent;
    color: #94a3b8;
    border-color: #1e293b;
}
html.dark .sidebar-chip.active {
    background: #334155;
    color: #e2e8f0;
}

/* Sidebar file list */
html.dark .sidebar-file-item {
    color: #cbd5e1;
    border-color: transparent;
}
html.dark .sidebar-file-item .file-name {
    color: #f1f5f9;
}
html.dark .sidebar-file-item .file-date {
    color: #94a3b8;
}
html.dark .sidebar-file-item .file-date--upload {
    color: #94a3b8;
}
html.dark .sidebar-file-item .file-date-sep {
    background: #475569;
}
html.dark .sidebar-file-item .file-meta-icon {
    opacity: 0.7;
}
html.dark .sidebar-file-item .file-badge--type.diario {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}
html.dark .sidebar-file-item .file-badge--type.mensual {
    background: rgba(124, 58, 237, 0.2);
    color: #a78bfa;
}
html.dark .sidebar-file-item .file-cal-icon {
    background: #1e293b;
    border-color: #334155;
}
html.dark .sidebar-file-item .file-cal-icon.diario {
    border-color: rgba(59, 130, 246, 0.3);
}
html.dark .sidebar-file-item .file-cal-icon.mensual {
    border-color: rgba(139, 92, 246, 0.3);
}
html.dark .sidebar-file-item .file-cal-icon__day {
    color: #f1f5f9;
}
html.dark .sidebar-file-item:hover {
    background: #1e293b;
}
html.dark .sidebar-file-item.active {
    background: #1e293b;
    border-color: transparent;
}
html.dark .sidebar-file-item.active .file-name {
    color: #ffffff;
}

/* Sidebar footer */
html.dark .sidebar-footer {
    background: #111827;
    border-top-color: #1e293b;
}
html.dark .sidebar-footer span { color: #cbd5e1; }
html.dark .sidebar-logout-btn { color: #64748b; }
html.dark .sidebar-logout-btn:hover { background: #334155; color: #e2e8f0; }
html.dark .sidebar-theme-btn { color: #f59e0b; }
html.dark .sidebar-theme-btn:hover { background: #334155; color: #fbbf24; }

/* Top bar */
html.dark #top-bar {
    background: rgba(15, 23, 42, 0.9) !important;
    border-bottom-color: #1e293b !important;
    backdrop-filter: blur(16px);
}
html.dark #top-bar h1 { color: #e2e8f0; }
html.dark #top-bar p { color: #64748b; }

/* Main content area */
html.dark main {
    background: #0f172a;
}

/* Landing page */
html.dark .landing-left {
    background: #0f172a;
    box-shadow: none;
}
html.dark .landing-left h2 { color: #f1f5f9; }
html.dark .landing-left p { color: #94a3b8; }

/* Plataforma SAT badge */
html.dark .landing-left .bg-primary-50 {
    background: rgba(68, 158, 211, 0.15) !important;
}
html.dark .landing-left .border-primary-100 {
    border-color: rgba(68, 158, 211, 0.25) !important;
}
html.dark .landing-left .text-primary-600 {
    color: #7dd3fc !important;
}

/* Dropzone */
html.dark .landing-dropzone {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html.dark .landing-dropzone:hover {
    border-color: #449ed3 !important;
    box-shadow: 0 12px 35px rgba(44, 127, 184, 0.15);
}

/* Dropzone icon container */
html.dark .landing-dropzone .bg-gradient-to-br {
    background: linear-gradient(to bottom right, rgba(68, 158, 211, 0.2), rgba(56, 189, 248, 0.15)) !important;
}

/* Dropzone text */
html.dark .landing-dropzone h3,
html.dark .landing-dropzone .text-gray-800 {
    color: #e2e8f0 !important;
}
html.dark .landing-dropzone .text-gray-400 {
    color: #64748b !important;
}

/* File type badges (.JSON / .XML) */
html.dark .landing-dropzone .from-gray-50,
html.dark .landing-dropzone .bg-gradient-to-r {
    background: linear-gradient(to right, #1e293b, #334155) !important;
}
html.dark .landing-dropzone .text-gray-500 {
    color: #94a3b8 !important;
}
html.dark .landing-dropzone .border-gray-100 {
    border-color: #475569 !important;
}

/* Footer badges (Cifrado SHA-256, Procesamiento inmediato, Hasta 50 MB) */
html.dark .landing-left .text-gray-300 {
    color: #64748b;
}
html.dark .landing-left .bg-gray-200 {
    background-color: #475569 !important;
}

/* Login bar */
html.dark .landing-login-bar {
    background: #1e293b !important;
}
html.dark .landing-login-bar .text-gray-700,
html.dark .landing-login-bar #user-name-display {
    color: #cbd5e1 !important;
}
html.dark .landing-login-bar .text-gray-300 {
    color: #64748b !important;
}

/* KPI Cards */
html.dark .kpi-card {
    background: #1e293b;
    border-color: transparent;
}
html.dark .kpi-card:hover {
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
html.dark .kpi-card__value {
    color: #f1f5f9 !important;
}
html.dark .kpi-card__label {
    color: #64748b;
}
html.dark .kpi-card__sub {
    color: #64748b;
}
html.dark .kpi-card .kpi-card__icon,
html.dark .kpi-card--emerald .kpi-card__icon,
html.dark .kpi-card--orange .kpi-card__icon,
html.dark .kpi-card--blue .kpi-card__icon,
html.dark .kpi-card--red .kpi-card__icon,
html.dark .kpi-card--amber .kpi-card__icon,
html.dark .kpi-card--purple .kpi-card__icon,
html.dark .kpi-card--gray .kpi-card__icon,
html.dark .kpi-card--primary .kpi-card__icon {
    background: #0f172a;
    color: #64748b;
}
html.dark .kpi-card--tier-info,
html.dark .kpi-card--tier-metric {
    background: #1e293b;
    border-color: transparent;
}

/* Section labels */
html.dark .section-label__text { color: #64748b; }
html.dark .section-label__line { background: #1e293b; }

/* Chart containers */
html.dark .chart-container {
    background: #1e293b;
    border-color: transparent;
}
html.dark .chart-container:hover {
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
html.dark .chart-container__header {
    background: #162032;
    border-bottom-color: #1e293b;
}
html.dark .chart-container__title { color: #e2e8f0; }
html.dark .chart-container__badge { color: #64748b; }

/* Ficha Tecnica (Estacion de Servicio) */
html.dark #ficha-toggle {
    color: #e2e8f0;
}
html.dark #ficha-toggle:hover {
    background: rgba(255,255,255,0.03) !important;
}
html.dark #ficha-nombre {
    color: #e2e8f0 !important;
}
html.dark #ficha-toggle .bg-gradient-to-br {
    background: linear-gradient(to bottom right, rgba(68, 158, 211, 0.2), rgba(56, 189, 248, 0.15)) !important;
}
html.dark #ficha-content {
    border-top-color: #1e293b !important;
}
html.dark #ficha-content .text-gray-400 {
    color: #64748b !important;
}
html.dark #ficha-content .text-gray-700 {
    color: #cbd5e1 !important;
}
/* Product pills dark mode */
html.dark #ficha-productos .bg-green-50 {
    background: rgba(34, 197, 94, 0.15) !important;
}
html.dark #ficha-productos .border-green-200 {
    border-color: rgba(34, 197, 94, 0.3) !important;
}
html.dark #ficha-productos .text-green-700 {
    color: #4ade80 !important;
}
html.dark #ficha-productos .text-green-400 {
    color: #86efac !important;
}
html.dark #ficha-productos .bg-red-50 {
    background: rgba(239, 68, 68, 0.15) !important;
}
html.dark #ficha-productos .border-red-200 {
    border-color: rgba(239, 68, 68, 0.3) !important;
}
html.dark #ficha-productos .text-red-700 {
    color: #f87171 !important;
}
html.dark #ficha-productos .text-red-400 {
    color: #fca5a5 !important;
}
html.dark #ficha-productos .bg-gray-900 {
    background: rgba(255, 255, 255, 0.1) !important;
}
html.dark #ficha-productos .border-gray-700 {
    border-color: rgba(255, 255, 255, 0.2) !important;
}
html.dark #ficha-productos .text-white {
    color: #e2e8f0 !important;
}
html.dark #ficha-productos .text-gray-300 {
    color: #94a3b8 !important;
}
html.dark #ficha-productos .bg-primary-50 {
    background: rgba(99, 102, 241, 0.15) !important;
}
html.dark #ficha-productos .border-primary-100 {
    border-color: rgba(99, 102, 241, 0.3) !important;
}
html.dark #ficha-productos .text-primary-700 {
    color: #a5b4fc !important;
}
html.dark #ficha-productos .text-primary-400 {
    color: #c7d2fe !important;
}
/* Proveedor rows dark mode */
html.dark #ficha-proveedores .bg-gray-50 {
    background: rgba(255, 255, 255, 0.05) !important;
}
html.dark #ficha-proveedores .text-gray-700 {
    color: #e2e8f0 !important;
}
html.dark #ficha-proveedores .text-gray-800 {
    color: #f1f5f9 !important;
}
html.dark #ficha-proveedores .text-gray-400 {
    color: #64748b !important;
}
/* Border separator dark */
html.dark #ficha-content .border-gray-50 {
    border-color: #1e293b !important;
}

/* File table */
html.dark .file-table-container {
    background: #1e293b;
    border-color: transparent;
}
html.dark .file-table-container:hover {
    border-color: transparent;
}
html.dark .file-table-header {
    background: #162032;
    border-bottom-color: #1e293b;
}

/* Historial header (already dark) */

/* Filter bar */
html.dark .hist-filter-bar {
    background: #1e293b;
    border-color: transparent;
}
html.dark .hist-filter-bar__icon {
    background: #0f172a;
    color: #64748b;
}
html.dark .hist-filter-select,
html.dark .hist-filter-input {
    background: #0f172a;
    border-color: transparent;
    color: #e2e8f0;
}
html.dark .hist-filter-select:hover,
html.dark .hist-filter-input:hover {
    border-color: #475569;
}
html.dark .hist-filter-group__label { color: #64748b; }

/* DataTables */
html.dark table.dataTable thead th {
    background-color: #162032 !important;
    color: #94a3b8 !important;
    border-bottom-color: #1e293b !important;
}
html.dark table.dataTable tbody td {
    color: #cbd5e1 !important;
    border-bottom-color: #1e293b !important;
}
html.dark table.dataTable tbody tr:hover {
    background-color: #162032 !important;
}
html.dark .dataTables_wrapper .dataTables_filter input {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
html.dark .dataTables_wrapper .dataTables_filter input:focus {
    background: #1e293b !important;
    border-color: #2c7fb8 !important;
}
html.dark .dataTables_wrapper .dataTables_length select {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
html.dark .dataTables_wrapper .dataTables_info {
    color: #64748b !important;
}
html.dark .dataTables_wrapper .dataTables_filter label,
html.dark .dataTables_wrapper .dataTables_length label {
    color: #64748b !important;
}
html.dark .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #94a3b8 !important;
}
html.dark .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #2c7fb8 !important;
    color: white !important;
}
html.dark .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

/* Operations section (individual file) */
html.dark .operations-section__header::before {
    background: linear-gradient(90deg, transparent 0%, #334155 15%, #475569 50%, #334155 85%, transparent 100%);
}
html.dark .operations-section__title h2 {
    color: #e2e8f0;
}
html.dark .operations-table-card {
    background: #1e293b;
    border-color: transparent;
}
html.dark .filter-btn {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
html.dark .filter-btn:hover {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark .filter-btn.active {
    background: #2c7fb8;
    border-color: #2c7fb8;
    color: #ffffff;
}

/* DataTable row backgrounds */
html.dark table.dataTable tbody tr {
    background-color: #1e293b !important;
}
html.dark table.dataTable tbody tr:nth-child(even) {
    background-color: #162032 !important;
}
html.dark table.dataTable tbody tr:hover td {
    background-color: #334155 !important;
}

/* DataTable inline badge colors for dark mode */
html.dark table.dataTable .bg-emerald-50 {
    background: rgba(16, 185, 129, 0.15) !important;
}
html.dark table.dataTable .bg-orange-50 {
    background: rgba(249, 115, 22, 0.15) !important;
}
html.dark table.dataTable .bg-blue-50 {
    background: rgba(59, 130, 246, 0.15) !important;
}
html.dark table.dataTable .border-emerald-200 { border-color: rgba(16, 185, 129, 0.3) !important; }
html.dark table.dataTable .border-orange-200 { border-color: rgba(249, 115, 22, 0.3) !important; }
html.dark table.dataTable .border-blue-200 { border-color: rgba(59, 130, 246, 0.3) !important; }

/* Table summary footer */
html.dark .table-summary-footer td {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    border-top: 2px solid #334155 !important;
}

/* Top bar file indicator */
html.dark #file-indicator {
    background: rgba(16, 185, 129, 0.10) !important;
    color: #6ee7b7 !important;
    border-color: rgba(16, 185, 129, 0.20) !important;
    box-shadow: none !important;
}
html.dark #file-indicator i {
    color: #6ee7b7 !important;
}
html.dark #btn-reload {
    background: #1e293b !important;
    color: #94a3b8 !important;
}
html.dark #btn-reload:hover {
    background: #334155 !important;
    color: #e2e8f0 !important;
}
html.dark #file-type-badge {
    color: #94a3b8 !important;
}

/* SAT Audit */
html.dark .sat-audit-panel {
    background: #1e293b;
    border-color: transparent;
}
html.dark .sat-audit-panel .text-gray-800 { color: #e2e8f0 !important; }
html.dark .sat-audit-panel .text-gray-500 { color: #94a3b8 !important; }
html.dark .sat-progress-bar { background: #334155; }

/* SAT check cards dark mode */
html.dark .sat-check-v2.bg-emerald-50 {
    background: rgba(16, 185, 129, 0.08) !important;
    border-color: transparent !important;
}
html.dark .sat-check-v2.bg-amber-50 {
    background: rgba(245, 158, 11, 0.08) !important;
    border-color: transparent !important;
}
html.dark .sat-check-v2.bg-red-50 {
    background: rgba(239, 68, 68, 0.08) !important;
    border-color: transparent !important;
}
html.dark .sat-check-v2 .text-gray-800 { color: #cbd5e1 !important; }
html.dark .sat-check-v2 .text-gray-500 { color: #64748b !important; }
html.dark .sat-check-v2 .text-gray-400 { color: #475569 !important; }
html.dark .sat-audit-ia-btn {
    background: rgba(68, 158, 211, 0.15) !important;
    color: #7dd3fc !important;
}

/* Tanques stat cards — no borders */
html.dark .dark-tanque-stat {
    background: #0f172a !important;
    border: none !important;
}

/* Tanques table — subtle separators */
html.dark #hist-tanques-table table tr {
    border-color: #1e293b !important;
}
html.dark #hist-tanques-table .border-gray-50,
html.dark #hist-tanques-table .border-t {
    border-color: #1e293b !important;
}

/* Resumen por Archivo table — subtle separators */
html.dark #historial-file-table .border-gray-50,
html.dark #historial-file-table .border-t {
    border-color: #1e293b !important;
}
html.dark #historial-file-table tr:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}
html.dark #historial-file-table .bg-blue-50 {
    background: rgba(59, 130, 246, 0.15) !important;
}
html.dark #historial-file-table .bg-purple-50 {
    background: rgba(139, 92, 246, 0.15) !important;
}

/* Health Gauge */
html.dark .health-gauge-container {
    background: #1e293b;
    border-color: transparent;
}
html.dark .health-gauge__bg { stroke: #334155; }
html.dark .health-bar__label { color: #94a3b8; }
html.dark .health-bar__track { background: #334155; }

/* Anomaly cards */
html.dark .anomaly-card {
    background: #1e293b;
    border-color: transparent;
}
html.dark .anomaly-card--danger {
    background: linear-gradient(135deg, rgba(127, 29, 29, 0.15) 0%, #1e293b 40%);
    border-left-color: #ef4444;
}
html.dark .anomaly-card--warning {
    background: linear-gradient(135deg, rgba(120, 80, 0, 0.15) 0%, #1e293b 40%);
    border-left-color: #f59e0b;
}

/* Comparison cards */
html.dark .comparison-card {
    background: #1e293b;
    border-color: transparent;
}
html.dark .comparison-card .border-gray-50 { border-color: #334155 !important; }
html.dark .comparison-card .text-gray-700 { color: #e2e8f0 !important; }
html.dark .comparison-card .text-gray-500 { color: #94a3b8 !important; }
html.dark .comparison-card .text-gray-400 { color: #64748b !important; }
html.dark .comparison-card .text-gray-300 { color: #475569 !important; }
html.dark .comparison-card--global {
    background: linear-gradient(135deg, #1e293b 0%, #162032 100%);
    border-color: transparent;
}
html.dark .comparison-card--global .text-indigo-700 { color: #818cf8 !important; }
html.dark .mini-bar { background: #334155; }

/* Projection card */
html.dark .projection-card {
    background: linear-gradient(135deg, #162032 0%, #1e293b 50%);
    border-color: transparent;
}
html.dark .projection-item { border-bottom-color: #334155; }

/* Tank section */
html.dark .dark-tanque-stat {
    background: #0f172a !important;
}
html.dark #hist-tanques-table table {
    font-size: 12px;
}

/* Projection card height match */
#hist-projection-card .projection-card {
    height: 100%;
}
/* When tanques is hidden, projection takes full width */
#hist-tanques-section.hidden + #hist-projection-card {
    grid-column: 1 / -1;
}

/* Chatbot panel */
html.dark .chatbot-panel {
    background: #1e293b;
    border-left-color: transparent;
}
html.dark #chatbot-messages {
    background: #0f172a !important;
}
html.dark .chatbot-quick-btn {
    border-color: #334155;
    color: #94a3b8;
    background: #1e293b;
}
html.dark .chatbot-quick-btn:hover {
    border-color: #475569;
    color: #e2e8f0;
    background: #334155;
}
html.dark #chatbot-input {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
html.dark #chatbot-input::placeholder { color: #64748b; }
html.dark .chatbot-panel .border-t { border-color: #334155; }
html.dark .chatbot-panel .border-gray-100 { border-color: #334155 !important; }
html.dark .chatbot-panel .bg-white { background: #1e293b !important; }
html.dark .chatbot-panel .border-gray-100\/60,
html.dark .chatbot-panel .border-gray-100\/80 { border-color: #334155 !important; }
html.dark #chatbot-messages { scrollbar-color: #334155 transparent; }
html.dark #chatbot-messages::-webkit-scrollbar { width: 5px; }
html.dark #chatbot-messages::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
html.dark #chatbot-messages::-webkit-scrollbar-track { background: transparent; }

/* Chatbot provider selector */
.chatbot-provider-select {
    appearance: none;
    -webkit-appearance: none;
    background: #334155;
    color: #94a3b8;
    border: 1px solid #475569;
    border-radius: 4px;
    padding: 1px 16px 1px 6px;
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.15s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    line-height: 1.6;
}
.chatbot-provider-select:hover {
    border-color: #7c3aed;
    color: #e2e8f0;
}
.chatbot-provider-select:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 2px rgba(124,58,237,0.25);
}
.chatbot-provider-select option {
    background: #1e293b;
    color: #e2e8f0;
}

/* Chatbot markdown — dark mode */
html.dark .chatbot-markdown { color: #cbd5e1; }
html.dark .chatbot-markdown strong { color: #f1f5f9; }
html.dark .chatbot-markdown em { color: #94a3b8; }
html.dark .chatbot-markdown code { background: #0f172a; color: #e2e8f0; }
html.dark .chatbot-markdown h2 { color: #f1f5f9; }
html.dark .chatbot-markdown h3 { color: #e2e8f0; }
html.dark .chatbot-markdown h4 { color: #cbd5e1; }
html.dark .chatbot-markdown hr { background: #334155; }
html.dark .chatbot-markdown ul li::before { background: #64748b; }
html.dark .chatbot-markdown ul ul li::before { background: #475569; }
html.dark .chatbot-markdown ol li::marker { color: #64748b; }
html.dark .chatbot-markdown blockquote { border-left-color: #475569; color: #94a3b8; }

/* Chatbot inline values — dark mode */
html.dark .cm-val { color: #e2e8f0; background: rgba(99, 102, 241, 0.15); }
html.dark .cm-neg { color: #f87171; background: rgba(239, 68, 68, 0.15); }
html.dark .cm-pos { color: #34d399; background: rgba(16, 185, 129, 0.15); }

/* Chatbot cards — dark mode */
html.dark .cm-card { border-color: #334155; }
html.dark .cm-card--ok { background: rgba(16, 185, 129, 0.08); border-left-color: #10b981; }
html.dark .cm-card--tip { background: rgba(99, 102, 241, 0.08); border-left-color: #6366f1; }
html.dark .cm-card--warn { background: rgba(245, 158, 11, 0.08); border-left-color: #f59e0b; }

/* Chatbot KV grid — dark mode */
html.dark .cm-grid { background: #0f172a; border-color: #334155; }
html.dark .cm-kv { background: #1e293b; }
html.dark .cm-kv-k { color: #94a3b8; }
html.dark .cm-kv-v { color: #f1f5f9; }

/* Chatbot stat cards — dark mode */
html.dark .cm-stat-card { background: #0f172a; border-color: #334155; }
html.dark .cm-stat-card:hover { box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
html.dark .cm-stat-card-title { color: #94a3b8; border-bottom-color: #334155; }
html.dark .cm-stat-card .cm-kv { background: transparent; }
html.dark .cm-card-text { color: #cbd5e1; }

/* Chatbot section title — dark mode */
html.dark .cm-section-title {
    color: #e2e8f0 !important;
    background: linear-gradient(135deg, #1e293b 0%, #162032 100%) !important;
    border-left-color: #818cf8 !important;
}

/* Chatbot tables — dark mode */
html.dark .chatbot-markdown .cm-table-wrap { background: #0f172a; border-color: #334155; }
html.dark .chatbot-markdown table { background: #0f172a; }
html.dark .chatbot-markdown thead th { background: #1e293b; color: #e2e8f0; border-bottom-color: #334155; }
html.dark .chatbot-markdown tbody td { color: #cbd5e1; border-bottom-color: #1e293b; }
html.dark .chatbot-markdown tbody tr:hover td { background: #1e293b; }
html.dark .chatbot-markdown tbody td:first-child { color: #e2e8f0; }

/* Chatbot chart blocks — dark mode */
html.dark .chatbot-panel .bg-gradient-to-b { background: linear-gradient(to bottom, rgba(15,23,42,0.5), #1e293b) !important; border-color: #334155 !important; }

/* Chatbot followup buttons — dark mode */
html.dark .chatbot-followup-btn { background: #0f172a; border-color: #334155; color: #94a3b8; }
html.dark .chatbot-followup-btn:hover { background: #1e293b; border-color: #475569; color: #e2e8f0; }

/* Chatbot welcome + inline Tailwind overrides — dark mode */
html.dark .chatbot-panel .text-gray-700 { color: #cbd5e1 !important; }
html.dark .chatbot-panel .text-gray-600 { color: #94a3b8 !important; }
html.dark .chatbot-panel .border-gray-50 { border-color: #1e293b !important; }
html.dark .chatbot-panel .border-gray-200\/60 { border-color: #334155 !important; }
html.dark .chatbot-panel .bg-gray-50\/50 { background: rgba(15, 23, 42, 0.5) !important; }
html.dark #chatbot-quick-actions { border-color: #1e293b; }

/* Chatbot filter buttons — dark mode */
html.dark .chatbot-filter-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
html.dark .chatbot-filter-btn:hover { color: #e2e8f0; }
html.dark .chatbot-filter-btn--green { background: rgba(22,163,74,0.15); border-color: rgba(22,163,74,0.3); color: #4ade80; }
html.dark .chatbot-filter-btn--red { background: rgba(220,38,38,0.15); border-color: rgba(220,38,38,0.3); color: #f87171; }
html.dark .chatbot-filter-btn--amber { background: rgba(217,119,6,0.15); border-color: rgba(217,119,6,0.3); color: #fbbf24; }
html.dark .chatbot-filter-btn--clear { border-color: #334155; color: #64748b; }
html.dark .chatbot-filter-sep { color: #334155; }

/* Chatbot chart filter chips — dark mode */
html.dark .chart-filter-bar { border-top-color: #334155; }

/* Chatbot error message — dark mode */
html.dark .chatbot-panel .bg-red-50 { background: rgba(239, 68, 68, 0.1) !important; border-color: rgba(239, 68, 68, 0.2) !important; }
html.dark .chatbot-panel .bg-red-100 { background: rgba(239, 68, 68, 0.15) !important; }

/* Auth modal */
html.dark #auth-card { background: #1e293b; }
html.dark #auth-card h3 { color: #f1f5f9; }
html.dark #auth-card p { color: #94a3b8; }
html.dark #auth-card label { color: #64748b; }
html.dark #auth-card input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
html.dark #auth-card input::placeholder { color: #64748b; }
html.dark #auth-card .bg-gray-100 { background: #0f172a; }
html.dark .auth-tab-inactive { color: #64748b; }
html.dark .auth-backdrop { background: rgba(0, 0, 0, 0.7); }

/* Change password modal */
#change-password-card {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#change-password-card.show {
    transform: scale(1);
    opacity: 1;
}
html.dark #change-password-card { background: #1e293b; }
html.dark #change-password-card h3 { color: #f1f5f9; }
html.dark #change-password-card p { color: #94a3b8; }
html.dark #change-password-card label { color: #64748b; }
html.dark #change-password-card input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
html.dark #change-password-card input::placeholder { color: #64748b; }

/* Progress modal */
html.dark #progress-card { background: #1e293b; }
html.dark #progress-card h3 { color: #f1f5f9; }
html.dark #progress-card p { color: #94a3b8; }
html.dark .progress-circle-track { stroke: #334155; }
html.dark #progress-card .bg-gray-100 { background: #334155; }

/* Tab navigation */
html.dark .tab-nav-container {
    background: linear-gradient(180deg, #1e293b 0%, #162032 100%);
    border-color: transparent;
}
html.dark .tab-btn { color: #64748b; }
html.dark .tab-btn:hover { color: #cbd5e1; background: rgba(255,255,255,0.06) !important; }
html.dark .tab-btn.tab-active {
    background: #334155 !important;
    color: #f1f5f9;
    box-shadow: none;
}

/* Section headers */
html.dark .section-header__title { color: #f1f5f9; }
html.dark .section-header__subtitle { color: #64748b; }

/* Section dividers */
html.dark .section-divider::before { background: linear-gradient(90deg, transparent, #334155, transparent); }

/* Toast */
html.dark .petrol-toast { background: #334155; color: #e2e8f0; }

/* Generic Tailwind overrides for common dark patterns */
html.dark .bg-white { background-color: #1e293b !important; }
html.dark .bg-\[\\#f8f9fb\],
html.dark .bg-\[\\#f5f7fa\] { background-color: #0f172a !important; }
html.dark .border-gray-100,
html.dark .border-gray-200 { border-color: transparent !important; }
html.dark .text-gray-800 { color: #e2e8f0 !important; }
html.dark .text-gray-700 { color: #cbd5e1 !important; }
html.dark .text-gray-600 { color: #94a3b8 !important; }
html.dark .text-gray-500 { color: #94a3b8 !important; }
html.dark .text-gray-400 { color: #64748b !important; }
html.dark .text-gray-300 { color: #475569 !important; }
html.dark .text-gray-900 { color: #f1f5f9 !important; }

/* Scrollbar */
html.dark ::-webkit-scrollbar-track { background: #0f172a; }
html.dark ::-webkit-scrollbar-thumb { background: #334155; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Smooth transition for all elements when toggling */
html.dark * {
    transition-property: background-color, border-color, color;
    transition-duration: 0.2s;
    transition-timing-function: ease;
}

/* ============================================
   INSIGHTS TIMELINE (F10)
   ============================================ */
.insights-timeline {
    background: #ffffff;
    border-radius: var(--radius-card);
    border: 1px solid #eef0f3;
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}
.insights-timeline__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.insights-timeline__title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}
.insights-timeline__title i {
    color: #f59e0b;
    font-size: 14px;
}
.insights-timeline__badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: #fef3c7;
    color: #d97706;
}
.insights-timeline__feed {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: none;
    overflow-y: auto;
}
.insights-timeline__feed::-webkit-scrollbar { width: 4px; }
.insights-timeline__feed::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: none;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #f0f1f3;
    opacity: 0;
    animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.insight-item:last-child { border-bottom: none; }

.insight-item__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
    position: relative;
}
.insight-item__dot::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    top: -4px;
    left: -4px;
    opacity: 0.2;
}
.insight-item__dot--positive { background: #22c55e; }
.insight-item__dot--positive::after { background: #22c55e; }
.insight-item__dot--negative { background: #ef4444; }
.insight-item__dot--negative::after { background: #ef4444; }
.insight-item__dot--neutral { background: #3b82f6; }
.insight-item__dot--neutral::after { background: #3b82f6; }
.insight-item__dot--warning { background: #f59e0b; }
.insight-item__dot--warning::after { background: #f59e0b; }

.insight-item__content {
    flex: 1;
    min-width: 0;
}
.insight-item__text {
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    line-height: 1.5;
}
.insight-item__text strong {
    font-weight: 700;
    color: #0f172a;
}
.insight-item__meta {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.insight-item__tag {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.insight-item__tag--margin { background: #dcfce7; color: #16a34a; }
.insight-item__tag--volume { background: #dbeafe; color: #2563eb; }
.insight-item__tag--price { background: #fef3c7; color: #d97706; }
.insight-item__tag--risk { background: #fee2e2; color: #dc2626; }
.insight-item__tag--supplier { background: #f3e8ff; color: #9333ea; }
.insight-item__tag--ops { background: #e0f2fe; color: #0284c7; }

/* Dark mode for timeline */
html.dark .insights-timeline {
    background: #0f172a;
    border-color: #1e293b;
}
html.dark .insights-timeline__title { color: #e2e8f0; }
html.dark .insights-timeline__badge { background: #422006; color: #fbbf24; }
html.dark .insights-timeline__feed::-webkit-scrollbar-thumb { background: #334155; }
html.dark .insight-item { border-bottom-color: #1e293b; background: #1e293b; border-color: #334155; }
html.dark .insight-item__text { color: #94a3b8; }
html.dark .insight-item__text strong { color: #cbd5e1; }
html.dark .insight-item__meta { color: #475569; }
html.dark .insight-item__tag--margin { background: rgba(22, 163, 74, 0.15); color: #4ade80; }
html.dark .insight-item__tag--volume { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
html.dark .insight-item__tag--price { background: rgba(217, 119, 6, 0.15); color: #fbbf24; }
html.dark .insight-item__tag--risk { background: rgba(220, 38, 38, 0.15); color: #f87171; }
html.dark .insight-item__tag--supplier { background: rgba(147, 51, 234, 0.15); color: #c084fc; }
html.dark .insight-item__tag--ops { background: rgba(2, 132, 199, 0.15); color: #38bdf8; }

/* Insights grid responsive */
@media (max-width: 900px) {
    .insights-timeline__feed { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
    .insights-timeline__feed { grid-template-columns: 1fr; }
}

/* ============================================
   SUPER RESPONSIVE — Complete Mobile/Tablet
   ============================================ */

/* ---- Mobile hamburger button ---- */
.mobile-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: #f5f7fa;
    color: #64748b;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.mobile-menu-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}
html.dark .mobile-menu-btn {
    background: #334155;
    color: #94a3b8;
}
html.dark .mobile-menu-btn:hover {
    background: #475569;
    color: #e2e8f0;
}

/* ---- Landing page mobile menu button ---- */
.mobile-menu-btn-landing {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 45;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: white;
    color: #64748b;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}
.mobile-menu-btn-landing:hover {
    background: #f5f7fa;
    color: #1e293b;
}
html.dark .mobile-menu-btn-landing {
    background: #1e293b;
    color: #94a3b8;
}

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.sidebar-overlay.hidden {
    display: none;
}

/* ===================================================
   BREAKPOINT: TABLET (max-width: 1024px)
   =================================================== */
@media (max-width: 1024px) {
    /* Landing page — single column */
    .landing-page {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .landing-left {
        padding: 2rem;
        border-radius: 0;
        box-shadow: none;
    }
    .landing-right {
        border-radius: 0;
        padding: 2.5rem 2rem;
        min-height: 400px;
    }

    /* Historial header wraps */
    .historial-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem;
    }
    .historial-header__right {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Operations header wraps */
    .operations-section__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .operations-section__actions {
        width: 100%;
        flex-wrap: wrap;
    }

    /* Charts 3-col becomes 2 then 1 */
    .grid.grid-cols-1.lg\:grid-cols-3 {
        grid-template-columns: 1fr;
    }

    /* Health gauge */
    .health-gauge-container {
        flex-direction: column;
        gap: 20px;
        padding: 20px;
    }
}

/* ===================================================
   BREAKPOINT: MOBILE / SMALL TABLET (max-width: 768px)
   =================================================== */
@media (max-width: 768px) {
    /* Show mobile menu buttons */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* Sidebar becomes a mobile drawer */
    .nav-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        bottom: 0;
        width: 270px;
        min-width: 270px;
        z-index: 50;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        animation: none;
    }
    .nav-sidebar.mobile-open {
        left: 0;
    }
    .nav-sidebar.hidden {
        display: flex !important;
        left: -280px;
    }
    .nav-sidebar.hidden.mobile-open {
        left: 0;
    }

    /* Show overlay when sidebar is open */
    .sidebar-overlay.active {
        display: block;
    }

    /* Show landing menu button when sidebar is active */
    #app.sidebar-active .mobile-menu-btn-landing {
        display: flex;
    }

    /* On sidebar-active, landing right is hidden, keep that */
    #app.sidebar-active .landing-right {
        display: none;
    }
    #app.sidebar-active .landing-page {
        grid-template-columns: 1fr;
        min-height: calc(100vh + 3rem);
        margin: -0.75rem;
    }
    #app.sidebar-active .landing-left {
        padding: 2rem 1rem;
    }

    /* Landing page */
    .landing-left {
        padding: 1.5rem 1rem;
    }
    .landing-left-inner {
        max-width: 100%;
    }
    .landing-left-inner h2 {
        font-size: 2rem !important;
    }
    .landing-right {
        padding: 2rem 1.25rem;
        min-height: 350px;
    }
    .landing-right-inner {
        max-width: 100%;
    }
    .landing-login-bar {
        padding: 0.5rem 1rem 0.5rem 1.25rem;
    }
    .landing-mockup {
        padding: 10px 12px;
    }
    .landing-mockup .grid.grid-cols-3 .text-\[15px\] {
        font-size: 12px;
    }

    /* Top bar compact */
    #top-bar {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    #topbar-branding {
        display: none !important;
    }

    /* Main content padding */
    main {
        padding: 0.75rem !important;
    }

    /* KPI value font size on mobile */
    .kpi-card__value {
        font-size: 1.25rem;
    }

    /* Tab navigation — horizontal scroll */
    .tab-nav-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px 5px;
        gap: 0.25rem;
    }
    .tab-nav-container::-webkit-scrollbar {
        display: none;
    }
    .tab-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    /* Charts — full width */
    .grid.grid-cols-1.lg\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    /* Chart containers — smaller padding */
    .chart-container__header {
        padding: 0.625rem 0.875rem;
    }
    .chart-container__body {
        padding: 0.75rem;
    }
    .chart-container__title {
        font-size: 0.75rem;
    }

    /* Ficha Tecnica — 2 cols on mobile */
    #ficha-content .grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Operations table — smaller padding, scroll */
    .operations-table-card > .overflow-x-auto {
        padding: 0.5rem !important;
    }
    table.dataTable thead th {
        padding: 0.625rem 0.5rem !important;
        font-size: 0.6rem !important;
    }
    table.dataTable tbody td {
        padding: 0.5rem !important;
        font-size: 0.7rem !important;
    }

    /* DataTables controls stack */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        float: none !important;
        text-align: left !important;
        margin-bottom: 0.5rem !important;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.25rem !important;
    }
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
    }
    .dataTables_wrapper .dataTables_info {
        float: none !important;
        text-align: center !important;
    }

    /* Filter bar stacks */
    .hist-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .hist-filter-bar__icon { display: none; }
    .hist-filter-bar__controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    .hist-filter-group { width: 100%; }
    .hist-filter-select,
    .hist-filter-input { width: 100%; min-width: 0; }
    .hist-filter-bar__actions {
        justify-content: stretch;
    }
    .hist-filter-bar__actions .hist-filter-btn {
        flex: 1;
        justify-content: center;
    }

    /* Historial header */
    .historial-header {
        padding: 1rem;
        border-radius: 12px;
    }
    .historial-header__title {
        font-size: 1.125rem;
    }
    .historial-header__right {
        flex-wrap: wrap;
        width: 100%;
    }

    /* Chatbot panel — full width, full height */
    .chatbot-panel.open {
        width: 100% !important;
    }
    #main-content.chatbot-active {
        margin-right: 0 !important;
    }
    .chatbot-toggle-shifted {
        right: 1.5rem !important;
        bottom: 1.5rem !important;
        top: auto !important;
    }

    /* Chatbot toggle button — smaller on mobile */
    #chatbot-toggle {
        width: 48px;
        height: 48px;
        right: 1rem;
        bottom: 1rem;
        border-radius: 1rem;
    }
    #chatbot-toggle i {
        font-size: 1rem;
    }

    /* Auth modal — more padding */
    #auth-card {
        max-width: calc(100vw - 2rem);
        border-radius: 1.25rem;
    }

    /* Progress modal */
    #progress-card {
        max-width: calc(100vw - 2rem);
    }

    /* Anomaly cards grid */
    #hist-anomaly-section .grid {
        grid-template-columns: 1fr !important;
    }

    /* Period comparison */
    #hist-period-comparison .grid {
        grid-template-columns: 1fr !important;
    }

    /* Tank stats */
    #hist-tanques-section .grid.grid-cols-2.sm\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* File table scrollable */
    #historial-file-table {
        overflow-x: auto;
    }
    #historial-file-table table {
        min-width: 600px;
    }

    /* Toast notifications */
    .toast {
        left: 1rem;
        right: 1rem;
        max-width: none;
        top: auto;
        bottom: 1rem;
    }
    .toast.show { transform: translateX(0) translateY(0); }

    /* Chatbot quick actions scroll */
    #chatbot-quick-actions {
        max-height: 80px;
    }
    #chatbot-quick-actions .flex {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    #chatbot-quick-actions .flex::-webkit-scrollbar {
        display: none;
    }
    .chatbot-quick-btn {
        font-size: 0.625rem;
        padding: 0.25rem 0.5rem;
        flex-shrink: 0;
    }

    /* Delete modal */
    .delete-modal-card {
        max-width: calc(100vw - 2rem);
    }
}

/* ===================================================
   BREAKPOINT: SMALL MOBILE (max-width: 480px)
   =================================================== */
@media (max-width: 480px) {
    /* Landing - even more compact */
    .landing-left {
        padding: 1rem 0.75rem;
    }
    .landing-left-inner h2 {
        font-size: 1.6rem !important;
        line-height: 1.15 !important;
    }
    .landing-left-inner p {
        font-size: 13px !important;
    }
    .landing-right {
        padding: 1.5rem 1rem;
        min-height: 280px;
    }

    /* Drop zone — compact */
    #drop-zone {
        padding: 1.25rem !important;
    }
    #drop-zone .w-16 {
        width: 3rem !important;
        height: 3rem !important;
    }
    #drop-zone h3 {
        font-size: 13px !important;
    }
    #drop-zone label {
        padding: 0.625rem 1.25rem !important;
        font-size: 12px !important;
    }

    /* Feature cards — compact */
    .landing-feature-card {
        padding: 0.5rem 0.625rem;
    }
    .landing-feature-card p:first-child {
        font-size: 12px;
    }
    .landing-feature-card p:last-child {
        font-size: 10px;
    }

    /* Mockup — hide on very small */
    .landing-mockup .grid.grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
    }

    /* KPI cards — stacked */
    .kpi-card {
        padding: 0.875rem 1rem;
    }
    .kpi-card__value {
        font-size: 1.125rem;
    }
    .kpi-card__label {
        font-size: 0.625rem;
    }
    .kpi-card__icon {
        width: 28px;
        height: 28px;
        font-size: 0.625rem;
    }

    /* Main padding */
    main {
        padding: 0.5rem !important;
    }
    #dashboard-content {
        gap: 0.75rem;
    }

    /* Chart height on mobile */
    .chart-container__body .relative {
        height: 220px !important;
    }
    .chart-container__body .relative[style*="height: 260px"] {
        height: 200px !important;
    }
    .chart-container__body canvas {
        max-height: 220px;
    }

    /* Ficha Tecnica — single col on very small */
    #ficha-content .grid {
        grid-template-columns: 1fr !important;
    }
    #ficha-toggle {
        padding: 0.625rem 0.875rem;
    }

    /* Tab navigation */
    .tab-btn {
        padding: 0.35rem 0.625rem;
        font-size: 0.6875rem;
    }
    .tab-btn i {
        display: none;
    }

    /* Operations section */
    .operations-section__title h2 {
        font-size: 0.6875rem;
    }
    .filter-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.625rem;
    }
    .export-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.625rem;
    }

    /* Historial KPI grid — 1 col */
    #historial-content .grid.grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }

    /* Stats cards in Comercial tab — 2 cols */
    .lg\:col-span-2.grid.grid-cols-2.sm\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Auth modal */
    #auth-card {
        margin: 0.5rem;
    }
    #auth-card .px-6 {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    /* Chatbot messages */
    #chatbot-messages .max-w-\[85\%\] {
        max-width: 92% !important;
    }

    /* Chatbot input */
    #chatbot-input {
        font-size: 14px !important;
    }

    /* Landing login bar */
    .landing-login-bar {
        padding: 0.375rem 0.75rem 0.375rem 1rem;
    }
    .landing-login-bar span {
        font-size: 11px;
    }

    /* Section labels */
    .section-label__text {
        font-size: 0.5625rem;
    }

    /* Historial header buttons */
    .historial-report-btn,
    .historial-notif-btn,
    .historial-ai-btn {
        height: 28px;
        padding: 0 10px;
        font-size: 10px;
    }
    .historial-badge {
        font-size: 10px;
        padding: 0.25rem 0.5rem;
    }

    /* Period comparison cards */
    .comparison-card {
        padding: 12px;
    }

    /* Projection card */
    .projection-card {
        padding: 14px 16px;
    }
    .projection-item {
        gap: 8px;
        padding: 6px 0;
    }

    /* SAT audit panel */
    .sat-audit-panel {
        padding: 14px;
    }

    /* Health gauge */
    .health-gauge-container {
        padding: 16px;
        gap: 16px;
    }
    .health-gauge {
        width: 110px;
        height: 110px;
    }
    .health-gauge__svg {
        width: 110px;
        height: 110px;
    }
    .health-gauge__score {
        font-size: 22px;
    }
    .health-bar__label {
        width: 80px;
        font-size: 10px;
    }

    /* Chatbot markdown in small screens */
    .chatbot-markdown {
        font-size: 0.75rem;
    }
    .cm-cards {
        grid-template-columns: 1fr;
    }
}

/* ===================================================
   BREAKPOINT: BETWEEN TABLET AND DESKTOP (769-1024)
   =================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Show hamburger on tablet too */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* Sidebar as drawer on tablet */
    .nav-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        bottom: 0;
        width: 270px;
        z-index: 50;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        animation: none;
    }
    .nav-sidebar.mobile-open {
        left: 0;
    }
    .nav-sidebar.hidden {
        display: flex !important;
        left: -280px;
    }
    .nav-sidebar.hidden.mobile-open {
        left: 0;
    }

    #app.sidebar-active .mobile-menu-btn-landing {
        display: flex;
    }

    /* Landing page adjustments */
    .landing-left {
        padding: 2rem 1.5rem;
    }
    .landing-right {
        padding: 2rem 1.5rem;
    }
    .landing-left-inner h2 {
        font-size: 2.25rem !important;
    }

    /* Keep top bar branding hidden on tablet when sidebar active */
    #app.sidebar-active #topbar-branding {
        display: none;
    }
}

/* ===================================================
   BREAKPOINT: LARGE SCREENS (min-width: 1025px)
   =================================================== */
@media (min-width: 1025px) {
    /* Hide mobile elements */
    .mobile-menu-btn {
        display: none !important;
    }
    .mobile-menu-btn-landing {
        display: none !important;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* ===================================================
   SAFE AREA (notch) support for modern phones
   =================================================== */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .nav-sidebar {
            padding-top: max(0px, env(safe-area-inset-top));
            padding-bottom: max(0px, env(safe-area-inset-bottom));
        }
        .chatbot-panel {
            padding-top: max(0px, env(safe-area-inset-top));
            padding-bottom: max(0px, env(safe-area-inset-bottom));
        }
        main {
            padding-bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
        }
    }
}

/* ===================================================
   LANDSCAPE phone orientation
   =================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .landing-page {
        grid-template-columns: 50% 50%;
        min-height: 100vh;
    }
    .landing-left {
        padding: 1rem;
    }
    .landing-right {
        padding: 1rem;
        min-height: auto;
    }
    .landing-left-inner h2 {
        font-size: 1.5rem !important;
    }
    #drop-zone {
        padding: 0.75rem !important;
    }
    .kpi-card {
        padding: 0.75rem;
    }
    .kpi-card__value {
        font-size: 1rem;
    }
    .chart-container__body .relative {
        height: 180px !important;
    }
}

/* ===================================================
   PRINT styles — clean output
   =================================================== */
@media print {
    .nav-sidebar,
    #chatbot-toggle,
    .chatbot-panel,
    .mobile-menu-btn,
    .mobile-menu-btn-landing,
    .sidebar-overlay,
    #top-bar {
        display: none !important;
    }
    main {
        overflow: visible !important;
        height: auto !important;
    }
    #app {
        display: block !important;
        height: auto !important;
    }
    #main-content {
        margin-right: 0 !important;
        overflow: visible !important;
    }
    .chart-container,
    .kpi-card {
        break-inside: avoid;
    }
}

/* ===== F4: IA Promo Card ===== */
.ia-promo-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 50%, #2b6cb0 100%);
    border: 1px solid rgba(99, 179, 237, 0.2);
    box-shadow: 0 4px 20px -4px rgba(44, 82, 130, 0.3);
    animation: fadeInUp 0.3s ease forwards;
    cursor: default;
}
.ia-promo-card__icon {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #63b3de 0%, #4299e1 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff;
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.4);
}
.ia-promo-card__text { flex: 1; min-width: 0; }
.ia-promo-card__title {
    font-size: 14px; font-weight: 700; color: #fff;
    margin: 0 0 2px;
}
.ia-promo-card__subtitle {
    font-size: 12px; color: rgba(255,255,255,0.6);
    margin: 0; line-height: 1.4;
}
.ia-promo-card__btn {
    flex-shrink: 0;
    padding: 8px 20px;
    border-radius: 10px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: #fff; font-size: 12px; font-weight: 600;
    border: none; cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(56, 161, 105, 0.3);
    white-space: nowrap;
}
.ia-promo-card__btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(56, 161, 105, 0.5);
}
html.dark .ia-promo-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1a365d 100%);
    border-color: rgba(99, 179, 237, 0.15);
}
@media (max-width: 640px) {
    .ia-promo-card { flex-direction: column; text-align: center; padding: 16px; }
    .ia-promo-card__btn { width: 100%; }
}

/* ===== F9: Inventario Final Card ===== */
.inventario-final-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}
.inventario-final-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.inv-final-stat {
    text-align: center;
    padding: 10px 8px;
    border-radius: 10px;
    background: #f8fafc;
}
.inv-final-stat__value {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}
.inv-final-stat__label {
    font-size: 9px;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.05em;
    margin-top: 2px;
}
.inv-final-tank-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f8fafc;
}
.inv-final-bar {
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    overflow: hidden;
    margin-top: 4px;
}
.inv-final-bar__fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #14b8a6, #06b6d4);
    transition: width 0.5s ease;
}
html.dark .inventario-final-card {
    background: #1e293b;
    border-color: #334155;
}
html.dark .inventario-final-card h4 { color: #f1f5f9; }
html.dark .inv-final-stat { background: #0f172a; }
html.dark .inv-final-stat__value { color: #e2e8f0; }
html.dark .inv-final-tank-row { background: #0f172a; }
html.dark .inv-final-bar { background: #334155; }

/* ===== F3: Date filter in sidebar ===== */
.sidebar-date-input {
    cursor: pointer;
}
.sidebar-date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.5;
}
html.dark .sidebar-date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
}
.sidebar-search-wrap {
    position: relative;
}
.sidebar-date-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: #e2e8f0;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.sidebar-date-clear:hover {
    background: #cbd5e1;
    color: #334155;
}
html.dark .sidebar-date-clear {
    background: #334155;
    color: #94a3b8;
}
html.dark .sidebar-date-clear:hover {
    background: #475569;
}

/* ===== F6: Station Selector ===== */
.sidebar-estacion-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
}
.estacion-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 11px;
    color: #334155;
    background: #f8fafc;
    cursor: pointer;
    outline: none;
}
.estacion-select:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
.estacion-edit-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.estacion-edit-btn:hover {
    background: #e2e8f0;
    color: #475569;
}
html.dark .estacion-select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
html.dark .estacion-edit-btn {
    background: #0f172a;
    border-color: #334155;
    color: #64748b;
}
html.dark .estacion-edit-btn:hover {
    background: #1e293b;
    color: #94a3b8;
}
/* Station name label */
.estacion-name-label {
    flex: 1;
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.estacion-name-label i {
    color: #6366f1;
    margin-right: 4px;
}
html.dark .estacion-name-label {
    color: #94a3b8;
}
html.dark .estacion-name-label i {
    color: #818cf8;
}
/* Big rename button */
.estacion-rename-btn {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: #6366f1;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.estacion-rename-btn i {
    margin-right: 4px;
    font-size: 9px;
}
.estacion-rename-btn:hover {
    background: #4f46e5;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
html.dark .estacion-rename-btn {
    background: #818cf8;
    color: #0f172a;
}
html.dark .estacion-rename-btn:hover {
    background: #6366f1;
    color: white;
}
/* Alias editor modal */
.alias-editor-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-out;
}
.alias-editor-card {
    width: 100%;
    max-width: 400px;
    margin: 0 16px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.25s ease-out;
}
.alias-editor-save-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.alias-editor-save-btn:hover {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
html.dark .alias-editor-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

/* Rename button in KPI estacion card */
.kpi-rename-btn {
    padding: 3px 10px;
    font-size: 10px;
    font-weight: 600;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.kpi-rename-btn i {
    font-size: 8px;
}
.kpi-rename-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
}
html.dark .kpi-rename-btn {
    color: #818cf8;
    background: rgba(129, 140, 248, 0.1);
    border-color: rgba(129, 140, 248, 0.25);
}
html.dark .kpi-rename-btn:hover {
    background: rgba(129, 140, 248, 0.2);
    border-color: rgba(129, 140, 248, 0.5);
}

/* ===== F8: Product Group Headers in Table ===== */
.product-group-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}
.product-group-header td {
    background: #f1f5f9 !important;
    font-weight: 600;
    font-size: 13px;
    color: #334155;
    padding: 10px 16px !important;
    border-bottom: 2px solid #e2e8f0 !important;
}
.product-group-header:hover td {
    background: #e2e8f0 !important;
}
.product-group-header .group-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    font-size: 10px;
    margin-right: 8px;
    transition: transform 0.2s;
}
.product-group-header.collapsed .group-toggle {
    transform: rotate(-90deg);
}
.product-group-row {
    transition: opacity 0.15s;
}
.product-group-header.collapsed ~ .product-group-row {
    display: none;
}
html.dark .product-group-header td {
    background: #1e293b !important;
    color: #e2e8f0;
    border-bottom-color: #334155 !important;
}
html.dark .product-group-header:hover td {
    background: #334155 !important;
}
html.dark .product-group-header .group-toggle {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}
