/* ============================================
   RANDI - Design System
   South African Fintech UI
   ============================================ */

/* ---------- Mobile name-grid (register / settings) ---------- */
@media (max-width: 480px) {
    .name-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ---------- CSS Variables ---------- */
:root {
    /* Brand - SA Forest Green */
    --primary: #007A4D;
    --primary-light: #00A86B;
    --primary-dark: #005A38;
    --primary-glow: rgba(0, 122, 77, 0.18);

    /* Accent - SA Gold */
    --accent: #FFB612;
    --accent-light: #FFD166;
    --accent-dark: #E09900;
    --accent-glow: rgba(255, 182, 18, 0.15);

    /* Status */
    --success: #00A86B;
    --success-bg: rgba(0, 168, 107, 0.12);
    --warning: #FFB612;
    --warning-bg: rgba(255, 182, 18, 0.12);
    --danger: #DE3831;
    --danger-bg: rgba(222, 56, 49, 0.12);
    --info: #1A7DC4;
    --info-bg: rgba(26, 125, 196, 0.12);

    /* Dark Theme - Deep Green-tinted backgrounds */
    --bg-dark: #080E0A;
    --bg-card: #0F1A13;
    --bg-card-hover: #152019;
    --bg-elevated: #1C2B21;
    --bg-input: #0F1A13;
    --border: rgba(0, 168, 107, 0.10);
    --border-focus: rgba(0, 122, 77, 0.5);

    /* Text */
    --text-primary: #EDF5F0;
    --text-secondary: #8FB8A5;
    --text-muted: #4A7060;
    --text-accent: #FFD166;

    /* Sizing */
    --sidebar-width: 260px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(0, 122, 77, 0.25);
    --shadow-gold: 0 0 24px rgba(255, 182, 18, 0.2);

    /* Transitions */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

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

html,
body {
    width: 100%;
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

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

a:hover {
    color: var(--accent-light);
}

/* ---------- App Layout ---------- */
.app-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* SA flag accent stripe at top of sidebar */
.sidebar::before {
    content: '';
    display: block;
    height: 3px;
    /* background: linear-gradient(90deg, #000 0%, #000 16.6%, #FFB612 16.6%, #FFB612 33.3%, #007A4D 33.3%, #007A4D 50%, #007A4D 66.6%, #FFFFFF 66.6%, #FFFFFF 83.3%, #DE3831 83.3%, #DE3831 100%); */
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-name {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

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

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary-light);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: linear-gradient(180deg, var(--primary-light), var(--accent));
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 11px;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--text-muted) !important;
}

.logout-btn:hover {
    color: var(--danger) !important;
    background: var(--danger-bg) !important;
}

/* ---------- Mobile Header ---------- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 99;
}

/* SA flag stripe on mobile header */
.mobile-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 50%, var(--danger) 100%);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--bg-elevated);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* ---------- Overlay for mobile sidebar ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
    display: block;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
    max-width: calc(100% - var(--sidebar-width));
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-header {
    margin-bottom: 28px;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ---------- Cards & Containers ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
    min-width: 0;
    overflow: hidden;
}

.card:hover {
    border-color: rgba(0, 168, 107, 0.2);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

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

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0, 168, 107, 0.25);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 90px;
    height: 90px;
    border-radius: 0 0 0 90px;
    opacity: 0.07;
}

.stat-card.income::after {
    background: var(--success);
}

.stat-card.expense::after {
    background: var(--danger);
}

.stat-card.balance::after {
    background: var(--primary);
}

.stat-card.transactions::after {
    background: var(--accent);
}

/* Accent top border on stat cards */
.stat-card.income {
    border-top: 2px solid var(--success);
}

.stat-card.expense {
    border-top: 2px solid var(--danger);
}

.stat-card.balance {
    border-top: 2px solid var(--primary);
}

.stat-card.transactions {
    border-top: 2px solid var(--accent);
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.1;
}

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

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

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

.stat-change {
    font-size: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

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

.charts-grid > * {
    min-width: 0;
    overflow: hidden;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

/* ---------- Tables ---------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

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

/* ---------- Mobile Card List (replaces table on small screens) ---------- */
.mobile-tx-list {
    display: none;
    flex-direction: column;
    gap: 10px;
}

.mobile-tx-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.mobile-tx-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: var(--bg-card);
}

.mobile-tx-body {
    flex: 1;
    min-width: 0;
}

.mobile-tx-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-tx-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.mobile-tx-amount {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-primary {
    background: var(--primary-glow);
    color: var(--primary-light);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 12px rgba(0, 122, 77, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 122, 77, 0.5);
    color: white;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #0A0F0D;
    box-shadow: 0 2px 12px rgba(255, 182, 18, 0.3);
    font-weight: 700;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255, 182, 18, 0.45);
    color: #0A0F0D;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: rgba(0, 168, 107, 0.3);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #C42E28;
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
    border-radius: var(--radius-md);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%234A7060'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---------- Alerts ---------- */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
    gap: 12px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(0, 168, 107, 0.25);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(255, 182, 18, 0.25);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(222, 56, 49, 0.25);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(26, 125, 196, 0.25);
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    padding: 0 4px;
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
}

/* ---------- Auth Layout ---------- */
.auth-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
}

