/* MoneyFlow — Mobile-first Personal Finance App UI */

:root {
    --primary: #6C5CE7;
    --primary-dark: #5A45E4;
    --primary-soft: #A29BFE;
    --accent: #00CEC9;
    --income: #00B894;
    --expense: #FF7675;
    --transfer: #74B9FF;
    --surface: #FFFFFF;
    --background: #F7F8FC;
    --text: #2D3436;
    --text-muted: #636E72;
    --border: #ECEEF4;
    --shadow: 0 8px 30px rgba(45, 52, 54, 0.06);
    --shadow-soft: 0 4px 18px rgba(45, 52, 54, 0.05);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;
    --nav-height: 72px;
    --bottom-nav: 78px;
    --desktop-nav: 72px;
    --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --container: 1120px;
}

[data-theme="dark"] {
    --surface: #1E272E;
    --background: #12181F;
    --text: #F5F6FA;
    --text-muted: #A4B0BE;
    --border: #2F3542;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

img { max-width: 100%; display: block; }

a { color: var(--primary); text-decoration: none; }

/* App Shell */
.app-body {
    min-height: 100vh;
    min-height: 100dvh;
}

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 992px) {
    .app-shell {
        padding-top: var(--desktop-nav);
        padding-bottom: 2rem;
    }
}

.app-main { width: 100%; }

.app-container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 1rem 1rem 1.5rem;
}

@media (min-width: 992px) {
    .app-container { padding: 1.5rem 2rem 2rem; }
}

.home-main .app-container { padding-top: 0.5rem; }

body.sheet-open { overflow: hidden; }

/* Desktop Top Nav */
.desktop-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--desktop-nav);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 1030;
}

.desktop-nav-inner {
    max-width: calc(var(--container) + 4rem);
    margin: 0 auto;
    height: 100%;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    font-weight: 800;
    font-size: 1.1rem;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.28);
}

.desktop-nav-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
}

.desktop-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1rem;
    border-radius: 999px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.desktop-nav-link:hover { color: var(--primary); background: rgba(108, 92, 231, 0.06); }
.desktop-nav-link.active { color: var(--primary); background: rgba(108, 92, 231, 0.1); }

.desktop-nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-quick-add {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1.1rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), #8E44FF);
    color: #fff;
    font-weight: 700;
    font-size: 0.875rem;
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.25);
    transition: var(--transition);
}

.btn-quick-add:hover { transform: translateY(-1px); color: #fff; }

.profile-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.85rem 0.35rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: 0.875rem;
}

.profile-chip img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.app-dropdown {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 0.5rem;
}

.app-dropdown .dropdown-item {
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile Bottom Nav */
.mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottom-nav) + env(safe-area-inset-bottom, 0px));
    padding: 0.45rem 0.75rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr auto 1fr 1fr;
    align-items: center;
    gap: 0.25rem;
    z-index: 1030;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-decoration: none;
    padding: 0.35rem 0.25rem;
    border-radius: 12px;
    transition: var(--transition);
}

.mobile-nav-item i { font-size: 1.2rem; }
.mobile-nav-item.active { color: var(--primary); }

.mobile-nav-fab {
    width: 54px;
    height: 54px;
    margin-top: -22px;
    border: 4px solid var(--background);
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), #8E44FF);
    color: #fff;
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(108, 92, 231, 0.35);
    transition: var(--transition);
}

.mobile-nav-fab:active { transform: scale(0.96); }

/* Screen Header */
.screen-header {
    padding: 0.75rem 1rem 0.25rem;
    background: var(--background);
}

@media (min-width: 992px) {
    .screen-header {
        max-width: var(--container);
        margin: 0 auto;
        padding: 1.25rem 2rem 0.5rem;
    }
}

.screen-header-top {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 0.5rem;
}

.screen-back-btn, .header-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--surface);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.screen-back-spacer { width: 40px; height: 40px; }

.screen-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.02em;
}

