:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #232733;
    --bg-hover: #282d3a;
    --border: #2e3345;
    --text: #e4e6ef;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #10b981;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.2s ease;
    --nav-height: 60px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: var(--nav-height);
}

/* NAVIGATION — Mobile: bottom bar */

.sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sidebar-brand {
    display: none;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    max-width: 400px;
    gap: 0;
}

.sidebar-menu li {
    flex: 1;
}

.sidebar-menu a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.sidebar-menu a .material-icons-round {
    font-size: 24px;
}

.sidebar-menu a.active {
    color: var(--primary);
}

.sidebar-menu a:active {
    transform: scale(0.92);
}

.sidebar-logout {
    display: none;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.sidebar-logout-btn:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.08);
}

.sidebar-logout-btn .material-icons-round {
    font-size: 20px;
}

/* MAIN CONTENT — Mobile first */

.content {
    padding: 20px 16px;
    max-width: 600px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 2px;
}

.page-header .subtitle {
    color: var(--text-muted);
    font-size: 13px;
}

/* FORMS */

.launch-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-grid-3 {
    grid-template-columns: 1fr;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon .material-icons-round {
    position: absolute;
    left: 14px;
    font-size: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-icon input,
.input-icon select {
    width: 100%;
    padding: 14px 14px 14px 46px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
    -webkit-appearance: none;
}

.input-icon input:focus,
.input-icon select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-icon input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.input-icon select option {
    background: var(--bg-card);
    color: var(--text);
}

/* COLOR INPUT */

.color-input-wrapper {
    gap: 12px;
}

.color-input {
    width: 100% !important;
    height: 48px !important;
    padding: 4px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--bg-input) !important;
    cursor: pointer;
}

.color-preview {
    display: none;
}

/* CATEGORY GRID (Launch Page) */

.category-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

.category-card:active {
    transform: scale(0.95);
}

.category-card.selected {
    border-color: var(--cat-color);
    background: color-mix(in srgb, var(--cat-color) 12%, var(--bg-input));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat-color) 20%, transparent);
}

.category-card .cat-icon {
    font-size: 26px;
    color: var(--cat-color);
}

.category-card .cat-name {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}

