/* Custom styles for Personal Dashboard - Tailwind handles most styling */

:root {
    /* Primary Colors */
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --profit-color: #10b981;
    --loss-color: #ef4444;

    /* Light Mode */
    --dark-bg: #1f2937;
    --dark-surface: #374151;
    --light-bg: #f9fafb;
    --light-surface: #ffffff;
    --app-text-default: #0f172a;
    --app-text-muted: #475569;

    /* Dark Mode */
    --app-text-light: #f8fafc;
    --app-text-light-muted: #94a3b8;
    --app-card-dark-surface: rgba(15, 23, 42, 0.85);

    /* Gradients */
    --app-gradient-start: #f5f7ff;
    --app-gradient-end: #e0e7ff;

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    /* Finance Gradients */
    --finance-gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --finance-gradient-2: linear-gradient(135deg, #2af598 0%, #009efd 100%);
    --finance-gradient-3: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--app-gradient-start), var(--app-gradient-end));
    color: var(--app-text-default);
    transition: background 0.3s ease, color 0.3s ease;
}

.app-shell {
    min-height: 100vh;
    background: transparent;
}

body.dark-mode {
    background: radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.25), rgba(2, 6, 23, 0.95));
    color: var(--app-text-light);
}

#dashboard-section {
    background: transparent;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    background-color: var(--app-card-surface);
    border-right: 1px solid var(--app-card-border);
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.1);
    transition: background 0.3s ease, border 0.3s ease, width 0.3s ease, min-width 0.3s ease, transform 0.3s ease;
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
}

/* Ensure sidebar body grows so footer stays pinned to bottom */
.sidebar > .p-6 {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: auto;
}

body.dark-mode .sidebar {
    background-color: rgba(15, 23, 42, 0.8);
    border-right-color: rgba(255, 255, 255, 0.1);
}

#dashboard-section .sidebar {
    transition: transform 0.35s ease, opacity 0.35s ease, width 0.3s ease, min-width 0.3s ease;
}

#dashboard-section.sidebar-hidden .sidebar {
    width: 0;
    min-width: 0;
    transform: translateX(-280px);
    opacity: 0;
    pointer-events: none;
}

.sidebar-footer {
    background: transparent;
    border-top: 1px solid rgba(15, 23, 42, 0.05);
    color: var(--app-text-muted);
    padding: 0.75rem;
}

body.dark-mode .sidebar-footer {
    color: rgba(241, 245, 249, 0.85);
    border-top-color: rgba(255, 255, 255, 0.08);
}

.sidebar-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--app-text-muted);
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-btn:hover {
    background-color: rgba(59, 130, 246, 0.08);
    color: #0f172a;
}

.sidebar-btn.active {
    background-color: rgba(59, 130, 246, 0.2);
    color: #0f172a;
    box-shadow: inset 0 0 0 1px var(--primary-color);
}

body.dark-mode .sidebar-btn {
    color: #e2e8f0;
}

body.dark-mode .sidebar-btn:hover {
    background-color: rgba(59, 130, 246, 0.15);
    color: #fff;
}

body.dark-mode .sidebar-btn.active {
    background-color: rgba(59, 130, 246, 0.35);
    color: #fff;
}

header {
    background-color: #f8fafc !important;
    color: var(--app-text-default) !important;
    border-bottom: none !important;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.15);
    backdrop-filter: blur(18px);
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

body.dark-mode header {
    background-color: #374151 !important;
    color: var(--app-text-light) !important;
    border-bottom: none !important;
}

body.dark-mode .metric-card .metric-value {
    color: var(--app-text-light);
}

body.dark-mode .metric-card .metric-label {
    color: var(--app-text-light-muted);
}

body.dark-mode .text-gray-900 {
    color: var(--app-text-light) !important;
}

body.dark-mode .text-gray-500 {
    color: #e6eef8 !important;
}

body.dark-mode .text-gray-600 {
    color: #cbd5e1 !important;
}

body.dark-mode .text-gray-700 {
    color: #e2e8f0 !important;
}

/* Settings page dark-mode overrides */
body.dark-mode #settings-view {
    color: #e6eef8;
}

body.dark-mode #settings-view h1,
body.dark-mode #settings-view h3,
body.dark-mode #settings-view h4,
body.dark-mode #settings-view p,
body.dark-mode #settings-view .form-label,
body.dark-mode #settings-view .form-group .text-xs,
body.dark-mode #settings-view .settings-tab .card .text-gray-900 {
    color: #e6eef8 !important;
}

body.dark-mode #settings-view .card {
    background: var(--app-card-dark-surface);
}

body.dark-mode #settings-view .form-input,
body.dark-mode #settings-view .form-select,
body.dark-mode #settings-view .form-textarea {
    background: rgba(255,255,255,0.03);
    color: #e6eef8;
    border-color: rgba(255,255,255,0.08);
}

body.dark-mode #settings-view .form-input::placeholder,
body.dark-mode #settings-view .form-textarea::placeholder {
    color: #9fb0c9;
}

body.dark-mode #settings-view .bg-yellow-50,
body.dark-mode #settings-view .bg-blue-50 { 
    background-color: rgba(250, 204, 21, 0.06) !important;
    color: #fbbf24 !important;
    border-color: rgba(250, 204, 21, 0.12) !important;
}

body.dark-mode #settings-view .bg-blue-50 { 
    background-color: rgba(59,130,246,0.06) !important;
    color: #60a5fa !important;
    border-color: rgba(59,130,246,0.12) !important;
}

/* Dark-mode overrides for Overview / AI suggestion box */
body.dark-mode #overview-view h1,
body.dark-mode #overview-view h1.text-2xl,
body.dark-mode .page-title {
    color: var(--app-text-light) !important;
}

/* AI Suggestion Box - block layout for full width content */
#ai-suggestion-box {
    display: block;
}

body.dark-mode #ai-suggestion-box {
    background: linear-gradient(90deg, rgba(31,41,55,0.6), rgba(17,24,39,0.6)) !important;
    border-color: rgba(255,255,255,0.06) !important;
}

body.dark-mode #ai-suggestion-box .prose,
body.dark-mode #ai-suggestion-box p,
body.dark-mode #ai-suggestion-box span,
body.dark-mode #ai-suggestion-box h3 {
    color: #e6eef8 !important;
}
body.dark-mode #ai-suggestion-box .p-3 {
    background: rgba(255,255,255,0.03) !important;
    color: #60a5fa !important;
}

