@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --color-bg: #f8fafc;
    --color-card: rgba(255, 255, 255, 0.4);
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-primary-glow: rgba(99, 102, 241, 0.5);

    --color-success: #10b981;
    --color-success-glow: rgba(16, 185, 129, 0.4);

    --color-danger: #f43f5e;
    --color-danger-glow: rgba(244, 63, 94, 0.4);

    --color-warning: #f59e0b;
    --color-text: #0f172a;
    --color-text-light: #64748b;
    --color-border: rgba(255, 255, 255, 0.3);
    --color-input-bg: rgba(255, 255, 255, 0.5);

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-neon: 0 0 20px var(--color-primary-glow);

    --radius: 24px;
    --radius-sm: 14px;
    --sidebar-width: 280px;
    --navbar-height: 70px;

    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-blur: blur(20px);
    --transition-base: all 0.2s ease, transform 0.2s ease;
}

[data-theme="dark"] {
    --color-bg: #050810;
    --color-card: rgba(15, 23, 42, 0.3);
    --color-text: #f1f5f9;
    --color-text-light: #94a3b8;
    --color-border: rgba(255, 255, 255, 0.08);
    --color-input-bg: rgba(15, 23, 42, 0.5);

    --glass-bg: rgba(15, 23, 42, 0.4);
    --glass-border: rgba(255, 255, 255, 0.05);
}

body {
    transition: none;
}

.theme-ready body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

@keyframes meshGradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}



body {
    box-sizing: border-box;
    /* Global safety for layout containment */
    font-family: 'Outfit', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(244, 63, 94, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(245, 158, 11, 0.1) 0px, transparent 50%);
    background-size: 200% 200%;
    background-attachment: fixed;
    background-attachment: fixed;
    animation: meshGradient 20s ease infinite;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

*,
*::before,
*::after {
    box-sizing: inherit;
    /* Ensure all elements use border-box */
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    left: 1rem;
    top: 6rem;
    /* Space for floating header + gap */
    bottom: 1rem;
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.sidebar-logo {
    padding: 0 2rem;
    margin-bottom: 1rem;
}

.sidebar-logo h1 {
    font-size: 2rem;
    color: var(--color-primary);
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logo p {
    font-size: 0.8rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: -5px;
}


/* Switch Toggle Style */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    /* Slightly narrower for better proportion */
    height: 24px;
    box-sizing: border-box;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    /* Better contrast in light mode */
    transition: .4s;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .slider {
    background-color: #334155;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    background-color: white;
    transition: .4s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

input:checked+.slider {
    background-color: var(--color-primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--color-primary);
}

input:checked+.slider:before {
    left: calc(100% - 20px);
    /* 18px width + 2px margin */
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}


.sidebar-nav {
    list-style: none;
    padding: 1rem;
}

.sidebar-nav li {
    margin-bottom: 0.4rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    transition: var(--transition-base);
    font-weight: 600;
    border-radius: var(--radius-sm);
    gap: 1rem;
}

.sidebar-nav a:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--color-primary);
}

.sidebar-nav a.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 0 20px var(--color-primary-glow), 0 10px 15px -3px var(--color-primary-glow);
}

.sidebar-nav a span {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
}

.sidebar-footer {
    margin-top: auto;
    /* Push to bottom */
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Theme Switch in Sidebar */
.sidebar-theme-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--color-text);
}

/* Main Content */
.main-content {
    margin-left: calc(var(--sidebar-width) + 2rem);
    padding: 2rem;
    padding-top: 6.5rem;
    /* Space for floating header */
    min-height: 100vh;
    background: var(--color-bg);
    transition: all 0.3s ease;
}

/* Page Header & Welcome Section */
.welcome-section {
    margin-bottom: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .welcome-section {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-end;
    }
}

.welcome-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-greeting h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.user-greeting h3 span {
    color: var(--color-primary);
}

.user-greeting p {
    color: var(--color-text-light);
    font-size: 1rem;
}

/* Redesigned Period Navigator */
.period-navigator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--color-card);
    backdrop-filter: var(--glass-blur);
    padding: 0.6rem;
    border-radius: 100px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--glass-border);
}

.period-navigator .nav-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    text-decoration: none;
    transition: var(--transition-base);
}

.period-navigator .nav-btn:hover {
    background: var(--color-primary);
    color: white;
}

.period-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1.25rem;
    min-width: auto;
    /* More flexible for mobile */
}

.period-dates {
    font-weight: 800;
    font-size: 1rem;
    white-space: nowrap;
    color: var(--color-text);
}

