/* ================================================================
   BRIDGEBANKS360 DUAL-THEME SYSTEM
   ================================================================
   Theme 1: Imperial & Gold (Dark Mode) - Premium naval aesthetics
   Theme 2: Arctic & Azure (Light Mode) - Clean professional design
   
   Usage:
   - Add class 'theme-dark' to <body> for Imperial & Gold
   - Add class 'theme-light' to <body> for Arctic & Azure
   - Default: Uses system preference if no class specified
   ================================================================ */

/* ================================================================
   THEME 1: IMPERIAL & GOLD (DARK MODE)
   ================================================================ */
body.theme-dark {
    --bg-primary: #0C1E2F;          /* Deeper navy for premium feel */
    --bg-secondary: #1A2F45;        /* Richer secondary background */
    --bg-tertiary: #0D1F35;
    --border-color: #2E4A66;        /* Softer border for elegance */
    --text-primary: #F5F0E6;        /* Warmer cream for better readability */
    --text-secondary: #B8C5D3;      /* Lighter secondary text */
    --accent-gold: #D4AF37;         /* Rich metallic gold highlight */
    --accent-green: #2ECC71;        /* Modern emerald green */
    --accent-red: #E74C3C;          /* Vibrant red for alerts */
    --accent-blue: #5DADE2;         /* Sky blue for info */
    --metric-value-color: #6FE7C1;  /* Luminous teal metric highlight */
    --accent-gradient-strong: linear-gradient(135deg, rgba(212, 175, 55, 0.95), rgba(46, 204, 113, 0.82));
    --accent-gradient-soft: linear-gradient(135deg, rgba(212, 175, 55, 0.18), rgba(46, 204, 113, 0.12));
    --nav-bg: rgba(13, 31, 53, 0.78);
    --nav-border: rgba(212, 175, 55, 0.22);
    --header-bg: linear-gradient(135deg, rgba(12, 30, 47, 0.95), rgba(22, 73, 104, 0.9));
    --header-shadow: 0 18px 40px rgba(12, 30, 47, 0.45);
    --menu-control-bg: rgba(15, 29, 48, 0.35);
    --menu-control-border: rgba(212, 175, 55, 0.28);
    --pill-bg: rgba(212, 175, 55, 0.16);
    --pill-text: rgba(245, 240, 230, 0.95);
    --pill-border: rgba(212, 175, 55, 0.32);
    --admin-cta-gradient: linear-gradient(135deg, rgba(212, 175, 55, 0.92), rgba(46, 204, 113, 0.88));
    --admin-cta-text: #0C1E2F;
    --font-primary: 'Inter', sans-serif;
    --font-monospace: 'Roboto Mono', monospace;
    
    /* Shadows for depth */
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 6px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.7);
    
    /* Card styles */
    --card-bg: var(--bg-secondary);
    --card-border: var(--border-color);
    --card-hover-bg: rgba(255, 215, 0, 0.08);
}

/* ================================================================
   THEME 2: ARCTIC & AZURE (LIGHT MODE)
   ================================================================ */
body.theme-light {
    --bg-primary: #FAFBFC;          /* Slightly off-white for comfort */
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F4F6F8;         /* Subtle gray for cards */
    --border-color: #D0D7DE;        /* Softer border */
    --text-primary: #1F2937;        /* Darker for better contrast */
    --text-secondary: #6B7280;      /* Modern gray */
    --accent-blue: #0066CC;         /* Professional deep blue */
    --accent-green: #20C997;        /* Modern teal/turquoise */
    --accent-red: #DC3545;
    --accent-gold: #DAA520;         /* Goldenrod highlight */
    --accent-teal: #14B8A6;         /* Teal accent */
    --accent-gradient-strong: linear-gradient(135deg, rgba(0, 102, 204, 0.95), rgba(20, 184, 166, 0.9));
    --accent-gradient-soft: linear-gradient(135deg, rgba(0, 102, 204, 0.14), rgba(20, 184, 166, 0.1));
    --nav-bg: rgba(255, 255, 255, 0.94);
    --nav-border: rgba(209, 213, 219, 0.85);
    --header-bg: linear-gradient(135deg, rgba(224, 242, 254, 0.98), rgba(191, 219, 254, 0.9));
    --header-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
    --menu-control-bg: rgba(255, 255, 255, 0.95);
    --menu-control-border: rgba(209, 213, 219, 0.88);
    --pill-bg: rgba(0, 102, 204, 0.12);
    --pill-text: rgba(15, 23, 42, 0.85);
    --pill-border: rgba(0, 102, 204, 0.25);
    --admin-cta-gradient: linear-gradient(135deg, rgba(0, 102, 204, 0.95), rgba(20, 184, 166, 0.9));
    --admin-cta-text: #ffffff;
    --metric-value-color: #1FBFA4;  /* Fresh jade metric highlight */
    --font-primary: 'Inter', sans-serif;
    --font-monospace: 'Roboto Mono', monospace;
    
    /* Shadows for subtle depth */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.1);
    
    /* Card styles */
    --card-bg: var(--bg-secondary);
    --card-border: var(--border-color);
    --card-hover-bg: rgba(0, 102, 204, 0.04);
}

