/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

:root {
    --sidebar-width: 260px;
    --sidebar-handle: 44px;
}

/* Layout */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    padding: 30px;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.balance-check {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 15px;
    margin-top: 20px;
}

.balance-amount {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.balance-status {
    font-size: 1.1rem;
    font-weight: 500;
}

.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.tab {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #6c757d;
    transition: all .3s;
}

.tab.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab:hover:not(.active) {
    background: #e9ecef;
    color: #495057;
}

.tab-content {
    display: none;
    padding: 30px;
}

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

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.card.income {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.card.expenses {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.card.cash {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
}

.card h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.card .amount {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

.input-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
}

.input-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.input-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.input-group {
    flex: 1;
    min-width: 150px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color .3s;
}

textarea {
    resize: vertical;
    min-height: 60px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: transform .2s;
}

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

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.btn-full {
    width: 100%;
}

.transactions-list {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
}

.transaction-item,
.account-item,
.report-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.transaction-item:last-child,
.account-item:last-child,
.report-item:last-child {
    margin-bottom: 0;
}

.transaction-details,
.account-details,
.report-details {
    flex-grow: 1;
}

.transaction-description,
.account-name,
.report-description {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 3px;
}

.transaction-category,
.account-type,
.report-location {
    color: #6c757d;
    font-size: .9rem;
}

.transaction-amount,
.account-amount,
.report-amount {
    font-weight: bold;
    font-size: 1.1rem;
}

.income-amount {
    color: #28a745;
}

.expense-amount {
    color: #dc3545;
}

.cash-amount {
    color: #f39c12;
}

.delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    font-size: .9rem;
}

.delete-btn:hover {
    background: #c82333;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.report-filters {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: end;
}

.report-item {
    flex-direction: column;
    align-items: stretch;
}

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

.report-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: .9rem;
}

.report-notes {
    grid-column: 1/-1;
    font-style: italic;
    color: #6c757d;
    margin-top: 8px;
}

@media (max-width: 600px) {

    .input-row,
    .report-filters {
        flex-direction: column;
    }

    .input-group {
        min-width: auto;
    }

    .header h1 {
        font-size: 2rem;
    }

    .balance-amount {
        font-size: 1.5rem;
    }

    .tabs {
        flex-direction: column;
    }

    .report-details-grid {
        grid-template-columns: 1fr;
    }
}

/* Sidebar */
.app-layout {
    position: relative;
}

/* Sidebar base */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: #f1f3f5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: transform .3s ease;
    transform: translateX(0);
    /* open state */
}

/* Collapsed leaves a slim handle visible so you can reopen */
#sidebar.collapsed {
    transform: translateX(calc(-100% + var(--sidebar-handle)));
}

#sidebar.collapsed .sidebar-inner {
    display: none;
}

/* Sidebar content area */
.sidebar-inner {
    padding: 20px 16px 16px 16px;
    overflow-y: auto;
    height: 100%;
}

/* Handle button that sits on the right edge of the sidebar itself */
.sidebar-handle {
    position: absolute;
    top: 12px;
    right: -1px;
    width: var(--sidebar-handle);
    height: var(--sidebar-handle);
    border: none;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    background: #667eea;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.15);
}

/* Tabs list in sidebar */
#budgetTabs {
    list-style: none;
    margin: 12px 0 16px 0;
    padding: 0;
}

#budgetTabs li {
    background: white;
    padding: 10px 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#budgetTabs li.active {
    font-weight: 600;
    opacity: 0.9;
}


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

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 300px;
    max-width: 90%;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

/* Color circle choices */
.color-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.color-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.color-circle.selected {
    border-color: #333;
    transform: scale(1.1);
}

.sidebar-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.sidebar-actions .btn {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
}

#budgetTabs li.drag-over {
    border: 2px dashed #667eea;
}

.icon-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn,
.drag-handle {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px;
}

.drag-handle {
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Mobile responsive sidebar */
@media (max-width: 768px) {
    #sidebar {
        width: 80%;
        max-width: 300px;
        transform: translateX(-100%);
    }

    #sidebar.collapsed {
        transform: translateX(-100%);
    }

    #sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    /* Main container takes full width on mobile */
    .container {
        margin-left: 0 !important;
        max-width: 100%;
    }
}