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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    background-image: url('../branding/login-background.svg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: #fff;
}

/* Auth Loading Screen */
.auth-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.auth-loading.hidden {
    display: none;
}

.auth-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
}

.auth-loading-logo {
    width: 70px;
    height: 70px;
    animation: pulse 2s ease-in-out infinite;
}

.auth-loading-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00d9ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #4ecdc4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Top Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.back-link {
    color: #4ecdc4;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.back-link:hover {
    color: #fff;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo {
    width: 32px;
    height: 32px;
}

.nav-title {
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(90deg, #00d9ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
}

#userName {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Nav Right Section */
.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Language Selector */
.lang-selector {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 3px;
}

.lang-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.lang-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.lang-btn.active {
    background: #4ecdc4;
    color: #1a1a2e;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 2rem;
    background: linear-gradient(90deg, #00d9ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.month-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Material Design Inputs */
select, input[type="number"], input[type="text"], input[type="date"] {
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.23);
    border-radius: 4px;
    background: rgba(37, 37, 66, 0.9);
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    line-height: 1.5;
}

select:hover, input[type="number"]:hover, input[type="text"]:hover, input[type="date"]:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(45, 45, 75, 0.95);
}

select:focus, input:focus {
    outline: none;
    border-color: #00d9ff;
    box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.25);
    background: rgba(50, 50, 85, 1);
}

/* Material Design Select/Dropdown Styling */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2300d9ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 44px;
    cursor: pointer;
    min-height: 48px;
}

select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2300d9ff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

select option {
    background: #252542;
    color: #fff;
    padding: 14px 16px;
    min-height: 40px;
}

select option:hover, select option:focus, select option:checked {
    background: rgba(0, 217, 255, 0.15);
}

/* Material Design Date Input Wrapper */
.date-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 150px;
}

.date-input-wrapper input[type="date"] {
    width: 100%;
    padding-right: 44px;
    cursor: pointer;
    min-height: 48px;
}

.date-input-wrapper .date-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    stroke: #00d9ff;
    pointer-events: none;
    transition: stroke 0.2s ease;
}

.date-input-wrapper:hover .date-icon {
    stroke: #00ffcc;
}

.date-input-wrapper input[type="date"]:focus + .date-icon {
    stroke: #00ffcc;
}

/* Search Input Wrapper */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin: 16px 0;
}

.search-wrapper input {
    width: 100%;
    padding: 12px 44px 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-wrapper input:focus {
    outline: none;
    border-color: #00d9ff;
    background: rgba(0, 217, 255, 0.05);
}

.search-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-wrapper .search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    stroke: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    transition: stroke 0.2s ease;
}

.search-wrapper input:focus + .search-icon {
    stroke: #00d9ff;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Material Design specific styling for month/year selects */
.month-selector select {
    font-weight: 500;
    letter-spacing: 0.02em;
}

#yearSelect {
    min-width: 90px;
}

#monthSelect {
    min-width: 140px;
}

/* Material Design Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    position: relative;
    overflow: hidden;
    min-height: 40px;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn:active::after {
    width: 200px;
    height: 200px;
}

.btn-primary {
    background: #00d9ff;
    color: #1a1a2e;
    box-shadow: 0 2px 4px rgba(0, 217, 255, 0.3);
}

.btn-primary:hover {
    background: #00c4e6;
    box-shadow: 0 4px 8px rgba(0, 217, 255, 0.4);
}

.btn-success {
    background: #00ff88;
    color: #1a1a2e;
    box-shadow: 0 2px 4px rgba(0, 255, 136, 0.3);
}

.btn-success:hover {
    background: #00e67a;
    box-shadow: 0 4px 8px rgba(0, 255, 136, 0.4);
}

.btn-danger {
    background: #ff4757;
    color: #fff;
    box-shadow: 0 2px 4px rgba(255, 71, 87, 0.3);
}

.btn-danger:hover {
    background: #e63e4d;
    box-shadow: 0 4px 8px rgba(255, 71, 87, 0.4);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.tabs {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    border-bottom: 2px solid #3a3a5c;
    padding-bottom: 10px;
}

.tab {
    padding: 12px 24px;
    background: transparent;
    border: 2px solid #3a3a5c;
    border-radius: 8px;
    color: #888;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab.active {
    background: linear-gradient(90deg, #00d9ff, #0099cc);
    border-color: #00d9ff;
    color: #fff;
}

.tab:hover:not(.active) {
    border-color: #00d9ff;
    color: #00d9ff;
}

.tab-content {
    display: none;
}

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

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.card {
    background: rgba(37, 37, 66, 0.8);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #3a3a5c;
    backdrop-filter: blur(10px);
}

.card h2 {
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: #00d9ff;
}

.form-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.form-group input, .form-group select {
    flex: 1;
    min-width: 120px;
}

/* Form Grid Layout for better readability */
.form-group.form-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row input, .form-row select {
    flex: 1;
    min-width: 140px;
}

