:root {
    --bg: #f5f5f5;
    --card: #ffffff;
    --border: #e4e4e4;
    --text: #171717;
    --muted: #6d6d6d;
    --primary: #28a8ff;
    --primary-soft: #bfe4ff;
    --header: #cbeaff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    min-height: 100vh;
}

button,
input,
textarea,
select {
    font: inherit;
}

.hidden {
    display: none !important;
}

.shell {
    width: 100%;
    max-width: 520px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--bg);
    position: relative;
}

.screen {
    min-height: 100vh;
    padding: 24px 20px 120px;
}

.auth-screen {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hero-card {
    background: var(--primary-soft);
    min-height: 330px;
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.hero-title {
    font-size: 32px;
    font-weight: 700;
    color: #5a5a5a;
}

.auth-switch {
    display: grid;
    gap: 14px;
}

.card,
.modal-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.auth-card,
.profile-card,
.group-summary,
.modal-card {
    padding: 22px;
}

.form-stack {
    display: grid;
    gap: 16px;
}

label,
fieldset {
    display: grid;
    gap: 8px;
    border: 0;
    margin: 0;
    padding: 0;
}

label > span,
legend {
    font-weight: 600;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #d7d7d7;
    border-radius: 18px;
    padding: 16px 18px;
    background: #fff;
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(40, 168, 255, 0.15);
}

small {
    color: var(--muted);
}

.checkbox-row {
    grid-template-columns: auto 1fr;
    align-items: start;
}

.checkbox-row input,
.checkbox-list input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
}

.checkbox-list {
    display: grid;
    gap: 10px;
}

.checkbox-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fbfbfb;
}

.btn {
    border: 0;
    border-radius: 999px;
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 700;
}

.btn-block {
    width: 100%;
}

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

.btn-secondary {
    background: #ececec;
    color: #404040;
}

.topbar {
    background: var(--header);
    border-bottom-left-radius: 28px;
    border-bottom-right-radius: 28px;
    padding: 22px 20px 18px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.topbar-title {
    font-size: 24px;
    font-weight: 700;
}

.topbar-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    border: 1px solid var(--border);
    background: white;
    border-radius: 999px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.content {
    padding: 18px 20px 120px;
}

.view {
    display: grid;
    gap: 18px;
}

.view-header h2,
.view-header p {
    margin: 0;
}

.view-header p {
    color: var(--muted);
    margin-top: 6px;
}

.list-stack {
    display: grid;
    gap: 14px;
}

.list-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
}

.group-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    background: var(--primary-soft);
}

.group-card-title {
    font-size: 22px;
    font-weight: 600;
}

.group-card-arrow {
    font-size: 28px;
    color: #31405a;
}

.empty-state {
    background: white;
    border: 1px dashed #d7d7d7;
    border-radius: var(--radius-xl);
    padding: 28px 22px;
    text-align: center;
    color: var(--muted);
}

.empty-title {
    font-size: 20px;
    font-weight: 700;
    color: #555;
}

.empty-subtitle {
    margin-top: 8px;
}

.group-summary {
    background: var(--header);
}

.summary-amount {
    font-size: 44px;
    font-weight: 800;
    line-height: 1;
}

.summary-label {
    margin-top: 8px;
    color: #4f4f4f;
    font-weight: 600;
}

.tab-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}

.tab-btn {
    border: 0;
    border-radius: 18px;
    padding: 14px 12px;
    background: #f1f1f1;
    color: #2f2f2f;
    cursor: pointer;
    font-weight: 700;
}

.tab-btn.active {
    background: #54c7c3;
    color: white;
}

.expense-card,
.balance-card {
    display: grid;
    gap: 8px;
}

.expense-top,
.balance-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.expense-title,
.balance-title {
    font-size: 20px;
    font-weight: 700;
}

.expense-subtitle,
.balance-subtitle,
.meta-line {
    color: var(--muted);
}

.amount {
    font-size: 18px;
    font-weight: 800;
    white-space: nowrap;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    width: min(480px, calc(100% - 24px));
    display: grid;
    grid-template-columns: 1fr 88px 1fr;
    gap: 12px;
    padding: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--shadow);
}

.nav-btn {
    border: 0;
    border-radius: 999px;
    padding: 14px 18px;
    cursor: pointer;
    background: white;
    font-weight: 700;
}

.nav-btn.active {
    color: var(--primary);
}

.nav-btn-add {
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 28px;
    line-height: 1;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    z-index: 20;
}

.modal-card {
    width: min(520px, 100%);
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.modal-header h3 {
    margin: 0;
}

.toast {
    position: fixed;
    left: 50%;
    top: 16px;
    transform: translateX(-50%);
    background: #232323;
    color: white;
    padding: 12px 16px;
    border-radius: 14px;
    z-index: 30;
    box-shadow: var(--shadow);
}

.profile-line {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.profile-line:last-child {
    border-bottom: 0;
}

@media (max-width: 420px) {
    .hero-title {
        font-size: 28px;
    }

    .summary-amount {
        font-size: 38px;
    }

    .group-card-title,
    .expense-title,
    .balance-title {
        font-size: 18px;
    }
}