/* ================================================================
   GLOBAL STYLES (Applied to both themes)
   ================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography - Uniform Text Colors */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
}

p, span, div, td, th, li, label {
    color: var(--text-primary);
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

body.theme-light a {
    color: var(--accent-blue);
}

body.theme-light a:hover {
    color: var(--accent-teal);
}

/* Table text */
table {
    color: var(--text-primary);
}

thead th {
    color: var(--text-primary);
}

tbody td {
    color: var(--text-primary);
}

/* Form elements */
input, select, textarea, button {
    color: var(--text-primary);
}

/* Placeholder text */
::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ================================================================
   LAYOUT
   ================================================================ */
.page-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ================================================================
   HEADER
   ================================================================ */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    background: var(--bg-secondary);
}

body.theme-dark .main-header {
    background: var(--header-bg);
    border-color: transparent;
    box-shadow: var(--header-shadow);
    backdrop-filter: blur(12px);
}

body.theme-light .main-header {
    background: var(--header-bg);
    border-color: var(--nav-border);
    box-shadow: var(--header-shadow);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

body.theme-dark .logo span {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.theme-light .logo span {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.35rem 0.4rem;
    border-radius: 999px;
    background: var(--nav-bg, rgba(255, 255, 255, 0.06));
    border: 1px solid var(--nav-border, rgba(255, 255, 255, 0.12));
    box-shadow: var(--shadow-sm);
}

body.theme-dark .main-nav {
    backdrop-filter: blur(10px);
}

.main-nav a,
.main-nav button {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.55rem 1.15rem;
    transition: all 0.3s ease;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    position: relative;
    border: 1px solid transparent;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.main-nav a:hover,
.main-nav button:hover {
    color: var(--text-primary);
}

body.theme-dark .main-nav a:hover,
body.theme-dark .main-nav button:hover {
    background: var(--accent-gradient-soft);
    border-color: var(--menu-control-border);
    color: var(--accent-gold);
}

body.theme-light .main-nav a:hover,
body.theme-light .main-nav button:hover {
    background: var(--accent-gradient-soft);
    border-color: var(--nav-border);
    color: var(--accent-blue);
}

body.theme-dark .main-nav a.active,
body.theme-dark .main-nav button.active {
    color: var(--admin-cta-text);
    background: var(--accent-gradient-strong);
    border-color: transparent;
    box-shadow: 0 10px 26px rgba(212, 175, 55, 0.28);
}

body.theme-light .main-nav a.active,
body.theme-light .main-nav button.active {
    color: var(--admin-cta-text);
    background: var(--accent-gradient-strong);
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(0, 102, 204, 0.22);
}

.main-nav .badge-placeholder {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
}

body.theme-light .main-nav .badge-placeholder {
    background: rgba(0, 102, 204, 0.12);
    color: var(--accent-blue);
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

body.theme-dark .avatar {
    border-color: var(--accent-gold);
}

body.theme-light .avatar {
    border-color: var(--accent-blue);
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--menu-control-bg, transparent);
    border: 1px solid var(--menu-control-border, var(--border-color));
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

body.theme-dark .theme-toggle:hover {
    border-color: var(--menu-control-border);
    background-color: rgba(212, 175, 55, 0.12);
}

body.theme-light .theme-toggle:hover {
    border-color: var(--nav-border);
    background-color: rgba(0, 102, 204, 0.08);
}

.theme-toggle[disabled],
.theme-toggle.theme-toggle--locked {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.theme-toggle.theme-toggle--locked .theme-text {
    font-weight: 600;
}

/* Admin Button (only for admin users) */
.admin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
}

.admin-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

body.theme-dark .admin-button:hover {
    border-color: var(--accent-gold);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
}

body.theme-light .admin-button:hover {
    border-color: var(--accent-blue);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.03));
}

.admin-button i {
    width: 20px;
    height: 20px;
}

/* ================================================================
   CONTENT WRAPPER
   ================================================================ */
.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.welcome-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
    gap: 2rem;
    padding: 2.25rem;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

body.theme-dark .welcome-hero {
    background: radial-gradient(circle at top left, rgba(212, 175, 55, 0.18), transparent 58%),
                radial-gradient(circle at bottom right, rgba(90, 143, 214, 0.18), transparent 55%),
                linear-gradient(135deg, rgba(16, 36, 58, 0.96), rgba(10, 25, 49, 0.92));
    border-color: rgba(212, 175, 55, 0.25);
}

body.theme-light .welcome-hero {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.15), rgba(20, 184, 166, 0.1)), var(--bg-secondary);
    border-color: rgba(0, 102, 204, 0.12);
}

.welcome-hero__content {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    z-index: 1;
}

.welcome-hero__eyebrow {
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--accent-gold);
}

body.theme-light .welcome-hero__eyebrow {
    color: var(--accent-blue);
}

.welcome-hero__content h1 {
    font-size: clamp(2.1rem, 4vw, 2.65rem);
    font-weight: 700;
}

body.theme-dark .welcome-hero__content h1 {
    color: rgba(255, 255, 255, 0.94);
}

.welcome-hero__lede {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 32rem;
}

