/* ============================================
   سیستم مدیریت اجاره - نسخه فوق‌مدرن و پریمیوم
   Rental Management System - Premium Modern UI
   ============================================ */

:root {
    /* Primary Palette - Deep Indigo + Cyan */
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #818cf8;
    --primary-soft: rgba(79, 70, 229, 0.12);
    --secondary: #06b6d4;
    --secondary-soft: rgba(6, 182, 212, 0.12);

    /* Status Colors */
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --info: #0ea5e9;
    --info-soft: rgba(14, 165, 233, 0.12);

    /* Neutrals */
    --dark: #0f172a;
    --dark-2: #1e293b;
    --dark-3: #334155;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --light: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.05);
    --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.15);
    --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.25);

    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    background: #f1f5f9;
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.06) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(6, 182, 212, 0.06) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.04) 0px, transparent 50%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.7;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

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

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #312e81 0%, #4c1d95 40%, #7c3aed 70%, #a855f7 100%);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
    top: -250px;
    right: -200px;
    animation: float 12s ease-in-out infinite;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(6,182,212,0.15) 0%, transparent 70%);
    border-radius: 50%;
    bottom: -150px;
    left: -100px;
    animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 28px;
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(40px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo .icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    border-radius: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 12px 28px rgba(79, 70, 229, 0.4);
    position: relative;
}

.login-logo .icon::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 28px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    opacity: 0.3;
    z-index: -1;
    filter: blur(8px);
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.login-logo p {
    color: var(--gray);
    font-size: 0.95rem;
}

/* ========== App Layout ========== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ========== Sidebar ========== */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 28px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header .logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    position: relative;
}

.nav-item i {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.85;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(6, 182, 212, 0.25));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, #818cf8, #22d3ee);
    border-radius: 0 4px 4px 0;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-right: 280px;
    padding: 32px 36px;
    min-height: 100vh;
    position: relative;
}

.mobile-toggle {
    display: none;
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 110;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: white;
    border: none;
    box-shadow: var(--shadow-md);
    font-size: 1.2rem;
    color: var(--dark);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ========== Page Header ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--dark);
    letter-spacing: -0.5px;
    line-height: 1.3;
}

.page-header .subtitle {
    color: var(--gray);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ========== Stats Grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, currentColor);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.primary { color: var(--primary); }
.stat-card.success { color: var(--success); }
.stat-card.warning { color: var(--warning); }
.stat-card.info { color: var(--info); }
.stat-card.danger { color: var(--danger); }

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.stat-icon.primary {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: var(--primary);
}
.stat-icon.success {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: var(--success);
}
.stat-icon.warning {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: var(--warning);
}
.stat-icon.info {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    color: var(--info);
}
.stat-icon.danger {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: var(--danger);
}

.stat-card:hover .stat-icon {
    transform: scale(1.08);
}

.stat-content h4 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray);
    margin-bottom: 6px;
}

.stat-content .value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--dark);
    letter-spacing: -0.3px;
}

/* ========== Cards ========== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #fafbfc 0%, white 100%);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
    font-size: 1rem;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: #fafbfc;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn i {
    font-size: 0.95em;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca, #4f46e5);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #047857, #059669);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: white;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--dark-2);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 10px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark-2);
    margin-bottom: 8px;
}

.form-group label i {
    color: var(--primary);
    margin-left: 6px;
    font-size: 0.85em;
}

.form-control {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--dark);
    background: white;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.form-control::placeholder {
    color: var(--gray-light);
}

textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    padding-left: 40px;
}

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.4;
}

.badge-success {
    background: var(--success-soft);
    color: #047857;
}

.badge-danger {
    background: var(--danger-soft);
    color: #b91c1c;
}

.badge-warning {
    background: var(--warning-soft);
    color: #b45309;
}

.badge-info {
    background: var(--info-soft);
    color: #0369a1;
}

.badge-primary {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

/* ========== Tables ========== */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: #f8fafc;
    padding: 14px 16px;
    text-align: right;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.95rem;
    vertical-align: middle;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ========== Alerts ========== */
.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert i {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.alert-success {
    background: var(--success-soft);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: var(--danger-soft);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: var(--warning-soft);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: var(--info-soft);
    color: #0369a1;
    border: 1px solid rgba(14, 165, 233, 0.2);
}

/* ========== Months Grid (Dashboard & Calendar) ========== */
.months-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}

.month-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.month-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: var(--transition);
}