.form-row .input-amount {
    flex: 0.4;
    min-width: 100px;
}

.form-row .input-desc {
    flex: 1;
    min-width: 180px;
}

.list {
    max-height: 300px;
    overflow-y: auto;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: rgba(58, 58, 92, 0.5);
    border-radius: 8px;
    border-left: 4px solid #00d9ff;
}

.list-item.expense {
    border-left-color: #ff4757;
}

.list-item-info {
    flex: 1;
}

.list-item-amount {
    font-weight: 700;
    font-size: 1.1rem;
}

.list-item-desc {
    font-size: 0.9rem;
    color: #888;
}

.list-item-category {
    font-size: 0.8rem;
    color: #00ff88;
    margin-top: 4px;
}

.list-item-actions {
    display: flex;
    gap: 8px;
}

.list-item-actions button {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #3a3a5c;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: right;
}

.savings-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.savings-amount {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00ff88, #00cc6a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.savings-amount.negative {
    background: linear-gradient(90deg, #ff4757, #cc3344);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.savings-label {
    color: #888;
    margin-top: 10px;
}

.chart-card {
    min-height: 350px;
}

.chart-card canvas {
    max-height: 280px;
}

/* Gauge Styles */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.gauge {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: conic-gradient(#3a3a5c 0deg, #3a3a5c 360deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-fill {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(#00ff88 0deg, #00d9ff var(--progress, 0deg), #3a3a5c var(--progress, 0deg));
    transition: all 0.5s ease;
}

.gauge-center {
    position: relative;
    width: 150px;
    height: 150px;
    background: #252542;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.gauge-center span {
    font-size: 2rem;
    font-weight: 700;
    color: #00ff88;
}

.gauge-labels {
    font-size: 1.1rem;
    color: #888;
}

.gauge-labels span {
    color: #00ff88;
    font-weight: 600;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.kpi {
    text-align: center;
    padding: 20px;
    background: rgba(58, 58, 92, 0.3);
    border-radius: 12px;
    overflow: hidden;
    min-width: 0;
}

.kpi-value {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: 700;
    margin-bottom: 8px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.kpi:nth-child(1) .kpi-value {
    color: #00d9ff;
}

.kpi:nth-child(2) .kpi-value {
    color: #ff4757;
}

.kpi:nth-child(3) .kpi-value {
    color: #00ff88;
}

.kpi-label {
    color: #888;
    font-size: 0.9rem;
}

/* Category Management */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.category-item {
    background: rgba(58, 58, 92, 0.5);
    border-radius: 12px;
    padding: 16px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.category-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #00d9ff;
}

.subcategory-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.subcategory-tag {
    background: rgba(0, 217, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.subcategory-tag button {
    background: none;
    border: none;
    color: #ff4757;
    cursor: pointer;
    font-size: 1rem;
}

.add-subcategory {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.add-subcategory input {
    flex: 1;
    padding: 8px 12px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #252542;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #00d9ff;
}

.modal-content input, .modal-content select {
    width: 100%;
    margin-bottom: 15px;
}

.modal-content .date-input-wrapper.modal-date {
    width: 100%;
    margin-bottom: 15px;
}

.modal-content .date-input-wrapper.modal-date input {
    margin-bottom: 0;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

.close:hover {
    color: #ff4757;
}

.goal-display {
    margin-top: 15px;
    font-size: 1.2rem;
    color: #888;
}

.goal-display span:last-child {
    color: #00ff88;
    font-weight: 700;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: #00d9ff;
}

/* Savings Goals Grid */
.savings-goals-card {
    grid-column: span 2;
}

.savings-goals-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.savings-goal-item {
    background: rgba(58, 58, 92, 0.5);
    border-radius: 12px;
    padding: 20px;
}

.savings-goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.savings-goal-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #00d9ff;
}

.savings-goal-input {
    display: flex;
    gap: 5px;
}

.savings-goal-input input {
    width: 100px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Mini Gauge for subcategories */
.mini-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mini-gauge {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: conic-gradient(#3a3a5c 0deg, #3a3a5c 360deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-gauge-fill {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(#00ff88 0deg, #00d9ff var(--progress, 0deg), #3a3a5c var(--progress, 0deg));
    transition: all 0.5s ease;
}

.mini-gauge-center {
    position: relative;
    width: 70px;
    height: 70px;
    background: #252542;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.mini-gauge-center span {
    font-size: 1rem;
    font-weight: 700;
    color: #00ff88;
}

.savings-goal-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #888;
}

.savings-goal-stats span span {
    color: #00ff88;
    font-weight: 600;
}

/* Filtered expenses category */
.list-item.filtered {
    border-left-color: #ffa502;
}

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

/* Tablet and smaller */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .savings-goals-grid {
        grid-template-columns: 1fr;
    }

    .savings-goals-card {
        grid-column: span 1;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    /* Container */
    .container {
        padding: 12px;
    }

    /* Top Navigation - Stack on mobile */
    .top-nav {
        flex-direction: column;
        padding: 12px 16px;
        gap: 12px;
    }

    .nav-brand {
        width: 100%;
        justify-content: center;
    }

    .nav-right {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    .user-info {
        gap: 8px;
    }

    #userName {
        display: none; /* Hide username on mobile to save space */
    }

    .btn-logout {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Header */
    header {
        flex-direction: column;
        text-align: center;
        padding: 16px 0;
        gap: 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .month-selector {
        width: 100%;
        justify-content: center;
    }

    /* Tabs */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        padding: 10px 16px;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Cards */
    .card {
        padding: 16px;
        border-radius: 12px;
    }

    .card h2 {
        font-size: 1.1rem;
        margin-bottom: 16px;
    }

    /* Forms - Stack inputs vertically on mobile */
    .form-group {
        gap: 8px;
        margin-bottom: 16px;
    }

    .form-group input, .form-group select {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 8px;
    }

    .form-row input, .form-row select {
        min-width: 100%;
        width: 100%;
        flex: 1 1 100%;
    }

    .form-row .input-amount,
    .form-row .input-desc {
        flex: 1 1 100%;
        min-width: 100%;
    }

    /* Date input wrapper */
    .date-input-wrapper {
        width: 100%;
        min-width: 100%;
    }

    /* Add button wrapper - full width */
    .add-btn-wrapper {
        width: 100%;
    }

    .add-btn-wrapper button {
        width: 100%;
    }

    /* Search wrapper */
    .search-wrapper {
        margin: 12px 0;
    }

    .search-wrapper input {
        padding: 10px 40px 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Input sizes - prevent zoom on iOS */
    select, input[type="number"], input[type="text"], input[type="date"] {
        font-size: 16px;
        padding: 12px 14px;
        min-height: 44px; /* Touch-friendly height */
    }

    select {
        padding-right: 40px;
    }

    /* List items - Stack on mobile */
    .list {
        max-height: 250px;
    }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px;
    }

    .list-item-info {
        width: 100%;
    }

    .list-item-amount {
        font-size: 1.2rem;
    }

    .list-item-desc {
        font-size: 0.85rem;
        margin-top: 4px;
    }

    .list-item-category {
        font-size: 0.75rem;
    }

    .list-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .list-item-actions button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    /* Totals */
    .total {
        font-size: 1.1rem;
        margin-top: 12px;
        padding-top: 12px;
    }

    /* Savings card */
    .savings-amount {
        font-size: 2rem;
    }

    /* KPI Grid */
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kpi-card {
        padding: 16px;
    }

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

    /* Charts */
    .chart-card canvas {
        max-height: 200px;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-content h2 {
        font-size: 1.2rem;
    }

    .modal-content input,
    .modal-content select {
        width: 100%;
    }

    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }

    .modal-actions button {
        width: 100%;
    }

    /* Category management */
    .category-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .category-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Filtered expense list */
    .list-item.filtered {
        padding: 10px;
    }

    /* Language selector */
    .lang-selector {
        order: -1; /* Move to start on mobile */
    }

    .lang-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .top-nav {
        padding: 10px 12px;
    }

    .nav-title {
        font-size: 1rem;
    }

    header h1 {
        font-size: 1.3rem;
    }

    .card {
        padding: 14px;
        border-radius: 10px;
    }

    .card h2 {
        font-size: 1rem;
    }

    .tab {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .savings-amount {
        font-size: 1.8rem;
    }

    .list-item-amount {
        font-size: 1.1rem;
    }

    .btn, button {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* Ensure buttons are touch-friendly */
    .list-item-actions button {
        min-height: 40px;
        min-width: 60px;
    }
}

/* Savings Items - Visual Differentiation */
.list-item.savings-item {
    border-left-color: #00ff88;
    background: rgba(0, 255, 136, 0.1);
}

.list-item.savings-item .list-item-amount {
    color: #00ff88;
}

.list-item.savings-item .list-item-category {
    color: #00ff88;
}

/* Savings Category in Categories Management */
.category-item.savings-category {
    border: 2px solid #00ff88;
    background: rgba(0, 255, 136, 0.05);
}

.category-item.savings-category .category-name {
    color: #00ff88;
}

.category-protected {
    color: #00ff88;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 12px;
    background: rgba(0, 255, 136, 0.15);
    border-radius: 8px;
}

/* Icon Button Styles */
.btn-icon {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    position: relative;
}

.btn-icon svg {
    flex-shrink: 0;
}

.btn-icon:hover svg {
    transform: rotate(15deg);
    transition: transform 0.3s ease;
}

/* Add Button Wrapper for Animations */
.add-btn-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Rocket Animation for Savings */
.rocket-animation {
    position: absolute;
    width: 30px;
    height: 30px;
    pointer-events: none;
    opacity: 0;
    z-index: 100;
}

.rocket-animation.active {
    animation: rocketLaunch 1.2s ease-out forwards;
}

.rocket-animation::before {
    content: '🚀';
    font-size: 24px;
    position: absolute;
    transform: rotate(-45deg);
}

@keyframes rocketLaunch {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    20% {
        opacity: 1;
        transform: translate(5px, -10px) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(100px, -150px) scale(0.5);
    }
}

/* Satellite Animation for Income */
.satellite-animation {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
    opacity: 0;
    z-index: 100;
}

.satellite-animation.active {
    animation: satelliteOrbit 1.5s ease-in-out forwards;
}

.satellite-animation::before {
    content: '🛰️';
    font-size: 20px;
    position: absolute;
}

@keyframes satelliteOrbit {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        opacity: 1;
        transform: translate(30px, -20px) rotate(90deg);
    }
    50% {
        opacity: 1;
        transform: translate(50px, 10px) rotate(180deg);
    }
    75% {
        opacity: 1;
        transform: translate(30px, 30px) rotate(270deg);
    }
    100% {
        opacity: 0;
        transform: translate(0, 0) rotate(360deg) scale(0.3);
    }
}

/* Tooltip Enhancement */
[title] {
    position: relative;
}

.btn-icon[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    border: 1px solid #3a3a5c;
}

/* ===== HELP BUTTONS BAR ===== */
.help-bar {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    margin-bottom: 10px;
}

.help-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(0, 217, 255, 0.4);
    background: rgba(0, 217, 255, 0.1);
    color: #00d9ff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    /* Hidden by default */
    display: none;
}

/* Show only the visible help button */
.help-btn.visible {
    display: flex;
}

.help-btn:hover {
    background: rgba(0, 217, 255, 0.25);
    border-color: #00d9ff;
    transform: scale(1.1);
}

.help-btn.active {
    background: #00d9ff;
    color: #1a1a2e;
}

/* Help Popup */
.help-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(37, 37, 66, 0.98);
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    z-index: 2000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.help-popup.hidden {
    display: none;
}

.help-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.help-popup-close:hover {
    color: #ff4757;
}

.help-popup h4 {
    color: #00d9ff;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.help-popup p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Help popup overlay */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
}

.help-overlay.hidden {
    display: none;
}

/* ===== FLATPICKR CUSTOMIZATION ===== */
.flatpickr-calendar {
    background: #252542 !important;
    border: 1px solid rgba(0, 217, 255, 0.3) !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4) !important;
}

.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after {
    border-bottom-color: #252542 !important;
}

.flatpickr-months {
    background: rgba(0, 217, 255, 0.1);
    border-radius: 12px 12px 0 0;
}

.flatpickr-months .flatpickr-month {
    color: #fff !important;
    fill: #fff !important;
}

.flatpickr-current-month {
    color: #00d9ff !important;
    font-weight: 600;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: #252542;
    color: #fff;
    padding: 8px 4px !important;
    line-height: 1.8 !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months option {
    padding: 8px 12px !important;
    line-height: 1.8 !important;
}

.flatpickr-current-month input.cur-year {
    color: #00d9ff !important;
    padding: 4px 8px !important;
    line-height: 1.8 !important;
}

/* Increase height of month header */
.flatpickr-current-month {
    padding: 10px 0 !important;
    height: auto !important;
}

.flatpickr-months .flatpickr-month {
    height: 50px !important;
}

.flatpickr-weekdays {
    background: transparent !important;
}

.flatpickr-weekday {
    color: #00d9ff !important;
    font-weight: 600;
}

/* Days grid padding */
.flatpickr-days {
    padding: 10px 8px 16px 8px !important;
}

.dayContainer {
    padding: 4px 0 !important;
}

.flatpickr-day {
    color: #fff;
    border-radius: 8px;
    margin: 2px !important;
    height: 36px !important;
    line-height: 36px !important;
}

.flatpickr-day:hover {
    background: rgba(0, 217, 255, 0.2) !important;
    border-color: transparent !important;
}

.flatpickr-day.selected {
    background: #00d9ff !important;
    border-color: #00d9ff !important;
    color: #1a1a2e !important;
}

.flatpickr-day.today {
    border-color: #00ff88 !important;
}

.flatpickr-day.today:hover {
    background: rgba(0, 255, 136, 0.2) !important;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #666 !important;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    fill: #00d9ff !important;
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: #00ffcc !important;
}

/* ===== CHOICES.JS CUSTOMIZATION ===== */
.choices {
    margin-bottom: 0;
}

/* Specific width for year/month selects in header */
.month-selector .choices {
    min-width: 120px;
}

.month-selector .choices[data-type*="select-one"] .choices__inner {
    padding-right: 40px !important;
}

/* Year select - wider */
.month-selector .choices:first-of-type {
    min-width: 100px;
}

/* Month select - wider for long month names */
.month-selector .choices:nth-of-type(2) {
    min-width: 160px;
}

.choices__inner {
    background: rgba(37, 37, 66, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.23) !important;
    border-radius: 4px !important;
    min-height: 48px !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
}

.choices__inner:hover {
    border-color: rgba(255, 255, 255, 0.5) !important;
}

.choices.is-focused .choices__inner,
.choices.is-open .choices__inner {
    border-color: #00d9ff !important;
    box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.25) !important;
}

.choices__list--single {
    padding: 0 !important;
}

.choices__list--single .choices__item {
    color: #fff !important;
}

.choices__placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

.choices__list--dropdown {
    background: #252542 !important;
    border: 1px solid rgba(0, 217, 255, 0.3) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
    margin-top: 4px !important;
    min-width: 100% !important;
    width: auto !important;
}

/* Ensure dropdown is wide enough for month names */
.month-selector .choices__list--dropdown {
    min-width: 160px !important;
}

.choices__list--dropdown .choices__item {
    color: #fff !important;
    padding: 12px 16px !important;
    white-space: nowrap !important;
}

.choices__list--dropdown .choices__item--selectable.is-highlighted {
    background: rgba(0, 217, 255, 0.2) !important;
}

.choices__list--dropdown .choices__item--selectable.is-selected {
    background: rgba(0, 217, 255, 0.3) !important;
}

.choices[data-type*="select-one"]::after {
    border-color: #00d9ff transparent transparent transparent !important;
    right: 16px !important;
}

.choices[data-type*="select-one"].is-open::after {
    border-color: transparent transparent #00d9ff transparent !important;
}

/* Fix for date input with flatpickr */
.date-input-wrapper input.flatpickr-input {
    background: rgba(37, 37, 66, 0.9);
}

.date-input-wrapper .date-icon {
    z-index: 1;
}