.today-link {
    font-size: 0.75rem;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    margin-top: -2px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--color-primary-glow);
}

.fab-btn {
    display: none;
    /* Removed standalone FAB, integrated in nav bar */
}

/* Modern Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 20px;
}

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

/* Accounts Scroll Row (Mobile) */
@media (max-width: 768px) {
    .accounts-scroll-container {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding: 0 1.5rem 1.5rem 1.5rem;
        margin: 0 -1.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .accounts-scroll-container::-webkit-scrollbar {
        display: none;
    }

    .accounts-scroll-container .account-mini-card {
        flex: 0 0 75%;
        scroll-snap-align: start;
        background: var(--color-card);
        border: 1px solid var(--glass-border);
        box-shadow: var(--shadow-sm);
        padding: 1rem !important;
        margin-right: 1.25rem;
        /* Explicit reliable spacing */
        min-width: 260px !important;
    }

    .accounts-scroll-container .account-mini-card:last-child {
        margin-right: 0;
    }

    .accounts-scroll-container .account-card-header {
        font-size: 0.95rem !important;
        /* Larger text for readability */
        margin-bottom: 0.25rem !important;
    }

    .accounts-scroll-container .balance-value {
        font-size: 1.35rem !important;
        /* Larger balance value */
    }
}

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

    .mobile-carousel {
        display: flex;
        align-items: stretch;
        /* Cards will have the same height */
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 1rem;
        gap: 1rem;
        padding-top: 0.5rem;
        padding-bottom: 2rem;
        margin: 0 -1.5rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-carousel>.card {
        display: flex;
        flex-direction: column;
        height: auto;
        margin-bottom: 0 !important;
        padding: 1rem !important;
        /* Compact padding */
    }

    /* Compact vertical distribution */
    .mobile-carousel .accounts-grid,
    .mobile-carousel .table-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        /* Removed empty centering space */
    }

    .mobile-carousel::-webkit-scrollbar {
        display: none;
    }

    .mobile-carousel>* {
        scroll-snap-align: start;
        flex: 0 0 85%;
        margin-bottom: 0 !important;
    }

    /* Small adjustment for inner grids in carousel */
    .mobile-carousel .form-grid {
        grid-template-columns: 1fr !important;
    }

    .consolidated-sections {
        margin: 0 -1rem !important;
        padding-bottom: 2rem !important;
    }
}

/* Account Cards Refinement */
.account-mini-card {
    min-width: 280px;
    background: var(--color-card);
    transition: var(--transition-base);
}

.account-card-header {
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.account-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.account-card-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.balance-main {
    flex: 1;
}

.balance-label {
    font-size: 0.75rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.balance-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
}

.credit-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 1rem;
    border-left: 1px solid var(--color-border);
    min-width: 120px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 600;
}

.detail-item .label {
    color: var(--color-text-light);
    margin-right: 0.5rem;
}

.detail-item.danger .value {
    color: var(--color-danger);
}

.detail-item.success .value {
    color: var(--color-success);
}

/* Accounts Grid and Carousel Grouping */
.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

@media (max-width: 768px) {
    .accounts-group-card {
        padding: 1.25rem !important;
    }

    .accounts-grid {
        display: flex;
        flex-direction: column;
        gap: 0.4rem !important;
    }

    .accounts-grid .account-mini-card {
        min-width: 100% !important;
        background: var(--color-bg) !important;
        margin-bottom: 0 !important;
        box-shadow: none !important;
        padding: 0.4rem 0.6rem !important;
    }

    .account-card-header {
        margin-bottom: 0.1rem !important;
        font-size: 0.75rem !important;
    }

    .balance-value {
        font-size: 1.15rem !important;
        line-height: 1.2 !important;
        margin-top: -0.2rem !important;
    }

    .balance-label {
        font-size: 0.6rem !important;
        margin-bottom: 0 !important;
    }

    .top-bar {
        position: fixed;
        top: 0.75rem !important;
        left: 0.75rem !important;
        right: 0.75rem !important;
        height: 3.5rem !important;
        width: auto !important;
        z-index: 1001;
        border-radius: 12px;
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem;
        /* Standardized side padding */
        padding-top: 7.5rem !important;
        /* Balanced gap from top bar */
        padding-bottom: 6rem;
        width: 100%;
        box-sizing: border-box;
    }
}

.account-mini-card {
    border: 1px solid var(--color-border);
    padding: 1.25rem;
    border-radius: var(--radius);
}

