/* Modern Interactive Monthly Budget Planner - Custom Styling */

:root {
    /* Fonts Settings (Controlled by JavaScript selector) */
    --body-font: 'Outfit', sans-serif;
    --cursive-font: 'Sacramento', cursive;

    /* HSL Theme Colors (Defaults to Pastel Dusty Rose) */
    --primary-hue: 346;
    --primary-sat: 30%;
    --primary-light: 67%;
    
    /* Dynamic HSL Palette Generation */
    --primary-color: hsl(var(--primary-hue), var(--primary-sat), var(--primary-light));
    --primary-hover: hsl(var(--primary-hue), var(--primary-sat), calc(var(--primary-light) - 8%));
    --primary-dark: hsl(var(--primary-hue), calc(var(--primary-sat) + 5%), calc(var(--primary-light) - 15%));
    --primary-lightest: hsl(var(--primary-hue), var(--primary-sat), 94%);
    --primary-bg: hsl(var(--primary-hue), 15%, 97.5%);
    --primary-border: hsl(var(--primary-hue), var(--primary-sat), 88%);
    
    /* Additional Custom Theme Color Overrides (Defaults) */
    --secondary-color: #a78b9b;
    --secondary-hover: #927586;
    --secondary-light: #f5f1f3;
    
    --tertiary-color: #5c9e6c;
    --tertiary-light: #f4faf6;
    
    /* Core Layout Colors */
    --text-color: #2c2c2c;
    --text-muted: #6b6b6b;
    --card-bg: #ffffff;
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.01);
    --card-hover-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.01);
    --border-color: #e5e5e5;
    
    /* Alert / UI Feedback States */
    --danger-color: #c05c65;
    --danger-bg: #fff5f5;
    --danger-border: #f5d6d9;
    --success-color: #5c9e6c;
    --success-bg: #f5fbf6;
    --success-border: #d6f0db;
    
    /* Global Styles Constants */
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --transition-speed: 0.25s;
    --max-width: 1400px;
}

/* Base resets */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--body-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--primary-bg);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-speed) ease;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--primary-border);
    border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Glassmorphic Header Layout */
.app-header {
    background: var(--header-bg, rgba(255, 255, 255, 0.85));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.8rem 2rem;
    display: grid;
    grid-template-columns: 1fr auto 1.5fr;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Top-Left Profile & Cloud sync indicator */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background-color: var(--primary-lightest);
    color: var(--primary-dark);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--primary-border);
    transition: all var(--transition-speed) ease;
}

.user-profile-btn:hover {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.15);
}

.user-profile-btn i {
    font-size: 1rem;
}

/* Dynamic Sync Status bar styling */
.cloud-sync-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--tertiary-color);
    background-color: var(--tertiary-light);
    border: 1px solid rgba(0,0,0,0.04);
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    animation: fadeIn 0.3s ease;
    font-family: inherit;
    cursor: default;
}

button.cloud-sync-status {
    cursor: pointer;
}

button.cloud-sync-status:hover:not(:disabled) {
    filter: brightness(0.97);
}

.cloud-sync-status.sync-unsaved {
    color: var(--secondary-hover);
    background-color: hsla(var(--primary-hue, 346), 30%, 94%, 1);
    border-color: var(--primary-border);
    cursor: pointer;
}

.cloud-sync-status:disabled {
    opacity: 0.85;
    cursor: default;
}

.cloud-sync-status i {
    font-size: 0.85rem;
}

.sync-working i {
    animation: spin 1s linear infinite;
    color: var(--secondary-hover) !important;
}

.sync-working {
    color: var(--text-muted) !important;
    background-color: var(--border-color) !important;
}

/* App Title Logo */
.header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.header-logo i {
    font-size: 1.4rem;
    color: var(--primary-color);
}

/* App Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}

/* Currency Select Widget */
.currency-selector-container {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.select-clean {
    border: 1px solid var(--primary-border);
    background-color: var(--card-bg);
    color: var(--text-color);
    padding: 0.4rem 0.6rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-speed) ease;
}

