:root {
    --bg-color: #f3f0eb;
    /* Warm darker white */
    --sidebar-bg: #6b4f3f;
    /* Custom Brown */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(139, 69, 19, 0.1);
    /* SaddleBrown low opacity */

    --text-primary: #3e2723;
    /* Dark Brown */
    --text-secondary: #795548;
    /* Medium Brown */

    --accent-color: #558b2f;
    /* Leaf Green */
    --accent-hover: #33691e;
    --accent-glow: rgba(85, 139, 47, 0.3);

    --success-color: #558b2f;
    --warning-color: #fdd835;
    --danger-color: #d84315;
    /* Burnt Orange/Red */

    --font-heading: 'Noto Sans KR', sans-serif;
    --font-body: 'Inter', 'Noto Sans KR', sans-serif;

    --nav-width: 250px;
    --header-height: 80px;

    --blob-1: #dcedc8;
    /* Light Green */
    --blob-2: #ffe0b2;
    /* Light Orange/Brown */
    --blob-3: #ffecb3;
    /* Light Yellow */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
    /* Prevent body scroll, custom scroll for main */
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Background Animation */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    filter: blur(60px);
    /* Slightly less blur for soft pastel look */
    opacity: 0.5;
    /* Reduced opacity so white bg shows more */
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    animation: blob-bounce 20s infinite ease;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--blob-1);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--blob-2);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: var(--blob-3);
    bottom: 20%;
    left: 30%;
    animation-delay: -10s;
}

