:root {
    --primary: #7C3AED;
    --primary-dark: #6D28D9;
    --secondary: #06B6D4;
    --success: #10B981;
    --saving: #F59E0B;
    --saving-dark: #D97706;
    --danger: #EF4444;
    --dark: #1E293B;
    --text: #334155;
    --text-light: #64748B;
    --border: #E2E8F0;
    --soft: #F8FAFC;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 4px 15px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Tajawal', sans-serif; -webkit-tap-highlight-color: transparent; }

body {
    background: linear-gradient(135deg, #F0F4FF, #FAF5FF);
    color: var(--text);
    direction: rtl;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    line-height: 1.6;
}

/* ═══ شاشة القفل ═══ */
.lock-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #F0F4FF 0%, #FAF5FF 50%, #F0F4FF 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 40px 30px;
}

.lock-content { text-align: center; color: var(--text); width: 100%; max-width: 400px; }

.lock-icon {
    font-size: 6rem;
    margin-bottom: 20px;
    animation: lockBounce 2s infinite;
    filter: drop-shadow(0 10px 30px rgba(124, 58, 237, 0.3));
}

@keyframes lockBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.lock-content h1 {
    font-size: 2.8rem;
    font-weight: 900;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #7C3AED, #06B6D4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lock-content h1::after {
    content: '❤️';
    font-size: 2rem;
    animation: heartbeat 1.5s ease-in-out infinite;
    -webkit-text-fill-color: initial;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.35); }
    30% { transform: scale(1); }
}

.lock-content p { font-size: 1.1rem; opacity: 0.75; margin-bottom: 40px; color: var(--text-light); font-weight: 700; }

.lock-content form { width: 100%; display: flex; flex-direction: column; gap: 15px; }

.lock-content input {
    padding: 18px;
    border: 2px solid var(--border);
    border-radius: 16px;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 3px;
    background: #fff;
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    outline: none;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.06);
}