.select-clean:focus {
    border-color: var(--primary-color);
}

/* Toolbars */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 10px rgba(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.2);
}

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

.btn-secondary:hover {
    background-color: var(--primary-lightest);
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

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

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

.btn-text {
    background: none;
    border: none;
    color: var(--primary-dark);
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
}

.btn-text:hover {
    color: var(--primary-color);
    background: var(--primary-lightest);
    border-radius: var(--border-radius-sm);
}

/* Dashboard Wrapper Container */
.dashboard-container {
    flex: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Layout Cards */
.dashboard-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.dashboard-card:hover {
    box-shadow: var(--card-hover-shadow);
    border-color: var(--primary-border);
}

.dashboard-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-color);
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--primary-lightest);
    padding-bottom: 0.5rem;
}

/* Top Dashboard Row Grid */
.top-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;   /* single column on small screens */
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .top-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1024px) {
    /* 2×2: branding + summary on top, charts below (avoids crushing chart columns) */
    .top-dashboard-grid {
        grid-template-columns: minmax(240px, 0.9fr) minmax(460px, 1.6fr);
        grid-template-areas:
            "brand summary"
            "barchart donutchart";
        gap: 1.75rem;
    }

    .top-dashboard-grid > .branding-card {
        grid-area: brand;
    }

    .top-dashboard-grid > .summary-card {
        grid-area: summary;
    }

    .top-dashboard-grid > .chart-card:nth-child(3) {
        grid-area: barchart;
    }

    .top-dashboard-grid > .chart-card:nth-child(4) {
        grid-area: donutchart;
    }
}

@media (min-width: 1500px) {
    /* Wide screens: give the donut card room for its right-side legend. */
    .top-dashboard-grid {
        grid-template-columns: minmax(220px, 0.8fr) minmax(430px, 1.45fr) minmax(290px, 1fr) minmax(420px, 1.35fr);
        grid-template-areas: none;
    }

    .top-dashboard-grid > .branding-card,
    .top-dashboard-grid > .summary-card,
    .top-dashboard-grid > .chart-card:nth-child(3),
    .top-dashboard-grid > .chart-card:nth-child(4) {
        grid-area: auto;
    }
}

/* Left-Side Cursive Branding Card */
.branding-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--primary-lightest) 150%);
    border-color: var(--primary-border);
    position: relative;
    overflow: visible; /* allow cursive text to breathe */
}

.branding-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary-lightest);
    opacity: 0.5;
    z-index: 0;
}

.cursive-month-container {
    z-index: 1;
    margin: 0.5rem 0 1rem;
}

#monthDisplay {
    font-family: var(--cursive-font), 'Sacramento', cursive;
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    font-weight: 400;
    color: var(--primary-dark);
    line-height: 1;
    margin-bottom: 0.25rem;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
    white-space: nowrap;
}

.brand-subtitle {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.meta-controls {
    z-index: 1;
    background: rgba(255, 255, 255, 0.65);
    border-radius: var(--border-radius-md);
    padding: 0.75rem;
    border: 1px solid var(--primary-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.meta-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.meta-field label {
    font-weight: 500;
    color: var(--text-muted);
}

.meta-field input, .meta-field select {
    width: 48%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--primary-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-weight: 500;
    text-align: right;
    outline: none;
    transition: all var(--transition-speed) ease;
}

.meta-field select {
    text-align-last: right;
    cursor: pointer;
}

.meta-field input:focus, .meta-field select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-lightest);
}

/* REMOVE UP/DOWN SPIN BUTTONS FROM YEAR INPUT VISUALLY */
#yearInput {
    -moz-appearance: textfield; /* Firefox */
    width: 55% !important; /* Slightly wider */
    text-align: center !important; /* Center-aligned for visual ease */
    padding-right: 0.5rem !important;
}

#yearInput::-webkit-outer-spin-button,
#yearInput::-webkit-inner-spin-button {
    -webkit-appearance: none; /* Chrome/Edge/Safari */
    margin: 0;
}

