:root {
    --ink: #1c2421;
    --muted: #5e6b66;
    --paper: #f3f1ec;
    --card: #fffcf7;
    --line: #e4dfd4;
    --forest: #143d34;
    --forest-2: #1f5c4d;
    --good: #1b7a46;
    --warn: #9a6700;
    --bad: #a33b32;
    --info: #1d5f8a;
    --shadow: 0 8px 24px rgba(28, 36, 33, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: #c9cfc9;
    color: var(--ink);
    font-family: "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
}

.phone {
    width: min(100%, 430px);
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    background: var(--paper);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, .18);
}

.phone.is-loading .screen { opacity: .45; }
.topbar { position: relative; }
.phone.is-loading .topbar::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 3px;
    border-radius: 3px;
    background: #f3e6c8;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--forest);
    color: #f6f3ee;
}
.topbar h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -.02em;
}
.topbar p, .topbar-text p { margin: 0; color: rgba(246, 243, 238, .75); font-size: .8rem; }
.mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #f3e6c8;
    color: var(--forest);
    font-weight: 750;
    flex: none;
}
.mark.lg { width: 64px; height: 64px; border-radius: 20px; font-size: 1.8rem; }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: inherit;
    background: rgba(255, 255, 255, .12);
    text-decoration: none;
    flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.off { opacity: .35; }

.screen {
    flex: 1;
    overflow: auto;
    padding: 16px 16px 24px;
    -webkit-overflow-scrolling: touch;
}

.tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 2px 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: .68rem;
    font-weight: 600;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--forest); }

.hello { margin: 0 0 2px; font-size: 1.25rem; font-weight: 700; }
.sub, .hint { color: var(--muted); font-size: .88rem; }
.hint { margin: 8px 0 0; }
.section-title { margin: 22px 0 10px; font-size: .95rem; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
    background: var(--card);
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}
.stat span, .stat em { display: block; color: var(--muted); font-style: normal; font-size: .75rem; }
.stat strong { display: block; margin: 4px 0; font-size: 1.15rem; letter-spacing: -.03em; }
.stat.good strong { color: var(--good); }
.stat.warn strong { color: var(--warn); }