/* Ensure small utility text and icons inside AI box remain readable */
body.dark-mode #ai-suggestion-box .text-gray-500 { color: #93c5fd !important; }


/* Mobile Sidebar Fix */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }

    #dashboard-section.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* When in light mode on small screens, force the sidebar to use the dark surface
       so navigation items remain visible (mirrors desktop dark appearance). */
    body:not(.dark-mode) .sidebar {
        background-color: rgba(15, 23, 42, 0.95) !important;
        border-right-color: rgba(255,255,255,0.02) !important;
        color: #e5e7eb !important;
        box-shadow: 0 25px 45px rgba(2,6,23,0.45) !important;
        backdrop-filter: blur(12px) !important;
    }

    body:not(.dark-mode) .sidebar .sidebar-btn {
        color: #cbd5e1 !important;
    }

    body:not(.dark-mode) .sidebar .sidebar-btn:hover {
        background-color: rgba(59, 130, 246, 0.12) !important;
        color: #ffffff !important;
    }

    body:not(.dark-mode) .sidebar .sidebar-brand-title {
        color: #ffffff !important;
    }

    body:not(.dark-mode) .sidebar-close-btn {
        color: #cbd5e1 !important;
    }
}

.theme-toggle-btn {
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
    background-color: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.theme-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.4), 0 12px 24px rgba(15, 23, 42, 0.2);
}

body.dark-mode .theme-toggle-btn {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--app-text-light);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.sidebar-toggle-btn {
    border-radius: 0;
    padding: 0.4rem 0.65rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
    transition: all 0.25s ease;
    margin-left: 0.5rem;
}

.sidebar-toggle-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(59, 130, 246, 0.6);
}

body.dark-mode .sidebar-toggle-btn {
    background: rgba(55, 65, 81, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e5e7eb;
}

body.dark-mode .sidebar-toggle-btn:hover {
    border-color: rgba(59, 130, 246, 0.8);
    background: rgba(75, 85, 99, 0.95);
}

/* Sidebar Close Button */
.sidebar-close-btn {
    padding: 0rem;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.sidebar-close-btn:hover {
    color: #0f172a;
    background: rgba(0, 0, 0, 0.05);
}
body.dark-mode .sidebar-close-btn {
    color: #94a3b8;
}
body.dark-mode .sidebar-close-btn:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.1);
}

/* Sidebar Brand Text */
.sidebar-brand-title {
    color: #0f172a;
}
.sidebar-brand-subtitle {
    color: #64748b;
}

/* Light-mode explicit: ensure the standard light divider remains consistent */
@media (prefers-color-scheme: light) {
    .divide-y.divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
        border-top-color: #e5e7eb !important; /* Tailwind gray-200 */
    }
}

body:not(.dark-mode) .divide-y.divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
    border-top-color: #e5e7eb !important; /* Explicit light fallback for non-dark body */
}

/* Dark-mode override: use #0f172a for dividers in dark mode */
@media (prefers-color-scheme: dark) {
    .divide-y.divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
        border-top-color: #0f172a !important; /* desired dark divider */
    }
}

/* Support explicit dark class used by the app */
.dark .divide-y.divide-gray-200 > :not([hidden]) ~ :not([hidden]),
body.dark-mode .divide-y.divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
    border-top-color: #0f172a !important;
}

body.dark-mode .sidebar-brand-title {
    color: #f1f5f9;
}
body.dark-mode .sidebar-brand-subtitle {
    color: #94a3b8;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card {
    background: var(--app-card-surface);
    border-radius: 18px;
    padding: 1.5rem;
    border: 1px solid var(--app-card-border);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border 0.3s ease;
    backdrop-filter: blur(var(--app-card-blur));
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 32px 60px rgba(15, 23, 42, 0.18);
    border-color: rgba(59, 130, 246, 0.35);
}

body.dark-mode .card {
    background: var(--app-card-dark-surface);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.5);
}

body.dark-mode .overview-section-header h3 {
    color: #f8fafc;
}

.overview-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Styles moved from fitness.php: meal grid and mobile overrides */
.meal-slot {
    min-height: 48px;
    padding: 0.25rem;
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.meal-slot:hover {
    background-color: #f9fafb;
}
.day-row-header { text-align: center; }
.meal-card {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.25;
    margin-bottom: 0.25rem;
}

/* Mobile horizontal scroll for meals grid */
.meal-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.meal-scroll-inner {
    min-width: 640px;
}

/* Reduce extra left/right padding on small screens so columns are tighter (keep top/bottom padding) */
@media (max-width: 640px) {
    /* Target only the meal grid area inside the scroll wrapper */
    .meal-scroll-inner .grid > div,
    .meal-scroll-inner .meal-slot,
    .meal-scroll-inner .day-row-header {
        /* preserve vertical spacing, remove horizontal padding */
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    #shopping-list .flex.items-center.justify-between {
        flex-direction: row!important;
    }

    #shopping-list .group > button {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }

    /* Tailwind utility override for header cells that use p-3 */
    .meal-scroll-inner .p-3 {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Slightly tighten the meal-card on mobile */
    .meal-scroll-inner .meal-card {
        padding: 0.125rem 0.25rem;
        font-size: 0.7rem;
    }

    /* Allow a slightly smaller min-width on small devices while keeping horizontal scroll */
    .meal-scroll-inner {
        min-width: 480px;
    }
}

/* Checklist mobile tweaks: show delete button and keep item inline */
@media (max-width: 640px) {
    #checklist-items .checklist-card {
        align-items: center;
    }
    #checklist-items .checklist-card > button {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
    /* Ensure title wraps but stays inline with checkbox and delete button */
    #checklist-items .checklist-item-title {
        display: inline-block;
        margin-left: 0.5rem;
    }
}

/* Tighter inline checklist layout on small screens */
@media (max-width: 640px) {
    #checklist-items .checklist-card {
        padding: 0.5rem !important;
        gap: 0.75rem;
        align-items: center;
    }
    /* Ensure the left content aligns horizontally */
    #checklist-items .checklist-card > .flex-1 {
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem;
        flex-direction: row !important;
    }
    /* Smaller checkbox */
    #checklist-items .checklist-card .checklist-checkbox {
        width: 1rem !important;
        height: 1rem !important;
    }
    /* Slightly smaller title text */
    #checklist-items .checklist-item-title {
        font-size: 0.95rem !important;
        line-height: 1.2 !important;
        word-break: break-word !important;
    }
    /* Make delete button small and aligned */
    #checklist-items .checklist-card > button {
        padding: 0.35rem !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #checklist-items .checklist-card > button i {
        font-size: 0.95rem !important;
    }
}

