:root {
    --bg: #f4f7f6;
    --surface: #ffffff;
    --text: #172421;
    --muted: #65736f;
    --line: #dfe7e4;
    --primary: #146c5b;
    --primary-dark: #0f5548;
    --primary-soft: #e7f3f0;
    --danger: #a93636;
    --danger-soft: #fff0f0;
    --success: #226c42;
    --success-soft: #eaf7ef;
    --shadow: 0 10px 30px rgba(20, 55, 47, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.container { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }

.guest-page { min-height: 100vh; background: radial-gradient(circle at 50% -10%, #d8eee8 0, var(--bg) 42%); display: flex; flex-direction: column; }
.guest-shell { width: min(100% - 32px, 430px); margin: auto; padding: 32px 0 22px; }
.login-card, .error-card { background: var(--surface); border: 1px solid rgba(20, 108, 91, .09); border-radius: 22px; box-shadow: var(--shadow); padding: 26px 22px; }
.login-brand { text-align: center; margin-bottom: 25px; }
.login-brand h1 { margin: 12px 0 4px; font-size: 1.75rem; letter-spacing: -.04em; }
.login-brand p { margin: 0 auto; color: var(--muted); max-width: 290px; font-size: .95rem; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: var(--primary); font-weight: 800; box-shadow: 0 5px 12px rgba(20,108,91,.22); }
.brand-mark.large { width: 50px; height: 50px; margin-inline: auto; border-radius: 14px; font-size: 1.25rem; }
.login-form { display: grid; gap: 9px; }
.login-form label:not(.checkbox-row), .install-form label { color: #344540; font-size: .89rem; font-weight: 650; margin-top: 4px; }
input[type="email"], input[type="password"], input[type="text"], input[type="number"] { width: 100%; min-height: 48px; border: 1px solid #cdd9d5; border-radius: 11px; background: #fff; color: var(--text); padding: 11px 13px; outline: 0; transition: border .15s, box-shadow .15s; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20,108,91,.12); }
.password-field { position: relative; }
.password-field input { padding-right: 50px; }
.password-field button { position: absolute; inset: 0 3px 0 auto; width: 44px; border: 0; background: transparent; color: #64746f; cursor: pointer; }
.password-field svg { width: 22px; fill: currentColor; }
.checkbox-row { display: flex; align-items: center; gap: 9px; min-height: 40px; color: #465651; font-size: .92rem; cursor: pointer; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.primary-button, .secondary-button { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 11px 18px; border-radius: 11px; font-weight: 750; border: 0; cursor: pointer; }
.primary-button { background: var(--primary); color: #fff; text-transform: uppercase; letter-spacing: .035em; }
.primary-button:hover { background: var(--primary-dark); }
.primary-button.inline { width: auto; }
.secondary-button { color: var(--primary); background: var(--primary-soft); }
.alert { padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; font-size: .9rem; }
.alert.error { color: var(--danger); background: var(--danger-soft); border: 1px solid #f2c9c9; }
.alert.success { color: var(--success); background: var(--success-soft); border: 1px solid #c7e8d3; }
.public-footer, .app-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 10px; padding: 18px 16px 24px; color: var(--muted); font-size: .75rem; }
.public-footer a, .app-footer a { color: inherit; }

.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.topbar-inner { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.02rem; font-weight: 800; letter-spacing: -.02em; }
.desktop-nav { display: none; align-self: stretch; }
.desktop-nav a { display: flex; align-items: center; padding: 0 14px; color: #52615d; border-bottom: 2px solid transparent; font-size: .92rem; font-weight: 600; }
.desktop-nav a:hover, .desktop-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.user-menu { position: relative; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; cursor: pointer; }
.dropdown { position: absolute; top: calc(100% + 10px); right: 0; z-index: 30; width: 220px; padding: 7px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.dropdown-user { padding: 9px 10px 11px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.dropdown-user strong, .dropdown-user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-user span { color: var(--muted); font-size: .82rem; }
.dropdown a, .dropdown button { display: block; width: 100%; border: 0; background: transparent; color: var(--text); padding: 10px; border-radius: 8px; text-align: left; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--bg); }
.main-content { min-height: calc(100vh - 190px); padding-top: 24px; padding-bottom: 110px; }
.welcome p { margin: 0; color: var(--muted); font-size: 1rem; }
.welcome p strong { color: var(--text); }
.welcome h1 { margin: 2px 0 19px; font-size: 1.35rem; letter-spacing: -.025em; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.metric-card { min-height: 105px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-card span { color: var(--muted); font-size: .84rem; }
.metric-card strong { font-size: 1.75rem; letter-spacing: -.04em; }
.metric-card.money strong { font-size: 1.16rem; color: var(--primary); white-space: nowrap; }
.recent-section { margin-top: 25px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.section-heading a { font-size: .86rem; font-weight: 700; }
.empty-state { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 20px; text-align: center; }
.empty-icon { display: grid; place-items: center; margin: 0 auto 12px; width: 44px; height: 44px; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-weight: 800; font-size: 1.25rem; }
.empty-state h1, .empty-state h3 { margin: 0 0 6px; font-size: 1.05rem; }
.empty-state p { margin: 0 auto 18px; max-width: 440px; color: var(--muted); font-size: .9rem; }
.service-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.service-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.service-row:last-child { border-bottom: 0; }
.service-row > div:last-child { text-align: right; }
.service-row strong, .service-row span { display: block; }
.service-row strong { font-size: .9rem; }
.service-row span { color: var(--muted); font-size: .8rem; }
.new-action { position: fixed; z-index: 18; right: 18px; bottom: 79px; }
.new-action > button { height: 48px; padding: 0 18px; border: 0; border-radius: 24px; color: #fff; background: var(--primary); box-shadow: 0 10px 25px rgba(20,108,91,.3); font-weight: 750; cursor: pointer; }
.new-menu { position: absolute; right: 0; bottom: calc(100% + 10px); width: 190px; padding: 7px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.new-menu a { display: block; padding: 10px; border-radius: 8px; color: var(--text); font-size: .9rem; }
.new-menu a:hover { background: var(--bg); }
.bottom-nav { position: fixed; inset: auto 0 0; z-index: 16; display: grid; grid-template-columns: repeat(4, 1fr); min-height: 66px; padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #687671; font-size: .68rem; font-weight: 650; }
.bottom-nav a span { font-size: 1.15rem; line-height: 1; }
.bottom-nav a.active { color: var(--primary); }
.app-footer { display: none; }
.simple-page { max-width: 650px; margin: 0 auto; }
.simple-page .empty-state { margin-top: 16px; }
.back-link { display: inline-block; color: var(--muted); font-size: .9rem; }
.error-card { text-align: center; }
.error-card > strong { display: block; color: var(--primary); font-size: 3rem; }
.error-card h1 { margin: 0 0 6px; font-size: 1.45rem; }
.error-card p { margin: 0 0 20px; color: var(--muted); }

@media (min-width: 720px) {
    .desktop-nav { display: flex; margin-left: auto; }
    .main-content { padding-top: 32px; padding-bottom: 40px; }
    .welcome h1 { font-size: 1.55rem; }
    .metrics { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
    .metric-card { min-height: 120px; padding: 19px; }
    .metric-card.money strong { font-size: 1.3rem; }
    .recent-section { margin-top: 32px; }
    .empty-state { padding: 44px 24px; }
    .bottom-nav { display: none; }
    .new-action { right: max(28px, calc((100vw - 1120px) / 2)); bottom: 30px; }
    .app-footer { display: flex; }
}

@media (max-width: 370px) {
    .container { width: min(100% - 22px, 1120px); }
    .metrics { gap: 8px; }
    .metric-card { padding: 13px; }
    .metric-card.money strong { font-size: 1.02rem; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }

