@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700;800&family=Space+Grotesk:wght@500;700&display=swap');

:root {
    --bg: #f4f7fb;
    --bg-2: #e9eff8;
    --surface: #ffffff;
    --surface-soft: #f9fcff;
    --text: #17324a;
    --muted: #5f7892;
    --line: #d6e0eb;

    --brand: #0f8f8a;
    --brand-2: #087a75;
    --accent: #f28b32;

    --success-bg: #e8fff3;
    --success-text: #09643f;
    --danger-bg: #ffecec;
    --danger-text: #9f1f1f;
    --warning-bg: #fff8e6;
    --warning-text: #8a5a00;
    --info-bg: #eaf6ff;
    --info-text: #0f4c81;

    --shadow: 0 20px 40px rgba(17, 46, 72, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    font-family: 'Manrope', sans-serif;
    background:
        radial-gradient(circle at 12% 10%, rgba(15, 143, 138, 0.2), transparent 20%),
        radial-gradient(circle at 86% 8%, rgba(242, 139, 50, 0.15), transparent 26%),
        linear-gradient(140deg, var(--bg) 0%, var(--bg-2) 100%);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.01em;
}

a {
    color: inherit;
    text-decoration: none;
}

p {
    margin: 0;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    background: linear-gradient(180deg, #0f2e45 0%, #173c58 80%);
    color: #f6fcff;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.brand {
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand h1 {
    font-size: 1.14rem;
    margin-bottom: 8px;
}

.brand p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.84rem;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    color: rgba(245, 255, 255, 0.9);
    font-weight: 700;
    font-size: 0.92rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.menu a i {
    font-size: 1rem;
}

.menu a:hover {
    transform: translateX(2px);
    background: rgba(255, 255, 255, 0.12);
}

.menu a.active {
    background: linear-gradient(120deg, rgba(15, 143, 138, 0.95), rgba(8, 122, 117, 0.95));
    color: #ffffff;
}

.userbox {
    margin-top: auto;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
    display: grid;
    gap: 6px;
    font-size: 0.92rem;
}

.userbox small {
    color: rgba(255, 255, 255, 0.78);
}

.userbox a {
    margin-top: 6px;
    color: #ffe0c2;
    font-weight: 700;
}

.content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.topbar {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar .left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar .left p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
}

.menu-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 1.35rem;
    cursor: pointer;
    display: none;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: rgba(15, 143, 138, 0.12);
    color: var(--brand-2);
    border: 1px solid rgba(15, 143, 138, 0.3);
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.alert {
    border-radius: 12px;
    padding: 11px 13px;
    border: 1px solid transparent;
    font-size: 0.92rem;
    font-weight: 700;
}

.alert.success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #9ee2bf;
}

.alert.error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #f1adad;
}

.alert.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: #f6d57c;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 18px;
    display: grid;
    gap: 14px;
}

.card h3 {
    font-size: 1.06rem;
}