/* Charts Containers */
.chart-card {
    display: flex;
    flex-direction: column;
}

.chart-wrapper {
    position: relative;
    flex: 1;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bottom Grid for tables */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .tables-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1200px) {
    .tables-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.table-card {
    display: flex;
    flex-direction: column;
}

.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-lightest);
    padding-bottom: 0.5rem;
}

.table-card h3 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-dark);
}

/* Standard Tables Stylesheet */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.summary-card .table-responsive {
    overflow: visible;
}

.budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.budget-table th {
    font-weight: 500;
    color: white;
    background-color: var(--primary-color);
    padding: 0.5rem 0.75rem;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.budget-table th:first-child {
    border-top-left-radius: var(--border-radius-sm);
    border-bottom-left-radius: var(--border-radius-sm);
}

.budget-table th:last-child {
    border-top-right-radius: var(--border-radius-sm);
    border-bottom-right-radius: var(--border-radius-sm);
}

.budget-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.budget-table tbody tr:hover {
    background-color: var(--primary-bg);
}

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

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

/* Table Total Lines */
.total-row {
    font-weight: 600;
    background-color: var(--primary-lightest) !important;
}

.total-row td {
    border-top: 2px solid var(--primary-border);
    border-bottom: 2px double var(--primary-border);
    color: var(--primary-dark);
    padding: 0.5rem !important;
}

/* In-place Editable Input controls inside tables */
.editable-table input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    font-family: inherit;
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: all 0.15s ease;
}

.editable-table input[type="text"] {
    text-align: left;
    color: var(--text-color);
    font-weight: 400;
}

.editable-table input[type="number"] {
    text-align: right;
    color: var(--text-color);
    font-weight: 500;
}

.editable-table input::-webkit-outer-spin-button,
.editable-table input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.editable-table input[type=number] {
    -moz-appearance: textfield;
}

.editable-table tr:hover input {
    border-color: rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.8);
}

.editable-table input:focus {
    border-color: var(--primary-color) !important;
    background: white !important;
    box-shadow: 0 0 4px rgba(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.3);
}

/* Table Row delete buttons */
.row-actions {
    text-align: center;
    vertical-align: middle;
    border-bottom: none !important;
}

.delete-row-btn {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s ease;
}

.budget-table tr:hover .delete-row-btn {
    opacity: 0.6;
}

.budget-table tr:hover .delete-row-btn:hover {
    opacity: 1;
    background-color: var(--danger-bg);
    color: var(--danger-color);
}

/* Table Summary specifics */
#summaryTable tbody tr:last-child {
    font-weight: 700;
}

#summaryTable tbody tr:last-child td {
    border-top: 2px solid var(--border-color);
    border-bottom: 2px double var(--border-color);
}

#summaryTable {
    table-layout: fixed;
}

#summaryTable th,
#summaryTable td {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

#summaryTable th:nth-child(1),
#summaryTable td:nth-child(1) {
    width: 31%;
}

#summaryTable th:nth-child(2),
#summaryTable td:nth-child(2),
#summaryTable th:nth-child(3),
#summaryTable td:nth-child(3) {
    width: 22%;
}

#summaryTable th:nth-child(4),
#summaryTable td:nth-child(4) {
    width: 25%;
}

#summaryTable .text-right {
    white-space: nowrap;
}

/* Math variance feedbacks */
.diff-positive {
    background-color: var(--success-bg);
    color: var(--success-color) !important;
    font-weight: 600;
}

.diff-negative {
    background-color: var(--danger-bg);
    color: var(--danger-color) !important;
    font-weight: 600;
}

.diff-neutral {
    color: var(--text-muted);
    font-weight: 500;
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.4);
}

/* ========================================== */
/* OVERLAYS, DRAWER AND MODAL STYLE ENGINE */
/* ========================================== --> */

/* Generic Modals Overlays Background */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease;
}