/* Ensure checklist cards stay in a single row on mobile */
@media (max-width: 640px) {
    #checklist-items .checklist-card {
        flex-direction: row !important;
    }
}

.overview-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.overview-section-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--app-text-default);
}


/* Metric Card - Replaced by Finance Redesign Cards, kept minimal for other modules if needed */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

/* Stat Cards - Used across multiple pages */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    text-decoration: none;
    transition: all 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
body.dark-mode .stat-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255,255,255,0.1);
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Dark mode colors for stat icons */
body.dark-mode .stat-card:nth-child(1) .stat-icon {
    background-color: #1e3a8a !important;
    color: #93c5fd !important;
}

body.dark-mode .stat-card:nth-child(2) .stat-icon {
    background-color: #78350f !important;
    color: #fcd34d !important;
}

body.dark-mode .stat-card:nth-child(3) .stat-icon {
    background-color: #134e4a !important;
    color: #6ee7b7 !important;
}

body.dark-mode .stat-card:nth-child(4) .stat-icon {
    background-color: #7f1d1d !important;
    color: #fca5a5 !important;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}
body.dark-mode .stat-value { color: #f8fafc; }
.stat-label {
    font-size: 0.75rem;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
body.dark-mode .stat-label { color: #9ca3af; }

/* Filter Tabs - Used across multiple pages */
.filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(229, 231, 235, 0.8);
}

body.dark-mode .filter-container {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}

.filter-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}
.filter-tab:hover { background: #f3f4f6; color: #374151; }
.filter-tab.active { background: #3b82f6; color: white; }
body.dark-mode .filter-tab { color: #cbd5e1; }
body.dark-mode .filter-tab:hover { background: rgba(255,255,255,0.15); color: #f1f5f9; }
body.dark-mode .filter-tab.active { background: #3b82f6; color: white; }

/* Page Title and Subtitle Styling */
.page-title {
    color: #111827;
}

.page-subtitle {
    color: #6b7280;
}

body.dark-mode .page-title {
    color: #0f172a;
}

body.dark-mode .page-subtitle {
    color: #1e293b;
}


.chart-legend-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chart-legend-row .legend-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.7);
    padding: 0.85rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.chart-legend-row .legend-item .legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-top: 3px;
}

body.dark-mode .chart-legend-row .legend-item {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .chart-legend-row .legend-item .text-gray-900 {
    color: #f8fafc;
}

body.dark-mode .chart-legend-row .legend-item .text-gray-500 {
    color: #cbd5f5;
}

#upcoming-workload {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.workload-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.workload-label {
    width: 110px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--app-text-muted);
}

.workload-count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--app-text-default);
    min-width: 60px;
    text-align: right;
}

.workload-progress {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.3);
    overflow: hidden;
    position: relative;
}

.workload-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #38bdf8, #6366f1);
    transition: width 0.4s ease;
}

body.dark-mode .workload-progress {
    background: rgba(59, 130, 246, 0.25);
}

/* View content styles */
.view-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view-content.active {
    display: block;
}

/* Header styles - prevent dark mode changes - REMOVED for dark mode fix */

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

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.recurring-card {
    border-radius: 16px;
    padding: 1.5rem;
    background: #fff;
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recurring-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: #475569;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    align-items: stretch;
}

@media (max-width: 768px) {
    .notes-grid {
        gap: 1rem;
    }
}

.note-card {
    border-radius: 16px;
    padding: 2rem;
    color: #1f2937;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    line-height: 1.6;
    position: relative;
    overflow: hidden;
    border: none;
    height: 100%;
    min-height: 300px;
    max-height: 500px;
}

/* Note card color variations */
.note-card--warm {
    background: #fffbeb;
    color: #7c2d12;
}

.note-card--cool {
    background: #eff6ff;
    color: #1e40af;
}

.note-card--emerald {
    background: #f0fdf4;
    color: #065f46;
}

.note-card--rose {
    background: #fff5f7;
    color: #831843;
}

.note-card--indigo {
    background: #f0f4ff;
    color: #312e81;
}

.note-card--amber {
    background: #fffbeb;
    color: #78350f;
}

.note-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.note-card__header div {
    flex: 1;
}

.note-card__header p:first-child {
    margin: 0;
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.3;
    word-break: break-word;
}

.note-card__header p:last-child {
    margin: 0.5rem 0 0 0;
    font-size: 0.8rem;
    opacity: 0.7;
}

.note-card__actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.note-card__content {
    font-size: 1rem;
    line-height: 1.6;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    flex-grow: 1;
    color: inherit;
    opacity: 0.85;
    word-break: break-word;
}

.note-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-top: auto;
}

.note-card__tags span {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    padding: 0.35rem 0.9rem;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.15);
    font-weight: 500;
}

/* Note card button styling */
.note-card .btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.note-card .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Button styles */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    /* Slightly darker secondary color on hover and lift to match other buttons */
    background-color: #059669; /* slightly darker than --secondary-color (#10b981) */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.12);
}

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

.btn-danger:hover {
    /* Slightly darker red on hover and lift to match other buttons */
    background-color: #dc2626; /* slightly darker than --danger-color (#ef4444) */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.12);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

/* Ensure theme toggle keeps larger vertical padding even when .btn-sm is applied */
.theme-toggle-btn.btn.btn-sm {
    padding: 0.5rem 0.85rem;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

body.dark-mode .modal-content {
    background-color: #1f2937;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .bg-white {
    background-color: #1f2937 !important;
    color: #f8fafc !important;
}

body.dark-mode .bg-gray-50 {
    background-color: #111827 !important;
}

/* Ensure the reusable confirmation modal sits above other open modals (e.g., edit dialogs) */
#modal-confirm {
    z-index: 1100;
}

/* Dark Mode Polish */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #1f2937 !important;
    color: #f8fafc !important;
    border-color: #374151 !important;
    text-align: inherit;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #9ca3af !important;
}

body.dark-mode th {
    background-color: #1f2937 !important;
    color: #f8fafc !important;
}

