:root {
    --primary: #2563eb;          /* Matches Tailwind blue-600 */
    --primary-hover: #1d4ed8;    
    --secondary: #f3f4f6;        
    --danger: #ef4444; 
    --warning: #f59e0b; 
    --success: #10b981; 
    --text-main: #111827;        /* Matches Tailwind gray-900 */
    --text-muted: #6b7280;       
    --bg-body: #f3f4f6;          /* Matches Tailwind gray-100 */
    --bg-card: #ffffff;          
    --border-light: #e5e7eb;     
    --radius-md: 0.75rem;        /* 12px */
    --radius-lg: 1rem;           /* 16px */
    --radius-pill: 9999px;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

html.dark {
    --secondary: #374151;    
    --text-main: #f9fafb;    
    --text-muted: #9ca3af;   
    --bg-body: #111827;      
    --bg-card: #1f2937;      
    --border-light: #374151; 
}

body { font-family: 'Inter', 'Segoe UI', sans-serif; margin: 0; padding: 20px; background-color: var(--bg-body); color: var(--text-main); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--text-main); margin-top: 0; font-weight: 600; } h1 { font-size: 1.25rem; margin: 0; } h2 { font-size: 1.15rem; margin-bottom: 20px; }
#appContainer { max-width: 1300px; margin: 0 auto; }

/* Navigation Tabs */
.tab-container-wrapper { text-align: center; margin-bottom: 24px; }
.tab-container { display: inline-flex; background: var(--bg-card); padding: 6px; border-radius: var(--radius-lg); gap: 4px; box-shadow: var(--shadow-card); border: 1px solid var(--border-light); }
.tab-btn { background: transparent; color: var(--text-muted); border: none; padding: 10px 24px; cursor: pointer; border-radius: var(--radius-md); transition: all 0.2s ease; display: flex; align-items: center; gap: 8px; }
.tab-icon { font-size: 16px; filter: grayscale(100%); opacity: 0.7; transition: 0.2s;}
.tab-label { font-size: 13px; font-weight: 600; }
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { background: var(--bg-body); color: var(--primary); }
.tab-btn.active .tab-icon { filter: grayscale(0%); opacity: 1; }

.card { background: var(--bg-card); padding: 24px; border-radius: var(--radius-lg); margin-bottom: 24px; box-shadow: var(--shadow-card); border: 1px solid var(--border-light); }
.header-actions { background: var(--bg-card); padding: 16px 24px; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); border: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }

.grand-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border-light); }
.summary-item { text-align: left; background: var(--bg-card); padding: 20px; border-radius: var(--radius-md); border: 1px solid var(--border-light); }
.summary-item h3 { margin: 0; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.summary-item p { margin: 8px 0 0; font-size: 24px; font-weight: 700; color: var(--text-main); }
.bank-summaries { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.bank-card { background: var(--bg-card); border: 1px solid var(--border-light); padding: 20px; border-radius: var(--radius-md); }
.bank-card h4 { margin: 0 0 16px 0; font-size: 14px; color: var(--primary); display: flex; align-items: center; gap: 8px;}
.bank-card h4::before { content: "🏦"; }
.bank-card p { margin: 8px 0; font-size: 13px; display: flex; justify-content: space-between; color: var(--text-muted); }
.bank-card span { font-weight: 600; color: var(--text-main); }

.form-section { background: var(--secondary); padding: 20px; border-radius: var(--radius-md); border: 1px solid var(--border-light); margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; align-items: end; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
input, select { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border-light); font-size: 14px; background: var(--bg-card); transition: all 0.2s; width: 100%; box-sizing: border-box; color: var(--text-main); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
button { cursor: pointer; background: var(--primary); color: white; border: none; font-weight: 500; font-size: 13px; padding: 10px 20px; border-radius: 8px; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px;}
button:hover { background: var(--primary-hover); }
button.archive-btn { background: var(--secondary); color: var(--text-main); border: 1px solid var(--border-light); } 
button.archive-btn:hover { background: #e2e8f0; }
input[type="file"] { width: auto; padding: 4px; border: none; box-shadow: none; background: transparent; font-size: 13px; }

.table-container { overflow-x: auto; padding-bottom: 60px; background: transparent; border: none; }
#ledgerTable, #transactionTable { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
#ledgerTable thead th, #transactionTable thead th { position: sticky; top: 0; background-color: var(--secondary); color: var(--text-muted); z-index: 10; font-weight: 600; font-size: 11px; padding: 12px 20px; text-align: left; border-bottom: 1px solid var(--border-light); border-top: 1px solid var(--border-light); text-transform: uppercase; letter-spacing: 0.5px; }
#ledgerTable thead th:first-child, #transactionTable thead th:first-child { border-top-left-radius: 8px; border-left: 1px solid var(--border-light); }
#ledgerTable thead th:last-child, #transactionTable thead th:last-child { border-top-right-radius: 8px; border-right: 1px solid var(--border-light); }
#ledgerTable tbody tr, #transactionTable tbody tr { background-color: var(--bg-card); transition: background-color 0.1s; } 
#ledgerTable tbody tr:hover, #transactionTable tbody tr:hover { background-color: var(--secondary); }
#ledgerTable td, #transactionTable td { border-bottom: 1px solid var(--border-light); padding: 16px 20px; font-size: 13px; vertical-align: middle; }
#ledgerTable td:first-child, #transactionTable td:first-child { border-left: 1px solid var(--border-light); } 
#ledgerTable td:last-child, #transactionTable td:last-child { border-right: 1px solid var(--border-light); }

.bank-header { background-color: var(--bg-body) !important; color: var(--text-main); } 
.bank-header td { border-bottom: none !important; padding: 24px 20px 8px 20px !important; border-left: none !important; border-right: none !important;}
.bank-header span { font-size: 14px !important; }
.primary-text { font-size: 14px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; } 
.sub-text { font-size: 12px; color: var(--text-muted); }

.dropdown { position: relative; display: inline-block; } 
.dropdown-content { display: none; position: absolute; right: 0; top: 100%; background-color: var(--bg-card); min-width: 150px; box-shadow: var(--shadow-card); z-index: 100; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-light); } 
.dropdown:hover .dropdown-content { display: block; } 
.dropdown-content button { color: var(--text-main) !important; padding: 10px 16px !important; display: block !important; width: 100% !important; text-align: left !important; background: var(--bg-card) !important; border: none !important; border-bottom: 1px solid var(--secondary) !important; font-size: 13px !important; border-radius: 0 !important; font-weight: 500 !important; } 
.dropdown-content button:hover { background-color: var(--secondary) !important; color: var(--primary) !important; } 
.dropdown-content button.danger-text { color: var(--danger) !important; }

.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px); }
.modal-content { background-color: var(--bg-card); margin: 10% auto; padding: 0; border-radius: var(--radius-lg); width: 90%; max-width: 450px; overflow: hidden; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); position: relative; }
.close-btn { position: absolute; right: 15px; top: 12px; color: var(--text-muted); font-size: 24px; font-weight: bold; cursor: pointer; z-index: 10; } .close-btn:hover { color: var(--text-main); }
.modal-header { background-color: var(--bg-card); color: var(--text-main); padding: 20px; text-align: center; font-weight: 600; font-size: 16px; border-bottom: 1px solid var(--border-light);}
.fy-table { width: 100%; border-collapse: collapse; } .fy-table th { background-color: var(--secondary); color: var(--text-muted); padding: 12px 20px; text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; } .fy-table td { padding: 12px 20px; text-align: left; font-size: 13px; color: var(--text-main); border-bottom: 1px solid var(--border-light); }
.gain-link { color: var(--primary); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; background: #eff6ff; border-radius: 4px; } .gain-link:hover { background: #dbeafe; }
#toast { visibility: hidden; min-width: 250px; background-color: var(--text-main); color: #fff; text-align: center; border-radius: var(--radius-pill); padding: 12px 24px; position: fixed; z-index: 3000; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 13px; font-weight: 500; opacity: 0; transition: opacity 0.4s, bottom 0.4s; box-shadow: var(--shadow-card); } #toast.show { visibility: visible; opacity: 1; bottom: 50px; }
#syncStatus { font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 6px 12px; background: var(--secondary); border-radius: var(--radius-pill); border: 1px solid var(--border-light);} #syncStatus.active { background: #ecfdf5; color: #047857; border-color: #a7f3d0;}
.hidden { display: none !important; }

@media (max-width: 768px) {
    body { padding: 10px; padding-bottom: 90px; }
    .tab-container-wrapper { position: fixed; bottom: 0; left: 0; width: 100%; background: var(--bg-card); border-top: 1px solid var(--border-light); z-index: 1000; margin: 0; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 10px rgba(0,0,0,0.03); }
    .tab-container { display: flex; justify-content: space-around; width: 100%; padding: 8px 5px; border: none; box-shadow: none; border-radius: 0; background: transparent; }
    .tab-btn { flex: 1; flex-direction: column; gap: 4px; padding: 6px 0; border-radius: 8px; background: transparent !important; }
    .tab-icon { font-size: 22px; margin-bottom: 2px;} .tab-label { font-size: 11px; font-weight: 700; }
    .tab-btn.active { color: var(--primary); } .tab-btn.active .tab-icon { transform: scale(1.1); }
    
    .header-actions { flex-direction: column; align-items: stretch !important; gap: 12px; padding: 16px; }
    .card { padding: 16px; } .form-grid { grid-template-columns: 1fr; } 
    #ledgerTable thead, #transactionTable thead { display: none; } #ledgerTable, #ledgerTable tbody, #ledgerTable tr, #ledgerTable td, #transactionTable, #transactionTable tbody, #transactionTable tr, #transactionTable td { display: block; width: 100%; box-sizing: border-box; }
    #ledgerTable tr, #transactionTable tr { margin-bottom: 16px; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 10px; box-shadow: var(--shadow-card); }
    #ledgerTable td, #transactionTable td { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--secondary); padding: 10px 4px; text-align: right; border-top: none; border-left: none; border-right: none;} #ledgerTable td::before, #transactionTable td::before { content: attr(data-label); font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 11px; text-align: left; margin-right: 15px; } #ledgerTable td:empty, #transactionTable td:empty { display: none; }
}