/* Authentication Card modal */
.auth-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 420px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--primary-border);
    padding: 2.25rem 2.25rem 2rem;
    box-shadow: 0 20px 50px -15px rgba(0,0,0,0.15);
    position: relative;
    animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.close-modal-btn {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-speed) ease;
}

.close-modal-btn:hover {
    color: var(--danger-color);
}

/* Tab Selector buttons for login/register */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--primary-lightest);
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.6rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

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

/* Forms layout */
.auth-form h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.input-icon-wrapper {
    position: relative;
    width: 100%;
}

.input-icon-wrapper i {
    position: absolute;
    top: 50%;
    left: 0.9rem;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-size: 0.95rem;
    opacity: 0.7;
}

.input-icon-wrapper input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition-speed) ease;
    background-color: var(--primary-bg);
}

.input-icon-wrapper input:focus {
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 3px var(--primary-lightest);
}

.auth-submit-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* Auth Alert container for error and verification messages */
.auth-alert {
    padding: 10px 15px;
    margin: 10px 0 15px 0;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: left;
    box-sizing: border-box;
}
.auth-alert.success {
    background-color: var(--success-bg, #f4f7f5);
    border: 1px solid var(--success-border, #e0ebe3);
    color: var(--tertiary-color, #5c9e6c);
}
.auth-alert.error {
    background-color: #fde8e8;
    border: 1px solid #f8b4b4;
    color: #9b1c1c;
}
.auth-alert.warning {
    background-color: #fef9c3;
    border: 1px solid #fef08a;
    color: #854d0e;
}
.auth-alert a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
}

/* Left-Side Dropdown Account Drawer panel */
.user-drawer {
    position: fixed;
    top: 5rem;
    left: 2rem;
    background-color: var(--card-bg);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--primary-border);
    width: 280px;
    box-shadow: 0 15px 35px -10px rgba(0,0,0,0.12);
    z-index: 105;
    overflow: hidden;
    animation: slideDown 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.drawer-header {
    background-color: var(--primary-lightest);
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--primary-border);
}

.drawer-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.drawer-user-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.drawer-user-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.drawer-body {
    padding: 0.75rem 0;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    transition: background-color var(--transition-speed) ease;
}

.drawer-item:hover {
    background-color: var(--primary-bg);
}

.drawer-item i {
    font-size: 1.1rem;
    color: var(--primary-color);
    width: 20px;
    text-align: center;
}

.drawer-item div {
    display: flex;
    flex-direction: column;
}

.drawer-item strong {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
}

.drawer-item span {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.drawer-footer {
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--border-color);
}

.w-100 {
    width: 100%;
}

/* Right-Side slide-out Theme Customizer Drawer */
.theme-designer-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.08);
    z-index: 500;
    display: flex;
    flex-direction: column;
    animation: slideLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-drawer-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary-lightest);
}

.theme-drawer-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.theme-section {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.theme-section h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
}

.theme-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.theme-control-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.designer-select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    background-color: var(--primary-bg);
    color: var(--text-color);
    transition: border-color var(--transition-speed) ease;
}

.designer-select:focus {
    border-color: var(--primary-color);
}

/* Color Pickers overrides block */
.color-pickers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.color-picker-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.color-picker-item label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
}

.color-picker-box {
    position: relative;
    width: 100%;
    height: 36px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    cursor: pointer;
}

.color-picker-box input[type="color"] {
    position: absolute;
    top: -5px;
    left: -5px;
    width: calc(100% + 10px);
    height: calc(100% + 10px);
    border: none;
    background: none;
    cursor: pointer;
}

/* Cohesive Presets design buttons */
.theme-presets-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    background-color: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-speed) ease;
    color: var(--text-color);
}

.preset-btn:hover {
    background-color: var(--primary-lightest);
    transform: translateX(3px);
}

.theme-drawer-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--primary-bg);
}

/* Animations keys */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