.auth-layout::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 122, 77, 0.08), transparent 70%);
    top: -150px;
    right: -150px;
    pointer-events: none;
}

.auth-layout::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 182, 18, 0.05), transparent 70%);
    bottom: -150px;
    left: -150px;
    pointer-events: none;
}

/* SA flag bottom stripe on auth pages */
.auth-layout .sa-stripe {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #000 0%, #000 20%, #FFB612 20%, #FFB612 40%, #007A4D 40%, #007A4D 60%, #FFFFFF 60%, #FFFFFF 80%, #DE3831 80%, #DE3831 100%);
    z-index: 10;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-brand .brand-icon {
    margin: 0 auto 12px;
}

.auth-brand .brand-name {
    font-size: 30px;
}

.auth-brand p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 8px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-footer a {
    font-weight: 600;
    color: var(--primary-light);
}

.auth-footer a:hover {
    color: var(--accent);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ---------- Upload Dropzone ---------- */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 50px 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.dropzone-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 20px;
    background: var(--primary-glow);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropzone-icon svg {
    width: 28px;
    height: 28px;
    color: var(--primary-light);
}

.dropzone-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.dropzone-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.dropzone-formats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.format-badge {
    padding: 4px 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid var(--border);
}

/* ---------- Insight Cards ---------- */
.insight-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    gap: 14px;
    transition: var(--transition);
    margin-bottom: 10px;
}

.insight-card:hover {
    border-color: rgba(0, 168, 107, 0.2);
    transform: translateX(4px);
}

.insight-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}

.insight-icon.success {
    background: var(--success-bg);
}

.insight-icon.warning {
    background: var(--warning-bg);
}

.insight-icon.info {
    background: var(--info-bg);
}

.insight-icon.critical {
    background: var(--danger-bg);
}

.insight-content {
    flex: 1;
    min-width: 0;
}

.insight-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.insight-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.insight-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition-fast);
}

.insight-dismiss:hover {
    color: var(--text-primary);
}

/* ---------- Category Tag ---------- */
.category-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    white-space: nowrap;
}

.category-emoji {
    font-size: 13px;
}

/* ---------- File List ---------- */
.file-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: var(--transition);
    flex-wrap: wrap;
}

.file-item:hover {
    border-color: rgba(0, 168, 107, 0.25);
}

.file-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.file-icon.pdf {
    background: var(--danger-bg);
    color: var(--danger);
}

.file-icon.csv {
    background: var(--success-bg);
    color: var(--success);
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---------- Progress Bar ---------- */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-icon svg {
    width: 36px;
    height: 36px;
    color: var(--primary);
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
    max-width: 360px;
    margin: 0 auto 24px;
    line-height: 1.6;
}

/* ---------- Loading Spinner ---------- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.pagination a:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
}

/* ---------- Animations ---------- */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes shimmer {
    0% {
        background-position: -400px 0;
    }

    100% {
        background-position: 400px 0;
    }
}

.animate-in {
    animation: slideUp 0.4s ease forwards;
}

/* ---------- SA Flag Divider ---------- */
.sa-divider {
    height: 3px;
    background: linear-gradient(90deg,
            #000 0%, #000 20%,
            #FFB612 20%, #FFB612 40%,
            #007A4D 40%, #007A4D 60%,
            #FFFFFF 60%, #FFFFFF 80%,
            #DE3831 80%, #DE3831 100%);
    border-radius: var(--radius-full);
    margin: 24px 0;
    opacity: 0.4;
}

/* ---------- Filter Bar ---------- */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-bar .form-group {
    margin-bottom: 0;
}

.filter-search {
    flex: 1;
    min-width: 180px;
}

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

/* ---------- Responsive Breakpoints ---------- */

/* --- Tablet (1024px) --- */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 28px 24px;
    }
}

