/* Greyed out form group for disabled fields */
.greyed-out {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(60%);
    transition: opacity 0.2s, filter 0.2s;
}

/* Disabled input styling */
input:disabled,
select:disabled,
textarea:disabled {
    background-color: #f0f0f0 !important;
    color: #999 !important;
    cursor: not-allowed !important;
    border-color: #ddd !important;
}

/* ========================================
   BASE STYLES - Budget Tracker
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family:
        'Inter',
        'Noto Color Emoji',
        'Apple Color Emoji',
        'Segoe UI Emoji',
        'Segoe UI',
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
    background: #f8fafc;
    min-height: 100vh;
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */
.side-nav {
    width: 250px;
    height: 100vh;
    background: #ffffff;
    position: fixed;
    top: 0;
    left: 0;
    padding: 20px 15px;
    padding-bottom: 150px;
    z-index: 1000;
    box-shadow: 1px 0 0 #e2e8f0;
    border-right: none;
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
}

/* Sidebar Header with Logo and Collapse Button */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
    transition: flex-direction 0.4s ease,
        gap 0.4s ease,
        padding 0.4s ease;
}

.logo-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex: 1;
    min-width: 0;
}

.logo-nav:hover {
    opacity: 0.9;
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    flex-shrink: 0;
    line-height: 1;
    transition: font-size 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.logo-text {
    color: #1e293b;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s ease,
        width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-width: 150px;
}

.side-nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.side-nav-links li {
    margin: 4px 0;
}

.side-nav-links li:nth-child(1) {
    animation: slideInLeft 0.3s ease 0.1s forwards;
    opacity: 0;
}

.side-nav-links li:nth-child(2) {
    animation: slideInLeft 0.3s ease 0.2s forwards;
    opacity: 0;
}

.side-nav-links li:nth-child(3) {
    animation: slideInLeft 0.3s ease 0.3s forwards;
    opacity: 0;
}

.side-nav-links li:nth-child(4) {
    animation: slideInLeft 0.3s ease 0.4s forwards;
    opacity: 0;
}

.side-nav-links li a {
    color: #475569;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    padding: 12px 15px;
    align-items: center;
    border-radius: 10px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    gap: 12px;
    position: relative;
}

.side-nav-links li a i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

/* Distinct icon colors for each nav item */
.side-nav-links li[data-view="input"] a i {
    color: #22c55e;
}

.side-nav-links li[data-view="table"] a i {
    color: #3b82f6;
}

.side-nav-links li[data-view="dashboard"] a i {
    color: #f59e0b;
}

.side-nav-links li a p {
    margin: 0;
    font-weight: 500;
    letter-spacing: 0.2px;
    transition: opacity 0.3s ease,
        max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-width: 150px;
    overflow: hidden;
}

.side-nav-links li a:hover {
    color: #1e293b;
    background: #f8fafc;
    border-left: 3px solid #e2e8f0;
}

.side-nav-links li.current a {
    color: #1e293b;
    background: #f1f5f9;
    border-left: 3px solid #1e293b;
    font-weight: 600;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   SIDEBAR COLLAPSE BUTTON & COLLAPSED STATE
   ======================================== */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #cbd5e1;
}

.sidebar-collapse-btn i {
    font-size: 11px;
    transition: transform 0.3s ease;
}

/* Collapsed Sidebar State */
.side-nav.collapsed {
    width: 72px;
    padding: 15px 10px;
    padding-bottom: 150px;
}

.side-nav.collapsed .sidebar-header {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.side-nav.collapsed .logo-nav {
    justify-content: center;
    width: 100%;
}

.side-nav.collapsed .logo-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    position: absolute;
}

.side-nav.collapsed .logo-icon {
    font-size: 26px;
}

.side-nav.collapsed .sidebar-collapse-btn {
    width: 42px;
    height: 26px;
    border-radius: 6px;
}

/* Icon direction is handled by JavaScript via class changes */

.side-nav.collapsed .side-nav-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.side-nav.collapsed .side-nav-links li {
    width: 100%;
    display: flex;
    justify-content: center;
}

.side-nav.collapsed .side-nav-links li a {
    justify-content: center;
    padding: 12px;
    width: 46px;
    height: 46px;
    position: relative;
    border-left: none;
    border-radius: 12px;
    gap: 0;
}

.side-nav.collapsed .side-nav-links li.current a {
    border-left: none;
    background: rgba(102, 126, 234, 0.25);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.side-nav.collapsed .side-nav-links li a i {
    font-size: 20px;
    width: auto;
    margin: 0;
}

.side-nav.collapsed .side-nav-links li a p {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    position: absolute;
}

/* Tooltip for collapsed state */
.side-nav.collapsed .side-nav-links li a::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 15px;
    padding: 8px 14px;
    background: #1e293b;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1001;
}

.side-nav.collapsed .side-nav-links li a::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    border: 6px solid transparent;
    border-right-color: #1e293b;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.side-nav.collapsed .side-nav-links li a:hover::after,
.side-nav.collapsed .side-nav-links li a:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Collapsed sidebar footer */
.side-nav.collapsed .sidebar-footer {
    padding: 10px 6px;
    align-items: center;
}

.side-nav.collapsed .sidebar-status-row {
    flex-direction: column;
    gap: 4px;
    align-items: center;
    width: 100%;
}

.side-nav.collapsed .sidebar-status-row .status-divider {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
}

.side-nav.collapsed .sidebar-status-row #connectionStatus,
.side-nav.collapsed .sidebar-status-row #sync-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.3s ease,
        max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.side-nav.collapsed .sidebar-date {
    justify-content: center;
}

.side-nav.collapsed .sidebar-date span {
    opacity: 0;
    max-width: 0;
}

.side-nav.collapsed .logout-btn {
    padding: 10px;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin: 0 auto;
}

.side-nav.collapsed .logout-btn span {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    position: absolute;
    transition: opacity 0.3s ease,
        max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.side-nav.collapsed .logout-btn i {
    font-size: 16px;
    margin: 0;
}

/* Container adjustment when sidebar collapsed */
.container.expanded {
    margin-left: 72px;
    #weekday_plot,
    #expenses_box,
    #date_filters,
    #var,
    #category_var,
    #day_var,
    #month_var,
    #year_var {
        box-sizing: border-box;
    }
    width: calc(100vw - 72px);
}
    #var, #category_var {
        width: 100%;
        max-width: 440px;
        margin-bottom: 12px;
    }