@keyframes slideLeft {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

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

/* Responsive Table Layout Adjustments */
@media (max-width: 768px) {
    .app-header {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .header-left, .header-logo, .header-actions {
        justify-content: center;
    }
    
    .header-actions {
        flex-wrap: wrap;
    }
    
    .user-drawer {
        left: 50%;
        transform: translateX(-50%);
        top: 11rem;
    }
}

@media (max-width: 576px) {
    .dashboard-container {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }
    
    .toolbar span, #toggleThemePanelBtn span {
        display: none; /* Hide labels on mobile toolbar */
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
    }
    
    #monthDisplay {
        font-size: 3rem;
    }
}

/* Print options modal — matches support form styling */
.print-option-item {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--primary-border);
    border-radius: var(--border-radius-sm);
    margin-top: 0.45rem;
    cursor: pointer;
    background: var(--primary-bg);
    transition: border-color var(--transition-speed) ease, background var(--transition-speed) ease;
}

.print-option-item:has(input:checked) {
    border-color: var(--primary-color);
    background: var(--primary-lightest);
}

.print-option-item input {
    margin-top: 0.2rem;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.print-option-item span {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.82rem;
    line-height: 1.4;
}

.print-option-item strong {
    color: var(--primary-dark);
    font-weight: 600;
}

.print-option-item small {
    color: var(--text-muted);
    font-weight: 400;
}

/* Print — polished paper layout with readable chart snapshots */
@page {
    size: letter landscape;
    margin: 0.32in;
}

@media print {
    *,
    *::before,
    *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    .no-print,
    .app-header,
    .app-footer,
    .branding-card-actions,
    .add-row-btn,
    .delete-row-btn,
    .row-actions,
    .modal-overlay,
    .user-drawer,
    .theme-designer-drawer {
        display: none !important;
    }

    html,
    body,
    body.printing {
        background: var(--print-page-bg, var(--primary-bg)) !important;
        color: var(--text-color) !important;
        min-height: auto !important;
    }

    /* White paper option only — keeps accent colors, removes dark page fill */
    body.print-save-ink,
    body.print-save-ink.dark-mode {
        --print-page-bg: #ffffff !important;
        --print-card-bg: #ffffff !important;
        --text-color: #1a1a1a !important;
        --text-muted: #555555 !important;
        --card-bg: #ffffff !important;
        --border-color: #d5d5d5 !important;
        --primary-lightest: hsl(var(--primary-hue), var(--primary-sat), 94%) !important;
        --primary-border: hsl(var(--primary-hue), var(--primary-sat), 82%) !important;
        --primary-dark: hsl(var(--primary-hue), calc(var(--primary-sat) + 5%), calc(var(--primary-light) - 20%)) !important;
        --success-bg: hsla(120, 40%, 94%, 1) !important;
        --success-border: hsla(120, 35%, 85%, 1) !important;
        --danger-bg: #fff5f5 !important;
        --danger-border: #f0d4d6 !important;
    }

    body.print-with-background {
        background: var(--print-page-bg, var(--primary-bg)) !important;
    }

    .dashboard-container {
        margin: 0 auto !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        gap: 0.18in !important;
    }

    .top-dashboard-grid {
        display: grid !important;
        grid-template-columns: 1fr 1.15fr 1.75fr !important;
        grid-template-areas:
            "brand summary summary"
            "barchart barchart donutchart" !important;
        gap: 0.18in !important;
        align-items: start !important;
    }

    .top-dashboard-grid > .branding-card {
        grid-area: brand !important;
    }

    .top-dashboard-grid > .summary-card {
        grid-area: summary !important;
    }

    .top-dashboard-grid > .chart-card:nth-child(3) {
        grid-area: barchart !important;
    }

    .top-dashboard-grid > .chart-card:nth-child(4) {
        grid-area: donutchart !important;
    }

    .tables-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 0.18in !important;
    }

    .dashboard-card {
        box-shadow: none !important;
        transform: none !important;
        background: var(--print-card-bg, var(--card-bg)) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 10px !important;
        padding: 0.18in !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .dashboard-card h2,
    .table-card h3 {
        font-size: 12px !important;
        line-height: 1.25 !important;
        margin-bottom: 0.12in !important;
        padding-bottom: 0.08in !important;
    }

    .branding-card::before {
        display: none !important;
    }

    .cursive-month-container h1 {
        font-size: 38px !important;
        line-height: 1.1 !important;
    }

    .brand-subtitle {
        font-size: 9px !important;
        letter-spacing: 0.12em !important;
    }

    .date-selector {
        padding: 0.12in !important;
        gap: 0.08in !important;
    }

    .date-input-group {
        display: grid !important;
        grid-template-columns: 1fr 0.9in !important;
        gap: 0.08in !important;
        align-items: center !important;
    }

    .date-input-group label,
    .date-input-group input,
    .date-input-group select {
        font-size: 10px !important;
    }

    .chart-card .chart-wrapper {
        overflow: visible !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 2.25in !important;
    }

    .chart-card .chart-wrapper canvas {
        display: none !important;
    }

    .print-chart-snapshot {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        object-fit: contain !important;
        flex-shrink: 0;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .budget-table {
        table-layout: fixed !important;
        width: 100% !important;
        font-size: 10px !important;
    }

    .budget-table th,
    .budget-table td {
        padding: 0.07in 0.08in !important;
        line-height: 1.25 !important;
    }

    .budget-table th {
        font-size: 8px !important;
        letter-spacing: 0.04em !important;
    }

    #summaryTable {
        font-size: 10.5px !important;
    }

    body.print-frozen .editable-table input {
        display: none !important;
    }

    body.print-frozen .editable-table td[data-print-value]::before {
        content: attr(data-print-value);
        display: block;
        color: var(--text-color);
        white-space: nowrap;
    }

    body.print-frozen .editable-table td[data-print-value]:first-child::before {
        white-space: normal;
    }

    body.print-frozen .editable-table td.text-right[data-print-value]::before {
        text-align: right;
    }

    .budget-table tfoot td,
    .budget-table .text-right {
        white-space: nowrap !important;
    }
}

/* ========================================== */
/* DYNAMIC DARK MODE OVERRIDES */
/* ========================================== */
body.dark-mode {
    --text-color: #f3f4f6;
    --text-muted: #9ca3af;
    --card-bg: hsl(var(--primary-hue), 12%, 14%);
    --primary-bg: hsl(var(--primary-hue), 14%, 9%) !important;
    --border-color: hsl(var(--primary-hue), 12%, 22%);
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.2);
    --card-hover-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.2);

    --secondary-light: hsl(var(--primary-hue), 10%, 18%);
    --primary-lightest: hsl(var(--primary-hue), 12%, 18%);
    --primary-border: hsl(var(--primary-hue), 15%, 24%);
    --primary-dark: hsl(var(--primary-hue), calc(var(--primary-sat) + 5%), calc(var(--primary-light) + 15%));

    --success-bg: hsla(120, 25%, 12%, 0.4);
    --success-border: hsla(120, 25%, 20%, 0.5);
    --success-color: #81c784;
    --danger-bg: hsla(0, 25%, 12%, 0.4);
    --danger-border: hsla(0, 25%, 20%, 0.5);
    --danger-color: #e57373;

    --header-bg: hsla(var(--primary-hue), 12%, 14%, 0.85);
}

