/* ╔═══════════════════════════════════════════════════════════════╗
 * ║              T-cost · Stylesheet                             ║
 * ╚═══════════════════════════════════════════════════════════════╝
 *
 * ┌──────────── TABLE OF CONTENTS ────────────┐
 * │                                           │
 * │  Design Tokens .................. L   42   │
 * │  Reset .......................... L   77   │
 * │  Login Screen ................... L   95   │
 * │  User Profile (Sidebar) ......... L  345   │
 * │  Sidebar ........................ L  395   │
 * │  Main Content ................... L  495   │
 * │  Views .......................... L  555   │
 * │  Stats Grid ..................... L  570   │
 * │  Period Selector ................ L  680   │
 * │  Date-Grouped Transactions ...... L  715   │
 * │  Charts Grid .................... L  750   │
 * │  Category Bars .................. L  810   │
 * │  Recent List .................... L  850   │
 * │  Filter Bar ..................... L  890   │
 * │  Transaction Table .............. L  925   │
 * │  Accounts Grid .................. L 1005   │
 * │  Filter Chip .................... L 1050   │
 * │  Debt Cards ..................... L 1160   │
 * │  Workspace + Button ............. L 1235   │
 * │  Loans View ..................... L 1270   │
 * │  Quick Transfer ................. L 1575   │
 * │  Contacts ....................... L 1610   │
 * │  Category Tree .................. L 1680   │
 * │  Collapsible Groups ............. L 1780   │
 * │  Budgets ........................ L 1820   │
 * │  Modal .......................... L 1940   │
 * │  Empty State .................... L 2050   │
 * │  Scrollbar ...................... L 2065   │
 * │  Spinner ........................ L 2085   │
 * │  Button Loading ................. L 2110   │
 * │  App Loading Overlay ............ L 2135   │
 * │  Toast Notifications ............ L 2180   │
 * │  Responsive ..................... L 2250   │
 * │                                           │
 * └───────────────────────────────────────────┘
 */

/* ── Design Tokens ── */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #1e1e35;
    --bg-modal: #16162b;
    --border: #2a2a45;
    --border-light: #353555;

    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #5a5a78;

    --accent: #6c5ce7;
    --accent-hover: #7c6df7;
    --accent-glow: rgba(108, 92, 231, 0.3);

    --income: #00cec9;
    --income-bg: rgba(0, 206, 201, 0.12);
    --expense: #ff6b6b;
    --expense-bg: rgba(255, 107, 107, 0.12);
    --balance: #ffeaa7;
    --balance-bg: rgba(255, 234, 167, 0.12);
    --count-color: #74b9ff;
    --count-bg: rgba(116, 185, 255, 0.12);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.2s ease;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ── Login Screen ── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: radial-gradient(ellipse at 30% 20%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(0, 206, 201, 0.1) 0%, transparent 50%),
        var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    text-align: center;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.4s ease;
}

.login-brand {
    margin-bottom: 36px;
}

.login-logo {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--income));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.login-tagline {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.login-version {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    background: #fff;
    color: #333;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
}

.google-btn:hover {
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.google-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-hint {
    margin-top: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.login-error {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--expense);
    padding: 8px 12px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 6px;
}

/* Login Tabs */
.login-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.login-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-tab.active {
    background: var(--accent);
    color: #fff;
}

.login-tab:hover:not(.active) {
    background: rgba(108, 92, 231, 0.15);
}

.login-tab-content {
    display: none;
}

.login-tab-content.active {
    display: block;
}

/* Email Form */
.email-form .form-group {
    margin-bottom: 12px;
}

.email-form input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.email-form input:focus {
    border-color: var(--accent);
}

.email-submit-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
}

.email-footer {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.link-btn:hover {
    color: var(--accent);
}

.link-btn strong {
    color: var(--accent);
}

/* Role Badges */
.role-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.role-owner {
    background: rgba(108, 92, 231, 0.2);
    color: var(--accent);
}

.role-editor {
    background: rgba(0, 206, 201, 0.2);
    color: var(--income);
}

.role-viewer {
    background: rgba(149, 165, 166, 0.2);
    color: var(--text-secondary);
}

.selector-actions {
    display: flex;
    gap: 4px;
}

/* Invite & Members */
.invite-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 4px 0 12px;
}

.members-list {
    margin: 8px 0 16px;
}

.members-list label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 6px;
}