.month-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.month-card.paid {
    border-color: #6ee7b7;
    background: linear-gradient(160deg, #ecfdf5 0%, #d1fae5 100%);
}

.month-card.paid::after {
    background: var(--success);
}

.month-card.unpaid {
    border-color: #fca5a5;
    background: linear-gradient(160deg, #fef2f2 0%, #fee2e2 100%);
}

.month-card.unpaid::after {
    background: var(--danger);
}

.month-card .month-name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--dark);
}

.month-card .month-status {
    font-size: 0.8rem;
    font-weight: 600;
}

.month-card .month-amount {
    font-size: 0.85rem;
    margin-top: 6px;
    color: var(--dark-2);
    font-weight: 500;
}

/* ========== Profile ========== */
.profile-avatar-large {
    width: 110px;
    height: 110px;
    border-radius: 28px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    color: white;
    font-weight: 700;
    margin: 0 auto 20px;
    box-shadow: 0 12px 32px rgba(79, 70, 229, 0.35);
    position: relative;
}

.profile-avatar-large::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 32px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    opacity: 0.25;
    z-index: -1;
    filter: blur(10px);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item .label {
    color: var(--gray);
    font-weight: 500;
    font-size: 0.9rem;
}

.info-item .value {
    font-weight: 600;
    color: var(--dark);
    text-align: left;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--gray);
}

.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 20px;
    opacity: 0.35;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.empty-state h4 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--dark-2);
    font-weight: 700;
}

.empty-state p {
    font-size: 0.95rem;
    max-width: 320px;
    margin: 0 auto 20px;
}

/* ========== Utilities ========== */
.text-center { text-align: center; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.w-100 { width: 100%; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ========== Spinner ========== */
.spinner {
    width: 42px;
    height: 42px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 24px auto;
}

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

/* ========== Calendar Specific ========== */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-nav .btn {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 12px;
}

.calendar-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--dark);
}

/* ========== Action Buttons Group ========== */
.action-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btns .btn {
    padding: 8px 12px;
}

/* ========== Modal (if used) ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #fafbfc;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-right: 0;
        padding: 24px 20px;
        padding-top: 80px;
    }
    .mobile-toggle {
        display: flex;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-header h1 {
        font-size: 1.4rem;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .login-card {
        padding: 36px 24px;
    }
    .months-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .main-content {
        padding: 20px 16px;
        padding-top: 76px;
    }
}

/* ========== Overlay for mobile sidebar ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* ========== Extra Polish ========== */
.stat-card, .card, .month-card, .btn, .nav-item, .form-control {
    will-change: transform;
}

/* Soft selection */
::selection {
    background: rgba(79, 70, 229, 0.2);
    color: var(--dark);
}

/* ========== Calendar Full Styles ========== */
.calendar-wrapper {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.calendar-wrapper .calendar-header {
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 50%, #1e1b4b 100%);
    color: white;
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.calendar-wrapper .calendar-header h3 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin: 0;
    color: white;
}

.calendar-wrapper .calendar-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.calendar-wrapper .calendar-nav button {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.calendar-wrapper .calendar-nav button:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: scale(1.05);
}

.calendar-wrapper .calendar-nav a {
    text-decoration: none;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    padding: 1px;
}

.calendar-weekday {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 14px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--dark-2);
}

.calendar-day {
    background: white;
    min-height: 96px;
    padding: 10px;
    position: relative;
    transition: var(--transition);
    cursor: default;
}

.calendar-day:hover {
    background: #f8fafc;
}

.calendar-day.other-month {
    background: #fafbfc;
    color: #cbd5e1;
}

.calendar-day.today {
    background: linear-gradient(160deg, #eef2ff 0%, #e0e7ff 100%);
}

.calendar-day.today .day-number {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.day-number {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 6px;
    display: inline-block;
}

.day-payment {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 8px;
    margin-top: 4px;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.day-payment.paid {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
}

.day-payment.unpaid {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #991b1b;
}

.day-payment.partial {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

/* Form row used in calendar details & profile */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 24px;
    margin-bottom: 8px;
}

.form-section {
    margin-bottom: 32px;
}

.form-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Calendar responsive */
@media (max-width: 768px) {
    .calendar-day {
        min-height: 64px;
        padding: 6px;
    }
    .day-payment {
        font-size: 0.62rem;
        padding: 2px 5px;
    }
    .calendar-weekday {
        padding: 10px 4px;
        font-size: 0.75rem;
    }
    .calendar-wrapper .calendar-header {
        padding: 16px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .calendar-wrapper .calendar-header h3 {
        font-size: 1.1rem;
        order: -1;
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        min-height: 52px;
        padding: 4px;
    }
    .day-number {
        font-size: 0.85rem;
    }
    .day-payment {
        display: none;
    }
}