body.dark-mode .app-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .meta-controls {
    background: rgba(0, 0, 0, 0.25);
}

body.dark-mode .editable-table tr:hover input {
    border-color: rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .editable-table input:focus {
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
}

body.dark-mode .input-icon-wrapper input:focus {
    background-color: var(--card-bg);
    color: var(--text-color);
}

body.dark-mode .app-footer {
    background-color: rgba(0, 0, 0, 0.2);
}

body.dark-mode .modal-overlay {
    background-color: rgba(0, 0, 0, 0.6);
}

body.dark-mode .budget-table td.row-actions {
    border-bottom: none !important;
}

body.dark-mode .total-row td {
    border-top-color: rgba(255, 255, 255, 0.08);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .budget-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

body.dark-mode .theme-designer-drawer,
body.dark-mode .user-drawer {
    border-color: var(--border-color);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
}

/* ========================================== */
/* PROFILE PICTURE & AVATAR UPLOAD            */
/* ========================================== */

/* Header avatar image (circular, replaces icon) */
.header-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    display: block;
}

/* Drawer avatar wrapper — relative container for overlay */
.drawer-avatar-wrap {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
}

/* Override the existing avatar circle inside the wrapper */
.drawer-avatar-wrap .user-avatar-circle {
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
    transition: filter 0.2s ease;
}

/* Photo version of the drawer avatar */
.drawer-avatar-photo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    position: absolute;
    top: 0; left: 0;
    transition: filter 0.2s ease;
}

