@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
    color-scheme: light;
    --ink: #493541;
    --muted: #9a8290;
    --green: #e67da9;
    --green-dark: #d65f91;
    --line: #f3dce7;
    --surface: #ffffff;
    --background: #fff6fa;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: 'DM Sans', sans-serif;
}

h1, h2, strong, .brand { font-family: 'Manrope', sans-serif; }
h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.25rem); letter-spacing: -.04em; }
h2 { margin: 0 0 18px; font-size: 1.15rem; }
p { line-height: 1.55; }

.topbar {
    height: 72px;
    padding: 0 max(calc((100vw - 1180px) / 2), 24px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fffafd;
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--green-dark); font-size: 1.1rem; font-weight: 800; letter-spacing: .08em; text-decoration: none; }
.brand-cat { display: inline-grid; width: 34px; height: 34px; place-items: center; border-radius: 12px; background: #ffe8f1; font-size: 1.1rem; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.username { color: #806477; font-size: .9rem; }
.paw-print { color: #e9a1bd; font-size: 1.1rem; }
.menu { position: relative; }
.menu-toggle { width: 42px; height: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 14px; background: white; cursor: pointer; list-style: none; }
.menu-toggle::-webkit-details-marker { display: none; }
.menu-toggle span { display: block; width: 19px; height: 2px; border-radius: 2px; background: #a45b7e; }
.menu-panel { position: absolute; z-index: 10; top: calc(100% + 10px); right: 0; width: 220px; padding: 7px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 12px 30px #9a4f701a; }
.menu-panel a, .menu-panel button { display: block; width: 100%; padding: 11px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; text-decoration: none; font: inherit; font-size: .88rem; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--background); color: var(--green); }
.menu-panel a[aria-current="page"] { background: #fff0f6; color: var(--green-dark); font-weight: 700; }
.menu-panel form { margin: 5px 0 0; padding-top: 5px; border-top: 1px solid var(--line); }
.menu-panel button { color: #bd5a43; }
.container { width: min(1180px, calc(100% - 48px)); margin: 42px auto 72px; }
.page-heading { position: relative; min-height: 95px; margin-bottom: 26px; padding-right: 100px; }
.page-heading::after { content: "🐱"; position: absolute; top: 0; right: 8px; display: grid; width: 76px; height: 76px; place-items: center; border: 1px solid #f6dce7; border-radius: 26px 26px 26px 10px; background: #ffebf3; font-size: 2.15rem; transform: rotate(3deg); }
.eyebrow { margin: 0 0 8px; color: var(--green-dark); font-size: .72rem; font-weight: 700; letter-spacing: .15em; }
.muted { color: var(--muted); font-size: .9rem; }
.page-heading .muted { margin: 8px 0 0; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.summary-card, .panel, .auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 8px 26px #a84c7410; }
.summary-card { padding: 22px 24px; }
.summary-card span { display: block; color: var(--muted); font-size: .85rem; }
.summary-card strong { display: block; margin-top: 12px; font-size: 1.55rem; }
.summary-card.balance { background: linear-gradient(135deg, #ed91b6, #dd72a0); border-color: #e989af; color: white; }
.summary-card.balance span { color: #fff0f6; }

.panel { padding: 24px; }
.participant-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; }
.participant-form label { margin: 0; }
.participants-panel { margin-bottom: 20px; }
.panel > .muted { margin: -10px 0 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: grid; gap: 7px; margin-bottom: 16px; color: #39483f; font-size: .84rem; font-weight: 600; }
.form-grid label { margin: 0; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #efd6e2; border-radius: 12px; background: white; color: var(--ink); font: inherit; outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px #e67da91c; }
button { min-height: 44px; padding: 10px 16px; border: 0; border-radius: 12px; background: var(--green); color: white; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 700; }
button:hover { background: var(--green-dark); }
.button-secondary { min-height: 36px; padding: 7px 12px; background: #eff4f1; color: #43544a; font-size: .82rem; }
.button-secondary:hover { background: #e3ebe6; }
.full-width { grid-column: 1 / -1; }
.transactions-panel { padding-bottom: 8px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; }
.section-heading h2 { margin-bottom: 3px; }
.section-heading .muted { margin-top: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .84rem; }
th { padding: 13px 10px; color: var(--muted); font-size: .75rem; font-weight: 600; white-space: nowrap; }
td { padding: 15px 10px; border-top: 1px solid #edf1ee; }
.amount { text-align: right; white-space: nowrap; font-weight: 700; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 20px; font-size: .74rem; font-weight: 700; }
.badge-income { background: #fff0f6; color: #cb5889; }
.badge-expense { background: #fff2ec; color: #c87953; }
.text-income { color: #cb5889; }
.text-expense { color: #c87953; }
.empty-state { padding: 30px 0; color: var(--muted); text-align: center; }
.alert { margin-bottom: 18px; padding: 12px 15px; border-radius: 8px; font-size: .9rem; }
.alert.error { background: #fff0ec; color: #9e3f2c; }
.alert.success { background: #fff0f6; color: #a84c74; }

.auth-card { width: min(440px, calc(100% - 32px)); margin: 10vh auto; padding: 34px; box-shadow: 0 18px 50px #9a4f7016; }
.auth-card h1 { font-size: 1.8rem; }
.auth-card > .muted { margin: 8px 0 24px; }
.auth-card button { width: 100%; margin-top: 4px; }

@media (max-width: 760px) {
    .topbar { height: 64px; padding: 0 18px; }
    .container { width: min(100% - 32px, 560px); margin-top: 28px; }
    .page-heading { min-height: 75px; padding-right: 66px; }
    .page-heading::after { right: 0; width: 54px; height: 54px; border-radius: 19px 19px 19px 8px; font-size: 1.55rem; }
    .summary-grid { grid-template-columns: 1fr; gap: 10px; }
    .summary-card { padding: 17px 19px; }
    .summary-card strong { margin-top: 7px; font-size: 1.3rem; }
    .panel { padding: 19px; }
    .participant-form { grid-template-columns: 1fr; gap: 0; }
    .username { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .form-grid { grid-template-columns: 1fr; }
    .full-width { grid-column: auto; }
    .auth-card { margin-top: 7vh; padding: 26px; }
}
