:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --dark: #0f172a;
    --light-bg: #f8fafc;
    --sidebar-bg: #1e293b;
    --border: #e2e8f0;
    --text-muted: #64748b;
}

* { font-family: 'Inter', sans-serif; }
body { background: var(--light-bg); color: #1e293b; }

/* Auth pages */
.auth-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.auth-container { width: 100%; max-width: 450px; }
.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-logo {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 25px rgba(79,70,229,.3);
}
.auth-header h2 { font-weight: 700; margin-bottom: .5rem; }

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    left: 0; top: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .3s;
}
.sidebar .brand {
    padding: 1.5rem;
    border-bottom: 1px solid #334155;
}
.logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
}
.sidebar .brand h4 { color: #fff; font-size: 1.1rem; font-weight: 700; }
.sidebar .brand small { color: #94a3b8; }

.tenant-info {
    padding: 1rem 1.5rem;
    background: rgba(255,255,255,.03);
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}
.sidebar .nav-link {
    color: #cbd5e1;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .9rem;
    transition: all .2s;
    border-left: 3px solid transparent;
}
.sidebar .nav-link:hover {
    background: #334155;
    color: #fff;
}
.sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(79,70,229,.2), transparent);
    color: #fff;
    border-left-color: var(--primary);
}
.sidebar .nav-link i { font-size: 1.1rem; width: 20px; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #334155;
}
.user-info {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: .9rem;
}
.user-details { flex: 1; }
.user-name { color: #fff; font-size: .875rem; font-weight: 500; }
.user-role { color: #94a3b8; }
.logout-btn {
    color: #94a3b8;
    padding: .5rem;
    border-radius: 8px;
    transition: all .2s;
}
.logout-btn:hover { background: #334155; color: #fff; }

.sidebar-toggle {
    position: fixed;
    top: 1rem; left: 1rem;
    z-index: 1001;
    background: var(--primary);
    color: #fff;
    border: none;
    width: 40px; height: 40px;
    border-radius: 10px;
    display: none;
}

/* Main content */
.main-content {
    margin-left: 260px;
    padding: 1.5rem;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Cards */
.card-custom {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    overflow: hidden;
}
.card-custom-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.card-custom-body { padding: 1.5rem; }
.card-custom-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

.card-stat {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    transition: all .2s;
}
.card-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,.08);
}
.card-stat .icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.card-stat h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: .75rem 0 .25rem;
}
.card-stat p { color: var(--text-muted); margin: 0; font-size: .85rem; }

/* Buttons */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: #fff;
    padding: .6rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all .2s;
}
.btn-primary-custom:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(79,70,229,.3);
    color: #fff;
}

/* Tables */
.table-custom { background: #fff; }
.table-custom thead { background: #f8fafc; }
.table-custom th {
    font-weight: 600;
    color: #475569;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.table-custom td {
    vertical-align: middle;
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
}
.table-custom tbody tr:hover { background: #fafbfc; }

/* Badges */
.badge-status {
    padding: .35rem .75rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 500;
}
.badge-draft { background: #e2e8f0; color: #475569; }
.badge-issued { background: #dbeafe; color: #1e40af; }
.badge-sent { background: #e0e7ff; color: #4338ca; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-canceled { background: #f3f4f6; color: #6b7280; }

/* Summary */
.summary-row {
    display: flex;
    justify-content: space-between;
    padding: .5rem 0;
}
.total-row {
    font-size: 1.25rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
    margin-top: .5rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: .75rem 0;
    border-bottom: 1px solid #f1f5f9;
}
.summary-item:last-child { border-bottom: none; }

/* Invoice preview */
.invoice-preview {
    border-radius: 12px;
    max-width: 900px;
    margin: 0 auto;
}

/* Pricing */
.pricing-card {
    transition: all .3s;
    border: 2px solid transparent;
}
.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,.1);
}
.pricing-card.border-primary { border-color: var(--primary); }

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    padding: .6rem .9rem;
    border: 1px solid var(--border);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-label {
    font-weight: 500;
    font-size: .875rem;
    color: #475569;
    margin-bottom: .4rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 4rem; }
    .sidebar-toggle { display: block; }
    .topbar { flex-direction: column; align-items: stretch; }
}

/* Print */
@media print {
    .sidebar, .topbar, .btn { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .invoice-preview { box-shadow: none; }
}

/* Notificaciones */
.notifications-dropdown {
    position: relative;
    border-top: 1px solid #334155;
    border-bottom: 1px solid #334155;
}
.notif-badge {
    position: absolute;
    top: 10px;
    right: 15px;
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}
.notif-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    margin-bottom: 10px;
    overflow: hidden;
    z-index: 1001;
}
.notif-header {
    padding: 12px 15px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notif-list {
    max-height: 400px;
    overflow-y: auto;
}
.notif-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
    cursor: pointer;
    transition: background .2s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; }
.notif-item .icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.notif-item .icon.info { background: #dbeafe; color: #1e40af; }
.notif-item .icon.success { background: #d1fae5; color: #065f46; }
.notif-item .icon.warning { background: #fef3c7; color: #92400e; }
.notif-item .icon.danger { background: #fee2e2; color: #991b1b; }
.notif-item .content { flex: 1; min-width: 0; }
.notif-item .title { font-weight: 600; font-size: 13px; color: #1e293b; margin-bottom: 2px; }
.notif-item .message { font-size: 12px; color: #64748b; line-height: 1.4; }
.notif-item .time { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.notif-empty { padding: 30px 15px; text-align: center; color: #94a3b8; }

/* Árbol de categorías */
.category-tree { max-height: 350px; overflow-y: auto; }
.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 6px;
    background: #fff;
    transition: all .2s;
}
.category-item:hover {
    border-color: var(--primary);
    background: #f8fafc;
}
.category-item .info {
    flex: 1;
    min-width: 0;
}
.category-item .name {
    font-weight: 500;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 6px;
}
.category-item .name i { color: var(--primary); }
.category-item .meta {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}
.category-item .actions {
    display: flex;
    gap: 4px;
}
.category-item.subcategory {
    margin-left: 24px;
    border-left: 3px solid var(--primary);
}
.category-empty {
    text-align: center;
    padding: 30px 15px;
    color: #94a3b8;
}
.category-empty i { font-size: 2.5rem; display: block; margin-bottom: 10px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.card-custom, .card-stat { animation: fadeIn .3s ease; }