.member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border);
}

/* ── User Profile (Sidebar) ── */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sign-out-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-family: var(--font);
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.sign-out-btn:hover {
    color: var(--expense);
}

#app {
    display: flex;
    height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    padding: 0 8px;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--income));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: var(--font);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.nav-icon {
    font-size: 1.1rem;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-footer label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

.sidebar-footer select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
}

/* ── Main Content ── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.topbar h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 10px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* ── Views ── */
.view {
    display: none;
    padding: 24px 32px;
    overflow-y: auto;
    flex: 1;
}

.view.active {
    display: block;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.income::before {
    background: linear-gradient(90deg, var(--income), transparent);
}

.stat-card.expense::before {
    background: linear-gradient(90deg, var(--expense), transparent);
}

.stat-card.balance::before {
    background: linear-gradient(90deg, var(--balance), transparent);
}

.stat-card.count::before {
    background: linear-gradient(90deg, var(--count-color), transparent);
}

.stat-card.income {
    background: var(--income-bg);
    border-color: rgba(0, 206, 201, 0.2);
}

.stat-card.expense {
    background: var(--expense-bg);
    border-color: rgba(255, 107, 107, 0.2);
}

.stat-card.balance {
    background: var(--balance-bg);
    border-color: rgba(255, 234, 167, 0.2);
}

.stat-card.count {
    background: var(--count-bg);
    border-color: rgba(116, 185, 255, 0.2);
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-card.income .stat-value {
    color: var(--income);
}

.stat-card.expense .stat-value {
    color: var(--expense);
}

.stat-card.balance .stat-value {
    color: var(--balance);
}

.stat-card.count .stat-value {
    color: var(--count-color);
}

.stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 1.5rem;
    opacity: 0.5;
}

/* ── Period Selector ── */
.period-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 4px;
    width: fit-content;
}

.period-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 50px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.2px;
}

.period-btn:hover {
    color: var(--text-primary);
    background: rgba(108, 92, 231, 0.1);
}

.period-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
    font-weight: 600;
}

/* ── Date-Grouped Recent Transactions ── */
.recent-group {
    margin-bottom: 12px;
}

.recent-group:last-child {
    margin-bottom: 0;
}

.recent-date-header {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 6px 0 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

/* ── Transaction Time ── */
.txn-time {
    color: var(--text-muted);
    font-size: 0.8em;
    margin-left: 4px;
}

/* ── Time Input in Modal ── */
.form-group-time {
    max-width: 140px;
}

/* ── Charts Grid ── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.chart-card-header h3 {
    margin-bottom: 0;
}

.chart-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 2px;
}

.chart-toggle-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-toggle-btn.active {
    background: var(--primary);
    color: white;
}

.chart-toggle-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(108, 92, 231, 0.15);
}

/* ── Category Bars ── */
.cat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.cat-label {
    font-size: 0.85rem;
    width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat-bar-wrap {
    flex: 1;
    height: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
}

.cat-bar {
    height: 100%;
    border-radius: 12px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 4px;
}

.cat-amount {
    font-size: 0.85rem;
    font-weight: 600;
    width: 80px;
    text-align: right;
    color: var(--expense);
}

/* ── Recent List ── */
.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.recent-left {
    display: flex;
    flex-direction: column;
}

.recent-cat {
    font-size: 0.85rem;
    font-weight: 500;
}

.recent-note {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recent-amount {
    font-weight: 600;
    font-size: 0.95rem;
}

.recent-amount.positive {
    color: var(--income);
}

.recent-amount.negative {
    color: var(--expense);
}

/* ── Filter Bar ── */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input,
.filter-select,
.filter-date {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: var(--transition);
}

.search-input:focus,
.filter-select:focus,
.filter-date:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.filter-select {
    min-width: 160px;
}

/* ── Transaction Table ── */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.txn-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.txn-table td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.txn-table tr:hover td {
    background: var(--bg-card-hover);
}

.txn-table tr:last-child td {
    border-bottom: none;
}

.text-right {
    text-align: right;
}

.amount-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.amount-cell.positive {
    color: var(--income);
}

.amount-cell.negative {
    color: var(--expense);
}

.amount-cell.transfer {
    color: #74b9ff;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.action-btn.delete:hover {
    color: var(--expense);
}

/* ── Accounts Grid (Enhanced) ── */
.accounts-section {
    margin-bottom: 28px;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.account-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition);
    position: relative;
}

.account-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-light);
}