.screen-subtitle {
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.screen-header-text { min-width: 0; }

/* Home Dashboard */
.home-hero {
    padding: 0.5rem 0 1.25rem;
}

.home-greeting {
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.home-balance-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.home-balance-value {
    font-size: clamp(2rem, 8vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    margin: 0 0 0.35rem;
    line-height: 1.1;
}

.home-balance-meta { margin: 0; font-size: 0.85rem; }

.trend-up { color: var(--income); font-weight: 700; }

.home-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.mini-stat {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-soft);
}

.mini-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.mini-stat-value {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

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

.app-card-block {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    margin-bottom: 0.85rem;
    box-shadow: var(--shadow-soft);
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.block-header h2 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
}

.block-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--income);
    background: rgba(0, 184, 148, 0.1);
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
}

.block-muted { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

.block-link {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
}

.progress-track {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s ease;
}

.progress-fill-saving { background: linear-gradient(90deg, var(--income), var(--accent)); }
.progress-fill-budget { background: linear-gradient(90deg, var(--primary), #a29bfe); }
.progress-fill-warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-fill-danger { background: linear-gradient(90deg, var(--expense), #ff8787); }
.progress-track-sm { height: 8px; margin-top: 0.35rem; }

.budget-progress-list { display: flex; flex-direction: column; gap: 1rem; }
.budget-progress-row { display: flex; flex-direction: column; gap: 0.35rem; }
.budget-progress-head { display: flex; align-items: center; gap: 0.75rem; }
.budget-progress-meta { flex: 1; min-width: 0; }
.budget-progress-name { display: block; font-weight: 700; font-size: 0.9rem; }
.budget-progress-sub { display: block; font-size: 0.78rem; color: var(--text-muted); }
.budget-progress-percent { font-weight: 800; font-size: 0.85rem; color: var(--text-muted); }
.budget-table-progress { min-width: 140px; }
.budget-table-progress-text { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.budget-table-percent { display: block; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); margin-top: 0.2rem; }
.amount-input-wrap-sm { padding: 0.5rem 0.85rem; }
.amount-input-wrap-sm .amount-input { font-size: 1.15rem; }
.category-icon-sm { width: 36px; height: 36px; border-radius: 10px; font-size: 0.95rem; }

.chart-wrap { height: 220px; position: relative; }

.chart-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
}

.dot-income { background: var(--income); }
.dot-expense { background: var(--expense); }

.home-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.quick-pill {
    border: none;
    border-radius: 999px;
    padding: 0.85rem 1rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.quick-pill-income { background: rgba(0, 184, 148, 0.12); color: var(--income); }
.quick-pill-expense { background: rgba(255, 118, 117, 0.12); color: var(--expense); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 1.5rem 0.5rem;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.85rem;
    border-radius: 18px;
    background: rgba(108, 92, 231, 0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* Segment Tabs */
.segment-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem;
    background: var(--surface);
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1rem;
}

.segment-tab {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 0.65rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: var(--transition);
}

.segment-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 16px rgba(108, 92, 231, 0.25);
}

.analytics-period-tabs { margin-bottom: 1.25rem; }

.analytics-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .analytics-summary-grid { grid-template-columns: repeat(4, 1fr); }
}

.analytics-kpi {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow-soft);
}

.analytics-kpi-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.analytics-kpi-value {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.analytics-charts-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 992px) {
    .analytics-charts-grid { grid-template-columns: repeat(2, 1fr); }
}

.chart-wrap-donut { height: 260px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.filter-date { min-width: 120px; max-width: 140px; }

.amount-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.amount-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.12);
}

.amount-currency {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-muted);
}

.amount-input {
    border: none !important;
    box-shadow: none !important;
    font-size: 1.5rem;
    font-weight: 800;
    padding: 0 !important;
}

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

.transaction-list { display: flex; flex-direction: column; gap: 0.65rem; }

.transaction-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}

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

.transaction-item-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.transaction-item-income .transaction-item-icon {
    background: rgba(0, 184, 148, 0.1);
    color: var(--income);
}

.transaction-item-expense .transaction-item-icon {
    background: rgba(255, 118, 117, 0.1);
    color: var(--expense);
}

.transaction-item-body { flex: 1; min-width: 0; }

.transaction-item-title {
    display: block;
    font-weight: 700;
    font-size: 0.925rem;
}

.transaction-item-meta {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.transaction-item-amount {
    font-weight: 800;
    font-size: 0.925rem;
    font-variant-numeric: tabular-nums;
}

/* More Menu */
.menu-profile-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-soft);
}