.success-card {
    background: linear-gradient(160deg, #ecfff7 0%, #ffffff 100%);
}

.warning-card {
    background: linear-gradient(160deg, #fff8e3 0%, #ffffff 100%);
}

.info-card {
    background: linear-gradient(160deg, #ecf7ff 0%, #ffffff 100%);
}

.muted {
    color: var(--muted);
    font-size: 0.88rem;
}

.plain-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
}

.stats-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
    display: grid;
    gap: 8px;
}

.stat-card h3 {
    font-size: 0.92rem;
    color: var(--muted);
}

.stat-card strong {
    font-size: 1.2rem;
}

.stat-card.income {
    border-color: #9adabc;
    background: linear-gradient(155deg, #edfff4 0%, #ffffff 95%);
}

.stat-card.expense {
    border-color: #efb2b2;
    background: linear-gradient(155deg, #fff2f2 0%, #ffffff 95%);
}

.stat-card.balance {
    border-color: #a6d9ee;
    background: linear-gradient(155deg, #edf8ff 0%, #ffffff 95%);
}

.stat-card.neutral {
    border-color: #cfdcea;
}

.stat-card.warning {
    border-color: #f0cf88;
    background: linear-gradient(155deg, #fff8eb 0%, #ffffff 95%);
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.wallet-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.wallet-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wallet-card {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #bfd4e7;
    background: linear-gradient(165deg, #f4fbff 0%, #ffffff 100%);
    display: grid;
    gap: 6px;
}

.wallet-card h4 {
    font-size: 0.94rem;
}

.wallet-card p,
.wallet-card small {
    color: var(--muted);
    font-size: 0.84rem;
}

.wallet-card strong {
    font-size: 1.12rem;
}

.wallet-card.negative {
    border-color: #f0adad;
    background: linear-gradient(165deg, #fff4f4 0%, #ffffff 100%);
}

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

.btn {
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 10px 14px;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(18, 56, 86, 0.15);
}

.btn.primary {
    background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #ffffff;
}

.btn.secondary {
    border-color: #b7cbde;
    background: #f5faff;
    color: #20415d;
}

.btn.warning {
    border-color: #e3b36b;
    background: #fff6e2;
    color: #855100;
}

.btn.danger {
    border-color: #e2a8a8;
    background: #ffecec;
    color: #9f1f1f;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-grid.compact {
    gap: 10px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    font-size: 0.86rem;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #6db9d6;
    box-shadow: 0 0 0 3px rgba(34, 143, 184, 0.16);
}

.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 600;
}

.checkbox-wrap input {
    width: auto;
    margin: 0;
}

.summary {
    display: grid;
    gap: 8px;
}

.summary div,
.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface-soft);
}

.summary span,
.row span {
    color: var(--muted);
    font-size: 0.88rem;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.report-hint {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.report-filter-card {
    border-color: #b9d0e3;
    background:
        radial-gradient(circle at 95% 8%, rgba(15, 143, 138, 0.16), transparent 30%),
        radial-gradient(circle at 8% 100%, rgba(242, 139, 50, 0.16), transparent 26%),
        linear-gradient(145deg, #f8fcff 0%, #f2f8ff 100%);
}

.report-filter-card h3 {
    color: #123f60;
    letter-spacing: 0.01em;
}

.report-filter-card .muted {
    color: #355b7b;
    font-weight: 700;
}

.report-stats .stat-card {
    box-shadow: 0 14px 28px rgba(20, 55, 85, 0.08);
}

.report-wallet-card,
.report-transactions {
    border-color: #bfd3e4;
    background: linear-gradient(160deg, #ffffff 0%, #f8fbff 100%);
}

.report-wallet-card h3,
.report-transactions h3 {
    color: #1d4f73;
}

.report-transactions table {
    min-width: 720px;
}

.report-mini-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.report-mini-stats article {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    padding: 10px 12px;
    display: grid;
    gap: 4px;
}

.report-mini-stats span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.report-mini-stats strong {
    font-size: 0.92rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 740px;
}

thead th {
    background: #edf3fa;
    color: #36516a;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.report-table thead th {
    background: linear-gradient(135deg, #dcecf8 0%, #ebf5fc 100%);
    color: #1a4a6c;
    border-bottom-color: #bdd3e5;
}

.report-table tbody tr:nth-child(even) {
    background: #f7fbff;
}

.report-table tbody tr:hover {
    background: #eaf4ff;
}

th,
td {
    border-bottom: 1px solid #e2eaf2;
    padding: 10px 12px;
    text-align: left;
    font-size: 0.86rem;
    vertical-align: top;
}

td.num,
th.num {
    text-align: right;
    white-space: nowrap;
}

tbody tr:hover {
    background: #f8fbff;
}

.tx-meta {
    display: grid;
    gap: 1px;
}

.tx-meta strong {
    font-size: 0.88rem;
}

.tx-meta small {
    font-size: 0.76rem;
    color: var(--muted);
}

.tx-flow.in,
.tx-cat.in {
    color: #177a4f;
    font-weight: 800;
}

.tx-flow.out,
.tx-cat.out {
    color: #bc3a3a;
    font-weight: 800;
}

.tx-description {
    min-width: 380px;
    max-width: 100%;
    line-height: 1.4;
    color: #1f4462;
}

.tx-description.muted-empty {
    color: var(--muted);
    font-style: italic;
}

.tx-amount {
    display: inline-block;
    font-weight: 800;
    white-space: nowrap;
}

.tx-amount.in {
    color: var(--success-text);
}

.tx-amount.out {
    color: var(--danger-text);
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.74rem;
    font-weight: 800;
}

.badge.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #96dab8;
}

.badge.danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #f2b4b4;
}

.badge.neutral {
    background: #edf4fb;
    color: #305370;
    border: 1px solid #b9d0e3;
}

.formula-box {
    border-radius: 12px;
    border: 1px solid #cee0f0;
    background: #f4faff;
    padding: 12px;
    display: grid;
    gap: 9px;
    font-size: 0.88rem;
}

.formula-box code {
    background: #e8f2fb;
    border-radius: 6px;
    padding: 2px 6px;
}

.row-form {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 8px;
    align-items: center;
}

.mini-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}

.mini-check input {
    width: auto;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inline-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.inline-form input[type='date'] {
    min-width: 150px;
}

.trend-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.trend-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #fcfeff;
    display: grid;
    gap: 8px;
}

.trend-item header {
    font-weight: 800;
}

.trend-row {
    display: grid;
    grid-template-columns: 44px minmax(100px, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.bar {
    height: 10px;
    border-radius: 999px;
    min-width: 2px;
}

.bar.income {
    background: linear-gradient(90deg, #37b47e 0%, #20a06a 100%);
}

.bar.expense {
    background: linear-gradient(90deg, #f08d69 0%, #dd5f45 100%);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(520px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 20px;
    padding: 22px;
    display: grid;
    gap: 14px;
}

.login-card p,
.login-card small {
    color: var(--muted);
}

@media (max-width: 1220px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .trend-grid {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(300px, 84vw);
        transform: translateX(-108%);
        transition: transform 0.25s ease;
        z-index: 30;
    }

    .app.menu-open .sidebar {
        transform: translateX(0);
    }

    .content {
        padding: 16px;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 860px) {
    .split-grid,
    .form-grid,
    .wallet-grid,
    .wallet-grid.compact,
    .stats-grid,
    .report-mini-stats {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar .left {
        width: 100%;
    }

    .topbar .right {
        width: 100%;
    }

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

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

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }
}