/* Account Grid on Desktop */
@media (min-width: 769px) {
    .account-carousel {
        display: flex;
        flex-wrap: wrap;
        gap: 1.5rem;
        overflow: visible;
        margin: 0;
        padding: 0;
    }

    .account-mini-card {
        flex: 1 1 calc(33.333% - 1.5rem) !important;
        min-width: 300px !important;
        max-width: 450px;
    }
}

@media (min-width: 769px) {
    .charts-grid.mobile-carousel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .consolidated-sections {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        margin-bottom: 1.5rem;
    }

    /* When as grid, remove individual card margins */
    .consolidated-sections>.card {
        margin-bottom: 0;
    }
}

/* Cards */
.card {
    background: var(--color-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition-base);
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    /* Reduced from 2rem */
    padding-bottom: 0 !important;
    border-bottom: none;
}

.card-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 20px 25px -5px var(--color-primary-glow);
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
    min-width: 0;
    /* Foundation for mobile scaling */
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.kpi-card.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 20px 25px -5px var(--color-success-glow);
}

.kpi-card.danger {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    box-shadow: 0 20px 25px -5px var(--color-danger-glow);
}


.kpi-label {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.kpi-subtitle {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    position: relative;
    height: 280px;
    /* Reduced from 350px to minimize empty vertical space on mobile */
    width: 100%;
    max-width: 100%;
}

@media (min-width: 769px) {
    .chart-container {
        height: 520px;
        /* Increased for maximum label space */
    }
}

/* Forms */
/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

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

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

.transfer-options-group {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    display: none;
    /* Defaults to hidden */
}

.commission-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.commission-input-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    display: none;
    animation: slideDown 0.2s ease;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    transition: opacity 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 14px 0 var(--color-primary-glow);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-success {
    background: var(--color-success);
    color: white;
    box-shadow: 0 4px 14px 0 var(--color-success-glow);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    box-shadow: 0 4px 14px 0 var(--color-danger-glow);
}

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

/* Tables */
.table-container {
    overflow-x: auto;
}

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

table th,
table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

table th {
    background: rgba(99, 102, 241, 0.03);
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    padding: 1rem;
}

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

table tr {
    transition: var(--transition-base);
}

table tr:hover {
    background: rgba(99, 102, 241, 0.02);
}

.amount-positive {
    color: var(--color-success);
    font-weight: 600;
}

.amount-negative {
    color: var(--color-danger);
    font-weight: 600;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #e0f2fe;
    color: #075985;
}

/* Account Color Dot */
.account-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-text);
}

.pagination a:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

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

/* Mobile Navigation */
.mobile-nav {
    display: none;
}

/* ... existing styles ... */

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    background: #ffffff;
    width: 100%;
    max-width: 900px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin: 1.5rem;
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    /* Prevent modal from being taller than viewport */
}



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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--color-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-light);
    transition: color 0.2s;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    /* Enable scrolling if content is too long */
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: #f8fafc;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Picker Dropdown Styles */
.picker-dropdown {
    position: relative;
    width: 100%;
}

.picker-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem;
    background: white;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-base);
    font-size: 0.95rem;
}

.picker-toggle:hover {
    border-color: var(--color-primary);
}

.picker-preview {
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--color-bg-alt);
}

/* Emoji Popover */
.emoji-popover {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 3000;
    margin-top: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    /* Adjust for mobile */
    max-width: 90vw;
}

emoji-picker {
    --num-columns: 8;
    --emoji-size: 1.5rem;
    --background: var(--color-card);
    --border-color: var(--color-border);
    --input-border-color: var(--color-border);
    --input-font-color: var(--color-text);
    --outline-color: var(--color-primary);
    width: 350px;
    height: 400px;
}

@media (max-width: 480px) {
    emoji-picker {
        width: 300px;
        height: 350px;
        --num-columns: 6;
    }
}

.color-picker-grid {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    margin-top: 0.5rem;
    display: none;
    /* Controlled by JS via .open class logic in script.js which might need update for consistency or keep separate */
}

.picker-dropdown.open .color-picker-grid {
    display: grid;
}