.lock-content input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12); }
.lock-content input::placeholder { color: #94A3B8; letter-spacing: 3px; }

.lock-content .submit-btn {
    padding: 18px;
    background: linear-gradient(135deg, #7C3AED, #06B6D4);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.3);
    transition: transform 0.2s;
}

.lock-content .submit-btn:active { transform: scale(0.97); }

/* ═══ التطبيق ═══ */
.app-container {
    width: 100%;
    max-width: 480px;
    background: #fff;
    min-height: 100vh;
    box-shadow: 0 0 60px rgba(0,0,0,0.1);
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 22px;
    background: linear-gradient(-45deg, #7C3AED, #06B6D4, #F472B6, #7C3AED);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: #fff;
    margin-bottom: 20px;
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    gap: 12px;
}

.manage-header {
    background: linear-gradient(-45deg, #F97316, #EF4444, #EC4899, #F97316);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.user-info { flex: 1; min-width: 0; }
.user-info h1 { font-size: 1.8rem; font-weight: 900; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.user-info h1::after { content: '❤️'; animation: heartbeat 1.5s ease-in-out infinite; }
.manage-header .user-info h1::after { content: ''; }
.user-info p { font-size: 0.9rem; opacity: 0.9; font-weight: 700; }

.header-actions { display: flex !important; gap: 10px !important; align-items: center !important; flex-shrink: 0 !important; }

.add-btn {
    background: rgba(255, 255, 255, 0.95) !important;
    color: var(--primary) !important;
    border: none !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    font-size: 1.3rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    transition: transform 0.2s !important;
    flex-shrink: 0 !important;
}

.add-btn:active { transform: scale(0.9); }
.godfather-btn { color: #F59E0B !important; }
.tasks-btn { color: #06B6D4 !important; }

.grid-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 0 20px 20px; }

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px 15px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.card:hover { transform: translateY(-4px); box-shadow: 0 12px 25px rgba(124,58,237,0.15); }
.card:active { transform: scale(0.96); }
.card-icon { font-size: 2.5rem; margin-bottom: 10px; }
.card-title { font-weight: 700; font-size: 1rem; }

.action-card { background: linear-gradient(135deg, #F8FAFC, #E0E7FF); border: 2px solid rgba(124,58,237,0.1); }

.flow-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 1.2rem;
    background: rgba(255,255,255,0.9);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page-header { display: flex; align-items: center; padding: 20px; gap: 15px; }

.back-btn {
    background: var(--soft);
    color: var(--primary);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.back-btn:active { transform: scale(0.9); }
.page-header h1 { font-size: 1.3rem; font-weight: 900; }

.total-banner {
    margin: 0 20px 20px;
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    padding: 18px 22px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    box-shadow: 0 8px 20px -6px rgba(16,185,129,0.4);
}

.total-banner strong { font-size: 1.3rem; font-weight: 900; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: flex-end;
    z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-top-left-radius: 30px;
    border-top-right-radius: 30px;
    padding: 28px 24px;
    animation: slideUp 0.35s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.modal-header h2 { font-size: 1.3rem; font-weight: 900; }

.close-btn {
    background: var(--soft);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.4rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: var(--soft);
    padding: 5px;
    border-radius: var(--radius-sm);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-weight: 700;
    font-family: 'Tajawal', sans-serif;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tab-btn.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.tab-content { display: none; }
.tab-content.active { display: block; }

form { display: flex; flex-direction: column; gap: 14px; }

input, select, textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    outline: none;
    background: var(--soft);
    color: var(--text);
    transition: all 0.3s;
}

input:focus, select:focus, textarea:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(124,58,237,0.1); }
input[type="color"] { height: 50px; padding: 5px; cursor: pointer; }
label { font-weight: 700; font-size: 0.9rem; color: var(--text-light); margin-bottom: -8px; padding-right: 5px; }

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    box-shadow: 0 8px 20px -6px rgba(124,58,237,0.5);
    transition: all 0.2s;
    margin-top: 5px;
}

.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.warning-text {
    background: #FEF3C7;
    color: #92400E;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
}

.delete-list { display: flex; flex-direction: column; gap: 10px; }

.delete-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: var(--soft);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.delete-item-info { display: flex; align-items: center; gap: 12px; font-weight: 700; flex: 1; min-width: 0; }
.delete-item-info .emoji { font-size: 1.5rem; }

.delete-action-btn, .edit-action-btn {
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.delete-action-btn { background: var(--danger); }
.edit-action-btn { background: var(--primary); margin-left: 6px; }

.transactions-list {
    margin: 20px;
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.transactions-list h3 { margin-bottom: 15px; font-weight: 900; }

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background: var(--soft);
    border: 1px solid var(--border);
}

.t-right { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.t-emoji { font-size: 1.7rem; }
.t-name { font-weight: 700; font-size: 0.95rem; }
.t-date { font-size: 0.75rem; color: var(--text-light); }
.t-amount { font-weight: 900; color: var(--danger); font-size: 1.05rem; }

.t-note {
    font-size: 0.8rem;
    color: #2563EB;
    font-style: italic;
    font-weight: 700;
    display: inline-block;
    background: rgba(37, 99, 235, 0.08);
    border: 2px solid #2563EB;
    border-radius: 10px;
    padding: 3px 9px;
    margin-top: 6px;
}

.installment-info {
    margin-top: 8px;
    padding: 10px;
    background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
    border-radius: 10px;
    border: 1px solid #FED7AA;
}

.installment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: #C2410C;
    margin-bottom: 6px;
}

.progress-bar {
    height: 8px;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #FED7AA;
}

.progress-fill { height: 100%; background: linear-gradient(90deg, #F97316, #EA580C); border-radius: 4px; }

.tabs-container { display: flex; gap: 6px; padding: 0 20px 20px; overflow-x: auto; scrollbar-width: none; }
.tabs-container::-webkit-scrollbar { display: none; }

.tabs-container .tab-btn {
    flex: 1;
    min-width: 90px;
    padding: 12px 8px;
    background: var(--soft);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    color: var(--text-light);
    white-space: nowrap;
    font-size: 0.85rem;
}

.tabs-container .tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border-color: transparent;
}

.report-tab { display: none; }
.report-tab.active { display: block; }
.month-selector { display: flex; gap: 10px; padding: 0 20px 20px; }
.month-selector select { flex: 1; }
.report-content { padding: 0 20px 20px; }

.report-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }

.report-card { padding: 20px 15px; border-radius: var(--radius); text-align: center; color: #fff; }
.report-card.expense { background: linear-gradient(135deg, #EF4444, #DC2626); }
.report-card.income { background: linear-gradient(135deg, #10B981, #059669); }
.report-card.saving { background: linear-gradient(135deg, #F59E0B, #D97706); }
.report-card.balance { background: linear-gradient(135deg, var(--primary), var(--secondary)); grid-column: 1/-1; }
.report-card .label { font-size: 0.9rem; margin-bottom: 8px; opacity: 0.95; }
.report-card .value { font-size: 1.5rem; font-weight: 900; }
.report-card .count { font-size: 0.75rem; opacity: 0.85; margin-top: 5px; }

.report-section {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.report-section h3 { margin-bottom: 15px; font-weight: 900; font-size: 1.05rem; }

.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

.report-row:last-child { border-bottom: none; }
.report-row .info { display: flex; align-items: center; gap: 10px; font-weight: 700; flex: 1; min-width: 0; }
.report-row .info .emoji { font-size: 1.4rem; }
.report-row .info .count { font-size: 0.75rem; color: var(--text-light); display: block; }
.report-row .amount { font-weight: 900; color: var(--danger); }

.bar-chart { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin-top: 6px; }

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.5s;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--dark);
    color: #fff;
    padding: 14px 26px;
    border-radius: 50px;
    font-weight: 700;
    opacity: 0;
    transition: all 0.4s;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 90%;
    text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.loading, .empty-msg {
    text-align: center;
    color: var(--text-light);
    padding: 30px;
    grid-column: 1/-1;
    font-weight: 700;
}

@media (max-width: 400px) {
    .lock-content h1 { font-size: 2.2rem; }
    .lock-icon { font-size: 5rem; }
    .user-info h1 { font-size: 1.5rem; }
    .header-actions .add-btn { width: 44px !important; height: 44px !important; }
    .card { padding: 20px 12px; }
    .card-icon { font-size: 2.2rem; }
}