.stack { display: flex; flex-direction: column; gap: 10px; }
.card {
    background: var(--card);
    border-radius: 16px;
    padding: 14px;
    box-shadow: var(--shadow);
}
.card p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.card.slim { padding: 12px 14px; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card-top strong { font-size: 1rem; }
.link-card { color: inherit; text-decoration: none; display: block; }
.money { color: var(--ink) !important; font-weight: 700; }

.chip {
    border-radius: 999px;
    padding: 3px 8px;
    font-size: .72rem;
    font-weight: 700;
    background: #ece7dc;
    color: var(--ink);
    white-space: nowrap;
}
.chip.paid, .chip.occupied, .chip.active { background: #e5f6ec; color: var(--good); }
.chip.pending, .chip.vacant { background: #fff4d6; color: var(--warn); }
.chip.overdue { background: #fde8e6; color: var(--bad); }
.chip.partial { background: #e7f2fa; color: var(--info); }
.chip.ended { background: #ece7dc; color: var(--muted); }

.empty {
    background: var(--card);
    border-radius: 16px;
    padding: 18px;
    color: var(--muted);
    text-align: center;
}
.empty a { color: var(--forest-2); }

.banner { border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: .9rem; }
.banner.ok { background: #e5f6ec; color: #146239; }
.banner.bad { background: #fde8e6; color: #8d2e27; }

.profile-hero { display: flex; align-items: center; gap: 14px; margin: 4px 2px 16px; }
.profile-hero strong { display: block; font-size: 1.15rem; }
.profile-hero p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.avatar {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--forest);
    color: #f3e6c8;
    font-size: 1.4rem;
    font-weight: 750;
    flex: none;
}
.form-card { padding: 4px 16px 16px; }
.form-card + .form-card { margin-top: 12px; }
.form-card .card-kicker { margin: 12px 0 0; font-weight: 750; }
.form-card .field { padding: 10px 0; border-bottom: 1px solid var(--line); gap: 2px; }
.form-card .field:last-of-type { border-bottom: 0; }
.form-card .form-control {
    border: 0;
    border-radius: 0;
    background: transparent;
    min-height: 32px;
    padding: 0;
    box-shadow: none;
}
.form-card .form-control:focus { box-shadow: none; background: transparent; }
.form-card .btn { margin-top: 14px; }
.logout-card { padding: 8px; }
.logout-card .btn { margin: 0; border: 0; }

.check-line {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 4px 0 0;
    font-size: .92rem;
}
.check-line input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--forest); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span, .card .label { font-size: .8rem; font-weight: 650; color: var(--muted); }
.card .label { display: inline-block; width: 58px; }
input[type="file"].form-control {
    padding: 10px 12px;
    line-height: 1.4;
}
.seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: #e7e2d8;
    border-radius: 14px;
    padding: 4px;
    margin: 18px 0 12px;
}
.seg button {
    border: 0;
    background: transparent;
    min-height: 40px;
    border-radius: 11px;
    font-weight: 700;
    color: var(--muted);
}
.seg button.on { background: #fff; color: var(--forest); box-shadow: var(--shadow); }
.pay-card p { margin-top: 2px; }
.section-row .section-title { margin-bottom: 8px; }
.text-btn { border: 0; background: transparent; color: var(--forest-2); font-weight: 700; padding: 0; min-height: 36px; }
.load-more { display: block; margin: 8px auto 0; }
.doc-list { background: var(--card); border-radius: 16px; padding: 0 12px; box-shadow: var(--shadow); }
.doc-line { display: flex; align-items: center; gap: 8px; min-height: 42px; border-bottom: 1px solid var(--line); }
.doc-line:last-child { border-bottom: 0; }
.doc-line form { margin: 0; flex: none; }
.doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 650; text-decoration: none; }
.file-view { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: #111; color: #fff; }
.file-view[hidden] { display: none; }
.file-view-bar { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; }
.file-view-bar strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.file-view-close { border: 0; background: transparent; color: #fff; font-size: 1.8rem; line-height: 1; min-width: 44px; min-height: 44px; }
.file-view-stage { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.file-view-stage img, .file-view-stage canvas { max-width: 100%; height: auto; }
.file-view-status { padding: 24px; color: #ddd; }
.file-view-pages { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 16px; }
.file-view-pages button { border: 0; background: #2a2a2a; color: #fff; border-radius: 10px; min-height: 40px; padding: 0 14px; font-weight: 700; }
.doc-remove { border: 0; background: transparent; color: var(--bad); font-weight: 700; font-size: .8rem; padding: 6px 0; }
.upload-sheet {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: flex-end;
}
.upload-sheet[hidden] { display: none; }
.sheet-dismiss { position: absolute; inset: 0; border: 0; background: rgba(28, 36, 33, .4); }
.sheet-card {
    position: relative;
    width: 100%;
    background: #fff;
    border-radius: 22px 22px 0 0;
    padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 30px rgba(28, 36, 33, .12);
    transform: translateY(110%);
    transition: transform .24s ease;
}
.upload-sheet.open .sheet-card { transform: translateY(0); }
.sheet-grip { display: block; width: 36px; height: 4px; border-radius: 4px; background: #e4dfd4; margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-close { border: 0; background: #efeae1; width: 32px; height: 32px; border-radius: 10px; font-size: 1.3rem; line-height: 1; }

.form-control, .form-select {
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid #d9d3c7;
    background: #fff;
    font-size: 1rem;
}
textarea.form-control { min-height: 96px; }

.btn-app, .btn-quiet, .btn-danger-app {
    min-height: 48px;
    border-radius: 14px;
    font-weight: 700;
    width: 100%;
}
.btn-app { background: var(--forest); color: #f6f3ee; border: 0; }
.btn-quiet { background: #efeae1; color: var(--ink); border: 0; }
.btn-danger-app { background: transparent; color: var(--bad); border: 1px solid #f0c7c3; }

.fab {
    position: absolute;
    right: 18px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: var(--forest);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 2rem;
    line-height: 1;
    text-decoration: none;
    box-shadow: 0 10px 20px rgba(20, 61, 52, .28);
    z-index: 2;
}

.month-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    border-radius: 16px;
    padding: 8px;
    margin-bottom: 12px;
}
.month-bar .icon-btn { background: #efeae1; color: var(--forest); }
.month-bar strong { display: block; text-align: center; }
.month-bar p { margin: 0; text-align: center; color: var(--muted); font-size: .75rem; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.inline-form .grow { flex: 1; }
.inline-form .btn { width: auto; min-width: 96px; }
.text-link { display: inline-block; margin-top: 8px; color: var(--forest-2); font-weight: 700; text-decoration: none; }
.mt-3 { margin-top: 16px; }

.login-phone { background: var(--forest); }
.login-screen { padding: 48px 22px 24px; color: #f6f3ee; overflow: auto; }
.login-hero h1 { margin: 14px 0 4px; font-size: 2rem; }
.login-hero p { margin: 0 0 22px; color: rgba(246, 243, 238, .78); }
.login-screen .field span { color: rgba(246, 243, 238, .8); }
.login-screen .btn-app { background: #f3e6c8; color: var(--forest); }
.login-screen .hint { color: rgba(246, 243, 238, .7); }
.login-screen .banner.bad { color: #8d2e27; }

@media (min-width: 500px) {
    body { display: grid; place-items: center; }
    .phone { height: min(100dvh, 900px); border-radius: 28px; overflow: hidden; }
}