/* Modal Dark Mode Fixes */
[data-theme="dark"] .modal-content {
    background: var(--color-card);
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .modal-footer {
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
    /* Or darker shade */
}

/* Ensure Textarea and Inputs are readable */
textarea {
    background-color: var(--color-input-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.modal-footer {
    border-top: 1px solid var(--color-border);
    background-color: var(--color-bg);
    /* Default light */
}

.picker-dropdown.open .picker-grid {
    display: grid;
}

/* Modifiche ai vecchi stili picker per adattarli al dropdown */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
}



.color-option.selected {
    border-color: var(--color-text);
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
}

.emoji-option {
    font-size: 1.5rem;
    cursor: pointer;
    text-align: center;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.emoji-option:hover {
    background: #f1f5f9;
}

.emoji-option.selected {
    background: #e2e8f0;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }

    .picker-grid {
        position: fixed;
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        top: auto;
        width: auto;
        max-height: 40vh;
    }
}


/* Top Bar / Mobile Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    padding: 0 2rem;
    height: 4rem;
    border: 1px solid var(--glass-border);
    position: fixed;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    z-index: 1001;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

/* Floating header and sidebar are handled at the top of the file */

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.theme-toggle-group {
    display: flex;
    background: var(--color-bg);
    padding: 2px;
    border-radius: 100px;
    border: 1px solid var(--color-border);
    gap: 2px;
}

.theme-btn {
    background: transparent;
    border: none;
    padding: 6px 14px;
    cursor: pointer;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--color-text-light);
}

.theme-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 2px 4px var(--color-primary-glow);
}

.header-user-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--color-border);
}

.header-user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
}

.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.header-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    padding: 6px 12px !important;
}

.header-user a:hover {
    color: var(--color-primary);
    opacity: 1;
}

.desktop-only {
    display: block !important;
}

.mobile-only {
    display: none !important;
}

.mobile-header {
    display: flex;
}

/* Settings Sections (Details/Summary) - Global Style */
.settings-section {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: var(--transition-base);
}

.settings-section .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.settings-section label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    white-space: normal;
    line-height: 1.2;
}

.settings-section[open] {
    box-shadow: var(--shadow-md);
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.settings-appearance-card {
    display: flex;
    flex-direction: column;
}

.settings-section summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    list-style: none;
    transition: background-color 0.2s;
    position: relative;
}

.settings-section summary::-webkit-details-marker {
    display: none;
}

.settings-section summary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.settings-section summary::after {
    content: '+';
    margin-left: auto;
    font-weight: 300;
    font-size: 1.5rem;
    transition: transform 0.3s;
}

.settings-section[open] summary::after {
    transform: rotate(45deg);
}

