:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #4f46e5;
    --accent: #10b981;
    --accent-pink: #f472b6;
    --accent-teal: #2dd4bf;
    --bg-main: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.7);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 32px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(244, 114, 182, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(45, 212, 191, 0.15) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(99, 102, 241, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-md);
}

.hidden { display: none !important; }

/* --- Auth Interface --- */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(40px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 48px;
    border-radius: var(--radius-lg);
    text-align: center;
    animation: authIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-header ion-icon {
    font-size: 56px;
    color: var(--primary);
    margin-bottom: 24px;
}

.auth-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 40px;
}

.auth-body input {
    width: 100%;
    padding: 16px 24px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: white;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    outline: none;
    transition: var(--transition);
}

.auth-body input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1); }

.auth-body button {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
}

.auth-body button:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4); }

/* --- App Container --- */
.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 40px 0 32px;
}

.logo-group h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.logo-group p {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.btn-logout {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: white;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover { color: #ef4444; border-color: #fecaca; background: #fff1f2; transform: rotate(8deg); }

/* --- Stats Dashboard --- */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.stat-box {
    padding: 32px;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 6px; height: 100%;
}

.stat-box.co::before { background: var(--primary); }
.stat-box.dep::before { background: var(--accent-pink); }
.stat-box.me::before { background: var(--accent-teal); }

.stat-box:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }

.stat-box .label {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: block;
}

.stat-box .amount {
    font-size: 32px;
    font-weight: 900;
    font-family: 'Outfit';
    color: var(--text-main);
}

/* --- Entry Interface --- */
.entry-container {
    margin-bottom: 40px;
}

.entry-card {
    padding: 40px;
    border-radius: var(--radius-lg);
}

.type-pills {
    display: flex;
    gap: 6px;
    margin-bottom: 40px;
    background: rgba(241, 245, 249, 0.5);
    padding: 6px;
    border-radius: 16px;
}

.pill {
    flex: 1;
    padding: 12px 0;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-muted);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.pill.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr auto;
    gap: 20px;
    align-items: end;
}

.input-field label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.input-field input {
    width: 100%;
    padding: 16px 20px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: white;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: var(--transition);
}

.input-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1); }

.btn-post {
    height: 52px;
    padding: 0 32px;
    border-radius: 16px;
    border: none;
    background: var(--primary);
    color: white;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-post:hover { transform: translateY(-2px); box-shadow: 0 8px 16px -4px rgba(99, 102, 241, 0.3); }

/* --- Journal Section --- */
.journal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.journal-header h2 { font-family: 'Outfit'; font-size: 24px; font-weight: 900; }

.search-field {
    position: relative;
    width: 300px;
}

.search-field ion-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

.search-field input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: white;
    outline: none;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tx-card {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 24px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.tx-card:hover { transform: translateX(8px); }

.tx-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.tx-trip .tx-icon-box { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.tx-coll .tx-icon-box { background: rgba(244, 114, 182, 0.1); color: var(--accent-pink); }
.tx-sett .tx-icon-box { background: rgba(45, 212, 191, 0.1); color: var(--accent-teal); }

.tx-main { flex: 1; }
.tx-main h4 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.tx-main .meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.tx-main .meta span { display: flex; align-items: center; gap: 6px; }

.tx-val { text-align: right; }
.tx-val .price { display: block; font-size: 18px; font-weight: 900; font-family: 'Outfit'; }
.tx-val .type-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }

.tx-actions { display: flex; gap: 8px; opacity: 0; transition: var(--transition); }
.tx-card:hover .tx-actions { opacity: 1; }

.btn-circle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 18px;
}

.btn-circle:hover { color: var(--primary); background: #f5f3ff; border-color: var(--primary-light); }
.btn-circle.del:hover { color: #ef4444; border-color: #fee2e2; background: #fff1f2; }

/* --- Enhanced Edit Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.edit-modal {
    width: 100%;
    max-width: 480px;
    padding: 48px;
    border-radius: var(--radius-lg);
    transform: scale(0.9) translateY(30px);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .edit-modal { transform: scale(1) translateY(0); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.modal-title-group h3 { font-size: 28px; font-weight: 900; color: var(--text-main); }
.modal-title-group p { font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 6px; }

.btn-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #f1f5f9;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-close:hover { background: #fee2e2; color: #ef4444; transform: rotate(90deg); }

.modal-body { display: flex; flex-direction: column; gap: 24px; }

/* --- Mobile Optimization --- */
@media (max-width: 768px) {
    .stats-dashboard { grid-template-columns: 1fr; gap: 16px; }
    .input-row { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
    .btn-post { width: 100%; justify-content: center; }
    .journal-header { flex-direction: column; align-items: flex-start; gap: 20px; }
    .search-field { width: 100%; }
    
    .tx-card { flex-direction: row; padding: 16px; }
    .tx-icon-box { width: 44px; height: 44px; font-size: 20px; }
    .tx-actions { flex-direction: column; opacity: 1; }
    .btn-circle { width: 32px; height: 32px; font-size: 16px; }
    .tx-val { min-width: 80px; }
}

/* --- Fix SweetAlert Z-Index --- */
.swal2-container {
    z-index: 9999 !important;
}