:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
    font-weight: 400;
    color: #1b1f23;
    background: #f4f6f8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
}

a {
    color: inherit;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 20px;
    background: #ffffff;
    border-bottom: 1px solid #dce1e5;
}

.brand {
    font-weight: 750;
    font-size: 1.15rem;
    text-decoration: none;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.95rem;
}

.topbar-user form {
    margin: 0;
}

.link-button {
    border: 0;
    background: transparent;
    text-decoration: underline;
    cursor: pointer;
    padding: 4px;
}

.page {
    width: min(980px, calc(100% - 24px));
    margin: 24px auto 60px;
}

.card {
    background: #ffffff;
    border: 1px solid #dde2e6;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 18px;
}

.narrow {
    width: min(560px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.balance-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.balance-card {
    min-height: 140px;
}

.eyebrow {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #66727d;
}

.balance-value {
    margin-top: 10px;
    font-size: clamp(1.7rem, 5vw, 2.4rem);
    font-weight: 800;
}

.muted {
    color: #68747e;
    font-size: 0.92rem;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0;
}

.action-button {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 98px;
    padding: 18px;
    justify-content: center;
    background: #ffffff;
    border: 2px solid #cfd6dc;
    border-radius: 14px;
    text-decoration: none;
}

.action-button strong {
    font-size: 1.2rem;
}

.action-button span {
    color: #66727d;
    font-size: 0.9rem;
}

.action-button:hover,
.action-button:focus {
    border-color: #66727d;
}

.action-button.admin {
    border-style: dashed;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
}

.section-header h2 {
    margin: 4px 0 0;
}

.entries {
    margin-top: 8px;
}

.entry-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 0;
    border-top: 1px solid #edf0f2;
}

.entry-main {
    min-width: 0;
}

.entry-title {
    font-weight: 700;
}

.entry-amount {
    flex: 0 0 auto;
    font-weight: 800;
    white-space: nowrap;
}

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eef1f3;
    font-size: 0.7rem;
    font-weight: 600;
    color: #55616b;
}

.form-stack {
    display: grid;
    gap: 18px;
    margin-top: 20px;
}

.form-stack label {
    display: grid;
    gap: 7px;
    font-weight: 650;
}

.form-stack input {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid #bcc5cc;
    border-radius: 9px;
    font: inherit;
    background: #ffffff;
}

.form-stack input:focus {
    outline: 3px solid rgba(50, 100, 180, 0.18);
    border-color: #4f76a8;
}

.money-input {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
}

.money-input span {
    font-size: 1.1rem;
    font-weight: 700;
}

.button {
    min-height: 50px;
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.button.primary {
    background: #20262c;
    color: #ffffff;
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    color: #53616c;
}

.alert {
    padding: 12px 14px;
    border-radius: 9px;
    background: #edf2f6;
    margin: 14px 0;
}

.alert-success {
    background: #e9f5ed;
}

.alert-error {
    background: #fae9e9;
}

.summary {
    display: grid;
    gap: 0;
    margin: 20px 0;
    border: 1px solid #dde2e6;
    border-radius: 10px;
    overflow: hidden;
}

.summary > div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 11px 13px;
    border-top: 1px solid #edf0f2;
}

.summary > div:first-child {
    border-top: 0;
}

.summary-highlight {
    background: #f2f4f6;
}

.calculated-income {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 18px;
    margin: 20px 0;
    border: 2px solid #20262c;
    border-radius: 10px;
}

.calculated-income strong {
    font-size: 1.35rem;
}

small {
    font-weight: 400;
    color: #6b7680;
}

@media (max-width: 680px) {
    .page {
        margin-top: 14px;
    }

    .balance-grid,
    .action-grid {
        grid-template-columns: 1fr;
    }

    .action-button {
        min-height: 84px;
    }

    .entry-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }

    .entry-amount {
        font-size: 1.1rem;
    }

    .topbar-user > span {
        display: none;
    }

    .summary > div,
    .calculated-income {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }
}

.current-balance-card {
    max-width: 100%;
}

.current-balance-card .balance-value {
    margin-bottom: 4px;
}
.alert-warning {
    background: #fff3cd;
    border: 1px solid #ead28a;
}

.entry-side {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 7px;
    flex: 0 0 auto;
}

.edit-link {
    font-size: 0.86rem;
    color: #53616c;
}

.form-stack select {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid #bcc5cc;
    border-radius: 9px;
    font: inherit;
    background: #ffffff;
}

.checkbox-row {
    display: grid !important;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 10px !important;
    padding: 12px;
    border: 1px solid #d7dde2;
    border-radius: 9px;
    background: #f8f9fa;
}

.checkbox-row input {
    width: 20px !important;
    min-height: 20px !important;
    margin: 2px 0 0;
}

@media (max-width: 680px) {
    .entry-side {
        width: 100%;
        align-items: flex-start;
    }
}
.history-scroll {
    width: 100%;
    overflow-x: auto;
    margin-top: 12px;
}

.history-table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 12px 10px;
    border-top: 1px solid #edf0f2;
    vertical-align: top;
    text-align: left;
}

.history-table thead th {
    border-top: 0;
    color: #66727d;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.history-table .money-col {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.history-table .edit-col {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.history-time {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: #53616c;
    font-size: 0.9rem;
}

@media (max-width: 680px) {
    .history-table {
        min-width: 760px;
    }
}
.button.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef1f3;
    color: #20262c;
    text-decoration: none;
}

.choice-grid {
    margin: 18px 0;
}