/* Sync status indicator styles */
    #day_var, #month_var, #year_var {
        width: 100%;
        max-width: 160px;
        margin-bottom: 12px;
    }
.syncing {
    background: orange !important;
    #weekday_plot {
        width: 100%;
        margin-top: 18px;
        padding: 6px 12px;
    }
    animation: spin 1s linear infinite;
    width: 10px;
    #weekday_plot img,
    #weekday_plot canvas,
    #weekday_plot svg {
        width: 100% !important;
        height: auto !important;
    }
    height: 10px;
    display: inline-block;
    #expenses_box {
        width: 100%;
        max-width: 900px;
        margin-top: 12px;
    }
    border-radius: 50%;
}
    @media (min-width: 720px) {
        #day_var, #month_var, #year_var {
            display: inline-block;
            vertical-align: middle;
            margin-right: 12px;
            margin-bottom: 0;
        }

        #var, #category_var {

    /* Make date/month/year controls full-width on small screens */
    @media (max-width: 700px) {
        .filter-group.filter-date-group > div {
            display: flex !important;
            flex-direction: column !important;
            gap: 8px;
            align-items: stretch;
        }
        .filter-group.filter-date-group > div select {
            width: 100% !important;
            min-width: 0 !important;
        }
        .filter-group.filter-date-group label {
            margin-bottom: 6px;
        }
    }

    /* Ensure filter groups can shrink and occupy full width on mobile */
    @media (max-width: 700px) {
        .filter-group { min-width: 0 !important; flex: 1 1 100% !important; }
        .filter-row .filter-group select { width: 100% !important; min-width: 0 !important; }
        .filter-group.filter-date-group { flex-direction: column; flex: 1 1 100% !important; }
        .filter-group.filter-date-group > div { width: 100% !important; }
    }
            display: inline-block;
            vertical-align: middle;
            margin-right: 18px;
        }

        /* Give the plot more breathing room on wide screens */
        #weekday_plot {
            padding-left: 18px;
            padding-right: 18px;
        }
    }

    /* Small screens: reduce padding to save space */
    @media (max-width: 420px) {
        #weekday_plot {
            padding-left: 6px;
            padding-right: 6px;
        }

        #expenses_box {
            padding-left: 6px;
            padding-right: 6px;
        }
    }

    /* Target Shiny input containers for responsive layout */
    .date-filters .shiny-input-container,
    .date-filters .form-group {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 8px !important;
    }

    .date-filters .selectize-control,
    .date-filters .selectize-input,
    .date-filters select,
    .date-filters input {
        width: 100% !important;
        box-sizing: border-box;
    }

    @media (min-width: 720px) {
        /* allow date selectors to appear inline on larger screens */
        .date-filters .shiny-input-container,
        .date-filters .form-group {
            display: inline-block !important;
            width: auto !important;
            vertical-align: middle !important;
            margin-right: 12px !important;
            margin-bottom: 0 !important;
        }
    }

    /* Top-filters: payer + category inline on wider screens, stacked on small */
    .top-filters {
        width: 100%;
        box-sizing: border-box;
    }
    .top-filters .shiny-input-container,
    .top-filters .form-group {
        width: 100%;
        max-width: none;
    }

    @media (min-width: 640px) {
        .top-filters .shiny-input-container,
        .top-filters .form-group {
            display: inline-block !important;
            vertical-align: top !important;
            width: calc(50% - 9px) !important;
            margin-bottom: 0 !important;
        }
    }

    /* Keep payer + category side-by-side and adjacent on all sizes
       - Always keep controls on the same row (no large gap at the ends)
       - Let inputs size naturally and cap their maximum width so they don't stretch
       - Use !important to override inline styles from the server-side UI
    */
    .top-filters {
        display: flex !important;
        gap: 12px !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }
    .top-filters .shiny-input-container,
    .top-filters .form-group {
        display: block !important;
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: 420px !important;
        box-sizing: border-box !important;
        margin-bottom: 8px !important;
    }
    /* Ensure inner select inputs expand to fit their small containers */
    .top-filters .selectize-control,
    .top-filters .selectize-input,
    .top-filters select,
    .top-filters input {
        width: 100% !important;
        min-width: 140px !important;
    }

    /* High-specificity override: ensure the two main selects stay compact
       and adjacent when inside the top-filters wrapper on large screens. */
    .top-filters #var,
    .top-filters #category_var,
    .top-filters #var .selectize-control,
    .top-filters #category_var .selectize-control {
        display: inline-block !important;
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: 420px !important;
        margin-right: 8px !important;
        box-sizing: border-box !important;
        vertical-align: middle !important;
    }