/* --- Mobile (768px) --- */
@media (max-width: 768px) {

    /* Sidebar hidden by default - slide in */
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: var(--shadow-lg);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Show mobile top bar */
    .mobile-header {
        display: flex;
    }

    /* Push content below mobile header */
    .main-content {
        margin-left: 0;
        padding: 76px 16px 32px;
        max-width: 100%;
        width: auto;
        overflow-x: hidden;
    }

    /* Prevent any child from exceeding viewport */
    .app-layout {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Hide desktop top header on mobile */
    .top-header {
        display: none !important;
    }

    /* Notification dropdown mobile overrides */
    .notification-dropdown {
        position: fixed !important;
        top: 65px !important;
        right: 16px !important;
        width: calc(100% - 32px) !important;
        max-width: 350px !important;
        z-index: 2000 !important;
    }

    /* Adjust page header on mobile */
    .page-header {
        margin-bottom: 20px;
    }

    .page-header.flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .page-header.flex-between .btn {
        width: 100%;
        justify-content: center;
    }

    .page-title {
        font-size: 22px;
    }

    /* Stats - 2 columns */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 20px;
    }

    /* Auth card */
    .auth-card {
        padding: 28px 22px;
        border-radius: var(--radius-lg);
    }

    /* Charts full width */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Tables: on mobile, hide table and show card list if .mobile-tx-list exists */
    .desktop-table {
        display: none !important;
    }

    .mobile-tx-list {
        display: flex !important;
    }

    /* Card padding reduce */
    .card {
        padding: 18px 16px;
        overflow-x: hidden;
    }

    /* Dashboard alert banners - stack vertically on mobile */
    .alert-transfer {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 14px 16px !important;
    }
    .alert-transfer .btn {
        width: 100%;
        justify-content: center;
    }

    /* Budget Health card - stack on mobile */
    .dashboard-health-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        padding: 16px !important;
    }

    /* Financial Goals card - stack on mobile */
    .dashboard-goal-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        padding: 16px !important;
    }
    .dashboard-goal-card > div[style*="flex: 1"] {
        width: 100% !important;
    }
    .dashboard-goal-card > div[style*="flex: 1"] > div[style*="flex-start"] {
        flex-direction: column !important;
        gap: 4px !important;
    }

    /* Month vs Month section */
    .dashboard-month-compare > div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Savings opportunity items */
    .savings-opp-item {
        padding: 10px 8px !important;
        min-width: 0;
        overflow: hidden;
    }
    .savings-opp-item > div {
        min-width: 0 !important;
    }

    #dashboard-savings-card {
        overflow: hidden;
    }

    /* Insight cards - prevent clipping */
    .insight-card {
        padding: 14px 12px;
        overflow: hidden;
    }
    .insight-text {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Dropzone */
    .dropzone {
        padding: 36px 20px;
    }

    /* Filter bar */
    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .form-group,
    .filter-bar .filter-search,
    .filter-bar .filter-select {
        width: 100%;
        min-width: 0;
    }

    .filter-bar .btn {
        width: 100%;
    }

    /* Pagination */
    .pagination a,
    .pagination span {
        padding: 8px 11px;
        font-size: 12px;
    }
}

/* --- Small Mobile (480px) --- */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 72px 10px 28px;
    }

    .card {
        padding: 14px 12px;
        border-radius: var(--radius-md);
        overflow-x: hidden;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 20px;
    }

    .auth-card {
        padding: 24px 18px;
    }

    .btn-lg {
        padding: 13px 24px;
        font-size: 15px;
    }

    .page-title {
        font-size: 20px;
    }

    /* Dashboard inline-styled cards: enforce wrapping */
    .alert-transfer {
        padding: 12px !important;
    }

    .dashboard-health-card,
    .dashboard-goal-card,
    .dashboard-month-compare {
        padding: 14px 12px !important;
    }

    /* Savings card */
    #dashboard-savings-card {
        padding: 14px 12px !important;
    }

    .savings-opp-item {
        gap: 8px !important;
    }
    .savings-opp-item > div > div[style*="font-size: 12px"],
    .savings-opp-item > div > div[style*="font-size: 13px"] {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Recent Transactions card header */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Insight cards */
    .insight-card {
        padding: 12px 10px;
        gap: 10px;
    }
    .insight-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    .insight-title {
        font-size: 13px;
    }
    .insight-text {
        font-size: 12px;
    }

    /* Mobile amount values - prevent cutoff */
    .mobile-tx-amount {
        font-size: 13px;
    }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

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

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

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

/* ---------- Utilities ---------- */
.text-center {
    text-align: center;
}

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

.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-primary {
    color: var(--primary-light);
}

.text-accent {
    color: var(--accent);
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 22px 20px;
    width: min(440px, 96vw);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.modal-form .form-input {
    width: 100%;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

/* ---------- Category Picker (Transactions page) ---------- */
.category-cell {
    display: flex;
    align-items: center;
}

.category-tag-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px;
    transition: background 0.2s;
}

.category-tag-wrapper:hover {
    background: rgba(0, 122, 77, 0.08);
}

.ai-badge {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 5px;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(0, 122, 77, 0.35);
}

.category-picker {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    width: 260px;
    margin-top: 6px;
    animation: slideDown 0.2s ease;
}

.picker-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-left: 4px;
    letter-spacing: 0.5px;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.picker-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.picker-item:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.72rem;
    border-radius: 4px;
}

/* ---------- Review page specific ---------- */
.review-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 14px;
    overflow: hidden;
    transition: var(--transition);
}

.review-card:hover {
    border-color: rgba(0, 168, 107, 0.2);
}

/* ---------- Chat page specific ---------- */
.chat-bubble-user {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}

.chat-bubble-ai {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

/* ---------- Settings page ---------- */
.settings-section {
    margin-bottom: 32px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    gap: 20px;
    flex-wrap: wrap;
}

.settings-row:last-child {
    border-bottom: none;
}

/* ---------- Gold Highlight Accent ---------- */
.gold-accent {
    color: var(--accent);
    font-weight: 700;
}

/* Number highlight on dashboard */
.highlight-number {
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}