/* ============================================================
   Facturas CPyEM — Light Theme
   Inspired by: clean fintech dashboard, white cards, soft shadows
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #eef0f5;
    --bg-secondary: #f5f6fa;
    --bg-card: #ffffff;
    --bg-input: #f8f9fc;
    --bg-sidebar: #ffffff;

    --text-primary: #1a1d2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-placeholder: #b0b8c9;

    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-light: rgba(99, 102, 241, 0.08);

    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.09);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.09);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.09);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.09);

    --border-color: #e5e7eb;
    --border-focus: rgba(99, 102, 241, 0.4);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 4px rgba(0, 0, 0, .06);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, .08);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, .10);

    --sidebar-width: 240px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
    font-size: .85rem;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    padding: 1.4rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.logo-img {
    max-width: 100%;
    height: auto;
    max-height: 80px;
    object-fit: contain;
    transition: var(--transition);
}

.logo:hover .logo-img {
    transform: scale(1.05);
}


.sidebar-nav {
    flex: 1;
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .9rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--accent-light);
    color: var(--accent-primary);
}

.nav-link.active {
    background: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 600;
    border-left: 3px solid var(--accent-primary);
}

.nav-icon {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: .9rem .75rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .4rem .5rem;
    margin-bottom: .4rem;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: white;
    flex-shrink: 0;
}

.user-avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .7rem;
    color: white;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-email {
    font-size: .78rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .68rem;
    margin-top: 2px;
}

.logout-link {
    color: var(--danger) !important;
}

.logout-link:hover {
    background: var(--danger-bg) !important;
    color: var(--danger) !important;
}

.app-version {
    font-size: .68rem;
    color: var(--text-muted);
    text-align: center;
    padding: .5rem 0 0;
    margin-top: .75rem;
    border-top: 1px dashed var(--border-color);
    letter-spacing: .02em;
    font-weight: 500;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem 2.25rem;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: calc(100vw - var(--sidebar-width));
}

.main-fullscreen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: var(--bg-primary);
}

/* ============================================================
   Cards
   ============================================================ */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.glass-card:hover {
    box-shadow: var(--shadow-lg);
}

.card {
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.3rem;
    padding-bottom: .9rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: .4rem;
}

/* ============================================================
   Page Headers
   ============================================================ */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: .2rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: .875rem;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .18rem .55rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.badge-admin {
    background: rgba(99, 102, 241, .1);
    color: var(--accent-primary);
}

.badge-user {
    background: rgba(5, 150, 105, .1);
    color: var(--success);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.text-danger {
    color: var(--danger) !important;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    margin-bottom: .35rem;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: .75rem;
    font-size: .9rem;
    pointer-events: none;
    z-index: 1;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: .65rem .9rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: .875rem;
    transition: var(--transition);
    outline: none;
}

.input-wrapper input,
.input-wrapper textarea,
.input-wrapper select {
    padding-left: 2.4rem;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--border-focus);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-placeholder);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
}

.form-hint {
    display: block;
    margin-top: .25rem;
    font-size: .75rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.toggle-password {
    position: absolute;
    right: .75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .65rem 1.4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, .25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
    color: white;
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: #d1d5db;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: .35rem .8rem;
    font-size: .78rem;
}

/* ============================================================
   Flash Messages
   ============================================================ */
.flash-container {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.flash {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .75rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    cursor: pointer;
    animation: flash-in .25s ease-out;
    border: 1px solid transparent;
}

@keyframes flash-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flash-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(5, 150, 105, .2);
    border-left: 3px solid var(--success);
}

.flash-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(220, 38, 38, .2);
    border-left: 3px solid var(--danger);
}

.flash-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(217, 119, 6, .2);
    border-left: 3px solid var(--warning);
}

.flash-info {
    background: var(--info-bg);
    color: var(--info);
    border-color: rgba(37, 99, 235, .2);
    border-left: 3px solid var(--info);
}

.flash-icon {
    font-size: 1rem;
}

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: .6;
    padding: 0;
}

.flash-close:hover {
    opacity: 1;
}

/* ============================================================
   Login Page
   ============================================================ */
.main-fullscreen {
    background: var(--bg-primary);
}

.login-container {
    position: relative;
    width: 100%;
    max-width: 420px;
}