.settings-content {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        margin: 0 !important;
        padding-left: 5px !important;
    }

    .sidebar {
        display: none;
    }

    .top-bar {
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
        height: 3.5rem;
        border-radius: 12px;
        margin: 0;
        z-index: 1001;
        box-shadow: var(--shadow-lg);
    }

    /* Duplicate main-content block removed for consolidation */

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    .mobile-theme-switch {
        display: block;
    }

    .mobile-theme-switch .switch {
        width: 44px;
        height: 24px;
    }

    .mobile-theme-switch .slider:before {
        height: 18px;
        width: 18px;
        left: 3px;
        bottom: 3px;
    }

    input:checked+.slider:before {
        left: 23px;
    }

    /* Redundant main-content block removed */

    .card {
        padding: 1rem;
        /* Further reduced to optimize content space */
        margin-bottom: 1rem;
    }

    .card-header {
        margin-bottom: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding-bottom: 0 !important;
    }

    .card-header .btn {
        width: 100%;
        text-align: center;
    }

    .kpi-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 1rem;
        padding: 1rem 1rem 3rem 1rem;
        /* Increased padding-bottom for shadows too */
        margin: 0 -1rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .kpi-grid::-webkit-scrollbar {
        display: none;
    }

    .kpi-card {
        flex: 0 0 85%;
        scroll-snap-align: center;
        margin-bottom: 0;
        padding: 1.25rem;
        /* Reduced padding for mobile */
    }



    .table-container {
        border: none;
        background: transparent;
        padding: 0;
        width: 100%;
        margin: 0;
        overflow-x: visible;
        /* Prevent inner scroll area on mobile cards */
    }

    table thead {
        display: none;
    }

    table,
    table tbody,
    table tr,
    table td {
        display: block;
        width: 100%;
    }

    table tr {
        background: var(--color-card);
        border-radius: var(--radius);
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--color-border);
        box-sizing: border-box;
        /* Crucial to keep padding inside 100% width */
    }

    table td {
        display: flex;
        flex-direction: column;
        /* Vertical stack to prevent horizontal overflow in carousel cards */
        align-items: flex-start;
        padding: 0.5rem 0 !important;
        border: none !important;
        text-align: left;
        gap: 0.15rem;
        font-size: 0.85rem;
        word-break: break-all;
        overflow-wrap: anywhere;
    }

    table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--color-text-light);
        text-align: left;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0.1rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        margin-bottom: 1.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-header h2 {
        font-size: 1.5rem;
    }

    .period-navigator {
        width: 100%;
        justify-content: space-between;
        font-size: 0.8rem;
        gap: 0.25rem;
        padding: 0.5rem;
    }

    .period-navigator .nav-btn {
        width: 36px;
        height: 36px;
    }

    .period-display {
        padding: 0 0.5rem;
    }

    .kpi-value {
        font-size: 1.75rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    /* Stacking settings buttons on mobile */
    .settings-section form {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    .settings-section form .btn {
        width: 100%;
    }

    .mobile-nav {
        display: block;
        position: fixed;
        bottom: 1.25rem;
        left: 1.25rem;
        right: 1.25rem;
        background: var(--glass-bg);
        backdrop-filter: var(--glass-blur);
        border: 1px solid var(--glass-border);
        padding: 0.25rem 0.5rem;
        z-index: 999;
        box-shadow: var(--shadow-lg);
        border-radius: 100px;
    }

    .mobile-nav-list {
        display: flex;
        justify-content: space-around;
        align-items: center;
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-nav-list li {
        flex: 1;
        text-align: center;
    }

    .nav-fab-item {
        flex: 0 0 60px !important;
        position: relative;
        top: -15px;
    }

    .nav-fab-link {
        width: 62px;
        height: 62px;
        background: var(--color-primary);
        color: white !important;
        border-radius: 50%;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 2.2rem !important;
        font-weight: 200;
        box-shadow: 0 10px 25px var(--color-primary-glow);
        text-decoration: none;
        margin: 0 auto;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -75%);
        z-index: 1010;
        border: 4px solid var(--color-card);
        /* Cut-out effect matching nav row */
    }

    /* Custom Vertical Legend for Mobile */
    .custom-legend {
        display: flex;
        flex-direction: column;
        gap: 0.6rem;
        /* Tightened gap */
        margin-top: 1.25rem;
        /* Reduced margin */
        padding: 0 0.5rem;
        border-top: 1px solid var(--glass-border);
        padding-top: 1rem;
    }

    .legend-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        font-size: 1rem;
        font-weight: 500;
    }

    .legend-color {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .legend-label {
        flex: 1;
        color: var(--color-text-light);
    }

    .legend-value {
        font-weight: 700;
        color: var(--color-text);
    }

    .mobile-nav-list a {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: var(--color-text-light);
        font-size: 0.7rem;
        padding: 0.4rem;
        border-radius: 12px;
    }

    .mobile-nav-list a.active {
        color: var(--color-primary);
    }

    .mobile-nav-list a span {
        font-size: 1.25rem;
        margin-bottom: 0.1rem;
    }

    .mobile-menu-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-menu-list li {
        border-bottom: 1px solid var(--color-border);
    }

    .mobile-menu-list li:last-child {
        border-bottom: none;
    }

    .mobile-menu-list a {
        display: flex;
        align-items: center;
        padding: 1rem 1.5rem;
        color: var(--color-text);
        text-decoration: none;
        font-weight: 500;
        font-size: 1rem;
    }

    .mobile-menu-list a span {
        margin-right: 1rem;
        font-size: 1.25rem;
    }

    .mobile-menu-list a:active {
        background-color: var(--color-bg);
    }
}

/* Extra Small Screens */
@media (max-width: 480px) {
    .main-content {
        padding: 1.5rem;
        padding-top: 7.5rem !important;
        padding-bottom: 6rem;
    }

    .card {
        padding: 0.75rem;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .page-header h2 {
        font-size: 1.25rem;
    }

    .badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .action-buttons {
        gap: 0.25rem;
    }
}

/* Radio Card Style for Forms */
.radio-card {
    position: relative;
    cursor: pointer;
}

.radio-card input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-card .radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition-base);
    color: var(--color-text);
}

.radio-card input:checked+.radio-label {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

.radio-card:hover .radio-label {
    background: rgba(255, 255, 255, 0.1);
}

/* Period Navigator */
.period-navigator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-card);
    padding: 0.75rem 1rem;
    border-radius: 100px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    margin-bottom: 2rem;
    max-width: 400px;
    margin-inline: auto;
}

/* Round Up Card */
/* Round Up Widgets */
/* Round Up Container - Uses Grid for stable columns */
/* Round Up Container - Forced 2 columns on desktop */
/* --- ROUND UP SECTION - STRICT GRID SYSTEM --- */