.welcome-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: center;
}

.welcome-hero__primary,
.welcome-hero__secondary,
.welcome-hero__tertiary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.35rem;
    border-radius: 999px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.welcome-hero__primary {
    color: #0C1E2F;
    background: linear-gradient(135deg, var(--accent-gold), #f1d678);
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.28);
}

body.theme-light .welcome-hero__primary {
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent-blue), #0056b3);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.25);
}

.welcome-hero__primary:hover,
.welcome-hero__secondary:hover,
.welcome-hero__tertiary:hover {
    transform: translateY(-2px);
}

.welcome-hero__secondary {
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
}

body.theme-light .welcome-hero__secondary {
    background: rgba(0, 102, 204, 0.05);
}

.welcome-hero__tertiary {
    color: var(--accent-gold);
    border: 1px dashed rgba(212, 175, 55, 0.6);
    background: transparent;
    padding: 0.75rem 1.2rem;
}

.welcome-hero__tertiary i {
    height: 18px;
}

body.theme-light .welcome-hero__tertiary {
    color: var(--accent-blue);
    border-color: rgba(0, 102, 204, 0.45);
}

/* Analyze New Statement Button (Top Right of Welcome Hero) */
.welcome-hero__upload-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-gold), #f1d678);
    color: var(--bg-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
    z-index: 10;
    border: none;
}

body.theme-light .welcome-hero__upload-btn {
    background: linear-gradient(135deg, var(--accent-blue), #60a5fa);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.welcome-hero__upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(212, 175, 55, 0.4);
}

body.theme-light .welcome-hero__upload-btn:hover {
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.welcome-hero__upload-btn i {
    width: 18px;
    height: 18px;
}

.welcome-hero__metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    z-index: 1;
}

.metric-card {
    display: flex;
    gap: 1rem;
    padding: 1.35rem;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.theme-light .metric-card {
    border-color: rgba(0, 102, 204, 0.08);
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.metric-card__icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

body.theme-light .metric-card__icon {
    background: rgba(0, 102, 204, 0.08);
}

.metric-card__content h2 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.metric-card__value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-card__value--negative {
    color: var(--accent-red);
}

.metric-card__value--positive {
    color: var(--accent-green);
}

.metric-card__meta {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.metric-card--bridge .metric-card__value {
    font-size: 1.5rem;
}

.metric-card--bridge .metric-card__meta {
    color: var(--accent-green);
}

body.theme-light .metric-card--bridge .metric-card__meta {
    color: var(--accent-blue);
}

.nav-placeholder-banner {
    display: none;
    margin-bottom: 1.75rem;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px dashed var(--border-color);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.nav-placeholder-banner.active {
    display: block;
}

.nav-placeholder-banner h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.nav-placeholder-banner p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.nav-placeholder-banner .placeholder-cta {
    margin-top: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--accent-gold);
    text-decoration: none;
}

body.theme-light .nav-placeholder-banner .placeholder-cta {
    color: var(--accent-blue);
}

/* ================================================================
   KPI CARDS
   ================================================================ */
.kpi-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.2rem;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    min-height: 120px;
}

body.theme-dark .kpi-card {
    background: linear-gradient(135deg, rgba(24, 58, 89, 0.86), rgba(10, 25, 49, 0.94));
    backdrop-filter: blur(4px);
}

body.theme-light .kpi-card {
    background: var(--bg-secondary);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

body.theme-dark .kpi-card:hover {
    background: linear-gradient(135deg, rgba(24, 58, 89, 0.95), rgba(10, 25, 49, 1));
    border-color: var(--accent-gold);
}

body.theme-light .kpi-card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 8px 16px rgba(0, 123, 255, 0.15);
}

/* KPI Icons */
.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

body.theme-dark .kpi-icon {
    background: linear-gradient(135deg, var(--accent-gold), #f1d678);
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.3);
}

body.theme-light .kpi-icon {
    background: linear-gradient(135deg, var(--accent-blue), #0056b3);
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}

body.theme-dark .kpi-icon.warning {
    background: linear-gradient(135deg, #C95D63, #a84a50);
}

body.theme-light .kpi-icon.warning {
    background: linear-gradient(135deg, var(--accent-red), #c82333);
}

body.theme-dark .kpi-icon.success {
    background: linear-gradient(135deg, var(--accent-green), #3d8b6e);
}

body.theme-light .kpi-icon.success {
    background: linear-gradient(135deg, var(--accent-green), #218838);
}

.kpi-icon svg {
    color: white;
    stroke-width: 2.5;
}

/* KPI Details */
.kpi-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.kpi-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.kpi-details .label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-details .value {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-monospace);
    line-height: 1.2;
    color: var(--accent-gold);
}

body.theme-light .kpi-details .value {
    color: var(--accent-blue);
}

.kpi-details .trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend.positive {
    color: var(--accent-green);
}

.trend.negative {
    color: var(--accent-red);
}

.trend svg {
    width: 13px;
    height: 13px;
}

/* ================================================================
   TABS
   ================================================================ */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-link {
    padding: 0.65rem 1.35rem;
    background: transparent;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    white-space: nowrap;
}

body.theme-dark .tab-link:hover {
    background-color: rgba(212, 175, 55, 0.1);
    color: var(--text-primary);
}

body.theme-light .tab-link:hover {
    background-color: rgba(0, 123, 255, 0.05);
    color: var(--text-primary);
}

body.theme-dark .tab-link.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.32), rgba(46, 204, 113, 0.28));
    color: var(--text-primary);
    border: 1px solid rgba(212, 175, 55, 0.35);
    box-shadow: 0 8px 18px rgba(212, 175, 55, 0.18);
    border-bottom: none;
}

body.theme-light .tab-link.active {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.18), rgba(20, 184, 166, 0.16));
    color: var(--accent-blue);
    border: 1px solid rgba(0, 102, 204, 0.25);
    box-shadow: 0 8px 18px rgba(0, 102, 204, 0.18);
    border-bottom: none;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================================
   CARDS & SECTIONS
   ================================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

body.theme-dark .card {
    background: var(--bg-secondary);
}

body.theme-light .card {
    background: var(--bg-secondary);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2, .card h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}
body.theme-dark .card h2,
body.theme-dark .card h3 {
    color: var(--accent-gold);
}

body.theme-light .card h2,
body.theme-light .card h3 {
    color: var(--text-primary);
}

.grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

#expense-category-card {
    margin-bottom: 1.5rem;
}

#budgets .card + .card {
    margin-top: 2.25rem;
}

@media (max-width: 768px) {
    #budgets .card + .card {
        margin-top: 1.5rem;
    }
}