.synced {
    background: #2ecc40 !important;
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
}

.sync-error {
    background: #e74c3c !important;
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Status message styles */
.status-message {
    margin-top: 16px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    background: #f6f8fa;
    color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.status-message i {
    font-size: 18px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-message.loading {
    color: #d97706;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fcd34d;
}

.status-message.success {
    color: #059669;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #6ee7b7;
}

.status-message.error {
    color: #dc2626;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #fca5a5;
}


/* ========================================
   SIDEBAR FOOTER (Status Strip)
   ======================================== */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 15px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.sidebar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #64748b;
}

.sidebar-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: #64748b;
    transition: flex-direction 0.4s ease,
        gap 0.4s ease;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-divider {
    color: #cbd5e1;
    font-size: 9px;
    transition: opacity 0.3s ease;
}

.sidebar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #94a3b8;
    transition: justify-content 0.4s ease;
}

.sidebar-date i {
    font-size: 9px;
    opacity: 0.7;
}

.sidebar-date span {
    transition: opacity 0.3s ease,
        max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-width: 200px;
    overflow: hidden;
}

.btn-refresh-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 14px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 5px;
}

.btn-refresh-sidebar:hover {
    background: #e2e8f0;
}

.btn-refresh-sidebar i {
    font-size: 11px;
}

/* ========================================
   MAIN CONTAINER
   ======================================== */