/* Main Container: Always 2 equal columns when active */
/* Main Container: Equal width columns to maximize space */
#round-up-container {
    display: none;
    /* Managed by JS */
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Maximize width for both */
    gap: 0.5rem;
    /* Reduced gap to allow more width */
    margin-bottom: 1.5rem;
    width: 100%;
}

/* Base Widget Style */
.round-up-widget {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    border: 1px solid var(--color-primary-glow);
    border-radius: 12px;
    padding: 0.75rem;
    height: 88px;
    /* Fixed height requested by user */
    box-sizing: border-box;
}

/* Disabled State for Target Widget */
.round-up-widget.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.2);
    border-style: dashed;
    border-color: var(--color-border);
    background: var(--color-bg);
    /* Reset gradient to flat when disabled */
}

/* TOGGLE WIDGET: STRICT 3-COLUMN GRID */
/* Col 1: Icon (Fixed) | Col 2: Text (Flexible) | Col 3: Switch (Fixed) */
.toggle-widget {
    display: flex;
    grid-template-columns: 40px 1fr 50px;
    align-items: center;
    gap: 0.5rem;
}

/* Icon */
.round-up-icon {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    justify-self: center;
    /* Center in grid cell */
}

/* Info Text */
.round-up-info {
    min-width: 0;
    /* Crucial for text-overflow to work in Grid/Flex */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.round-up-info h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.round-up-info p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--color-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toggle Switch Container - Fixed Size */
.switch {
    position: relative;
    appearance: none;
    outline: none;
    width: 44px;
    height: 24px;
    margin: 0;
    padding: 0;
    justify-self: center;
    /* Center in grid cell */
    cursor: pointer;
    flex-shrink: 0;
    display: block;
    /* Ensure block model */
}

/* Hide Checkbox */
.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Track */
.slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    border-radius: 24px;
    transition: 0.3s;
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .slider {
    background-color: #334155;
}

/* Knob */
.slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    /* (24 - 18 - 2*border) / 2 approx 2 */
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Checked State */
input:checked+.slider {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

input:checked+.slider:before {
    /*transform: translateX(20px);*/
    /* 44 - 4 (margins) - 18 (width) - 2 (space) = 20? 2+20=22. Left 22. +Width 18 = 40. +Right 2 = 42. Border? */
    /* Exact calc: Width 44. Padding 2? Left 2.
       OFF: Left 2. Right 24.
       ON: Left 24. Right 2.
       Translate: 22px.
    */
    /*transform: translateX(20px);*/
}

/* TARGET WIDGET */
.target-widget {
    background: var(--color-bg);
    border: 1px dashed var(--color-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 250%;
}

.target-widget label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--color-text-light);
}

.round-up-widget select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background-color: var(--color-input-bg);
    color: var(--color-text);
}

.round-up-widget select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Mobile Stack */
@media (max-width: 768px) {
    #round-up-container {
        grid-template-columns: 1fr;
    }
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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

@media (max-width: 768px) {
    #round-up-container {
        grid-template-columns: 1fr;
        /* Stack on mobile */
    }
}

/* Animations */
.fade-element {
    transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
    opacity: 1;
    transform: translateY(0);
    max-height: 500px;
    /* Arbitrary large max-height */
    overflow: hidden;
}

.fade-element.hidden {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    pointer-events: none;
}

/* Widgets Grid */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.widget-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
}

.widget-card.active {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.02);
    box-shadow: var(--shadow-sm);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.widget-info {
    display: flex;
    align-items: center;
}

.widget-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
    background: var(--color-input-bg);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.widget-title h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
}

.widget-title p {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin: 0;
}

.widget-content {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

/* Collapsible Picker */
.picker-container {
    position: relative;
    width: 100%;
}

.picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--color-bg);
    transition: var(--transition-base);
}

.picker-trigger:hover {
    border-color: var(--color-primary);
}

.picker-dropdown {
    display: none;
    margin-top: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg);
    position: absolute;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    width: 100%;
    left: 0;
}

.picker-dropdown.show {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
    gap: 0.5rem;
    animation: slideDown 0.2s ease;
}

/* Mark Paid Button (Small & Clean) */
.mark-paid-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: transparent;
    border: 1px solid var(--color-success);
    color: var(--color-success);
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-top: 4px;
}

.mark-paid-btn:hover {
    background-color: var(--color-success);
    color: white;
    box-shadow: 0 2px 5px var(--color-success-glow);
    transform: translateY(-1px);
}