#budget-performance-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ================================================================
   CHARTS
   ================================================================ */
.chart-container {
    position: relative;
    height: 320px;
    margin-top: 1rem;
}

canvas {
    max-height: 320px;
}

/* ================================================================
   TABLES
   ================================================================ */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

thead {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

body.theme-dark thead {
    background: linear-gradient(135deg, #183A59, #0D1F35);
    color: var(--accent-gold);
}

body.theme-light thead {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: var(--text-primary);
}

thead th {
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

tbody tr {
    transition: background-color 0.2s ease;
}

body.theme-dark tbody tr:hover {
    background-color: rgba(212, 175, 55, 0.08);
}

body.theme-light tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.03);
}

tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child td {
    border-bottom: none;
}

.amount-positive {
    color: var(--accent-green);
    font-family: var(--font-monospace);
    font-weight: 600;
}

.amount-negative {
    color: var(--accent-red);
    font-family: var(--font-monospace);
    font-weight: 600;
}

.category-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

body.theme-dark .category-badge {
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

body.theme-light .category-badge {
    background: rgba(0, 123, 255, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(0, 123, 255, 0.2);
}

.temp-category-select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.temp-category-select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.18);
}

body.theme-light .temp-category-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.18);
}

/* ================================================================
   DASHBOARD INSIGHTS: TRANSACTIONS BY SOURCE
   ================================================================ */
.dashboard-insights-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-insights-card .insights-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.25rem;
}

.dashboard-insights-card .insights-card-titles h3 {
    margin: 0;
    font-size: 1.35rem;
}

.dashboard-insights-card .insights-card-subtitle {
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.dashboard-insights-card .insights-actions .btn-secondary {
    white-space: nowrap;
}

.transactions-by-source-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.transactions-by-source-summary .summary-tile {
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(212, 175, 55, 0.08);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

body.theme-light .transactions-by-source-summary .summary-tile {
    background: rgba(0, 102, 204, 0.06);
}

.transactions-by-source-summary .summary-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
}

.transactions-by-source-summary .summary-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--accent-gold);
    font-family: var(--font-monospace);
}

body.theme-light .transactions-by-source-summary .summary-value {
    color: var(--accent-blue);
}

.transactions-by-source-summary .summary-footnote {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.insights-lock-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(212, 175, 55, 0.08);
    border: 1px dashed rgba(212, 175, 55, 0.35);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: none;
}

body.theme-light .insights-lock-hint {
    background: rgba(0, 102, 204, 0.06);
    border-color: rgba(0, 102, 204, 0.3);
}

.source-group-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-insights-card .source-group {
    border-radius: 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.dashboard-insights-card .source-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    align-items: center;
}

body.theme-dark .dashboard-insights-card .source-header {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(26, 47, 69, 0.75));
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

body.theme-light .dashboard-insights-card .source-header {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.08), rgba(20, 184, 166, 0.08));
    border-bottom: 1px solid rgba(0, 102, 204, 0.18);
}

.dashboard-insights-card .source-title h3 {
    margin: 0;
    font-size: 1.15rem;
}