.login-card {
    padding: 2.5rem;
    position: relative;
    z-index: 2;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-img {
    max-width: 180px;
    height: auto;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
    animation: float 6s ease-in-out infinite;
}


@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.login-header h1 {
    font-size: 1.45rem;
    font-weight: 300;
    color: var(--text-secondary);
}

.login-header h1 strong {
    color: var(--accent-primary);
    font-weight: 700;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: .82rem;
    margin-top: .2rem;
}

.login-form {
    margin-bottom: 1rem;
}

.login-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    font-size: .75rem;
    color: var(--text-muted);
}

/* Light subtle background blobs for login */
.login-bg-shapes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .12;
}

.shape-1 {
    width: 350px;
    height: 350px;
    background: var(--accent-primary);
    top: -80px;
    right: -80px;
    animation: drift 10s ease-in-out infinite;
}

.shape-2 {
    width: 250px;
    height: 250px;
    background: #8b5cf6;
    bottom: -60px;
    left: -60px;
    animation: drift 13s ease-in-out infinite reverse;
}

.shape-3 {
    width: 180px;
    height: 180px;
    background: #06b6d4;
    top: 50%;
    left: 50%;
    animation: drift 15s ease-in-out infinite;
}

@keyframes drift {

    0%,
    100% {
        transform: translate(0, 0);
    }

    33% {
        transform: translate(25px, -25px);
    }

    66% {
        transform: translate(-18px, 18px);
    }
}

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Category selector */
.category-select-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.category-input-grow {
    flex: 1;
}

.btn-add-category {
    padding: .65rem .85rem;
    font-size: 1.1rem;
    flex-shrink: 0;
    line-height: 1;
}

.add-category-form {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .7rem;
    padding: .7rem;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    animation: flash-in .18s ease-out;
}

.add-category-form .input-wrapper {
    flex: 1;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2.25rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    margin-bottom: 1.1rem;
    background: var(--bg-secondary);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.drop-zone.drag-over {
    transform: scale(1.01);
}

.drop-zone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-icon {
    font-size: 2.5rem;
    margin-bottom: .5rem;
    opacity: .6;
}

.drop-zone-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .2rem;
}

.drop-zone-subtitle {
    font-size: .82rem;
    color: var(--text-muted);
}