body.dark-mode .text-gray-900 {
    color: #f8fafc !important;
}

body.dark-mode .text-gray-700 {
    color: #e2e8f0 !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

/* Small checkbox styling to use with the inline label */
.checkbox {
    width: 1rem;
    height: 1rem;
    display: inline-block;
    vertical-align: middle;
}

.form-select {
    width: 100%;
    padding: 0.77rem;
    padding-right: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    background-color: white;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Priority badges */
.priority-urgent {
    background-color: #fef2f2;
    color: #991b1b;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.priority-high {
    background-color: #fff7ed;
    color: #c2410c;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.priority-medium {
    background-color: #fef9c3;
    color: #854d0e;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.priority-low {
    background-color: #f0fdf4;
    color: #166534;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Task list (used in Tasks page project groups) */
.task-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.task-list-item {
    display: flex;
    align-items: center;
    /* vertically center checkbox/content/actions */
    gap: 1rem;
    padding: 0.75rem 0.75rem;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.03), rgba(59, 130, 246, 0.01));
    border-left: 2px solid var(--primary-dark);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
    margin-bottom: 0.75rem;
    border-radius: 5px;
}

.task-list-item:last-child {
    border-bottom: none;
    margin-bottom: 0.75rem;
}

.task-list-item.clickable .btn {
    cursor: pointer;
}

/* Dark mode: tone down the highlight but keep the accent visible */
body.dark-mode .task-list-item {
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.04), rgba(37, 99, 235, 0.02));
    border-left-color: var(--primary-color);
    box-shadow: none;
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    /* push actions to the right */
    flex-shrink: 0;
    min-width: 0;
    justify-content: flex-end;
}

/* Ensure action area vertically centers with the card */
.task-actions {
    align-self: center;
}

.task-buttons {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.task-buttons .btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Ghost button styles for task actions */
.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
}

.btn-ghost:hover {
    background: rgba(59, 130, 246, 0.06);
}

.btn-ghost-blue {
    color: #2563eb;
    border-color: rgba(37, 99, 235, 0.08);
}

.btn-ghost-blue:hover {
    background: rgba(37, 99, 235, 0.06);
}

.btn-ghost-red {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.06);
}

.btn-ghost-red:hover {
    background: rgba(220, 38, 38, 0.05);
}

.task-list-item .priority-urgent,
.task-list-item .priority-high,
.task-list-item .priority-medium,
.task-list-item .priority-low {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
}

.task-due {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
}

.task-due i {
    font-size: 0.95rem;
}

/* Small icon-only buttons used in task lists */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.btn-icon i {
    font-size: 14px;
}

.btn-icon:hover {
    background: rgba(15, 23, 42, 0.04);
}

/* Recent tasks: smaller icon buttons and no hover background to match compact grid */
#recent-tasks .btn-icon {
    width: 18px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
}

#recent-tasks .btn-icon i {
    font-size: 12px;
}

#recent-tasks .btn-icon:hover {
    background: transparent;
}

/* Task separator: subtle full-width line (starts after checkbox area) */
.task-list-item {
    position: relative;
}

/* Keep border-bottom for separators - remove pseudo element which conflicted with list layout */

/* Task list styles (projects view) - consolidated above */

/* removed duplicate/empty .task-list-item ruleset (card-style rules above are used) */

.task-list-item .priority-urgent,
.task-list-item .priority-high,
.task-list-item .priority-medium,
.task-list-item .priority-low {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
}