.dashboard-insights-card .source-title p {
    margin: 0.3rem 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.dashboard-insights-card .source-metrics {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dashboard-insights-card .metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    background: rgba(212, 175, 55, 0.12);
    color: var(--accent-gold);
}

.dashboard-insights-card .metric-chip.debit {
    background: rgba(231, 76, 60, 0.15);
    color: #ff6b6b;
}

.dashboard-insights-card .metric-chip.credit {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.transactions-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 720px;
}

.transactions-table thead th {
    background: transparent;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.45px;
}

.transactions-table tbody tr.debit-row {
    background: rgba(231, 76, 60, 0.04);
}

.transactions-table tbody tr.credit-row {
    background: rgba(46, 204, 113, 0.04);
}

.transactions-table tbody tr.debit-row:hover {
    background: rgba(231, 76, 60, 0.08);
}

.transactions-table tbody tr.credit-row:hover {
    background: rgba(46, 204, 113, 0.08);
}

.dashboard-insights-card .category-cell {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.dashboard-insights-card .parent-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.18);
    color: #93c5fd;
    font-size: 0.75rem;
    width: fit-content;
}

.dashboard-insights-card .btn-secondary.btn-compact {
    font-weight: 600;
}

.dashboard-insights-card .ai-suggestion-tags {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.dashboard-insights-card .ai-suggestion-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    cursor: pointer;
    border: 1px dashed rgba(20, 184, 166, 0.4);
    color: var(--accent-teal, #14B8A6);
    background: rgba(20, 184, 166, 0.08);
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.dashboard-insights-card .ai-suggestion-tag:hover {
    background: rgba(20, 184, 166, 0.2);
}

.dashboard-insights-card .ai-confidence-high {
    border-color: rgba(46, 204, 113, 0.5);
}

.dashboard-insights-card .ai-confidence-medium {
    border-color: rgba(255, 193, 7, 0.5);
}

.dashboard-insights-card .ai-confidence-low {
    border-color: rgba(231, 76, 60, 0.5);
}

/* ================================================================
   DASHBOARD INSIGHTS: HIGHLIGHTS
   ================================================================ */
.insights-empty-state {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.4rem;
    border: 1px dashed var(--card-border);
    border-radius: 16px;
    background: rgba(212, 175, 55, 0.08);
    margin-bottom: 0.6rem;
    transition: border-color 0.25s ease, background 0.25s ease;
}

.insights-empty-state[hidden] {
    display: none !important;
}

body.theme-light .insights-empty-state {
    background: rgba(0, 102, 204, 0.08);
    border-color: rgba(0, 102, 204, 0.32);
}

.insights-empty-icon {
    font-size: 1.75rem;
}

.insights-empty-copy {
    flex: 1 1 220px;
    min-width: 200px;
}

.insights-empty-copy h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.insights-empty-copy p {
    margin: 0.2rem 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 360px;
}

.insights-highlight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.highlight-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem 1.35rem;
    border-radius: 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

body.theme-dark .highlight-card {
    background: linear-gradient(135deg, rgba(21, 33, 50, 0.95), rgba(12, 20, 34, 0.9));
}

body.theme-light .highlight-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.92));
}

.highlight-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(212, 175, 55, 0.45);
}

body.theme-light .highlight-card:hover {
    border-color: rgba(0, 102, 204, 0.35);
}

.highlight-icon {
    font-size: 1.9rem;
    line-height: 1;
}

.highlight-content {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.highlight-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-tertiary, var(--text-secondary));
}

.highlight-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-monospace);
}

.highlight-subtext {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

.highlight-card.positive {
    border-color: rgba(20, 184, 166, 0.45);
}

.highlight-card.positive .highlight-value {
    color: var(--accent-teal);
}

.highlight-card.negative {
    border-color: rgba(239, 68, 68, 0.55);
}

.highlight-card.negative .highlight-value {
    color: #f87171;
}

.highlight-card.neutral .highlight-value {
    color: var(--accent-gold);
}

.highlight-card.warning {
    border-color: rgba(251, 191, 36, 0.55);
}

.highlight-card.warning .highlight-value {
    color: var(--accent-gold);
}

.highlight-card.info {
    border-color: rgba(59, 130, 246, 0.4);
}

.highlight-card.info .highlight-value {
    color: var(--accent-blue);
}

.highlight-card.flippable {
    cursor: pointer;
}

.highlight-card.flippable:hover {
    border-color: rgba(20, 184, 166, 0.6);
    box-shadow: var(--shadow-lg);
}

.card-flip-container {
    perspective: 1200px;
    min-height: 120px;
    position: relative;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    min-height: 120px;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

.card-flip-container.flipped .card-flip-inner {
    transform: rotateY(180deg);
    min-height: 320px;
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    backface-visibility: hidden;
}

.card-flip-front {
    min-height: 120px;
}

.card-flip-back {
    transform: rotateY(180deg);
    min-height: 320px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.stability-breakdown {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow-md);
}

.stability-breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--card-border);
}

.stability-breakdown-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.45px;
    font-weight: 600;
    color: var(--text-primary);
}

.stability-breakdown-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
}

.stability-breakdown-close:hover {
    color: var(--accent-gold);
    border-color: rgba(212, 175, 55, 0.5);
}

.stability-components {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.stability-component {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: rgba(148, 163, 184, 0.12);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

body.theme-light .stability-component {
    background: rgba(240, 249, 255, 0.6);
}

body.theme-dark .stability-component {
    background: rgba(15, 23, 42, 0.55);
}

.stability-component:hover {
    border-color: rgba(20, 184, 166, 0.45);
    box-shadow: var(--shadow-sm);
}

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

.component-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.component-weight {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
}

.component-score-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.35rem;
}

.component-bar-bg {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
}

.component-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.component-bar-fill.excellent {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.85), rgba(16, 185, 129, 0.95));
}