.menu-profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    object-fit: cover;
}

.menu-profile-card h3 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 0.15rem;
}

.menu-profile-card p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.menu-profile-link {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.menu-section { margin-bottom: 1.25rem; }

.menu-section-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

.menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: none;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-soft);
    color: var(--text);
    text-align: left;
    transition: var(--transition);
}

.menu-item:hover { transform: translateY(-1px); color: var(--text); }
.menu-item-disabled { opacity: 0.55; pointer-events: none; }
.menu-item-danger { color: var(--expense); }

.menu-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

.menu-icon-violet { background: rgba(108,92,231,.12); color: var(--primary); }
.menu-icon-rose { background: rgba(255,118,117,.12); color: var(--expense); }
.menu-icon-blue { background: rgba(116,185,255,.12); color: var(--transfer); }
.menu-icon-amber { background: rgba(253,203,110,.18); color: #E17055; }
.menu-icon-teal { background: rgba(0,206,201,.12); color: var(--accent); }
.menu-icon-indigo { background: rgba(99,110,255,.12); color: #636EFF; }
.menu-icon-gray { background: rgba(99,110,114,.1); color: var(--text-muted); }
.menu-icon-danger { background: rgba(255,118,117,.12); color: var(--expense); }

.menu-item-text { flex: 1; font-weight: 700; font-size: 0.925rem; }
.menu-item-arrow { color: var(--text-muted); }
.menu-soon {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--background);
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
}

/* Filters & Tables */
.filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

@media (min-width: 768px) {
    .filter-row { flex-direction: row; }
}

.filter-search { position: relative; flex: 1; }
.filter-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-search .mf-input { padding-left: 2.75rem; }
.filter-select { max-width: 140px; }

.table-block { padding: 0.5rem 0.25rem 0.75rem; }
.table-responsive-wrap { overflow-x: auto; }

.mf-table thead th {
    font-size: 0.68rem !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted) !important;
    border-bottom: 1px solid var(--border) !important;
    white-space: nowrap;
}

.mf-table tbody td {
    vertical-align: middle !important;
    border-bottom: 1px solid rgba(236, 238, 244, 0.8) !important;
    padding: 0.9rem 0.65rem !important;
}

.category-cell { display: flex; align-items: center; gap: 0.75rem; }
.category-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--cat-color) 14%, transparent);
    color: var(--cat-color);
}
.category-name { font-weight: 700; font-size: 0.9rem; }

.order-chip {
    display: inline-flex;
    min-width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--background);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
}
.status-pill-active { background: rgba(0,184,148,.12); color: var(--income); }
.status-pill-pending { background: rgba(245,158,11,.12); color: #d97706; }
.status-pill-inactive { background: rgba(99,110,114,.1); color: var(--text-muted); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.table-action-group { display: inline-flex; gap: 0.35rem; }
.table-action-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.table-action-edit { background: rgba(108,92,231,.1); color: var(--primary); }
.table-action-delete { background: rgba(255,118,117,.1); color: var(--expense); }

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { display: none; }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: 0.78rem; color: var(--text-muted); padding-top: 0.75rem !important; }
.dataTables_wrapper .page-link { border: none !important; border-radius: 10px !important; font-weight: 700; }
.dataTables_wrapper .page-item.active .page-link { background: var(--primary) !important; }

/* Forms & Buttons */
.mf-input, .mf-select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    background: var(--surface);
    color: var(--text);
    font-size: 0.925rem;
    transition: var(--transition);
}

.mf-input:focus, .mf-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.12);
}

.mf-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 0.45rem;
    color: var(--text);
}

.mf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.85rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 0.925rem;
    transition: var(--transition);
}

.mf-btn-primary {
    background: linear-gradient(135deg, var(--primary), #8E44FF);
    color: #fff;
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.25);
}

.mf-btn-primary:hover { color: #fff; transform: translateY(-1px); }
.mf-btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.mf-btn-block { width: 100%; }

.icon-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.45rem; }
@media (min-width: 576px) { .icon-picker { grid-template-columns: repeat(8, 1fr); } }
.icon-picker-item {
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-picker-item.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(108, 92, 231, 0.08);
}

