/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #6366f1; --primary-dark: #4f46e5; --primary-light: #a5b4fc;
    --surface: #0f172a; --surface-card: #1e293b; --surface-card2: #334155;
    --text: #f1f5f9; --text-muted: #94a3b8; --text-dim: #64748b;
    --error: #ef4444; --success: #10b981; --warning: #f59e0b;
    --tertiary: #06b6d4; --border: #334155;
    --radius: 16px; --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,.3);
}
html { font-size: 16px; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--surface); color: var(--text);
    min-height: 100vh; overflow-x: hidden;
}
a { color: var(--primary-light); text-decoration: none; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ===== AUTH ===== */
.auth-container {
    max-width: 420px; margin: auto; padding: 32px 24px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh;
}
.auth-icon {
    width: 72px; height: 72px; border-radius: 20px;
    background: linear-gradient(135deg, var(--primary), var(--tertiary));
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 900; color: #fff; margin-bottom: 16px;
}
.auth-container h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 28px; }
.auth-container .form-group { width: 100%; margin-bottom: 12px; }
.auth-container label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.auth-container input {
    width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface-card);
    color: var(--text); outline: none; transition: border-color .2s;
}
.auth-container input:focus { border-color: var(--primary); }
.error-card { background: #451a1a; color: #fca5a5; padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; width: 100%; margin-bottom: 12px; }
.hidden { display: none !important; }

/* ===== BUTTONS ===== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; border: none; padding: 12px 24px; border-radius: var(--radius-sm);
    font-weight: 700; cursor: pointer; transition: all .2s; font-size: .95rem;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,.4); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-outline {
    background: transparent; color: var(--primary-light); border: 1px solid var(--border);
    padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; transition: all .2s;
}
.btn-outline:hover { border-color: var(--primary); background: rgba(99,102,241,.1); }
.btn-full { width: 100%; }
.btn-link { background: none; border: none; color: var(--primary-light); cursor: pointer; margin-top: 12px; font-size: .9rem; }
.btn-sm { padding: 8px 14px; font-size: .8rem; }
.btn-danger { background: var(--error); color: #fff; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .8rem; }
.btn-success { background: var(--success); color: #fff; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .8rem; }
.btn-warn { background: var(--warning); color: #000; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .8rem; }

/* ===== TOP BAR ===== */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; background: var(--surface-card); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.top-bar h2 { font-size: 1.1rem; font-weight: 800; }
.top-actions { display: flex; gap: 4px; align-items: center; }
.icon-btn {
    background: none; border: none; color: var(--text); font-size: 1.3rem;
    cursor: pointer; padding: 8px; border-radius: 8px; transition: background .2s;
}
.icon-btn:hover { background: var(--surface-card2); }
.icon-btn.syncing { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.dropdown { position: relative; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: 100%; background: var(--surface-card2);
    border: 1px solid var(--border); border-radius: var(--radius-sm); min-width: 160px;
    box-shadow: var(--shadow); z-index: 200; overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-menu button {
    display: block; width: 100%; text-align: left; padding: 12px 16px;
    background: none; border: none; color: var(--text); cursor: pointer; font-size: .9rem;
}
.dropdown-menu button:hover { background: rgba(99,102,241,.15); }

/* ===== DASHBOARD ===== */
.dashboard { padding: 16px 20px; }
.summary-card {
    background: linear-gradient(135deg, var(--surface-card), var(--surface-card2));
    border-radius: var(--radius); padding: 20px; border: 1px solid var(--border);
}
.summary-header { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 12px; }
.summary-row { display: flex; justify-content: space-between; }
.summary-item { display: flex; flex-direction: column; }
.summary-label { font-size: .75rem; color: var(--text-dim); margin-bottom: 2px; }
.summary-value { font-size: 1.3rem; font-weight: 800; }
.summary-value.invested { color: var(--primary-light); }
.summary-value.available { color: var(--tertiary); }
.clickable { cursor: pointer; transition: opacity .2s; }
.clickable:hover { opacity: .8; }

/* ===== TABS ===== */
.tab-bar {
    display: flex; border-bottom: 2px solid var(--border);
    padding: 0 12px; position: sticky; top: 56px; background: var(--surface); z-index: 90;
}
.tab {
    flex: 1; padding: 12px 8px; text-align: center; background: none; border: none;
    color: var(--text-dim); font-weight: 600; font-size: .85rem; cursor: pointer;
    border-bottom: 3px solid transparent; transition: all .2s; margin-bottom: -2px;
}
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }
.tab-content { flex: 1; overflow-y: auto; padding: 12px 16px; padding-bottom: 80px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== FD CARDS ===== */
.fd-card {
    background: var(--surface-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
    cursor: pointer; transition: all .25s;
}
.fd-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.fd-card-header { display: flex; justify-content: space-between; align-items: center; }
.fd-bank { font-weight: 700; font-size: 1rem; }
.fd-amount { font-weight: 800; color: var(--tertiary); font-size: 1rem; }
.fd-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: .8rem; color: var(--text-muted); }
.fd-progress { width: 100%; height: 4px; background: var(--surface-card2); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.fd-progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--tertiary)); border-radius: 4px; transition: width .5s; }
.fd-expanded { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.fd-expanded .slip-table { width: 100%; font-size: .8rem; margin: 8px 0; }
.fd-expanded .slip-table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 4px 8px; }
.fd-expanded .slip-table td { padding: 4px 8px; }
.fd-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.status-badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: .7rem; font-weight: 700; text-transform: uppercase;
}
.status-active { background: rgba(99,102,241,.2); color: var(--primary-light); }
.status-matured { background: rgba(245,158,11,.2); color: var(--warning); }
.status-closed { background: rgba(239,68,68,.2); color: var(--error); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 4px; color: var(--text-muted); }