.component-bar-fill.good {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.8), rgba(14, 116, 230, 0.85));
}

.component-bar-fill.fair {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.85), rgba(217, 119, 6, 0.85));
}

.component-bar-fill.poor {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.85), rgba(220, 38, 38, 0.9));
}

.component-score-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

.component-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    line-height: 1.4;
}

.stability-footer {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--card-border);
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
}

.table-expand-controls {
    padding: 0.75rem 1rem 1rem;
}

.expand-table-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 20px;
}

.locked-expand-notice {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    color: var(--text-secondary);
    font-weight: 500;
}

.locked-expand-icon {
    font-size: 1rem;
}

.temp-category-save-banner {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.85), rgba(118, 75, 162, 0.85));
    color: white;
    display: none;
    flex-direction: column;
    gap: 0.75rem;
}

.temp-category-save-banner.active {
    display: flex;
}

.temp-category-save-banner .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.temp-category-save-banner .actions .btn-primary {
    background: white;
    color: #4f46e5;
}

.temp-category-save-banner .actions .btn-secondary {
    border-color: rgba(255, 255, 255, 0.7);
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.temp-category-save-banner .actions .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ================================================================
   BUDGET BARS
   ================================================================ */
.budget-bar-container {
    margin: 0.75rem 0;
}

.budget-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.budget-bar-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.5s ease;
}

body.theme-dark .budget-bar-fill {
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-green));
}

body.theme-light .budget-bar-fill {
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-teal));
}