.color-picker { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.color-picker-item {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--surface);
    background: var(--swatch);
    box-shadow: 0 0 0 1px var(--border);
    padding: 0;
}
.color-picker-item.active { transform: scale(1.08); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch); }

.color-preview { display: flex; align-items: center; gap: 0.65rem; }
.mf-switch .form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

.type-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(108, 92, 231, 0.08);
    color: var(--primary);
}

.balance-cell { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Bottom Sheets */
.mf-sheet {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.mf-sheet.show {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
}

.mf-sheet-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(45, 52, 54, 0.45);
    pointer-events: auto;
    cursor: pointer;
}

.mf-sheet-panel {
    position: relative;
    z-index: 2;
    width: 100%;
    max-height: 92dvh;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    touch-action: manipulation;
    overflow: hidden;
}

.mf-sheet.show .mf-sheet-panel {
    transform: translateY(0);
}

.mf-sheet-body {
    padding: 0.5rem 1.25rem 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 992px) {
    .mf-sheet {
        align-items: center;
        padding: 2rem;
    }

    .mf-sheet-panel {
        max-width: 520px;
        border-radius: var(--radius-xl);
        max-height: 85vh;
        transform: translateY(20px) scale(0.98);
    }

    .mf-sheet.show .mf-sheet-panel {
        transform: translateY(0) scale(1);
    }

    .mf-sheet-md .mf-sheet-panel {
        max-width: 640px;
    }
}

.mf-sheet-handle {
    width: 42px;
    height: 5px;
    background: var(--border);
    border-radius: 999px;
    margin: 0.65rem auto 0;
}

.mf-sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem 0.5rem;
}

.mf-sheet-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.02em;
}

.mf-sheet-subtitle {
    margin: 0.15rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.sheet-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--background);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mf-sheet-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
}

.quick-add-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 0 1.25rem 1.5rem;
}

.quick-add-option {
    border: none;
    background: var(--background);
    border-radius: var(--radius-md);
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    transition: var(--transition);
}

.quick-add-option:active { transform: scale(0.98); }
.quick-add-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.quick-add-income .quick-add-icon { background: rgba(0,184,148,.12); color: var(--income); }
.quick-add-expense .quick-add-icon { background: rgba(255,118,117,.12); color: var(--expense); }
.quick-add-transfer .quick-add-icon { background: rgba(116,185,255,.12); color: var(--transfer); }
.quick-add-label { font-weight: 800; font-size: 0.82rem; color: var(--text); }

/* Auth */
.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(circle at top right, rgba(108, 92, 231, 0.18), transparent 28%),
        radial-gradient(circle at bottom left, rgba(0, 206, 201, 0.12), transparent 24%),
        var(--background);
}

.auth-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem 1rem;
    max-width: 440px;
    margin: 0 auto;
}

.auth-top { margin-bottom: 1.25rem; }

.auth-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.auth-logo-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 10px 24px rgba(108, 92, 231, 0.28);
}

.auth-logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.auth-heading h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
    letter-spacing: -0.03em;
}

.auth-heading p {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.auth-field { margin-bottom: 1rem; }
.auth-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 0.45rem;
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.auth-link, .auth-back-link {
    font-weight: 700;
    font-size: 0.875rem;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
}

.auth-footer-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 1.25rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Settings Profile */
.settings-profile-card {
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-soft);
}

.settings-profile-card h3 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0.85rem 0 0.15rem;
}

.settings-profile-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.profile-avatar-wrapper {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 0 auto;
}

.profile-avatar-lg {
    width: 96px;
    height: 96px;
    border-radius: 24px;
    object-fit: cover;
}

.profile-avatar-edit {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--surface);
    cursor: pointer;
}

.settings-tabs { margin-top: 0.5rem; }

/* Toastr */
#toast-container > div {
    border-radius: 12px;
    box-shadow: var(--shadow);
    opacity: 1;
    font-weight: 600;
}

/* Utilities */
.text-truncate-cell {
    display: block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.85rem;
}

