* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #111827;
    --primary-soft: #f3f4f6;
    --income: #15803d;
    --income-bg: #dcfce7;
    --expense: #b91c1c;
    --expense-bg: #fee2e2;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --radius: 22px;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(17, 24, 39, 0.08), transparent 28%),
        linear-gradient(180deg, #f9fafb 0%, #eef2f7 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    padding-bottom: 110px;
}

.app-shell {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 18px 14px 24px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 6px 2px;
}

.app-header h1 {
    margin: 0;
    font-size: 25px;
    line-height: 1.1;
    letter-spacing: -0.05em;
    color: var(--text);
}

.app-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-icon-button {
    width: 40px;
    height: 40px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
    font-weight: 800;
}

.user-pill {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--primary);
    color: #ffffff;
    border-radius: 999px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 800;
}

.card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.card h2,
.card h3 {
    margin: 0 0 12px;
    letter-spacing: -0.03em;
}

.card h2 {
    font-size: 22px;
}

.card h3 {
    font-size: 17px;
}

.card p {
    color: var(--muted);
    line-height: 1.45;
}

label {
    display: block;
    margin: 12px 0 7px;
    color: #374151;
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: var(--text);
    border-radius: 15px;
    padding: 14px;
    font: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
    resize: vertical;
    min-height: 92px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.08);
}

button,
.button-link {
    display: inline-flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 16px;
    background: var(--primary);
    color: #ffffff;
    text-decoration: none;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    padding: 13px 16px;
    margin-top: 14px;
}

button:active,
.button-link:active,
.small-button:active,
.header-icon-button:active,
.settings-card:active {
    transform: scale(0.99);
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.summary-grid .card {
    margin-bottom: 0;
}

.summary-grid .card p {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--muted);
}

.amount {
    font-size: 22px;
    font-weight: 950;
    letter-spacing: -0.04em;
}

.income {
    color: var(--income);
}

.expense {
    color: var(--expense);
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.list-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.list-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.list-row strong {
    white-space: nowrap;
}

small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.transaction-card {
    padding: 16px;
}

.transaction-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.transaction-row p {
    margin: 6px 0 0;
    font-size: 13px;
}

.transaction-side {
    min-width: 116px;
    text-align: right;
}

.transaction-side .amount {
    font-size: 18px;
}

.transaction-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 10px;
}

.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    background: var(--primary-soft);
    color: var(--text);
    border: 1px solid var(--border);
    text-decoration: none;
    padding: 8px 11px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 13px;
}

.danger-button {
    width: auto;
    min-height: 36px;
    margin-top: 0;
    background: var(--expense-bg);
    color: var(--expense);
    border: 1px solid #fecaca;
    padding: 8px 11px;
    border-radius: 12px;
    font-size: 13px;
}

.budget-item,
.goal-item,
.settings-category {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.budget-item:last-child,
.goal-item:last-child,
.settings-category:last-child {
    border-bottom: 0;
}

.budget-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.budget-heading span {
    font-weight: 850;
    font-size: 13px;
    text-align: right;
}

.progress-bar {
    width: 100%;
    height: 11px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin: 10px 0 13px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
}

.progress-fill.over {
    background: var(--expense);
}

.progress-fill.complete {
    background: var(--income);
}

.goal-edit {
    margin-top: 12px;
}

.goal-edit summary {
    cursor: pointer;
    font-weight: 850;
    color: var(--text);
    background: var(--primary-soft);
    border: 1px solid var(--border);
    padding: 11px 13px;
    border-radius: 14px;
}

.goal-edit form {
    margin-top: 12px;
}

.settings-menu {
    display: grid;
    gap: 12px;
}

.settings-card {
    display: flex;
    gap: 14px;
    align-items: center;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
}

.settings-card strong {
    display: block;
    font-size: 15px;
    margin-bottom: 3px;
}

.settings-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.settings-icon {
    width: 44px;
    height: 44px;
    border-radius: 15px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: 720px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 8px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
    z-index: 100;
    backdrop-filter: blur(12px);
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 50px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 850;
    border-radius: 17px;
}

.bottom-nav a.active {
    background: var(--primary);
    color: #ffffff;
}

.nav-icon {
    font-size: 18px;
    line-height: 1;
}

.login-body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(17, 24, 39, 0.12), transparent 32%),
        linear-gradient(180deg, #f9fafb 0%, #eef2f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 60px;
    height: 60px;
    border-radius: 21px;
    background: var(--primary);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 950;
    letter-spacing: -0.04em;
    margin-bottom: 14px;
}

.login-brand h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.05em;
    color: var(--text);
}

.login-brand p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.login-error {
    background: var(--expense-bg);
    color: var(--expense);
    border: 1px solid #fecaca;
    border-radius: 15px;
    padding: 12px 14px;
    font-weight: 800;
    margin-bottom: 16px;
    font-size: 14px;
}

.login-form label {
    display: block;
    margin-bottom: 7px;
    color: #374151;
    font-weight: 850;
    font-size: 13px;
}

.login-form input {
    margin-bottom: 16px;
}

.login-form button {
    margin-top: 4px;
}

.login-footer-text {
    margin: 18px 0 0;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

@media (min-width: 700px) {
    .app-shell {
        padding-top: 28px;
    }

    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .card {
        padding: 20px;
    }
}

.transaction-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 10px;
}

.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    background: var(--primary-soft);
    color: var(--text);
    border: 1px solid var(--border);
    text-decoration: none;
    padding: 8px 11px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 13px;
}

.transaction-actions .danger-button {
    margin-top: 0;
}