.account-card.clickable {
    cursor: pointer;
}

.account-card.clickable:active {
    transform: scale(0.98);
}

/* ── Filter Chip ── */
.filter-chip-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.chip-clear {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.chip-clear:hover {
    color: #fff;
}

.filter-balance {
    font-size: 0.9rem;
    font-weight: 600;
    margin-left: 8px;
}

.filter-balance.positive {
    color: var(--green);
}

.filter-balance.negative {
    color: var(--red);
}

.account-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.account-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.account-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-type {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.account-balance {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.account-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.account-card:hover .account-actions {
    opacity: 1;
}

.account-balance.positive {
    color: var(--income);
}

.account-balance.negative {
    color: var(--expense);
}

/* ── Debt Cards ── */
.debts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.debt-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 107, 107, 0.2);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.debt-card:hover {
    border-color: rgba(255, 107, 107, 0.35);
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.08);
}

.debt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.debt-name {
    font-weight: 600;
    font-size: 1rem;
}

.debt-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.debt-amount {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--expense);
    font-variant-numeric: tabular-nums;
}

.debt-progress {
    margin-top: 4px;
}

.debt-bar-wrap {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.debt-bar {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--income), #55efc4);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.debt-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Workspace + Button ── */
.selector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.add-btn-sm {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.add-btn-sm:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.modal-sm {
    max-width: 420px;
}

/* ── Loans View ── */
.loans-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.loans-section {
    margin-bottom: 24px;
}

.loans-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.loan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.loan-card:hover {
    border-color: var(--border-light);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.loan-given {
    border-left: 3px solid var(--income);
}

.loan-received {
    border-left: 3px solid var(--expense);
}

.loan-settled {
    opacity: 0.6;
    border-left-color: var(--text-muted);
}

/* Collapsible Debt Accounts in Accounts View */
.debt-accounts-section {
    margin-top: 24px;
}

.debt-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: var(--transition);
    user-select: none;
}

.debt-section-header:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}

.debt-section-chevron {
    font-size: 0.75rem;
    transition: var(--transition);
}

.debt-section-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.badge-loan {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 6px;
}

.badge-cleared {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 4px;
}

.account-card.cleared {
    opacity: 0.65;
}

.btn-toggle-cleared {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-toggle-cleared:hover {
    color: var(--text);
    border-color: var(--border-light);
}

.debt-card {
    border-left: 3px solid #a855f7;
}

.account-interest {
    font-size: 0.75rem;
    color: #f59e0b;
    margin-top: 2px;
}

.loan-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.loan-name {
    font-weight: 600;
    font-size: 1rem;
}

.loan-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.loan-interest {
    font-size: 0.75rem;
    color: #f0ad4e;
    margin-top: 2px;
    font-weight: 500;
}

.loan-account-badge {
    display: inline-block;
    background: var(--surface-2);
    font-size: 0.7rem;
    padding: 1px 7px;
    border-radius: 6px;
    margin-left: 6px;
    vertical-align: middle;
    color: var(--text-secondary);
}

.loan-amount {
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.loan-given .loan-amount {
    color: var(--income);
}

.loan-received .loan-amount {
    color: var(--expense);
}

.loan-progress {
    margin-top: 4px;
}

.loan-bar-wrap {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.loan-bar {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), #a29bfe);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.loan-given .loan-bar {
    background: linear-gradient(90deg, var(--income), #55efc4);
}

.loan-received .loan-bar {
    background: linear-gradient(90deg, var(--expense), #fab1a0);
}

.loan-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.loan-interest-label {
    color: #f59e0b;
}

.loan-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.btn-sm {
    padding: 4px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-sm:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-danger {
    border-color: rgba(255, 107, 107, 0.3);
    color: var(--expense);
}

.btn-danger:hover {
    background: var(--expense-bg);
    border-color: var(--expense);
}

.btn-pay {
    border-color: rgba(0, 206, 201, 0.3);
    color: var(--income);
}

.btn-pay:hover {
    background: var(--income-bg);
    border-color: var(--income);
}

/* Inline loan payment dialog */
.loan-pay-inline {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.pay-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pay-from-select,
.pay-amount-input {
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
}

.pay-from-select {
    flex: 1;
    min-width: 120px;
}

.pay-amount-input {
    width: 100px;
}

.pay-from-select:focus,
.pay-amount-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Quick Transfer ── */
.transfer-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.transfer-arrow {
    font-size: 1.3rem;
    color: var(--accent);
    font-weight: 700;
}

.transfer-input {
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    width: 120px;
    transition: var(--transition);
}

.transfer-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Contacts ── */
.contacts-header,
.categories-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.contacts-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: var(--transition);
}

.contact-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    border-color: var(--border-light);
}

.contact-avatar {
    font-size: 2rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: 50%;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.contact-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.contact-stats {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.contact-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ── Category Tree ── */
.categories-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cat-tree-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.cat-tree-item:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.cat-tree-item.child {
    margin-left: 32px;
    background: transparent;
    border-color: transparent;
    border-left: 2px solid var(--border);
    border-radius: 0;
}

.cat-tree-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cat-tree-indent {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.85rem;
}

.cat-tree-icon {
    font-size: 1.2rem;
}

.cat-tree-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.cat-tree-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.cat-tree-badge.expense {
    color: var(--expense);
    background: var(--expense-bg);
}

.cat-tree-badge.income {
    color: var(--income);
    background: var(--income-bg);
}

.cat-tree-count {
    font-size: 0.72rem;
    color: var(--accent);
    background: rgba(108, 92, 231, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

.cat-tree-orphan {
    font-size: 0.65rem;
    color: var(--balance);
    background: var(--balance-bg);
    padding: 2px 8px;
    border-radius: 10px;
}

.cat-tree-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cat-tree-txns {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Collapsible Groups ── */
.cat-toggle {
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
    user-select: none;
}

.cat-toggle:hover {
    background: var(--bg-primary);
    color: var(--accent);
}

.cat-toggle-spacer {
    width: 18px;
    flex-shrink: 0;
}

.cat-children-group {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 1;
}

.cat-children-group.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ── Budgets ── */
.budgets-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.budget-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.budget-item:hover {
    border-color: var(--border-light);
}

.budget-item.budget-over {
    border-color: var(--expense);
    background: rgba(255, 59, 48, 0.05);
}

.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.budget-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.budget-cat {
    font-weight: 600;
    font-size: 1rem;
}

.budget-period {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: capitalize;
}

.budget-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.budget-nums {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.budget-actions {
    display: flex;
    gap: 4px;
}

.budget-bar-wrap {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.budget-bar {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.6s ease;
}

.budget-bar.over {
    background: var(--expense);
}

.budget-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.8rem;
}

.budget-pct {
    color: var(--text-secondary);
}

.budget-remaining.positive {
    color: var(--green);
}

.budget-remaining.negative {
    color: var(--red);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 480px;
    max-width: 90vw;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

.empty-state .emoji {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ── Spinner ── */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

.spinner--dark {
    border-color: rgba(0, 0, 0, 0.15);
    border-top-color: #333;
}

/* ── Button Loading State ── */
.btn-loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.btn-loading .btn-text {
    visibility: hidden;
}

.btn-loading .spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.btn-primary .btn-text,
.btn-secondary .btn-text,
.google-btn .btn-text,
.email-submit-btn .btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ── App Loading Overlay ── */
.app-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.4s ease;
}

.app-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

.app-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.app-loader-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.app-loader-logo {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--income));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-size: 0.88rem;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 380px;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.success {
    border-left: 3px solid var(--income);
}

.toast.error {
    border-left: 3px solid var(--expense);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(60px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateX(60px) scale(0.95);
    }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        padding: 16px 8px;
    }

    .sidebar-header .logo {
        font-size: 1rem;
    }

    .version,
    .nav-item span:not(.nav-icon),
    .sidebar-footer label {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 10px;
    }

    .sidebar-footer select {
        font-size: 0.7rem;
        padding: 6px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .view {
        padding: 16px;
    }
}