/* PXDB - Estilos personalizados */
:root {
    --pxdb-primary: #2563eb;
    --pxdb-primary-dark: #1d4ed8;
    --pxdb-secondary: #64748b;
    --pxdb-success: #16a34a;
    --pxdb-warning: #d97706;
    --pxdb-danger: #dc2626;
    --pxdb-bg: #f1f5f9;
    --pxdb-card: #ffffff;
    --pxdb-text: #1e293b;
    --pxdb-text-muted: #64748b;
    --pxdb-border: #e2e8f0;
    --pxdb-sidebar-w: 240px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--pxdb-bg);
    color: var(--pxdb-text);
    margin: 0;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--pxdb-sidebar-w);
    height: 100vh;
    background: #1e293b;
    color: #e2e8f0;
    padding: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-brand span { color: var(--pxdb-primary); }
.sidebar-nav { padding: 0.75rem 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    color: #fff;
    background: #334155;
    border-left-color: var(--pxdb-primary);
}
.sidebar-nav a svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
}
.sidebar-section {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    margin-top: 0.5rem;
}
.sidebar-footer {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 1rem 1.25rem;
    border-top: 1px solid #334155;
    font-size: 0.8rem;
    color: #64748b;
}
.sidebar-footer a { color: #94a3b8; text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }

/* Main content */
.main-content {
    margin-left: var(--pxdb-sidebar-w);
    padding: 2rem;
    min-height: 100vh;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* Cards */
.card {
    background: var(--pxdb-card);
    border: 1px solid var(--pxdb-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--pxdb-card);
    border: 1px solid var(--pxdb-border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--pxdb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .stat-sub {
    font-size: 0.8rem;
    color: var(--pxdb-text-muted);
    margin-top: 0.25rem;
}
.stat-primary .stat-value { color: var(--pxdb-primary); }
.stat-success .stat-value { color: var(--pxdb-success); }
.stat-warning .stat-value { color: var(--pxdb-warning); }
.stat-danger .stat-value { color: var(--pxdb-danger); }

/* Charts grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.chart-card {
    background: var(--pxdb-card);
    border: 1px solid var(--pxdb-border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chart-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--pxdb-text);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--pxdb-border);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
th {
    background: #f8fafc;
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--pxdb-border);
    white-space: nowrap;
    color: var(--pxdb-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--pxdb-border);
    vertical-align: middle;
}
tr:hover td { background: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-pagado { background: #dcfce7; color: #15803d; }
.badge-pendiente { background: #fef3c7; color: #b45309; }
.badge-write_off { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-red { background: #fee2e2; color: #b91c1c; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.5;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--pxdb-primary); color: #fff; }
.btn-primary:hover { background: var(--pxdb-primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--pxdb-text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-success { background: var(--pxdb-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--pxdb-warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-danger { background: var(--pxdb-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-outline {
    background: transparent;
    border-color: var(--pxdb-border);
    color: var(--pxdb-text);
}
.btn-outline:hover { background: #f1f5f9; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pxdb-text);
    margin-bottom: 0.3rem;
}
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--pxdb-border);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--pxdb-text);
    background: #fff;
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--pxdb-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--pxdb-border);
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.search-bar .form-control {
    width: auto;
    min-width: 250px;
}
.filter-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    margin-top: 1rem;
    justify-content: center;
}
.pagination a, .pagination span {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--pxdb-border);
    border-radius: 6px;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--pxdb-text);
}
.pagination a:hover { background: #e2e8f0; }
.pagination .active {
    background: var(--pxdb-primary);
    color: #fff;
    border-color: var(--pxdb-primary);
}

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}
.login-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}
.login-card h1 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 0.25rem;
}
.login-card p {
    text-align: center;
    color: var(--pxdb-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}
.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 0.65rem;
    font-size: 1rem;
}

/* Año selector */
.year-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.year-selector select {
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--pxdb-border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; }
    .charts-grid { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .hamburger { display: block !important; }
}
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--pxdb-text);
}

/* Money formatting */
.money { font-variant-numeric: tabular-nums; }

/* Top clientes mini table */
.mini-table { font-size: 0.85rem; }
.mini-table td { padding: 0.4rem 0.75rem; }
.mini-table th { padding: 0.5rem 0.75rem; }