/* BUTTONS */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-submit {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 15px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

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

.btn-icon .material-icons-round {
    font-size: 18px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: stretch;
    margin-top: 8px;
}

.form-actions .btn {
    flex: 1;
    justify-content: center;
}

.inline-form {
    display: inline;
}

/* MONTH SELECTOR */

.month-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.month-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.month-nav-btn:active {
    transform: scale(0.9);
}

.month-nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.month-current {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.month-current .material-icons-round {
    font-size: 20px;
    color: var(--primary);
}

.month-current select {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    text-align: center;
    padding: 4px 8px;
}

.month-current select option {
    background: var(--bg-card);
    color: var(--text);
}

/* TOTAL BANNER */

.banner-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 24px;
    border-radius: var(--radius);
    overflow: hidden;
}

.banner-grid .total-banner {
    border-radius: 0;
}

.total-banner {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 0;
}

.banner-grid + .dashboard-grid {
    margin-top: 24px;
}

.total-banner:not(.banner-income):not(.banner-expense):not(.banner-positive):not(.banner-negative) {
    margin-bottom: 24px;
}

.banner-income {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.banner-expense {
    background: linear-gradient(135deg, #ef4444, #f87171);
}

.banner-positive {
    background: linear-gradient(135deg, #6366f1, #818cf8);
}

.banner-negative {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.total-banner-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.total-banner-content .material-icons-round {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.85);
}

.total-label {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.total-value {
    font-size: 18px;
    font-weight: 700;
    color: white;
}

/* DASHBOARD CARDS */

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--cat-color);
}

.dash-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-card-title .material-icons-round {
    font-size: 20px;
}

.dash-card-title h3 {
    font-size: 15px;
    font-weight: 600;
}

.dash-card-total {
    font-size: 16px;
    font-weight: 700;
    color: var(--cat-color);
}

.dash-card-body {
    padding: 0;
}

/* TABLE — Mobile: card-style rows */

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

.cost-table thead {
    display: none;
}

.cost-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}

.cost-table tbody tr:last-child {
    border-bottom: none;
}

.cost-table td {
    padding: 0;
    font-size: 14px;
}

.cell-value {
    font-weight: 600;
    white-space: nowrap;
    margin-right: auto;
}

.cell-comment {
    color: var(--text-muted);
    width: 100%;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    order: 10;
}

.cell-date {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    order: 11;
    width: 100%;
}

.cell-actions {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* CATEGORIES LIST */

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--cat-color);
    border-radius: var(--radius-sm);
}

.cat-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cat-info .material-icons-round {
    font-size: 20px;
    flex-shrink: 0;
}

.cat-list-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-cost-count {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

/* EMPTY STATE */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    text-align: center;
}

.empty-state .material-icons-round {
    font-size: 48px;
    color: var(--text-muted);
    opacity: 0.4;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 16px;
}

/* SCROLLBAR */

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* DESKTOP — min-width: 768px */

@media (min-width: 768px) {
    body {
        display: flex;
        padding-bottom: 0;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: auto;
        right: auto;
        left: 0;
        width: 220px;
        height: 100vh;
        height: 100dvh;
        border-top: none;
        border-right: 1px solid var(--border);
        flex-direction: column;
        justify-content: flex-start;
        padding: 24px 14px;
    }

    .sidebar-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 0 10px 20px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 20px;
    }

    .sidebar-brand .material-icons-round {
        font-size: 26px;
        color: var(--primary);
    }

    .sidebar-brand h1 {
        font-size: 20px;
        font-weight: 700;
        background: linear-gradient(135deg, var(--primary), var(--primary-hover));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .sidebar-menu {
        flex-direction: column;
        width: 100%;
        max-width: none;
        gap: 4px;
    }

    .sidebar-menu li {
        flex: none;
    }

    .sidebar-menu a {
        flex-direction: row;
        justify-content: flex-start;
        gap: 10px;
        padding: 11px 14px;
        font-size: 14px;
        border-radius: var(--radius-sm);
    }

    .sidebar-menu a .material-icons-round {
        font-size: 20px;
    }

    .sidebar-menu a.active {
        background: rgba(99, 102, 241, 0.12);
    }

    .sidebar-menu a:hover {
        background: var(--bg-hover);
        color: var(--text);
    }

    .sidebar-logout {
        display: block;
        margin-top: auto;
    }

    .content {
        margin-left: 220px;
        padding: 32px 36px;
        max-width: 900px;
    }

    .page-header h2 {
        font-size: 26px;
    }

    .page-header .subtitle {
        font-size: 14px;
    }

    .launch-container {
        padding: 28px;
        margin-bottom: 32px;
    }

    .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-bottom: 24px;
    }

    .form-grid-3 {
        grid-template-columns: 2fr 1fr 1fr;
    }

    .category-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
        margin-bottom: 28px;
    }

    .category-card {
        padding: 18px 12px;
    }

    .category-card:hover {
        border-color: var(--cat-color);
        background: var(--bg-hover);
        transform: translateY(-2px);
    }

    .category-card .cat-icon {
        font-size: 28px;
    }

    .category-card .cat-name {
        font-size: 12px;
    }

    .banner-grid {
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 28px;
    }

    .total-banner {
        padding: 14px 20px;
        margin-bottom: 28px;
    }

    .total-value {
        font-size: 20px;
    }

    .banner-grid .total-value {
        font-size: 20px;
    }

    .total-banner-content .material-icons-round {
        font-size: 26px;
    }

    .dashboard-grid {
        gap: 20px;
    }

    .dash-card-header {
        padding: 18px 24px;
    }

    .dash-card-title h3 {
        font-size: 16px;
    }

    .dash-card-total {
        font-size: 18px;
    }

    .cost-table thead {
        display: table-header-group;
    }

    .cost-table thead th {
        padding: 12px 24px;
        text-align: left;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--text-muted);
        background: var(--bg-input);
    }

    .cost-table tbody tr {
        display: table-row;
        padding: 0;
        gap: 0;
    }

    .cost-table tbody tr:hover {
        background: var(--bg-hover);
    }

    .cost-table td {
        padding: 14px 24px;
    }

    .cell-comment {
        width: auto;
        max-width: 300px;
        font-size: 14px;
        order: unset;
    }

    .cell-date {
        font-size: 13px;
        order: unset;
        width: auto;
    }

    .form-actions {
        justify-content: flex-end;
    }

    .form-actions .btn {
        flex: none;
    }

    .chart-container {
        padding: 28px;
    }

    .chart-full {
        height: calc(100vh - 160px);
    }
}

/* CHART CONTAINER */

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    height: 350px;
}

.chart-full {
    height: calc(100vh - 200px);
    min-height: 400px;
}

/* LARGE DESKTOP — min-width: 1200px */

@media (min-width: 1200px) {
    .sidebar {
        width: 240px;
        padding: 24px 16px;
    }

    .content {
        margin-left: 240px;
        padding: 32px 40px;
        max-width: 1000px;
    }
}