.container {
    margin-left: 250px;
    padding: 15px 15px 15px 15px;
    width: calc(100vw - 250px);
    min-height: 100vh;
    transition: margin-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Desktop: make main container use full viewport height and allow its content to stretch */
@media (min-width: 1024px) {
    .container {
        height: 100vh;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding: 12px 18px;
        width: calc(100vw - 250px);
    }

    /* View sections should expand to fill available vertical space */
    .view-section {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Ensure the inner summary section uses flex layout so header/footer stay visible */
    .section-summary {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    /* Reduce header/filter paddings to save vertical space on desktop */
    .table-header {
        margin-bottom: 8px;
        gap: 8px;
    }

    .filter-row {
        padding: 8px 12px;
        margin-bottom: 8px;
        gap: 8px;
    }

    .search-wrapper input {
        width: 220px;
        padding: 8px 32px 8px 36px;
    }

    /* Table container should take remaining space and scroll internally */
    .table-container {
        max-height: none !important;
        flex: 1 1 auto;
        overflow: auto;
        /* reserve space equal to pagination height + margin so rows aren't hidden */
        --pagination-height: 56px;
        padding-bottom: calc(var(--pagination-height) - 35px);
    }

    /* Pagination must remain visible and not be scrolled away inside table */
    .section-summary {
        position: relative; /* allow absolute-positioning pagination inside */
        padding-bottom: 0; /* table-container handles reserved space */
        display: flex;
        flex-direction: column;
        min-height: 0; /* allow child flex to shrink properly */
    }

    .section-summary .pagination {
        position: absolute;
        left: 18px; /* match container inner padding */
        right: 18px;
        bottom: 2px;
        height: var(--pagination-height, 45px);
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
        z-index: 60;
        background: #ffff;
        padding: 8px 12px;
        pointer-events: auto;
    }

    /* Ensure pagination doesn't overflow parent card when container is smaller */
    .section-summary { overflow: visible; }

    /* Reduce vertical padding of table rows slightly to fit more rows */
    .data-table td, .data-table th {
        padding: 10px 12px;
    }

    /* Keep top-strip and other headers from stretching */
    .top-strip,
    .section-summary,
    .section-title {
        flex: 0 0 auto;
    }
}

/* ========================================
   TOP STRIP (Minimal Header)
   ======================================== */
.top-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: #ffffff;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #e2e8f0;
}

.strip-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.strip-status,
.strip-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #64748b;
}

.strip-status {
    padding-right: 15px;
    border-right: 1px solid #e2e8f0;
}

.strip-date i {
    font-size: 11px;
    opacity: 0.7;
}

.btn-refresh-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-refresh-mini:hover {
    background: #e2e8f0;
}

.btn-refresh-mini i {
    font-size: 11px;
}

/* Legacy Top Bar (hidden but kept for compatibility) */
.top-bar {
    display: none;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.top-bar-left .logo {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status-pills {
    display: flex;
    gap: 10px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #e2e8f0;
    border-radius: 20px;
    font-size: 12px;
    color: #475569;
}

.status-pill i {
    font-size: 11px;
}

.live-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.live-indicator.connected {
    background: #48bb78;
    box-shadow: 0 0 6px #48bb78;
}

.live-indicator.disconnected {
    background: #fc8181;
    box-shadow: 0 0 6px #fc8181;
}

/* Sync status indicator states */
.live-indicator.syncing {
    background: #f6ad55;
    box-shadow: 0 0 6px #f6ad55;
    animation: pulse 1s infinite;
}

.live-indicator.synced {
    background: #48bb78;
    box-shadow: 0 0 6px #48bb78;
    animation: pulse 2s infinite;
}

.live-indicator.sync-error {
    background: #fc8181;
    box-shadow: 0 0 6px #fc8181;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-refresh {
    padding: 8px 16px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.btn-refresh:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

/* ========================================
   SECTION STYLES
   ======================================== */
.view-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-summary {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    height: calc(97vh + 2px);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: #64748b;
}

/* ========================================
   EXPENSE FORM STYLES
   ======================================== */
.expense-form {
    margin-top: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label i {
    color: #94a3b8;
    font-size: 14px;
}

.form-group input,
.form-group select {
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    color: #1e293b;
    background: #ffffff;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #94a3b8;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.15);
}

.form-group input::placeholder {
    color: #a0aec0;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Date Input with Flatpickr */
.flatpickr-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Flatpickr customizations for better mobile experience */
.flatpickr-calendar {
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid #e2e8f0 !important;
}

.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after {
    border-bottom-color: #1e293b !important;
}

.flatpickr-months .flatpickr-month {
    background: #1e293b !important;
    border-radius: 12px 12px 0 0 !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    color: white !important;
    font-weight: 600 !important;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    fill: white !important;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 50%;
}

span.flatpickr-weekday {
    color: #64748b !important;
    font-weight: 600 !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #1e293b !important;
    border-color: #1e293b !important;
}

.flatpickr-day:hover {
    background: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
}

.flatpickr-day.today {
    border-color: #64748b !important;
}

.flatpickr-day.today:not(.selected) {
    color: #1e293b !important;
}

/* Mobile-specific Flatpickr adjustments */
@media (max-width: 768px) {
    .flatpickr-calendar {
        width: 100% !important;
        max-width: 320px !important;
    }

    .flatpickr-day {
        height: 44px !important;
        line-height: 44px !important;
    }
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #1e293b;
    color: white;
}

.btn-primary:hover {
    background: #334155;
}

.btn-primary:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.btn-secondary {
    background: #edf2f7;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

/* Clear Button Wrapper & Toast */
.clear-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.submit-toast {
    position: absolute;
    top: 50%;
    right: calc(100% + 12px);
    transform: translateY(-50%);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.submit-toast::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: inherit;
}

.submit-toast.show {
    opacity: 1;
    visibility: visible;
    animation: toastSlideIn 0.3s ease;
}

.submit-toast.hide {
    animation: toastSlideOut 0.3s ease forwards;
}

.submit-toast.success {
    background: #22c55e;
    color: white;
}

.submit-toast.success::after {
    border-left-color: #22c55e;
}

.submit-toast.error {
    background: #ef4444;
    color: white;
}

.submit-toast.error::after {
    border-left-color: #ef4444;
}

.submit-toast.loading {
    background: #64748b;
    color: white;
}

.submit-toast.loading::after {
    border-left-color: #64748b;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }

    to {
        opacity: 0;
        transform: translateY(-50%) translateX(-10px);
    }
}

/* Status Message */
.status-message {
    margin-top: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-message.success {
    background: #c6f6d5;
    color: #276749;
    border: 1px solid #9ae6b4;
}

.status-message.error {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.status-message.loading {
    background: #e9d8fd;
    color: #553c9a;
    border: 1px solid #d6bcfa;
}

/* ========================================
   QUICK SUMMARY CARDS
   ======================================== */
.quick-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.summary-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.summary-card:hover {
    border-color: #cbd5e1;
}

.summary-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.summary-expense .summary-icon {
    background: #fef2f2;
    color: #ef4444;
}

.summary-income .summary-icon {
    background: #f0fdf4;
    color: #22c55e;
}

.summary-total .summary-icon {
    background: #f8fafc;
    color: #64748b;
}

.summary-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-label {
    font-size: 13px;
    color: #718096;
    font-weight: 500;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
}

/* ========================================
   TABLE STYLES
   ======================================== */
.table-section {
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.table-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    color: #a0aec0;
    font-size: 14px;
}

.search-wrapper input {
    padding: 10px 35px 10px 38px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    width: 250px;
    transition: all 0.3s ease;
}

.search-wrapper input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    display: none;
}

.search-wrapper input:not(:placeholder-shown)+.search-clear {
    display: block;
}

.btn-clear-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-filters:hover {
    background: #334155;
}

.btn-clear-filters i {
    font-size: 14px;
}

/* ========================================
   FILTER ROW STYLES
   ======================================== */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
    flex: 1;
}

/* Compact date trio on larger screens */
.filter-group.filter-date-group {
    flex: 0 1 360px;
}
.filter-group.filter-date-group select {
    min-width: 110px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 10px 32px 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23667eea' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px;
}

.filter-group select:hover {
    border-color: #667eea;
}

.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.filter-group select:not([value=""]):not(:placeholder-shown) {
    border-color: #667eea;
    background-color: #f0f4ff;
}

.table-info {
    font-size: 13px;
    color: #718096;
}

.table-info .table-info-full {
    display: inline;
}

.table-info .table-info-compact {
    display: none;
}

.table-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #718096;
}

.loader {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.table-container {
    max-height: calc(100vh - 420px);
    overflow: auto;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: #f8fafc;
    color: #475569;
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background 0.2s ease;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th:hover {
    background: #f1f5f9;
}

.sort-icon {
    margin-left: 5px;
    opacity: 0.5;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #4a5568;
}

/* Center align Transaction column */
.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    text-align: center;
}

.data-table tbody tr:hover {
    background: #f7fafc;
}

.data-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.data-table tbody tr:nth-child(even):hover {
    background: #f0f4f8;
}

/* ================= CATEGORY BADGES ================= */

.category-badge {
    display: inline-flex;
    /* better alignment */
    align-items: center;
    gap: 6px;
    /* spacing between icon & text */
    padding: 5px 12px;
    border-radius: 999px;
    /* perfect pill */
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
}

/* Icon inside badge */
.category-badge i {
    font-size: 11px;
}

/* Income */
.category-income {
    background: #dcfce7;
    color: #16a34a;
}

/* Expense (default) */
.category-expense {
    background: #fee2e2;
    color: #dc2626;
}


/* Payer badges */
.payer-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.payer-jason {
    background: #c3dafe;
    color: #3c366b;
}

.payer-phoebe {
    background: #fbb6ce;
    color: #702459;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #4a5568;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 13px;
    color: #718096;
    padding: 0 10px;
}

/* ========================================
   DASHBOARD STYLES - CLEAN FULL VIEW
   ======================================== */
.dashboard-section-clean {
    padding: 0;
    height: calc(100vh - 30px);
    overflow: hidden;
}

.dashboard-container-full {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: white;
}

.dashboard-iframe-full {
    width: 100%;
    height: 100%;
    border: none;
}

/* Legacy styles kept for compatibility */
.dashboard-section {
    padding: 8px;
    padding-bottom: 20px;
    height: calc(100vh - 90px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.dashboard-section .section-title {
    margin: 0;
    font-size: 16px;
}

.dashboard-container {
    width: 100%;
    flex: 1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    background: #1a1a2e;
    position: relative;
    min-height: 0;
    margin-bottom: 15px;
}

.dashboard-iframe {
    border: none;
    transform: scale(0.65);
    transform-origin: top left;
    width: 153.85%;
    height: 153.85%;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .dashboard-section-clean {
        height: calc(100vh - 90px);
        gap: 10px;
    }
    .filter-group.filter-date-group {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .dashboard-section-clean {
        height: calc(100vh - 80px);
        padding: 5px;
    }
}

/* Dashboard Controls */
.dashboard-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 6px 0;
    gap: 15px;
    flex-shrink: 0;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4a5568;
    font-size: 13px;
}

.zoom-control label {
    font-weight: 500;
}

.zoom-slider {
    width: 100px;
    cursor: pointer;
}

.zoom-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
}

.btn-fullscreen {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.btn-fullscreen:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Fullscreen mode styling */
.dashboard-container:fullscreen {
    background: #1a1a2e;
    border-radius: 0;
}

.dashboard-container:fullscreen .dashboard-iframe {
    width: 100vw;
    height: 100vh;
}

/* ========================================
   HAMBURGER MENU (Mobile)
   ======================================== */
.hamburger {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    width: 46px;
    height: 46px;
    background: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hamburger hide on scroll */
.hamburger.scroll-hidden {
    transform: translateY(-70px);
    opacity: 0;
    pointer-events: none;
}

.hamburger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.5);
}

.hamburger:active {
    transform: scale(0.95);
}

.hamburger-box {
    width: 24px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
    width: 24px;
    height: 3px;
    background: #1e293b;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-inner {
    position: relative;
}

.hamburger-inner::before,
.hamburger-inner::after {
    content: '';
    position: absolute;
    left: 0;
}

.hamburger-inner::before {
    top: -8px;
}

.hamburger-inner::after {
    bottom: -8px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Mobile Close Button inside Sidebar */
.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.sidebar-close-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #ef4444;
}

/* ========================================
   MOBILE BOTTOM NAVIGATION BAR
   ======================================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.bottom-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    margin-top: -10px;
}

/* Navigation items container */
.bottom-nav {
    display: none;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 6px 16px;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-width: 64px;
}

.bottom-nav-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
}

.bottom-nav-icon i {
    font-size: 18px;
    color: #64748b;
    transition: all 0.3s ease;
}

.bottom-nav-label {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.3s ease;
    white-space: nowrap;
}

/* Active state */
.bottom-nav-item.active {
    transform: translateY(-2px);
}

.bottom-nav-item.active .bottom-nav-icon {
    background: #f1f5f9;
    transform: scale(1.1);
}

.bottom-nav-item.active .bottom-nav-icon i {
    color: #1e293b;
}

.bottom-nav-item.active .bottom-nav-label {
    color: #1e293b;
    font-weight: 600;
}

/* Active indicator dot */
.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #1e293b;
    border-radius: 50%;
}

/* Hover state (non-active items) */
.bottom-nav-item:not(.active):hover .bottom-nav-icon i {
    color: #475569;
    transform: scale(1.1);
}

.bottom-nav-item:not(.active):hover .bottom-nav-label {
    color: #475569;
}

/* Tap feedback */
.bottom-nav-item:active {
    transform: scale(0.95);
}

.bottom-nav-item.active:active {
    transform: translateY(-2px) scale(0.98);
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .quick-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* ==================== BOTTOM NAV MOBILE LAYOUT ==================== */

    /* Hide hamburger on mobile - using bottom nav instead */
    .hamburger {
        display: none !important;
    }

    /* Hide sidebar completely on mobile */
    .side-nav {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .sidebar-close-btn {
        display: none !important;
    }

    /* Show bottom navigation */
    .bottom-nav {
        display: flex !important;
    }

    /* Container adjustments for bottom nav */
    .container {
        margin-left: 0;
        width: 100%;
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px));
    }

    /* Override expanded state on mobile */
    .container.expanded {
        margin-left: 0;
        width: 100%;
    }
}

/* ========================================
   SCROLLBAR STYLES
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Action Cell Styles */
.transaction-row {
    position: relative;
    /* iOS: Disable double-tap-to-zoom, enable pan/pinch */
    touch-action: manipulation;
    /* Make it clear rows are tappable */
    cursor: pointer;
    /* Prevent text selection on double-tap */
    -webkit-user-select: none;
    user-select: none;
}

/* Details cell - contains text and floating action buttons */
.details-cell {
    position: relative;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-actions {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.95) 30%);
    padding: 4px 8px 4px 20px;
    border-radius: 4px;
}

/* Show actions when row has show-actions class (double-tap on mobile) */
.transaction-row.show-actions .row-actions {
    opacity: 1;
    visibility: visible;
}

/* Show on row hover (desktop with mouse) */
@media (hover: hover) {
    .transaction-row:hover .row-actions {
        opacity: 1;
        visibility: visible;
    }
}

.action-btn {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.action-btn:hover {
    transform: translateY(-2px);
}

.action-btn.edit-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.action-btn.delete-btn:hover {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.4);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Dialog */
.modal-dialog {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 32px;
    max-width: 90vw;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.delete-modal {
    width: 400px;
}

.edit-modal {
    width: 550px;
    text-align: left;
}

/* Modal Icon */
.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 28px;
}

.delete-icon {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.edit-icon {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #667eea;
}

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

.modal-header .modal-icon {
    width: 48px;
    height: 48px;
    font-size: 20px;
    margin: 0;
}

.modal-header .modal-title {
    margin: 0;
    flex: 1;
}

.modal-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Modal Title & Message */
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
}

.modal-message {
    font-size: 0.95rem;
    color: #64748b;
    margin-bottom: 28px;
    line-height: 1.6;
}

/* Modal Buttons */
.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.modal-btn-cancel {
    background: #f1f5f9;
    color: #64748b;
}

.modal-btn-cancel:hover {
    background: #e2e8f0;
    color: #475569;
}

.modal-btn-danger {
    background: #ef4444;
    color: #fff;
}

.modal-btn-danger:hover {
    background: #dc2626;
}

.modal-btn-primary {
    background: #1e293b;
    color: #fff;
}

.modal-btn-primary:hover {
    background: #334155;
}

/* Edit Form Styles */
.edit-form {
    margin-top: 8px;
}

.edit-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.edit-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.edit-form-group.full-width {
    grid-column: 1 / -1;
}

.edit-form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.edit-form-group label i {
    color: #667eea;
    font-size: 0.8rem;
}

.edit-form-group input,
.edit-form-group select {
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    color: #1e293b;
    transition: all 0.2s ease;
    background: #f8fafc;
}

.edit-form-group input:focus,
.edit-form-group select:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.edit-form .modal-buttons {
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    justify-content: flex-end;
}

#sync-icon.syncing {
    animation: spin 1s linear infinite;
}

#sync-icon.synced {
    color: green;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   LOGIN PAGE STYLES
   ======================================== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    padding: 40px 35px;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.login-logo-icon {
    font-size: 42px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.login-subtitle {
    color: #64748b;
    font-size: 15px;
    margin: 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-field label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-field label i {
    color: #667eea;
    font-size: 14px;
}

.login-field input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    color: #1f2937;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.login-field input:focus {
    outline: none;
    border-color: #667eea;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.login-field input::placeholder {
    color: #9ca3af;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease;
}

.toggle-password:hover {
    color: #667eea;
}

.login-error {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #dc2626;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.login-error.show {
    display: flex;
}

.login-error i {
    font-size: 16px;
}

.login-btn {
    width: 100%;
    padding: 16px 24px;
    background: #1e293b;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.login-btn:hover:not(:disabled) {
    background: #334155;
}

.login-btn:active:not(:disabled) {
    background: #475569;
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.login-btn.success {
    background: #22c55e;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.login-footer p {
    color: #9ca3af;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
}

.login-footer i {
    color: #64748b;
}

/* Decorative circles - hidden for minimalist design */
.login-decoration {
    display: none;
}

/* Session timeout warning toast */
.session-warning {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #f59e0b;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideInRight 0.3s ease;
    font-weight: 500;
}

.session-warning.show {
    display: flex;
}

.session-warning i {
    font-size: 20px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Logout button in sidebar */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-top: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.logout-btn span {
    transition: opacity 0.3s ease,
        max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-width: 100px;
    overflow: hidden;
    white-space: nowrap;
}

.logout-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.logout-btn i {
    font-size: 14px;
}

/* Responsive login */
@media (max-width: 480px) {
    .login-card {
        padding: 30px 25px;
        border-radius: 20px;
    }

    .login-logo h1 {
        font-size: 24px;
    }

    .login-logo-icon {
        font-size: 36px;
    }
}

/* ========================================
   ENHANCED MOBILE STYLES (=768px)
   Clean, modern mobile-first design
   ======================================== */
@media (max-width: 768px) {

    /* Container - Proper padding for bottom nav */
    .container {
        padding: 16px 12px calc(90px + env(safe-area-inset-bottom, 0px));
    }

    /* Remove old sidebar mobile nav styles - using bottom nav now */

    /* Section Summary - Card container */
    .section-summary {
        padding: 18px 16px;
        border-radius: 14px;
    }

    /* Section Title - Compact header */
    .section-title {
        font-size: 17px;
        margin-bottom: 16px;
        gap: 8px;
    }

    .section-title i {
        font-size: 16px;
    }

    /* Form Grid - Single column on mobile */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* Form Group - Tighter spacing */
    .form-group {
        gap: 6px;
    }

    .form-group label {
        font-size: 13px;
        gap: 6px;
    }

    .form-group label i {
        font-size: 12px;
    }

    .form-group input,
    .form-group select {
        padding: 12px 14px;
        font-size: 14px;
        border-radius: 10px;
        border-width: 1.5px;
    }

    .form-group select {
        padding-right: 36px;
        background-size: 18px;
        background-position: right 10px center;
    }

    .flatpickr-input {
        background-size: 18px;
        background-position: right 10px center;
        padding-right: 36px;
    }

    /* Form Actions - Full width buttons stacked */
    .form-actions {
        flex-direction: column-reverse;
        gap: 10px;
        margin-top: 20px;
        padding-top: 16px;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 14px;
        border-radius: 10px;
    }

    .clear-wrapper {
        width: 100%;
    }

    .clear-wrapper .btn-secondary {
        width: 100%;
    }

    /* Toast on mobile - Position above bottom nav */
    .submit-toast {
        position: fixed;
        top: auto;
        bottom: 90px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        padding: 12px 20px;
        border-radius: 10px;
        font-size: 14px;
        max-width: calc(100vw - 40px);
    }

    .submit-toast::after {
        display: none;
    }

    /* Quick Summary Cards - Horizontal scroll */
    .quick-summary {
        display: flex;
        gap: 12px;
        margin-top: 16px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .quick-summary::-webkit-scrollbar {
        height: 4px;
    }

    .quick-summary::-webkit-scrollbar-thumb {
        background: rgba(102, 126, 234, 0.3);
        border-radius: 2px;
    }

    .summary-card {
        min-width: 150px;
        max-width: 180px;
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: 14px;
        border-radius: 12px;
        gap: 10px;
    }

    .summary-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        font-size: 16px;
    }

    .summary-label {
        font-size: 11px;
    }

    .summary-value {
        font-size: 16px;
    }

    /* ==================== TABLE VIEW MOBILE ==================== */

    /* Table Header */
    .table-header {
        gap: 12px;
        margin-bottom: 12px;
    }

    .table-controls {
        width: 100%;
        gap: 10px;
    }

    /* Table controls - row layout */
    .table-controls {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
    }

    /* Search wrapper - flexible width */
    .search-wrapper {
        flex: 1;
        min-width: 0;
    }

    .search-wrapper input {
        width: 100%;
        padding: 10px 32px 10px 36px;
        font-size: 13px;
        border-radius: 10px;
    }

    .search-wrapper i {
        font-size: 13px;
        left: 12px;
    }

    /* Clear filters button - compact icon only */
    .btn-clear-filters {
        width: auto;
        min-width: 44px;
        height: 42px;
        padding: 0 12px;
        font-size: 14px;
        border-radius: 10px;
        flex-shrink: 0;
    }

    .btn-clear-filters span {
        display: none;
    }

    /* Compact table info */
    .table-info {
        font-size: 11px;
        color: #667eea;
        font-weight: 600;
        white-space: nowrap;
        flex-shrink: 0;
        padding: 4px 8px;
        background: rgba(102, 126, 234, 0.1);
        border-radius: 6px;
    }

    /* Hide full text, show compact on mobile */
    .table-info .table-info-full {
        display: none;
    }

    .table-info .table-info-compact {
        display: inline;
    }

    /* Filter Row - Compact 2-column grid */
    .filter-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    .filter-group {
        min-width: 0;
        gap: 4px;
    }

    .filter-group label {
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    .filter-group select {
        padding: 10px 28px 10px 10px;
        font-size: 12px;
        border-radius: 8px;
        background-size: 14px;
        background-position: right 6px center;
    }

    /* Table Container - Card-style rows */
    .table-container {
        max-height: calc(100vh - 380px);
        border-radius: 10px;
        border: none;
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th {
        padding: 12px 10px;
        font-size: 12px;
    }

    .data-table td {
        padding: 10px 8px;
        font-size: 12px;
    }

    /* Category & Payer badges smaller */
    .category-badge,
    .payer-badge {
        padding: 3px 8px;
        font-size: 10px;
        border-radius: 12px;
    }

    /* Details cell on mobile */
    .details-cell {
        position: relative;
        max-width: none !important;
        overflow: visible !important;
        text-overflow: unset !important;
        white-space: normal !important;
        word-break: break-word;
        overflow-wrap: anywhere;
        padding-right: 72px;
        /* reserve space for action buttons on the right */
    }

    /* Row actions - floating overlay on mobile */
    .row-actions {
        position: absolute;
        right: -8px;
        top: 50%;
        transform: translateY(-50%);
        opacity: 0;
        visibility: hidden;
        display: flex;
        gap: 6px;
        background: rgba(255, 255, 255, 0.98);
        padding: 6px 10px;
        border-radius: 8px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
        z-index: 10;
        max-width: auto;
        padding: 4px 6px;
    }

    /* Show actions with CSS animation auto-hide (iOS compatible) */
    .transaction-row.show-actions .row-actions {
        animation: showThenHide 1.5s ease-out forwards;
        -webkit-animation: showThenHide 1.5s ease-out forwards;
    }

    @keyframes showThenHide {
        0% {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        70% {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        100% {
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
        }
    }

    @-webkit-keyframes showThenHide {
        0% {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        70% {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        100% {
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
        }
    }

    /* Double-tap visual feedback */
    .transaction-row.tapped {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%);
    }

    /* Active state feedback for iOS (shows on first tap) */
    .transaction-row:active {
        background-color: rgba(102, 126, 234, 0.06);
    }

    .action-btn {
        width: 28px;
        height: 28px;
        font-size: 11px;
        border-radius: 6px;
    }

    /* Pagination - Simplified for mobile */
    .pagination {
        gap: 6px;
        margin-top: 14px;
        padding-top: 12px;
        flex-wrap: nowrap;
        justify-content: space-between;
    }

    .page-btn {
        padding: 8px 10px;
        font-size: 12px;
        border-radius: 6px;
        flex: 1;
        text-align: center;
        max-width: 70px;
    }

    /* Hide First/Last on very small screens */
    .page-btn:first-child,
    .page-btn:last-child {
        display: none;
    }

    .page-info {
        font-size: 12px;
        padding: 0 6px;
        white-space: nowrap;
    }

    /* ==================== MODALS MOBILE ==================== */

    .modal-dialog {
        padding: 24px 20px;
        margin: 16px;
        border-radius: 16px;
        max-width: calc(100vw - 32px);
    }

    .delete-modal {
        width: 100%;
    }

    .edit-modal {
        width: 100%;
    }

    .modal-icon {
        width: 52px;
        height: 52px;
        font-size: 22px;
        margin-bottom: 16px;
    }

    .modal-title {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .modal-message {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .modal-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 14px;
    }

    /* Edit form on mobile */
    .edit-form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .edit-form-group label {
        font-size: 0.8rem;
    }

    .edit-form-group input,
    .edit-form-group select {
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    .modal-header {
        gap: 12px;
        margin-bottom: 18px;
        padding-bottom: 12px;
    }

    .modal-header .modal-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .modal-close {
        width: 32px;
        height: 32px;
    }

    /* ==================== DASHBOARD MOBILE ==================== */

    .dashboard-section-clean {
        height: calc(100vh - 90px);
        padding: 0;
    }

    .dashboard-container-full {
        border-radius: 10px;
    }

    /* Session warning mobile - position above bottom nav */
    .session-warning {
        top: auto;
        bottom: 90px;
        right: 16px;
        left: 16px;
        padding: 14px 18px;
        border-radius: 10px;
        font-size: 13px;
    }

    /* Toast position above bottom nav */
    .submit-toast {
        bottom: 90px;
    }
}

/* ========================================
   EXTRA SMALL MOBILE (=480px)
   Further optimizations for small phones
   ======================================== */
@media (max-width: 480px) {
    .container {
        padding: 12px 10px calc(85px + env(safe-area-inset-bottom, 0px));
    }

    .section-summary {
        padding: 16px 14px;
        border-radius: 12px;
    }

    .section-title {
        font-size: 16px;
        margin-bottom: 14px;
    }

    .form-grid {
        gap: 12px;
    }

    .form-group input,
    .form-group select {
        padding: 11px 12px;
        font-size: 14px;
    }

    /* Summary cards - full width stacked */
    .quick-summary {
        flex-direction: column;
        overflow-x: visible;
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
    }

    .summary-card {
        min-width: 100%;
        max-width: 100%;
        flex-direction: row;
        align-items: center;
    }

    .summary-info {
        flex: 1;
    }

    /* Filter row - Single column */
    .filter-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
    }

    /* Table - Hide less important columns (Day) on small screens */
    .data-table th:nth-child(6),
    .data-table td:nth-child(6) {
        display: none;
    }

    /* Details column - allow overflow for action buttons */
    .details-cell {
        position: relative;
        overflow: visible;
    }

    .table-container {
        max-height: calc(100vh - 350px);
    }

    /* Pagination - Show only prev/next */
    .page-btn:first-child,
    .page-btn:last-child {
        display: none;
    }

    .pagination {
        justify-content: center;
        gap: 8px;
    }

    .page-btn {
        max-width: 80px;
    }

    /* Modal adjustments */
    .modal-dialog {
        padding: 20px 16px;
        margin: 12px;
    }

    /* Bottom nav - slightly smaller on very small screens */
    .bottom-nav {
        height: 65px;
        padding: 6px 0;
    }

    .bottom-nav-icon i {
        font-size: 16px;
    }

    .bottom-nav-label {
        font-size: 10px;
    }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .form-group input,
    .form-group select {
        min-height: 48px;
    }

    .btn-primary,
    .btn-secondary,
    .modal-btn {
        min-height: 48px;
    }

    .filter-group select {
        min-height: 44px;
    }

    .page-btn {
        min-height: 40px;
    }

    .action-btn {
        min-width: 36px;
        min-height: 36px;
    }

    /* iOS tap highlight customization */
    .transaction-row {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.15);
    }

    /* Remove hover effects that don't work on touch */
    .summary-card:hover {
        transform: none;
    }

    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
    }

    /* Double-tap hint text for mobile users */
    .table-container::before {
        /* Use backhand index pointing up (tap) emoji via Unicode escape */
        content: '\01F446\00A0 Double-tap a row to edit/delete';
        display: block;
        width: 100%;
        box-sizing: border-box;
        text-align: center;
        font-size: 11px;
        color: #667eea;
        padding: 6px 12px;
        background: rgba(102, 126, 234, 0.08);
        border-radius: 6px 6px 0 0;
        margin-bottom: -1px;
    }
}

/* Plotly container tweaks: hide the modebar and add spacing so header doesn't overlap */
.weekday-plot-container .modebar,
.weekday-plot-container .modebar-container,
.weekday-plot-container .modebar-btn {
    display: none !important;
}
.weekday-plot-container .plotly {
    padding-top: 8px !important;
}