@media (min-width: 992px) {
    .home-hero {
        padding-top: 0.25rem;
    }

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

    .home-stats-grid .mini-stat:first-child { grid-column: span 1; }
}

/* Mobile List UI */
.list-block { padding: 0.35rem 0.5rem 0.85rem; }

.mf-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.mf-list-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.9rem 0.35rem;
    border-bottom: 1px solid rgba(236, 238, 244, 0.85);
}

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

.mf-list-item-link {
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    border-radius: var(--radius-sm);
    margin: 0 -0.35rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.mf-list-item-link:active { background: rgba(108, 92, 231, 0.06); }

.mf-list-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--cat-color) 14%, transparent);
    color: var(--cat-color);
    font-size: 1.05rem;
}

.mf-list-icon-tx {
    background: var(--background);
}
.mf-list-icon-tx.income { color: var(--income); background: rgba(0,184,148,.1); }
.mf-list-icon-tx.expense { color: var(--expense); background: rgba(255,118,117,.1); }
.mf-list-icon-tx.transfer { color: var(--primary); background: rgba(108,92,231,.1); }

.mf-list-body { flex: 1; min-width: 0; }
.mf-list-body-wide { flex: 1; min-width: 0; }

.mf-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.mf-list-title {
    font-weight: 800;
    font-size: 0.92rem;
    line-height: 1.3;
    color: var(--text);
}

.mf-list-meta {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.mf-list-date {
    display: block;
    margin-top: 0.15rem;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.mf-list-trailing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
    flex-shrink: 0;
}

.mf-list-value {
    font-weight: 800;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mf-list-percent {
    font-weight: 800;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.mf-list-actions {
    display: inline-flex;
    gap: 0.25rem;
}

.mf-list-action {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: var(--background);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mf-list-action-danger { color: var(--expense); }

.mf-list-load-more {
    width: 100%;
    margin-top: 0.65rem;
}

.mf-list-empty .empty-state { padding: 1.5rem 0.5rem; }

.mf-list-item-budget .progress-track { margin-top: 0.45rem; }

.mf-list-item-report .mf-list-value {
    align-self: center;
    max-width: 42%;
    text-align: right;
    word-break: break-word;
    white-space: normal;
}

.export-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.export-actions .mf-btn { flex: 1; min-width: 90px; }

.home-hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.home-search-btn,
.btn-search-global {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-sheet-input-wrap {
    position: relative;
    margin-bottom: 0.85rem;
}

.search-sheet-input-wrap i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-sheet-input-wrap .mf-input { padding-left: 2.75rem; }

.mf-sheet-panel-tall { max-height: 88vh; }

.mf-list-search .mf-list-item-link { padding-top: 0.85rem; padding-bottom: 0.85rem; }

@media (min-width: 768px) {
    .mf-list-item { padding-left: 0.65rem; padding-right: 0.65rem; }
    .mf-list-trailing { flex-direction: row; align-items: center; }
}

.impersonation-banner {
    position: sticky;
    top: 0;
    z-index: 1050;
    background: linear-gradient(135deg, #6C5CE7 0%, #5a4bd1 100%);
    color: #fff;
    padding: 0.65rem 1rem;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.35);
}

.impersonation-banner-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.875rem;
}

.impersonation-banner-inner i { font-size: 1rem; opacity: 0.9; }

.impersonation-leave-btn {
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.impersonation-leave-btn:hover { background: rgba(255, 255, 255, 0.22); }

body.is-impersonating .app-shell { padding-top: 0; }

.mf-list-item-admin-user .mf-list-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
}

.mf-list-trailing-admin {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
}

.mf-list-action-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.mf-list-icon-user {
    background: var(--surface);
    border: 1px solid var(--border);
}

.user-avatar-letter {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
}

.admin-chip {
    background: rgba(108, 92, 231, 0.12);
    color: var(--primary);
}

.current-chip {
    background: rgba(0, 184, 148, 0.12);
    color: var(--income);
}

.btn-switch-user,
.mf-list-action.btn-switch-user {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 12px;
    background: rgba(108, 92, 231, 0.12);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-switch-user:hover { background: rgba(108, 92, 231, 0.2); }