.task-due {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.task-due i {
    font-size: 0.9rem;
}

/* Status badges */
.status-active {
    background-color: #dbeafe;
    color: #1e40af;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-completed {
    background-color: #d1fae5;
    color: #065f46;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Tab navigation */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

/* AI Chat bubble */
.ai-chat-bubble {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 999;
}

.ai-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.ai-chat-panel {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 400px;
    max-height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 998;
}

.ai-chat-panel.active {
    display: flex;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 30;
    display: none;
}

#sidebar-overlay.active {
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1024px) {
    #dashboard-section {
        flex-direction: column;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 270px;
        z-index: 20;
        transform: translateX(-100%);
        background: rgba(15, 23, 42, 0.9);
        border-right: none;
        box-shadow: 0 25px 45px rgba(2, 6, 23, 0.45);
    }

    #dashboard-section.sidebar-open .sidebar {
        transform: translateX(0);
    }

    main {
        padding-top: 0;
    }

    header {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .sidebar-footer {
        display: block;
        position: relative;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .sidebar-toggle-btn {
        display: inline-flex;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .ai-chat-panel {
        width: calc(100% - 2rem);
        right: 1rem;
    }

    .tab-nav {
        gap: 0.25rem;
    }

    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

/* Responsive utility: show inline at md and up (matches Tailwind's md breakpoint) */
@media (min-width: 768px) {
    .md\:inline { display: inline !important; }
    .md\:inline-block { display: inline-block !important; }
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.font-bold {
    font-weight: 700;
}

.text-gray-600 {
    color: #4b5563;
}

.cursor-pointer {
    cursor: pointer;
}

/* Pagination styles */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    background-color: #ffffff;
    color: #374151;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.pagination-info {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0.5rem;
}

/* Project accordion caret rotation */
button[id^="project-header-"] svg {
    transition: transform 0.18s ease;
}

/* default: down arrow (no rotation) */
button[id^="project-header-"] svg {
    transform: rotate(0deg);
    transition: transform 0.18s ease;
}

/* when open: rotate 180deg to show up arrow */
button[id^="project-header-"].open svg {
    transform: rotate(180deg);
}

/* Ensure the content column can shrink so actions stay on the same line */
.task-list-item>.flex-1 {
    min-width: 0;
}

/* Truncate long task text but allow wrapping to two lines while keeping actions aligned */
.task-list-item .flex-1 p {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* compact look for due label */
.task-due {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.08rem 0.2rem;
    border-radius: 6px;
    background: rgba(243, 244, 246, 0.9);
}

.task-meta {
    font-size: 0.9rem;
    color: #374151;
}

.task-meta .task-due {
    background: transparent;
    padding: 0;
    font-weight: 600;
}

/* Center checkbox and action buttons vertically on the card */
.task-list-item input[type="checkbox"] {
    margin-top: 0;
    align-self: center;
}

.task-actions .btn {
    align-self: center;
}

/* Textarea styling */
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: #ffffff;
    color: #1f2937;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

body.dark-mode .form-select,
body.dark-mode .form-textarea,
body.dark-mode .form-input {
    background-color: var(--dark-bg);
    color: #f3f4f6;
    border-color: #4b5563;
}

body.dark-mode .form-select:focus,
body.dark-mode .form-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Mobile responsiveness */
@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    #sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 40;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    #sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-toggle-btn {
        display: flex !important;
    }
}

@media (min-width: 1024px) {
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }

    .sidebar-toggle-btn {
        display: inline-flex !important;
    }
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Overview Page Styles */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(229, 231, 235, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.metric-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.metric-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.metric-icon-blue {
    background-color: #eff6ff;
    color: #3b82f6;
}

.metric-icon-purple {
    background-color: #f5f3ff;
    color: #8b5cf6;
}

.metric-icon-green {
    background-color: #ecfdf5;
    color: #10b981;
}

.metric-icon-yellow {
    background-color: #fffbeb;
    color: #f59e0b;
}

body.dark-mode .metric-card {
    background-color: var(--dark-surface);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .metric-value {
    color: #f3f4f6;
}

body.dark-mode .metric-label {
    color: #9ca3af;
}

body.dark-mode .text-gray-900 {
    color: #f3f4f6 !important;
}

/* --- Finance Redesign Components --- */

/* Glassmorphism Card */
.finance-card {
    background: var(--app-card-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--app-card-border);
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.finance-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.1);
}

body.dark-mode .finance-card {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
}

/* Modern Tabs */
.finance-tabs-container {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    border-radius: 1rem;
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    margin-bottom: 2rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.dark-mode .finance-tabs-container {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(255, 255, 255, 0.05);
}

.finance-tab-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    color: #475569;
    transition: all 0.3s ease;
    border: none;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
}

.finance-tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
}

.finance-tab-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.dark-mode .finance-tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #60a5fa;
}

body.dark-mode .finance-tab-btn.active {
    background: var(--primary-dark);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

/* Modern Tables */
.modern-table-container {
    border-radius: 1.5rem;
    overflow: hidden;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.dark-mode .modern-table-container {
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(255, 255, 255, 0.05);
}

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

.modern-table th {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    text-align: center;
    font-weight: 600;
    color: #475569;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modern-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: #0f172a;
    font-size: 0.95rem;
    transition: background 0.2s;
    text-align: center;
    vertical-align: middle;
}

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

.modern-table tr:hover td {
    background: #f8fafc;
}

body.dark-mode .modern-table th {
    background: rgba(15, 23, 42, 0.8);
    color: #94a3b8;
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .modern-table td {
    color: #e2e8f0;
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .modern-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.modern-table tbody tr {
    transition: background 0.2s ease;
}

.modern-table td:first-child {
    text-align: left;
}

@media (max-width: 768px) {
    /* Keep tables as tables on small screens; allow horizontal scroll instead of stacking into cards */
    .modern-table th, .modern-table td {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    .modern-table td {
        text-align: left;
    }
    .modern-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Credit Card Visual */
.credit-card-visual {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 1.25rem;
    padding: 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease;
}

.credit-card-visual:hover {
    transform: scale(1.02) rotate(1deg);
}

.credit-card-visual::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    transform: rotate(30deg);
}

.card-chip {
    width: 40px;
    height: 30px;
    background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
    border-radius: 6px;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.card-chip::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(0, 0, 0, 0.2);
}

/* Stat Card */
.stat-value-lg {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--finance-gradient-1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

body.dark-mode .stat-value-lg.profit {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Status Badges */
.status-pill {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-pill.success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.status-pill.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.status-pill.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

body.dark-mode .status-pill.success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

body.dark-mode .status-pill.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

body.dark-mode .status-pill.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Global Table Alignment */
table th,
table td {
    text-align: center !important;
}

/* Fix for Finance Tab Header Text Color */
.finance-tab-content h3 {
    color: #111827 !important;
    /* gray-900 */
}

body.dark-mode .finance-tab-content h3 {
    color: #e5e7eb !important;
    /* gray-200 */
}

/* Fix for Finance Card Title Text Color */
.finance-card h4 {
    color: #111827 !important;
    /* gray-900 */
}

body.dark-mode .finance-card h4 {
    color: #e5e7eb !important;
    /* gray-200 */
}

/* ============================================================================
   Dark Mode CSS - Text, Background, and Interactive Elements
   These rules handle all dark mode styling for Tailwind utility classes
   used without dark: prefixes in the HTML
   ============================================================================ */

/* Text Colors for Dark Mode */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
    color: #f8fafc;
}

body.dark-mode .text-gray-900 {
    color: #f8fafc;
}

body.dark-mode .text-gray-800 {
    color: #f8fafc;
}

body.dark-mode .text-gray-700 {
    color: #e2e8f0;
}

body.dark-mode .text-gray-600 {
    color: #cbd5e1;
}

body.dark-mode .text-gray-500 {
    color: #94a3b8;
}

body.dark-mode .text-gray-400 {
    color: #64748b;
}

body.dark-mode .text-gray-300 {
    color: #475569;
}

body.dark-mode .text-green-600 {
    color: #4ade80;
}

body.dark-mode .text-red-600 {
    color: #f87171;
}

body.dark-mode .text-blue-600 {
    color: #60a5fa;
}

/* Background Colors for Dark Mode */
body.dark-mode .bg-gray-50 {
    background-color: #1e293b;
}

body.dark-mode .bg-gray-100 {
    background-color: #0f172a;
}

body.dark-mode .bg-gray-200 {
    background-color: #1a1f35;
}

body.dark-mode .bg-white {
    background-color: #1e293b;
}

/* Hover States for Dark Mode */
body.dark-mode .hover\:bg-gray-200:hover {
    background-color: #334155;
}

body.dark-mode .hover\:bg-gray-50:hover {
    background-color: #0f172a;
}

body.dark-mode .hover\:text-gray-900:hover {
    color: #f8fafc;
}

body.dark-mode .group:hover .group-hover\:text-blue-600 {
    color: #60a5fa;
}

/* Border Colors for Dark Mode */
body.dark-mode .border-gray-100 {
    border-color: #1e293b;
}

body.dark-mode .border-gray-200 {
    border-color: #0f172a;
}

body.dark-mode .border-transparent {
    border-color: transparent;
}

/* ============================================================================
   Mobile Responsive Fixes
   ============================================================================ */

/* Remove horizontal padding on header on mobile */
@media (max-width: 767px) {
    header .px-4 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Stats grid full width on mobile */
    .grid.grid-cols-2 {
        grid-template-columns: 1fr;
    }

    /* Reduce card padding on mobile to save space */
    #tasks-view .card {
        padding: 1rem;
    }

    /* Task list layout adjustments for mobile */
    .task-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0;
        border-left: none;
        background: transparent;
    }

    .task-row {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
        flex-wrap: wrap;
    }

    .task-row input[type="checkbox"] {
        flex-shrink: 0;
        margin-top: 0.2rem;
    }

    .task-row > .flex-1 {
        flex: 1;
        min-width: 0;
    }

    .task-row .flex-1 p {
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        white-space: normal;
    }

    .task-actions {
        width: 100%;
        justify-content: flex-start;
        margin-left: 0;
        padding-top: 0.50rem;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
    }

    body.dark-mode .task-actions {
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .task-buttons .btn {
        padding: 0.25rem 0.45rem;
        font-size: 0.7rem;
    }
}

/* User avatar and name dark mode styling */
body.dark-mode #user-avatar {
    background-color: #334155;
    color: #93c5fd;
}

body.dark-mode #user-name {
    color: #e2e8f0;
}

body.dark-mode .group:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Project Card Styling */
.project-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.project-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
body.dark-mode .project-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255,255,255,0.1);
}
.project-card.note-card--warm { background: #fff7ed; color: #7c2d12; border-color: transparent; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08); }
.project-card.note-card--cool { background: #eff6ff; color: #1e3a8a; border-color: transparent; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08); }
.project-card.note-card--emerald { background: #ecfdf5; color: #065f46; border-color: transparent; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08); }
.project-card.note-card--rose { background: #fff1f2; color: #831843; border-color: transparent; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08); }
.project-card.note-card--indigo { background: #eef2ff; color: #312e81; border-color: transparent; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08); }
.project-card.note-card--amber { background: #fffbeb; color: #78350f; border-color: transparent; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08); }
.project-card.note-card--warm h3,
.project-card.note-card--cool h3,
.project-card.note-card--emerald h3,
.project-card.note-card--rose h3,
.project-card.note-card--indigo h3,
.project-card.note-card--amber h3 {
    color: inherit;
}

.notes-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.notes-filter-btn {
    border: 1px solid transparent;
    padding: 0.4rem 0.9rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    background: #f3f4f6;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notes-filter-btn.active {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.15);
    color: #1d4ed8;
}

.tag-filter-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tag-filter-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.tag-filter-btn.active {
    background: #3b82f6;
    color: white;
}

.tag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 64px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-transform: capitalize;
    letter-spacing: 0.05em;
}

/* Keep themed backgrounds visible in dark mode */
body.dark-mode .project-card.note-card--warm { background: #6b2f13; color: #ffeacf; }
body.dark-mode .project-card.note-card--cool { background: #08203b; color: #dbeafe; }
body.dark-mode .project-card.note-card--emerald { background: #08332a; color: #bbf7d0; }
body.dark-mode .project-card.note-card--rose { background: #4a1234; color: #ffdde6; }
body.dark-mode .project-card.note-card--indigo { background: #0f172a; color: #e6eeff; }
body.dark-mode .project-card.note-card--amber { background: #5a3e10; color: #fff5d0; }

.project-card .tag-badge { margin-right: 0.5rem; margin-bottom: 0.5rem; }
.project-card .text-xs.text-gray-500 { margin-top: 0.5rem; }
.project-card .project-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.project-card .progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}
body.dark-mode .project-card .progress-bar { background: rgba(255,255,255,0.1); }
.project-card .progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s;
}

/* 3 columns on 1300+ screens */
@media (min-width: 1300px) {
    .projects-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* View Toggle Button Styling */
.view-toggle-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.view-toggle-btn:hover { background: #e5e7eb; }
.view-toggle-btn.active { background: #3b82f6; color: white; }
body.dark-mode .view-toggle-btn { background: rgba(255,255,255,0.1); color: #9ca3af; }
body.dark-mode .view-toggle-btn:hover { background: rgba(255,255,255,0.15); }
body.dark-mode .view-toggle-btn.active { background: #3b82f6; color: white; }

/* Event Item Styling */
.event-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
    background: white;
}
.event-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #3b82f6;
}
body.dark-mode .event-item {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(255,255,255,0.1);
}
body.dark-mode .event-item:hover {
    border-color: #3b82f6;
}

/* Event Date Box */
.event-date-box {
    width: 60px;
    text-align: center;
    padding: 0.5rem;
    background: #f3f4f6;
    border-radius: 8px;
    flex-shrink: 0;
}
body.dark-mode .event-date-box { background: rgba(255,255,255,0.1); }
.event-date-box .day {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3b82f6;
    line-height: 1;
}
.event-date-box .month {
    font-size: 0.7rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
body.dark-mode .event-date-box .month { color: #9ca3af; }

/* Event Content */
.event-content { flex: 1; min-width: 0; }
.event-title {
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.25rem;
}
body.dark-mode .event-title { color: #f8fafc; }
.event-meta {
    font-size: 0.875rem;
    color: #6b7280;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
body.dark-mode .event-meta { color: #9ca3af; }
.event-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

/* Timeline View */
.timeline-view .event-item {
    position: relative;
    padding-left: 2rem;
    margin-left: 1rem;
    border-left: 2px solid #e5e7eb;
    border-radius: 0 12px 12px 0;
}
.timeline-view .event-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 1.25rem;
    width: 12px;
    height: 12px;
    background: #3b82f6;
    border-radius: 50%;
    border: 2px solid white;
}
body.dark-mode .timeline-view .event-item { border-left-color: rgba(255,255,255,0.2); }
body.dark-mode .timeline-view .event-item::before { border-color: #1e293b; }

/* Goal Card Styling */
.goal-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s;
}
.goal-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
body.dark-mode .goal-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255,255,255,0.1);
}
.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.goal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}
body.dark-mode .goal-title { color: #f8fafc; }
.goal-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.goal-status.not-started { background: #f3f4f6; color: #6b7280; }
.goal-status.in-progress { background: #dbeafe; color: #1d4ed8; }
.goal-status.completed { background: #dcfce7; color: #15803d; }
.goal-status.abandoned { background: #fee2e2; color: #b91c1c; }
.goal-progress { margin: 1rem 0; }
.goal-progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}
body.dark-mode .goal-progress-bar { background: rgba(255,255,255,0.1); }
.goal-progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}
.goal-progress-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
}
body.dark-mode .goal-progress-text { color: #9ca3af; }
.subgoal-list {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}
body.dark-mode .subgoal-list { border-top-color: rgba(255,255,255,0.1); }

.subgoal-row { cursor: pointer; }
.subgoal-row .btn { cursor: pointer; }
.subgoal-row:hover { background-color: rgba(0,0,0,0.02); }

.status-badge { display: inline-flex; align-items: center; justify-content: center; text-align: center; min-width: 64px; }

.subgoal-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}
.subgoal-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.subgoal-text { color: #374151; }
.subgoal-text.done { text-decoration: line-through; color: #9ca3af; }
body.dark-mode .subgoal-text { color: #e5e7eb; }
body.dark-mode .subgoal-text.done { color: #6b7280; }

/* Fitness Badge Styling */
.fitness-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.fitness-type-badge.workout { background: #fee2e2; color: #b91c1c; }
.fitness-type-badge.cardio { background: #dbeafe; color: #1d4ed8; }
.fitness-type-badge.strength { background: #fef3c7; color: #b45309; }
.fitness-type-badge.yoga { background: #dcfce7; color: #15803d; }
.fitness-type-badge.other { background: #f3f4f6; color: #6b7280; }

/* Notes Styling */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.notes-grid.list-view {
    grid-template-columns: 1fr;
}
.notes-grid.list-view .note-card {
    flex-direction: row;
    align-items: center;
}
.note-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    min-height: 180px;
    position: relative;
    overflow: hidden;
}
.note-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
body.dark-mode .note-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255,255,255,0.1);
}
.note-card.color-warm { border-left: 4px solid #f59e0b; }
.note-card.color-cool { border-left: 4px solid #3b82f6; }
.note-card.color-emerald { border-left: 4px solid #10b981; }
.note-card.color-rose { border-left: 4px solid #f43f5e; }
.note-card.color-indigo { border-left: 4px solid #6366f1; }
.note-card.color-amber { border-left: 4px solid #d97706; }
.note-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
body.dark-mode .note-title { color: #f8fafc; }
.note-preview {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}
body.dark-mode .note-preview { color: #9ca3af; }
.note-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.75rem;
    color: #9ca3af;
}
body.dark-mode .note-meta { border-top-color: rgba(255,255,255,0.1); }
.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.note-tag {
    padding: 0.125rem 0.5rem;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
}
body.dark-mode .note-tag {
    background: rgba(255,255,255,0.1);
    color: #9ca3af;
}

/* Intensity badge styles for fitness table */
.intensity-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 64px;
}
.intensity-low {
    background: rgba(16, 185, 129, 0.12); /* green-100 */
    color: #059669; /* green-600 */
    border: 1px solid rgba(16,185,129,0.25);
}
.intensity-moderate {
    background: rgba(59, 130, 246, 0.12); /* blue-100 */
    color: #1d4ed8; /* blue-700 */
    border: 1px solid rgba(59,130,246,0.25);
}
.intensity-high {
    background: rgba(239, 68, 68, 0.12); /* red-100 */
    color: #dc2626; /* red-600 */
    border: 1px solid rgba(239,68,68,0.25);
}
.intensity-other {
    background: rgba(148, 163, 184, 0.12); /* gray-100 */
    color: #475569; /* gray-600 */
    border: 1px solid rgba(148,163,184,0.2);
}

body.dark-mode .intensity-low { background: rgba(4, 120, 87, 0.18); color: #bbf7d0; border-color: rgba(16,185,129,0.18); }
body.dark-mode .intensity-moderate { background: rgba(14, 94, 255, 0.08); color: #bfdbfe; border-color: rgba(59,130,246,0.12); }
body.dark-mode .intensity-high { background: rgba(127, 29, 29, 0.18); color: #fecaca; border-color: rgba(239,68,68,0.12); }
body.dark-mode .intensity-other { background: rgba(75, 85, 99, 0.12); color: #cbd5e1; border-color: rgba(148,163,184,0.08); }
.note-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}
#note-tags-filter {
    align-items: center;
}
.note-card:hover .note-actions { opacity: 1; }
.tag-filter-btn {
    padding: 0.3rem 0.85rem;
    font-size: 0.775rem;
    font-weight: 600;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}
.tag-filter-btn:hover { background: #e5e7eb; }
.tag-filter-btn.active { background: #3b82f6; color: white; }
body.dark-mode .tag-filter-btn { background: rgba(255,255,255,0.1); color: #9ca3af; }
body.dark-mode .tag-filter-btn:hover { background: rgba(255,255,255,0.15); }
body.dark-mode .tag-filter-btn.active { background: #3b82f6; color: white; }

/* Relationships / Contact Card Styling */
.contact-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.contact-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
body.dark-mode .contact-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255,255,255,0.1);
}
.contact-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}
.contact-avatar.family { background: linear-gradient(135deg, #f87171, #ef4444); }
.contact-avatar.friend { background: linear-gradient(135deg, #34d399, #10b981); }
.contact-avatar.work { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.contact-avatar.other { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.contact-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}
body.dark-mode .contact-name { color: #f8fafc; }
.contact-type {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    text-transform: capitalize;
}
.contact-type.family { background: #fee2e2; color: #b91c1c; }
.contact-type.friend { background: #dcfce7; color: #15803d; }
.contact-type.work { background: #ede9fe; color: #7c3aed; }
.contact-type.other { background: #f3f4f6; color: #6b7280; }
.contact-meta {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.5rem;
}
body.dark-mode .contact-meta { color: #9ca3af; }
.contact-meta i { width: 20px; }

/* Settings Tab Styling */
.settings-tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}
.settings-tab-btn:hover { color: #3b82f6; }
.settings-tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}
body.dark-mode .settings-tab-btn { color: #9ca3af; }
body.dark-mode .settings-tab-btn:hover { color: #60a5fa; }
body.dark-mode .settings-tab-btn.active { color: #60a5fa; border-bottom-color: #60a5fa; }
.settings-tab { display: none; }
.settings-tab.active { display: block; }

/* When Settings buttons also use filter-tab styles, ensure hover/active visuals match */
.settings-tab-btn.filter-tab:hover,
.filter-tab.settings-tab-btn:hover {
    background: #f3f4f6;
    color: #374151;
}
.settings-tab-btn.filter-tab.active,
.filter-tab.settings-tab-btn.active {
    background: #3b82f6;
    color: white;
    border-bottom-color: transparent;
}
body.dark-mode .settings-tab-btn.filter-tab:hover,
body.dark-mode .filter-tab.settings-tab-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #f1f5f9;
}
body.dark-mode .settings-tab-btn.filter-tab.active,
body.dark-mode .filter-tab.settings-tab-btn.active {
    background: #3b82f6;
    color: white;
    border-bottom-color: transparent;
}

/* Mobile Tasks Page Styling */
@media (max-width: 767px) {
    /* Full width inputs and buttons in task modal */
    .modal-content input[type="text"],
    .modal-content input[type="date"],
    .modal-content textarea,
    .modal-content select {
        width: 100% !important;
        margin-bottom: 0.75rem;
    }
    
    .modal-content .btn {
        width: 100% !important;
        margin: 0.5rem 0 !important;
    }
    
    /* Task list items with transparent background on mobile */
    .task-list-item {
        background: transparent !important;
        border: none !important;
        border-bottom: 1px solid rgba(229, 231, 235, 0.5) !important;
        padding: 1rem 0 !important;
        margin: 0 !important;
    }
    
    body.dark-mode .task-list-item {
        border-bottom-color: rgba(255, 255, 255, 0.1) !important;
    }
    
    /* Remove margin from status buttons on mobile */
    .task-list-item .priority-urgent,
    .task-list-item .priority-high,
    .task-list-item .priority-medium,
    .task-list-item .priority-low {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.65rem !important;
    }
    
    /* Filter tabs and view toggle in separate lines on mobile */
    /* Filter tabs and view toggle in separate lines on mobile (scope to .filter-bar) */
    .filter-bar.flex.items-center.justify-between,
    .view-toggle-bar.flex.items-center.justify-between {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    .filter-bar.flex.items-center.justify-between > .flex,
    .view-toggle-bar.flex.items-center.justify-between > .flex {
        width: 100% !important;
    }

    .filter-bar.flex.items-center.justify-between > .flex.gap-2:last-child,
    .view-toggle-bar.flex.items-center.justify-between > .flex.gap-2:last-child {
        justify-content: flex-start !important;
    }

    /* Page-level view-toggle and filter stacking for mobile when specific classes are not present */
    @media (max-width: 768px) {
        main .max-w-7xl .flex.items-center.justify-between {
            flex-direction: column !important;
            align-items: stretch !important;
            gap: 1rem !important;
        }

        main .max-w-7xl .flex.items-center.justify-between > .flex {
            width: 100% !important;
        }

        main .max-w-7xl .flex.items-center.justify-between > .flex.gap-2:last-child {
            justify-content: flex-start !important;
        }
    }

    /* Events page - reduce/remove padding on mobile for event/stat cards */
    @media (max-width: 768px) {

        /* Main events card container - reduce padding so the list fits tighter on mobile */
        .events-page .card {
            padding: 0.5rem !important;
        }
    }

    /* Ensure the dashboard header controls remain inline on small screens */
    @media (max-width: 768px) {
        header > div.flex.items-center.justify-between {
            flex-direction: row !important;
            align-items: center !important;
            gap: 0.5rem !important;
        }

        header > div.flex.items-center.justify-between > .flex {
            width: auto !important;
        }

        header > div.flex.items-center.justify-between > .flex:last-child {
            justify-content: flex-end !important;
        }
    }
    
    /* Event items on mobile */
    .event-item {
        flex-direction: column !important;
        padding: 0.75rem !important;
    }
    
    .event-date-box {
        width: auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        padding: 0.5rem 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .event-date-box .day {
        font-size: 1.25rem !important;
    }
    
    .event-date-box .month {
        font-size: 0.65rem !important;
    }
    
    .event-actions {
        margin-top: 0.75rem !important;
        justify-content: flex-end !important;
    }
    
    /* Timeline view mobile adjustments */
    .timeline-view .event-item {
        margin-left: 0.5rem !important;
        padding-left: 1.5rem !important;
    }
    
    .timeline-view .event-item::before {
        width: 10px !important;
        height: 10px !important;
        left: -6px !important;
    }
}


/* Collapsible Sub-goals Section */
#subgoals-chevron {
    display: inline-block;
    transform: rotate(0deg);
    transition: transform 0.3s ease;
}

body.dark-mode #subgoals-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Goals page - reduce padding on mobile for goal/stat cards */
@media (max-width: 768px) {
    .goals-page .stat-card {
        /* Match the default stat-card padding used across the app (keeps consistency with Tasks) */
        padding: 1.25rem !important;
        border-radius: 12px !important;
    }

    .goals-page .stat-card .stat-icon {
        /* Match default stat-icon dimensions to keep grid consistent with Tasks */
        width: 48px !important;
        height: 48px !important;
        margin-left: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Main goals card container - reduce padding so the list fits tighter on mobile */
    .goals-page .card {
        padding: 0.5rem !important;
    }

    /* Subgoals collapsible button on mobile */
    #subgoals-toggle {
        padding: 1rem !important;
    }

    #subgoals-container {
        padding: 1rem !important;
    }
}
/* Fallback for line-clamp if Tailwind plugin is missing */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* AI Briefing Styling */
#ai-briefing-text h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}
#ai-briefing-text h3:first-child {
    margin-top: 0;
}
#ai-briefing-text p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}
#ai-briefing-text ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}
#ai-briefing-text li {
    margin-bottom: 0.25rem;
}

/* User Dropdown Styling (portal) */
.user-dropdown-portal {
    position: fixed !important;
    right: 1rem;
    top: 60px;
    z-index: 99999 !important;
    min-width: 12rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(0);
    transition: opacity 150ms ease, transform 150ms ease;
    box-shadow: 0 8px 30px rgba(2,6,23,0.45) !important;
}
.user-dropdown-portal.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

@media (max-width: 640px) {
    .user-dropdown-portal {
        right: 0.5rem;
        left: auto;
        top: 56px;
        width: calc(100% - 1rem);
        max-width: none;
    }
}

/* Truncate long name/email inside dropdown */
#user-dropdown-name,
#user-dropdown-email {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