/* Camera overlay on hover */
.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: white;
    font-size: 1rem;
}

.drawer-avatar-wrap:hover .avatar-upload-overlay {
    opacity: 1;
}

.drawer-avatar-wrap:hover .user-avatar-circle,
.drawer-avatar-wrap:hover .drawer-avatar-photo {
    filter: brightness(0.7);
}

/* Uploading spinner state */
.drawer-avatar-wrap.uploading .avatar-upload-overlay {
    opacity: 1;
}

/* ========================================== */
/* CLICKABLE DRAWER ITEM BUTTON               */
/* ========================================== */

.drawer-item-btn {
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.drawer-item-btn:hover {
    background-color: var(--primary-lightest);
}

.drawer-item-btn:hover i {
    color: var(--primary-dark);
}

/* ========================================== */
/* SUPPORT EMAIL MODAL                        */
/* ========================================== */

.support-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 480px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--primary-border);
    padding: 2rem 2.25rem 1.75rem;
    box-shadow: 0 20px 50px -15px rgba(0,0,0,0.18);
    position: relative;
    animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.support-modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.support-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-lightest);
    border: 2px solid var(--primary-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.support-modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.35rem;
}

.support-textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    font-family: var(--body-font);
    outline: none;
    resize: vertical;
    min-height: 110px;
    transition: all var(--transition-speed) ease;
    background-color: var(--primary-bg);
    color: var(--text-color);
    box-sizing: border-box;
}

.support-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-lightest);
}

.input-readonly {
    background-color: var(--primary-lightest) !important;
    color: var(--text-muted) !important;
    cursor: default !important;
    font-style: italic;
}

.support-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.75rem;
}

/* ========================================== */
/* COPY / PASTE MONTH                         */
/* ========================================== */

.branding-card-actions {
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.branding-card-actions .btn {
    width: 100%;
    justify-content: center;
}

.branding-card-actions .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.copy-month-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 420px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--primary-border);
    padding: 2rem 2.25rem 1.75rem;
    box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.18);
    position: relative;
    animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.copy-month-body .form-group {
    margin-bottom: 0.75rem;
}

.copy-month-body .form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.copy-month-source {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    background: var(--primary-lightest);
    border: 1px solid var(--primary-border);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 0.9rem;
}

.copy-month-arrow {
    text-align: center;
    color: var(--text-muted);
    margin: 0.35rem 0 0.75rem;
    font-size: 1rem;
}

.copy-dest-row {
    display: flex;
    gap: 0.5rem;
}

.copy-dest-select {
    flex: 1;
    min-width: 0;
}

.copy-all-row {
    margin-top: 0.75rem;
}

.copy-all-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1.4;
}

.copy-all-label input {
    margin-top: 0.15rem;
    accent-color: var(--primary-color);
}

/* Dark mode overrides for support modal & avatar */
body.dark-mode .support-textarea {
    background-color: var(--input-bg-dark, rgba(255,255,255,0.06));
    border-color: rgba(255,255,255,0.12);
    color: var(--text-color);
}

body.dark-mode .support-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(195, 147, 158, 0.18);
}

body.dark-mode .input-readonly {
    background-color: rgba(255,255,255,0.04) !important;
}

body.dark-mode .support-icon-wrap {
    background: rgba(255,255,255,0.06);
}