/* ===== FAB ===== */
.fab {
    position: fixed; bottom: 24px; right: 24px;
    width: 56px; height: 56px; border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; font-size: 28px; border: none; cursor: pointer;
    box-shadow: 0 6px 24px rgba(99,102,241,.5); transition: all .2s; z-index: 50;
}
.fab:hover { transform: scale(1.1); }

/* ===== MODALS ===== */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 500; backdrop-filter: blur(4px);
}
.modal-content {
    background: var(--surface-card); border-radius: var(--radius);
    width: 95%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column;
    border: 1px solid var(--border); box-shadow: var(--shadow);
}
.wide-modal { max-width: 640px; }
.dialog-modal { max-width: 400px; padding: 24px; }
.dialog-modal h3 { margin-bottom: 12px; }
.dialog-modal p { color: var(--text-muted); margin-bottom: 8px; font-size: .9rem; }
.dialog-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-weight: 800; }
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.close-btn:hover { background: var(--surface-card2); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== FORM ===== */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.form-group input, .form-group textarea {
    width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.section-title { font-size: .85rem; font-weight: 700; color: var(--primary-light); margin: 16px 0 8px; }
.duration-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.slip-row {
    display: grid; grid-template-columns: 2fr 1fr 1.2fr auto; gap: 8px; align-items: end; margin-bottom: 8px;
}
.slip-row input { padding: 8px 10px; font-size: .85rem; }
.slip-remove { background: none; border: none; color: var(--error); cursor: pointer; font-size: 1.2rem; padding: 8px; }
.maturity-card {
    background: linear-gradient(135deg, rgba(6,182,212,.15), rgba(99,102,241,.15));
    border-radius: var(--radius-sm); padding: 14px; margin-top: 12px; border: 1px solid rgba(6,182,212,.3);
}
.maturity-label { font-size: .75rem; color: var(--text-muted); }
.maturity-amount { font-size: 1.4rem; font-weight: 900; color: var(--tertiary); }
.maturity-interest { font-size: .8rem; color: var(--text-dim); }
.available-funds-card {
    background: rgba(99,102,241,.1); border: 1px solid rgba(99,102,241,.3);
    border-radius: var(--radius-sm); padding: 14px; margin-top: 12px;
}
.checkbox-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.breakdown-row { display: flex; justify-content: space-between; font-size: .85rem; margin-top: 6px; }
.text-primary { color: var(--primary-light); font-weight: 700; }
.text-error { color: var(--error); font-weight: 700; }
.warning-text { font-size: .75rem; color: var(--warning); margin-top: 4px; }

/* ===== AVAILABLE ===== */
.available-summary {
    background: linear-gradient(135deg, rgba(6,182,212,.15), rgba(16,185,129,.15));
    border-radius: var(--radius); padding: 20px; margin-bottom: 16px; border: 1px solid rgba(6,182,212,.3);
}
.available-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 12px; }
.avail-tab {
    flex: 1; padding: 10px; text-align: center; background: none; border: none;
    color: var(--text-dim); font-weight: 600; font-size: .85rem; cursor: pointer;
    border-bottom: 3px solid transparent; transition: all .2s;
}
.avail-tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }
.avail-list { min-height: 100px; }
.notes-section { margin-top: 16px; }
.notes-section label { display: block; margin-bottom: 8px; }
.notes-section textarea {
    width: 100%; min-height: 80px; padding: 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    outline: none; resize: vertical;
}

/* ===== ACTIVITY LOG ===== */
.log-card {
    background: var(--surface-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px; margin-bottom: 8px;
    cursor: pointer; transition: border-color .2s;
}
.log-card:hover { border-color: var(--primary); }
.log-header { display: flex; justify-content: space-between; align-items: center; }
.log-action { font-weight: 700; font-size: .9rem; }
.log-time { font-size: .75rem; color: var(--text-dim); }
.log-details { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.log-expanded { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: .8rem; }
.change-row { display: flex; gap: 8px; padding: 4px 0; }
.change-field { color: var(--primary-light); font-weight: 600; min-width: 100px; }
.change-old { color: var(--error); text-decoration: line-through; }
.change-new { color: var(--success); font-weight: 600; }

/* ===== LANGUAGE ===== */
.language-options { display: flex; flex-direction: column; gap: 8px; }

/* ===== TOAST ===== */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--surface-card2); color: var(--text); padding: 12px 24px;
    border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 9999;
    font-size: .9rem; font-weight: 600; border: 1px solid var(--border);
    transition: opacity .3s, transform .3s;
}
.toast.show { display: block; animation: toastIn .3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .summary-value { font-size: 1.1rem; }
    .modal-content { width: 100%; max-height: 100vh; border-radius: 0; }
    .wide-modal { max-width: 100%; }
    .slip-row { grid-template-columns: 1fr 1fr; }
}
