:root {
    /* Modern & Clean Palette */
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary-color: #8b5cf6;
    /* Violet 500 */
    --accent-color: #06b6d4;
    /* Cyan 500 */
    --success-color: #10b981;
    /* Emerald 500 */
    --danger-color: #ef4444;
    /* Red 500 */

    /* Backgrounds */
    --background-dark: #0f172a;
    /* Slate 900 */
    --glass-bg: rgba(30, 41, 59, 0.7);
    /* Slate 800 with opacity */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.05);

    /* Text */
    --text-light: #f8fafc;
    /* Slate 50 */
    --text-dim: #94a3b8;
    /* Slate 400 */

    /* Shadows */
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

html {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    width: 100%;
    max-width: 100vw;
    min-height: 100%;
    margin: 0;
    padding: 2rem;
    overflow-x: hidden !important;
    position: relative;
    background-color: var(--background-dark);
    color: var(--text-light);
    line-height: 1.6;
}



/* --- Dynamic Background --- */
.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.background-shapes .shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.25;
    /* Reduced opacity for cleaner look */
    animation: float 15s ease-in-out infinite;
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: var(--primary-color);
}

.shape-2 {
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: var(--secondary-color);
    animation-delay: -5s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20px, -20px);
    }
}

/* --- Container --- */
.container {
    width: 100%;
    max-width: 1200px;
    z-index: 1;
    animation: fadeIn 0.6s ease-out;
    margin: 0 auto 2rem auto;
    /* Center and ensure bottom spacing */
}

header {
    text-align: center;
    margin-bottom: 3rem;
    width: 100%;
}

@media (max-width: 600px) {
    header .btn-primary {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    header>div {
        flex-wrap: wrap;
    }
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #fff, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-dim);
    font-size: 1.1rem;
}

/* --- Dashboard Cards --- */
/* ... (previous styles) ... */

@media (max-width: 480px) {
    body {
        padding: 1rem 0.75rem;
    }

    .glass-panel {
        padding: 1.25rem;
        border-radius: 20px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 1.25rem;
        border-radius: 20px;
    }

    .card p {
        font-size: 1.75rem;
    }

    /* Fixed: Ensure forms and inputs don't cause overflow */
    .form-group input,
    .form-group select,
    .btn-primary,
    button {
        max-width: 100%;
    }

    .dashboard {
        grid-template-columns: 1fr;
        /* Stack cards on very small screens */
        gap: 1rem;
    }
}

/* --- Dashboard Cards --- */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.card {
    padding: 2rem;
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    color: white;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.card.income-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 95, 70, 0.4));
    border-color: rgba(16, 185, 129, 0.3);
}

.card.expense-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(153, 27, 27, 0.4));
    border-color: rgba(239, 68, 68, 0.3);
}

.card.balance-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(67, 56, 202, 0.4));
    border-color: rgba(99, 102, 241, 0.3);
}


.card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.card p {
    font-size: 2.25rem;
    font-weight: 700;
}

.card .icon {
    position: absolute;
    right: 1.5rem;
    bottom: 1.5rem;
    font-size: 3rem;
    opacity: 0.2;
    transform: rotate(-10deg);
}

/* FIXED: Text colors for cards should be white as requested */
.income-card p {
    color: #fff;
}

.expense-card p {
    color: #fff;
}

.balance-card p {
    color: #fff;
}

/* --- Glass Panel --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 2rem;
    position: relative;
    width: 100%;
    overflow: hidden;
    /* Prevent child overflow from breaking the panel */
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 960px) {
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* --- Headings --- */
h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

h2 i {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    padding: 10px;
    border-radius: 12px;
    font-size: 1rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-light);
    outline: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

/* --- Buttons --- */
.btn-primary,
button {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

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

/* --- List & History --- */
.list-container {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.5rem;
    overscroll-behavior: contain;
    /* Prevents scroll chaining/trapping issues */
}

.transaction-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transaction-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.25rem;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.transaction-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(2px);
}

.transaction-item .info h4 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.transaction-item .info .date {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.amount-action {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.transaction-item .amount {
    font-weight: 600;
    font-size: 1rem;
}

.transaction-item.income .amount {
    color: var(--success-color);
}

.transaction-item.expense .amount {
    color: var(--danger-color);
}

/* --- Utilities --- */
.icon-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    background: transparent !important;
    color: var(--text-dim) !important;
}

.icon-btn:hover {
    color: var(--danger-color) !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* --- Search & Filters --- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    align-items: center;
}

.search-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

/* Icon Position - Make sure it is inside input area visually */
.search-wrapper i {
    position: absolute;
    left: 1.2rem;
    color: var(--text-dim);
    pointer-events: none;
    transition: color 0.3s ease;
    z-index: 10;
    font-size: 0.9rem;
}

.search-wrapper input:focus+i,
.search-wrapper input:not(:placeholder-shown)+i {
    color: var(--primary-color);
}

/* Search Input Specifics */
.search-wrapper input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    /* Left padding for icon */
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-light);
    outline: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

/* Select Specifics */
.filters select {
    width: 140px;
    /* Bit wider */
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    /* Right padding for arrow */
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-light);
    outline: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    appearance: none;
    /* Custom simple arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.filters input:focus,
.filters select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.9);
}

.filters input::placeholder {
    color: var(--text-dim);
    opacity: 0.7;
}

/* --- Admin Panel Responsiveness --- */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding-bottom: 2rem;
}

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

    .header-stack {
        flex-direction: column;
        align-items: stretch !important;
        /* Full width buttons */
        gap: 1rem;
    }

    .header-stack>div {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem !important;
    }

    .header-stack h2 {
        font-size: 1.25rem;
        justify-content: center;
    }

    .admin-container {
        padding: 1rem !important;
    }

    /* Ensure stats grid is 1 col on very small screens */
    #admin-dashboard>div:first-child {
        grid-template-columns: 1fr !important;
    }

    /* Adjust Modal width */
    .modal .glass-panel {
        width: 90% !important;
        padding: 1.5rem !important;
    }
}

/* Ensure equal height for grid items */
.glass-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Push footer/content to bottom if needed, or just let it flow */
/* .glass-panel > div:last-child { margin-top: auto; } */

/* Chat Widget Mobile */
@media (max-width: 480px) {
    .chat-window {
        width: 90%;
        right: 5%;
        bottom: 90px;
        height: 60vh;
    }
}

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 450px;
    background: var(--background-dark);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.chat-window.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.chat-header {
    background: var(--primary-color);
    padding: 15px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: rgba(30, 41, 59, 0.95);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-message.bot {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.chat-message.user {
    background: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-footer {
    padding: 10px;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    gap: 10px;
}

.chat-footer input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    padding: 10px;
    border-radius: 8px;
    color: white;
    outline: none;
}

.chat-footer button {
    width: auto;
    padding: 0 15px;
    border-radius: 8px;
}