:root {
    --bg: #f4f5f1;
    --card: #ffffff;
    --text: #1a1d18;
    --muted: #6d746a;
    --border: #dde0d8;
    --dark: #1e271f;
    --gold: #c8a74c;
    --gold-soft: #f1ead4;
    --green: #16733a;
    --red: #b53232;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.topbar {
    background: var(--dark);
    color: #fff;
    padding:
        max(20px, env(safe-area-inset-top))
        20px
        22px;

    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
}

.top-label {
    display: block;
    color: #d7bf78;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.18em;
    margin-bottom: 4px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.05;
}

.year-select {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.year-select label {
    font-size: 11px;
    color: #bdc4bb;
}

.year-select select {
    min-width: 95px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.08);
    color: #fff;
    outline: none;
}

.year-select option {
    color: #000;
}

.container {
    width: min(1240px, calc(100% - 30px));
    margin: 18px auto 50px;
}

.gold-current {
    background: var(--dark);
    color: #fff;
    border-radius: 18px;
    padding: 18px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.gold-current span {
    display: block;
    color: #bec5bb;
    font-size: 12px;
    margin-bottom: 5px;
}

.gold-current strong {
    font-size: 24px;
    color: #e0c66f;
}

.gold-current button,
.edit-month {
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 800;
}

.gold-current button {
    background: #e1c970;
    color: #1f241d;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.summary-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    min-width: 0;
}

.summary-card.gold {
    background: var(--gold-soft);
    border-color: #dfd09f;
}

.summary-card.highlight {
    background: var(--dark);
    color: #fff;
}

.summary-card span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 7px;
}

.summary-card.highlight span {
    color: #bfc6bc;
}

.summary-card strong {
    display: block;
    font-size: 21px;
    overflow-wrap: anywhere;
}

.section,
.year-result {
    margin-top: 20px;
}

.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 11px;
}

.section-title span {
    color: var(--gold);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
}

.section-title h2 {
    margin: 2px 0 0;
    font-size: 21px;
}

.section-title small {
    color: var(--muted);
}

.months {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.month-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 15px;
    min-width: 0;
}

.month-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.month-head span {
    display: block;
    color: var(--gold);
    font-size: 11px;
    font-weight: 800;
}

.month-head h3 {
    margin: 2px 0 0;
    font-size: 18px;
}

.edit-month {
    background: #eff1eb;
    color: #30362e;
}

.month-money {
    margin: 15px 0;
    padding: 13px;
    border-radius: 13px;
    background: #f5f6f2;
}

.month-money span,
.month-details span,
.month-cash span,
.year-grid span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 4px;
}

.month-money strong {
    font-size: 20px;
}

.month-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.month-details > div {
    min-width: 0;
}

.month-details strong {
    display: block;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.month-cash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;

    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.month-cash span {
    margin: 0;
}

.month-cash strong {
    color: var(--green);
}

.month-cash.negative strong,
.text-negative {
    color: var(--red);
}

.text-positive {
    color: var(--green);
}

.year-result {
    background: var(--dark);
    color: #fff;
    border-radius: 20px;
    padding: 18px;
}

.year-result .section-title h2 {
    color: #fff;
}

.year-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.year-grid > div {
    padding: 13px;
    border-radius: 13px;
    background: rgba(255,255,255,.06);
}

.year-grid span {
    color: #bac1b7;
}

.year-grid strong {
    display: block;
    font-size: 17px;
}

.year-grid .wealth {
    grid-column: span 3;
    background: #e1c970;
    color: #20251f;
}

.year-grid .wealth span,
.year-grid .wealth small {
    color: #4d503f;
}

.year-grid .wealth strong {
    font-size: 25px;
    margin: 5px 0;
}

/* TABLET */

@media (max-width: 900px) {
    .summary-grid,
    .months {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .year-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .year-grid .wealth {
        grid-column: span 2;
    }
}

/* MOBILE */

@media (max-width: 600px) {

    .topbar {
        align-items: center;
        padding-left: 16px;
        padding-right: 16px;
    }

    .topbar h1 {
        font-size: 23px;
    }

    .container {
        width: calc(100% - 20px);
        margin-top: 10px;
    }

    .gold-current {
        padding: 15px;
    }

    .gold-current strong {
        font-size: 19px;
    }

    .gold-current button {
        padding-left: 10px;
        padding-right: 10px;
        font-size: 12px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .summary-card {
        padding: 13px;
    }

    .summary-card strong {
        font-size: 17px;
    }

    .months {
        grid-template-columns: 1fr;
    }

    .month-card {
        padding: 14px;
    }

    .month-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .year-grid {
        grid-template-columns: 1fr;
    }

    .year-grid .wealth {
        grid-column: auto;
    }
}

@media (max-width: 360px) {

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .year-select {
        width: 100%;
    }

    .year-select select {
        width: 100%;
    }

    .gold-current {
        align-items: stretch;
        flex-direction: column;
    }

    .gold-current button {
        width: 100%;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}