@keyframes blob-bounce {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar.glass-panel {
    width: var(--nav-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    border-right: none;
    background: #6b4f3f;
    /* Custom Brown */
    color: #ffffff;
    box-shadow: 4px 0 20px rgba(62, 39, 35, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0;
    /* Handled by span margin */
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: #ffffff;
    /* White Logo Text */
    text-shadow: none;
}

.logo i {
    color: #dcedc8;
    /* Light green icon to pop on brown */
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    display: flex;
    align-items: center;
    padding: 1rem 1.2rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: rgba(255, 255, 255, 0.7);
    /* Muted white */
}

.nav-links li i {
    margin-right: 1rem;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.nav-links li:hover,
.nav-links li.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.nav-links li.active {
    background: rgba(255, 255, 255, 0.2);
    border-left: 3px solid #dcedc8;
    /* Light green indicator */
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: nowrap;
}

.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.user-info .name {
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .role {
    font-size: 0.75rem;
    color: #dcedc8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.mobile-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.date-selector {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.date-selector h2 {
    margin: 0;
    font-size: 1.8rem;
    font-family: var(--font-heading);
    color: var(--text-primary);
    white-space: nowrap;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.2s;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.actions {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #fff;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background: #f1f8e9;
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.btn-accent {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 10px var(--accent-glow);
}

.btn-accent:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--accent-glow);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

/* Panels & Cards */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid #fff;
    backdrop-filter: blur(12px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    /* Slightly stronger soft shadow */
}

.card {
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

/* Dashboard Grid */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.summary-card.total .card-icon {
    color: var(--accent-color);
    border: 1px solid rgba(85, 139, 47, 0.2);
}

.summary-card.spent .card-icon {
    color: var(--danger-color);
    border: 1px solid rgba(216, 67, 21, 0.2);
}

.summary-card.remaining .card-icon {
    color: var(--text-primary);
    border: 1px solid rgba(62, 39, 35, 0.2);
}

.summary-card.daily .card-icon {
    color: var(--warning-color);
    border: 1px solid rgba(253, 216, 53, 0.4);
}

.card-info h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.card-info p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Chart Placeholder */
.chart-container {
    height: 300px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding-bottom: 1rem;
}

.bar-chart {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    /* Space between for separate look */
    gap: 4px;
    /* Small gap */
}

.chart-bar {
    /* flex: 1; Removed flex to control width */
    width: 6px;
    /* Thinner bars */
    background: rgba(85, 139, 47, 0.2);
    /* Light Green bars */
    border-radius: 5px 5px 0 0;
    position: relative;
    transition: height 1s ease, background 0.2s;
    min-height: 5px;
    margin: 0 auto;
    /* Center in its slot if we used grid, but flex justify space-between handles it */
}

.chart-bar:hover {
    background: var(--accent-color);
}

.chart-bar::after {
    content: attr(data-day);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-secondary);
    display: none;
    /* Hide standard day numbers to avoid clutter */
}

.chart-bar:nth-child(5n)::after {
    display: block;
}

/* Show every 5th day */

/* Recent Transactions */
.transaction-list-mini {
    list-style: none;
}

.transaction-list-mini li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--glass-border);
}

.transaction-list-mini li:last-child {
    border-bottom: none;
}

.tx-info h4 {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
}

.tx-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tx-amount {
    font-weight: 600;
}

.tx-amount.expense {
    color: var(--text-primary);
}

/* Calendar */
.calendar-wrapper {
    padding: 0;
    overflow: hidden;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: rgba(139, 69, 19, 0.05);
    /* Light brown tint */
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    min-height: 120px;
    padding: 10px;
    border-right: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    transition: background 0.2s;
    cursor: pointer;
    /* Clickable */
    color: var(--text-primary);
}

.calendar-day:hover {
    background: rgba(139, 69, 19, 0.05);
}

.calendar-day.other-month {
    opacity: 0.4;
    background: rgba(0, 0, 0, 0.02);
    pointer-events: none;
}

.calendar-day.today {
    background: rgba(85, 139, 47, 0.1);
}

.day-num {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9rem;
}

.day-tx-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 2px;
}

.dot-expense {
    background: var(--danger-color);
}

.calendar-day-total {
    font-size: 0.75rem;
    color: var(--danger-color);
    font-weight: 600;
    display: block;
    margin-top: 5px;
    text-align: right;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(62, 39, 35, 0.4);
    /* Brownish overlay */
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 400px;
    padding: 2rem;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    /* Solid white for modal readability */
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* Scrollbar for modal */
.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    background: #fcfcfc;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    outline: none;
    transition: border 0.3s;
}

/* Filters */
.list-filters {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.list-filters input,
.list-filters select {
    background: #ffffff;
    border: 1px solid #d7ccc8;
    /* Light Brown styling */
    color: var(--text-primary);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    margin-right: 0;
    /* Handled by gap */
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.05);
    /* Warm shadow */
    outline: none;
    transition: all 0.2s ease;
    font-family: var(--font-body);
}

.list-filters input:focus,
.list-filters select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
    transform: translateY(-1px);
}

.list-filters input::placeholder {
    color: #bcaaa4;
}

.form-group input:focus {
    border-color: var(--accent-color);
    background: #fff;
}

.full-width {
    width: 100%;
    margin-top: 1rem;
}

/* Daily List Styles */
.daily-list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.daily-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #fafafa;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.daily-item-info h4 {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
}

.daily-item-category {
    font-size: 0.75rem;
    color: #fff;
    padding: 2px 8px;
    background: var(--text-secondary);
    border-radius: 12px;
    border: none;
}

.daily-total-summary {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.daily-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* Utilities */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Full List */
.table-container {
    overflow-x: auto;
}

.tx-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.tx-table th,
.tx-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.tx-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.delete-btn {
    color: var(--danger-color);
    background: none;
    border: none;
    cursor: pointer;
}

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.mobile-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 1024px) {

    /* Layout */
    .app-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* Mobile Header Visible */
    .mobile-header {
        display: flex;
    }

    /* Sidebar as Off-canvas Menu */
    .sidebar.glass-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        /* Standard drawer width */
        height: 100%;
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        border-radius: 0 20px 20px 0;
        /* Rounded right corners */
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);

        display: flex;
        flex-direction: column;
        padding: 2rem;
        padding-top: 3rem;
        /* Space from top */

        /* Ensure visibility */
        background: #6b4f3f !important;
    }

    .sidebar.glass-panel.active {
        transform: translateX(0);
    }

    /* Ensure items in sidebar are visible */
    .logo {
        display: flex !important;
        margin-bottom: 2rem;
        color: white !important;
    }

    .user-profile {
        display: flex !important;
        margin-top: auto;
        color: white;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        padding-top: 1rem;
    }

    .nav-links {
        display: block;
        /* Vertical list */
        margin-bottom: auto;
    }

    .nav-links li {
        margin-bottom: 0.5rem !important;
        background: transparent;
        color: rgba(255, 255, 255, 0.7);
        justify-content: flex-start;
        /* Align left */
        padding: 1rem;
    }

    .nav-links li.active {
        background: rgba(255, 255, 255, 0.15) !important;
        color: white;
        border-left: 3px solid #dcedc8 !important;
    }

    .nav-links li i {
        margin-right: 1rem !important;
        width: 24px;
        text-align: center;
    }

    /* Main Content */
    .main-content {
        width: 100%;
        padding: 1.5rem;
        padding-bottom: 2rem;
        overflow-y: auto;
    }

    /* Top Controls */
    .top-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        margin-bottom: 1.5rem;
        background: rgba(255, 255, 255, 0.5);
        padding: 1rem;
        border-radius: 12px;
    }

    .date-selector {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }

    .date-selector h2 {
        font-size: 1.4rem;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
    }

    .btn {
        justify-content: center;
        font-size: 0.9rem;
        padding: 0.6rem;
    }

    /* Dashboard Grid -> Adaptive */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    @media (max-width: 550px) {
        .summary-cards {
            grid-template-columns: 1fr;
        }
    }

    .summary-card {
        padding: 1rem;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 200px;
    }

    /* Smaller chart height */

    /* Calendar */
    .calendar-day {
        min-height: 80px;
    }

    .calendar-header {
        font-size: 0.8rem;
        padding: 0.5rem 0;
    }

    /* Table Responsive */
    .table-container {
        overflow-x: auto;
    }

    .tx-table {
        min-width: 500px;
        /* Force scroll if too narrow */
    }

    /* Modal */
    .modal {
        width: 90%;
        padding: 1.5rem;
        max-height: 80vh;
    }
}