.drop-zone-preview {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.file-icon {
    font-size: 1.5rem;
}

.file-name {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: .75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-remove-file {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

.btn-remove-file:hover {
    color: var(--danger);
}

/* ============================================================
   Activity Log
   ============================================================ */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.activity-item {
    display: grid;
    grid-template-columns: 32px 1fr auto auto;
    grid-template-rows: auto auto;
    gap: .1rem .75rem;
    align-items: center;
    padding: .8rem .6rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.activity-item:hover {
    background: var(--bg-secondary);
}

.activity-icon {
    font-size: 1.1rem;
    grid-row: span 2;
}

.activity-info {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    overflow: hidden;
}

.activity-filename {
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-detail {
    font-size: .75rem;
    color: var(--text-muted);
}

.activity-actions {
    grid-row: span 2;
}

.activity-meta {
    grid-column: 2;
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

.activity-user {
    font-size: .72rem;
    color: var(--text-muted);
}

.activity-time {
    font-size: .72rem;
    color: var(--text-muted);
}

.btn-view-pdf {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .7rem;
    border-radius: var(--radius-sm);
    font-size: .75rem;
    font-weight: 500;
    background: var(--accent-light);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, .2);
    transition: var(--transition);
    text-decoration: none;
}

.btn-view-pdf:hover {
    background: rgba(99, 102, 241, .15);
    color: var(--accent-hover);
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .75rem;
    opacity: .5;
}

.empty-state p {
    font-size: .875rem;
}

/* ============================================================
   Admin — Users Table
   ============================================================ */
.users-table-wrapper {
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.users-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.users-table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
}

.users-table tbody tr:last-child td {
    border-bottom: none;
}

.users-table tbody tr:hover {
    background: var(--bg-secondary);
}

.user-email-cell {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.table-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.btn-edit {
    padding: .3rem .7rem;
    font-size: .75rem;
    font-weight: 500;
    background: rgba(37, 99, 235, .08);
    color: var(--info);
    border: 1px solid rgba(37, 99, 235, .2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}

.btn-edit:hover {
    background: rgba(37, 99, 235, .15);
    color: var(--info);
}

.btn-danger {
    padding: .3rem .7rem;
    font-size: .75rem;
    font-weight: 500;
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, .2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}

.btn-danger:hover {
    background: rgba(220, 38, 38, .18);
}

/* ============================================================
   Review Page
   ============================================================ */
.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.review-field-group {
    padding: .9rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-color);
    margin-bottom: .75rem;
}

.review-field-group.missing {
    border-left-color: var(--warning);
    background: var(--warning-bg);
}

.review-field-group label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .4rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.review-field-group input {
    background: #fff;
}

/* ============================================================
   Error Page
   ============================================================ */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 5rem;
    font-weight: 800;
    color: var(--accent-primary);
    opacity: .3;
    line-height: 1;
}

.error-page p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 1rem 0 2rem;
}

/* ============================================================
   KPI + Chart (Dashboard extra)
   ============================================================ */
.stats-section {
    margin-top: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1.1rem 1.3rem;
}

.kpi-icon {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.kpi-body {
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.kpi-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: -.02em;
}

.chart-card {
    padding-bottom: 1.4rem;
    height: 100%;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.chart-wrapper {
    padding: .75rem 1rem 0;
    position: relative;
    height: 260px;
}

.chart-empty {
    text-align: center;
    color: var(--text-muted);
    margin-top: .5rem;
    font-size: .85rem;
}

/* ============================================================
   Invoice Table (facturas.html)
   ============================================================ */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    padding: .75rem 0 0;
}

.table-wrapper {
    display: block;
    width: 100%;
    overflow-x: scroll !important;
    /* Force visibility for debugging */
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-radius: var(--radius-sm);
}

/* Custom Scrollbar for modern feel */
.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    /* Use accent color for better visibility */
    border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.invoice-table {
    width: 100%;
    min-width: 1100px;
    /* Increased to ensure overflow on most screens */
    border-collapse: collapse;
    font-size: .85rem;
}

.invoice-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.invoice-table td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
}

.invoice-table tbody tr:last-child td {
    border-bottom: none;
}

.invoice-table tbody tr:hover {
    background: var(--bg-secondary);
}

.invoice-table tfoot td {
    border-top: 2px solid var(--border-color);
    border-bottom: none;
    font-weight: 600;
    padding-top: .9rem;
}

.text-right {
    text-align: right !important;
}

.nowrap {
    white-space: nowrap;
}

.mono {
    font-family: 'Courier New', monospace;
    letter-spacing: .02em;
}

.amount {
    color: var(--success);
    font-weight: 600;
}

.provider-cell,
.concept-cell {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.actions-cell {
    text-align: center;
}

.btn-view-pdf {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .65rem;
    border-radius: var(--radius-sm);
    font-size: .75rem;
    font-weight: 500;
    background: var(--accent-light);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, .2);
    transition: var(--transition);
    text-decoration: none;
}

.btn-view-pdf:hover {
    background: rgba(99, 102, 241, .15);
    color: var(--accent-hover);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .review-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 1.25rem 1rem;
        margin-left: 0;
        max-width: 100vw;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================
   @Media Print Rules for Infographic
   ============================================================ */
@media print {

    /* Hide non-essential elements */
    .sidebar,
    .upload-section,
    .activity-section,
    .no-print,
    .flash-container,
    .page-subtitle,
    .page-header,
    .dashboard-grid {
        display: none !important;
    }

    /* Reset background and padding for the main area */
    body {
        background: white !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* Force background colors to print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Optimize stats section layout */
    .stats-section {
        margin-top: 0 !important;
        display: block !important;
    }

    /* KPI Grid layout for print */
    .kpi-grid {
        display: flex !important;
        justify-content: space-between !important;
        margin-bottom: 2rem !important;
    }

    .kpi-card {
        flex: 1;
        margin: 0 0.5rem;
        border: 1px solid #e5e7eb !important;
        box-shadow: none !important;
    }

    /* Adjust Charts Grid */
    .charts-container {
        display: block !important;
    }

    .chart-card {
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 2rem !important;
        border: 1px solid #e5e7eb !important;
        box-shadow: none !important;
    }

    .chart-wrapper {
        height: 300px !important;
    }
}

/* ============================================================
   Mobile Responsiveness
   ============================================================ */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 110;
    box-shadow: var(--shadow-sm);
}

.mobile-logo .logo-img {
    height: 45px;
    max-height: 45px;
    object-fit: contain;
}

.mobile-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-toggle span {
    width: 24px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
        width: 100%;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        width: 260px;
        z-index: 120;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem 0.5rem;
        max-width: 100vw;
    }

    .card {
        padding: 1rem;
    }

    .dashboard-grid,
    .form-row,
    .review-grid {
        grid-template-columns: 1fr !important;
    }

    .filter-grid {
        grid-template-columns: 1fr !important;
    }

    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }
}