.budget-bar-fill.over-budget {
    background: linear-gradient(90deg, var(--accent-red), #a02929);
}

.budget-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.budget-stats .spent {
    font-family: var(--font-monospace);
    font-weight: 600;
}

body.theme-dark .budget-stats .spent {
    color: var(--accent-gold);
}

body.theme-light .budget-stats .spent {
    color: var(--accent-blue);
}

.budget-stats .limit {
    color: var(--text-secondary);
    font-family: var(--font-monospace);
}

/* ================================================================
   RESPONSIVE DESIGN
   ================================================================ */

/* Tablet: 768px - 1199px */
@media (max-width: 1199px) {
    .welcome-hero {
        grid-template-columns: 1fr;
        padding: 2rem;
    }
    
    .welcome-hero__metrics {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    
    .kpi-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-2col {
        grid-template-columns: 1fr;
    }
}

/* Mobile: 320px - 767px */
@media (max-width: 767px) {
    .page-container {
        padding: 1rem;
    }
    
    .main-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .main-nav {
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
    }
    
    .main-nav a {
        white-space: nowrap;
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
    
    .kpi-overview {
        grid-template-columns: 1fr;
    }
    
    .kpi-card {
        padding: 1.25rem;
    }
    
    .kpi-icon {
        width: 48px;
        height: 48px;
    }
    
    .kpi-details .value {
        font-size: 1.5rem;
    }
    
    .welcome-hero {
        padding: 1.65rem;
        gap: 1.5rem;
    }
    
    .welcome-hero__actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .welcome-hero__primary,
    .welcome-hero__secondary {
        width: 100%;
        justify-content: center;
    }
    
    .welcome-hero__metrics {
        grid-template-columns: 1fr;
    }
    
    .welcome-hero__content h1 {
        font-size: 1.85rem;
    }
    
    .tabs {
        gap: 0.25rem;
    }
    
    .tab-link {
        padding: 0.65rem 1rem;
        font-size: 0.875rem;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    thead th, tbody td {
        padding: 0.75rem 0.5rem;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* ================================================================
   CUSTOM SCROLLBAR (Dark theme only)
   ================================================================ */
body.theme-dark ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.theme-dark ::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

body.theme-dark ::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

body.theme-dark ::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}

body.theme-light ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.theme-light ::-webkit-scrollbar-track {
    background: #f1f1f1;
}

body.theme-light ::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

body.theme-light ::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* ================================================================
   UTILITY CLASSES
   ================================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.btn {
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.btn-compact {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
}

body.theme-dark .btn-secondary {
    border-color: rgba(212, 175, 55, 0.4);
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.08);
}

body.theme-dark .btn-secondary:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.6);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

body.theme-light .btn-secondary {
    border-color: rgba(0, 102, 204, 0.35);
    color: var(--accent-blue);
    background: rgba(0, 102, 204, 0.06);
}

body.theme-light .btn-secondary:hover {
    background: rgba(0, 102, 204, 0.12);
    border-color: rgba(0, 102, 204, 0.5);
    color: var(--text-primary);
    box-shadow: 0 4px 10px rgba(0, 102, 204, 0.15);
}

body.theme-dark .btn-primary {
    background: var(--accent-gradient-strong);
    color: var(--admin-cta-text);
}

body.theme-light .btn-primary {
    background: var(--accent-gradient-strong);
    color: var(--admin-cta-text);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ================================================================
   SPENDING BREAKDOWN TABLE - PARENT CATEGORY BADGES
   ================================================================ */
.parent-badge {
    display: inline-block;
    font-weight: 500;
    transition: all 0.2s ease;
}

/* Dark Theme */
body.theme-dark .parent-needs {
    background: rgba(231, 76, 60, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

body.theme-dark .parent-wants {
    background: rgba(241, 196, 15, 0.15);
    color: #ffd93d;
    border: 1px solid rgba(241, 196, 15, 0.3);
}

body.theme-dark .parent-savings {
    background: rgba(46, 204, 113, 0.15);
    color: #6fe7c1;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

body.theme-dark .parent-other {
    background: rgba(155, 135, 245, 0.15);
    color: #9b87f5;
    border: 1px solid rgba(155, 135, 245, 0.3);
}

/* Light Theme */
body.theme-light .parent-needs {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
    border: 1px solid rgba(231, 76, 60, 0.25);
}

body.theme-light .parent-wants {
    background: rgba(241, 196, 15, 0.1);
    color: #d68910;
    border: 1px solid rgba(241, 196, 15, 0.25);
}

body.theme-light .parent-savings {
    background: rgba(46, 204, 113, 0.1);
    color: #229954;
    border: 1px solid rgba(46, 204, 113, 0.25);
}

body.theme-light .parent-other {
    background: rgba(155, 135, 245, 0.1);
    color: #7c5fdc;
    border: 1px solid rgba(155, 135, 245, 0.25);
}

/* Spending Breakdown Table Enhancements */
.spending-breakdown-table {
    font-family: var(--font-primary);
}

.spending-breakdown-table thead th {
    color: var(--text-primary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.spending-breakdown-table tbody tr:hover {
    background: var(--card-hover-bg);
    transition: background 0.2s ease;
}

.btn-compact {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-compact:hover {
    background: var(--bg-primary);
    border-color: var(--accent-gold);
    transform: translateY(-1px);
}

body.theme-light .btn-compact:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
}

/* ================================================================
   KPI CARD - CLICKABLE BRIDGE SCORE
   ================================================================ */
.kpi-card-clickable {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.kpi-card-clickable:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 24px rgba(212, 175, 55, 0.3);
}

body.theme-light .kpi-card-clickable:hover {
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.25);
}

.kpi-card-hover-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kpi-card-hover-indicator i {
    width: 20px;
    height: 20px;
    color: var(--accent-gold);
}

body.theme-light .kpi-card-hover-indicator i {
    color: var(--accent-blue);
}

.kpi-card-clickable:hover .kpi-card-hover-indicator {
    opacity: 1;
}

.kpi-card-link:focus-visible .kpi-card {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

/* KPI Info Link */
.kpi-info-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

body.theme-dark .kpi-info-link {
    border-color: rgba(212, 175, 55, 0.35);
    color: rgba(212, 175, 55, 0.85);
}

body.theme-light .kpi-info-link {
    border-color: rgba(0, 102, 204, 0.28);
    color: rgba(0, 102, 204, 0.8);
}

.kpi-info-link:hover,
.kpi-info-link:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

body.theme-dark .kpi-info-link:hover,
body.theme-dark .kpi-info-link:focus-visible {
    background: rgba(212, 175, 55, 0.12);
    color: var(--accent-gold);
}

body.theme-light .kpi-info-link:hover,
body.theme-light .kpi-info-link:focus-visible {
    background: rgba(0, 102, 204, 0.08);
    color: var(--accent-blue);
}

.kpi-info-link i {
    font-size: 0.9rem;
    line-height: 1;
}

/* ================================================================
   CHART FLIP CARDS - Dashboard V2 Theme-Aware
   ================================================================ */
.chart-flip-container {
    perspective: 1000px;
    min-height: 400px;
    position: relative;
    margin-top: 1rem;
}

.chart-flip-inner {
    position: relative;
    width: 100%;
    min-height: 400px;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.chart-flip-container.flipped .chart-flip-inner {
    transform: rotateY(180deg);
}

.chart-flip-front,
.chart-flip-back {
    position: absolute;
    width: 100%;
    min-height: 400px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    top: 0;
    left: 0;
}

.chart-flip-front {
    position: relative;
    background: transparent;
}

.chart-flip-back {
    transform: rotateY(180deg);
    padding: 1.5rem;
    padding-bottom: 5rem;
    background: var(--bg-tertiary);
    overflow-y: auto;
    max-height: 500px;
    border: 1px solid var(--border-color);
}

/* Flip button on front (bottom center) */
.chart-flip-button {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gold);
    color: var(--bg-primary);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

body.theme-light .chart-flip-button {
    background: var(--accent-blue);
    color: white;
}

.chart-flip-button:hover {
    transform: translateX(-50%) scale(1.1) translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.chart-flip-button:active {
    transform: translateX(-50%) scale(0.95);
}

.chart-flip-button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.chart-flip-button[disabled]:hover {
    transform: none;
    box-shadow: none;
}

.chart-flip-button i {
    width: 20px;
    height: 20px;
}

/* Close button on back (bottom center) */
.chart-close-button {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gold);
    color: var(--bg-primary);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.chart-close-button:hover {
    transform: translateX(-50%) scale(1.1) translateY(-2px);
    box-shadow: var(--shadow-lg);
}

body.theme-light .chart-close-button {
    background: var(--accent-blue);
    color: white;
}

.chart-close-button i {
    width: 18px;
    height: 18px;
}

.category-chart-canvas-wrapper {
    position: relative;
    min-height: 360px;
    border-radius: 16px;
    background: var(--bg-tertiary);
    padding: 1.25rem;
    padding-bottom: 4.5rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    margin-top: 0;
    height: auto;
}

body.theme-light .category-chart-canvas-wrapper {
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.category-chart-canvas-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: none;
}

.chart-empty-state {
    position: absolute;
    inset: 1.25rem;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    padding: 2rem;
    z-index: 5;
}

.chart-empty-state i {
    width: 42px;
    height: 42px;
    opacity: 0.45;
}

.category-chart-summary {
    display: none;
}

.category-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.category-summary-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.category-summary-total {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.category-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.category-summary-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.category-summary-item--placeholder {
    justify-content: center;
    opacity: 0.65;
    font-style: italic;
}

.category-summary-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.category-summary-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-primary);
    color: var(--accent-gold);
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

body.theme-light .category-summary-rank {
    background: var(--bg-secondary);
    color: var(--accent-blue);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.category-summary-name {
    font-weight: 600;
    color: var(--text-primary);
}

.category-summary-metrics {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    font-family: 'Roboto Mono', monospace;
}

.category-summary-amount {
    font-weight: 600;
    color: var(--text-primary);
}

.category-summary-percent {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.category-summary-footnote {
    margin: auto 0 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chart-back-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.chart-back-header h4 {
    margin: 0;
    color: var(--text-primary);
}

.chart-back-header p {
    margin: 0.4rem 0 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.category-flip-table {
    min-height: 260px;
    max-height: 380px;
    overflow-y: auto;
}

/* Table styling inside flip card back */
.chart-flip-back table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 2rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

.chart-flip-back th {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.875rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.chart-flip-back td {
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.chart-flip-back tr:hover {
    background: var(--bg-tertiary);
}

.chart-flip-back tr:last-child td {
    border-bottom: none;
}

.needs-wants-explanation {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: rgba(56, 189, 248, 0.12);
    border-left: 4px solid rgba(56, 189, 248, 0.6);
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

body.theme-light .needs-wants-explanation {
    background: rgba(37, 99, 235, 0.1);
    border-left-color: rgba(37, 99, 235, 0.55);
}

.needs-wants-explanation p {
    margin: 0.35rem 0;
}

.needs-wants-explanation strong {
    color: var(--text-primary);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chart-flip-container,
    .chart-flip-inner,
    .chart-flip-front,
    .chart-flip-back {
        min-height: 350px;
    }
    
    .chart-flip-back {
        padding: 1rem;
        max-height: 500px;
    }
    
    .chart-flip-button {
        width: 40px;
        height: 40px;
        bottom: 0.75rem;
        right: 0.75rem;
    }
    
    .chart-close-button {
        width: 32px;
        height: 32px;
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* ========================================
   CATEGORY DRILLDOWN MODAL STYLES
   ======================================== */

/* Category drilldown links */
.category-drilldown {
    color: var(--accent-gold);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
    font-weight: 600;
}

body.theme-light .category-drilldown {
    color: var(--accent-blue);
}

.category-drilldown:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Drill-down Modal */
.drilldown-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.drilldown-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

body.theme-light .drilldown-modal-overlay {
    background-color: rgba(0, 0, 0, 0.5);
}

.drilldown-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.drilldown-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--accent-gold), rgba(212, 175, 55, 0.8));
    border-radius: 12px 12px 0 0;
}

body.theme-light .drilldown-modal-header {
    background: linear-gradient(135deg, var(--accent-blue), rgba(59, 130, 246, 0.8));
}

.drilldown-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bg-primary);
}

body.theme-light .drilldown-modal-header h3 {
    color: white;
}

.drilldown-close-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.drilldown-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.drilldown-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.drilldown-transactions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.drilldown-transactions-table thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.drilldown-transactions-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.drilldown-transactions-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.drilldown-transactions-table tbody tr:hover {
    background-color: var(--bg-tertiary);
}

.drilldown-transactions-table td {
    padding: 12px;
    color: var(--text-secondary);
}

.drilldown-transactions-table td:first-child {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.drilldown-transactions-table td:nth-child(2) {
    max-width: 400px;
    word-wrap: break-word;
    color: var(--text-primary);
}

.drilldown-transactions-table td:nth-child(3) {
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
}

.drilldown-modal-footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 12px 12px;
}

.drilldown-modal-footer p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.drilldown-modal-footer strong {
    color: var(--text-primary);
    font-weight: 600;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .drilldown-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .drilldown-modal-header h3 {
        font-size: 1.1rem;
    }
    
    .drilldown-transactions-table {
        font-size: 0.85rem;
    }
    
    .drilldown-transactions-table th,
    .drilldown-transactions-table td {
        padding: 8px;
    }
    
    .drilldown-modal-footer {
        flex-direction: column;
        gap: 8px;
    }
}
