:root {
    --ink: #1D1D1F;
    --muted: #6E6E73;
    --paper: #F5F5F7;
    --card: rgba(255, 255, 255, 0.88);
    --line: #D2D2D7;
    --line-hover: #A1A1A6;
    --forest: #1D1D1F;
    --forest-2: #2C2C2E;
    --gold: #e6b15a;
    --green: #34C759;
    --green-soft: #E9F9EE;
    --amber: #9a5b12;
    --amber-soft: #F8ECD8;
    --blue: #3478F6;
    --blue-soft: #E8F0FE;
    --accent: #3478F6;
    --accent-hover: #2C6BE0;
    --danger: #FF453A;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    --brand-font: "Michroma", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, sans-serif;
}

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

.app {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

aside {
    background: var(--forest);
    color: #F5F5F7;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.burger {
    display: none;
    margin-left: auto;
    width: 42px;
    height: 42px;
    padding: 11px 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
}
.burger span {
    display: block;
    height: 2px;
    margin: 5px 0;
    border-radius: 2px;
    background: #F5F5F7;
}
.brand strong {
    display: block;
    font-family: var(--brand-font);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.brand small { color: #A1A1A6; }
.login-brand {
    margin: 10px 0 0;
    font-family: var(--brand-font);
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
}

.langs {
    position: fixed;
    top: 14px;
    right: 22px;
    z-index: 5;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    max-width: none;
    white-space: nowrap;
}

.langs button {
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    padding: 0 0 2px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.langs button.active {
    color: var(--ink);
    font-weight: 800;
    border-bottom-color: currentColor;
}

.brand-logo-link {
    display: block;
    flex: 0 0 auto;
    line-height: 0;
    border-radius: 18px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.brand-logo-link:hover { opacity: 0.92; }
.brand-logo { width: 76px; height: 76px; object-fit: cover; display: block; flex: 0 0 auto; border-radius: 18px; }
.brand-logo-link .login-logo { display: block; margin-bottom: 12px; }
.firm-home .brand-logo-link { margin: 0 auto; }
.firm-home-logo { width: 148px; height: 148px; border-radius: 32px; object-fit: cover; display: block; }
.mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--gold);
    color: var(--forest);
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 24px;
}

.firms {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    /* ~10 firm rows + gaps */
    max-height: calc(10 * (16px + 1.25em) + 9 * 4px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.firms button, .firm-form button {
    text-align: left;
    background: transparent;
    border: 0;
    color: #D2D2D7;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
}

.firms button { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.firms button small { color: #A1A1A6; font-size: 12px; }
.firm-key { font-variant-numeric: tabular-nums; letter-spacing: 0.14em; font-weight: 700; }
.firms button .firm-key { color: var(--gold); font-size: 13px; }
.firms button.active, .firms button:hover { background: var(--forest-2); color: white; }
.firm-form { display: flex; flex-direction: column; gap: 6px; }
.firm-form input { background: #0e1b15; border-color: #2c4036; color: white; padding: 8px 10px; }
.firm-new { color: var(--gold) !important; }

.firm-list { display: flex; flex-direction: column; gap: 16px; }
.firm-card.selected { outline: 2px solid var(--green); }
.firm-page-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.firm-page-form input { width: 220px; }

.app.is-hidden { display: none; }

.gate { display: none; }
.gate.open {
    position: relative;
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px 16px;
}
.secret { position: relative; display: block; }
.secret input { padding-right: 42px; }
.secret .eye {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
}
.firm-form .secret .eye { color: #d9d0c3; }
.login-captcha-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: rgba(18, 22, 28, 0.45);
    padding: 24px;
}
.login-captcha-card {
    width: min(320px, 100%);
    display: grid;
    gap: 12px;
    padding: 22px;
}
.login-captcha-card .login-captcha-q {
    margin: 0;
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    color: #1a1f2a;
}
.login-captcha-card input { width: 100%; text-align: center; font-size: 20px; letter-spacing: 0.08em; }
.login-captcha-card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.login-card { width: min(400px, 100%); display: grid; gap: 0; justify-items: center; padding: 28px 28px 24px; transform: translateY(-6vh); }
.login-card h1 { margin: 0; font-size: 38px; }
.login-card .sub { margin: 8px 0 28px; font-size: 19px; text-align: center; }
.login-card label, .login-card input, .login-card .secret, .login-card .btn { width: 100%; }
.login-card .login-brand { margin: 0 0 28px; }
.login-logo {
    width: 116px;
    height: 116px;
    margin-bottom: 12px;
    border-radius: 26px;
    object-fit: cover;
    display: block;
}
.login-card .btn { margin-top: 16px; }
.login-card .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.login-lock {
    width: 100%;
    margin: 12px 0 0;
    color: #C62828;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.35;
    text-align: center;
}
.login-lock[hidden] { display: none; }
.app.is-hidden ~ .langs {
    top: 32px;
    left: auto;
    right: 40px;
    max-width: min(100vw - 32px, 100%);
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.app.is-hidden ~ .langs::-webkit-scrollbar { display: none; }
.app.is-hidden ~ .langs button { color: var(--muted); }
.app.is-hidden ~ .langs button.active {
    color: var(--ink);
    font-weight: 800;
    border-bottom-color: currentColor;
}
.app:not(.is-hidden) ~ .langs button.active {
    border-bottom-color: currentColor;
}
.renew { width: min(920px, 100%); }
.renew-contact { margin: 8px 0 0; }
.renew-contact a { color: inherit; }
.term-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.term {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--card);
    cursor: pointer;
}
.term input[type="radio"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 0;
    padding: 0;
    flex: 0 0 18px;
    accent-color: var(--green);
}
.term span { flex: 1; }
.term b { white-space: nowrap; }
.term:has(input:checked) { border-color: var(--green); }
.term small { color: var(--green); font-weight: 700; }
.pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pay-methods .card { display: grid; gap: 8px; align-content: start; }
.pay-methods .btn { margin-top: 8px; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(20, 24, 18, 0.55);
    place-items: center;
    padding: 24px;
}
.modal.open { display: grid; }
#confirm.modal { z-index: 60; }
.delete-warn {
    margin: 12px 0 0;
    color: #c62828;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.35;
}
label.auto-reminder {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: 0;
    cursor: pointer;
    position: relative;
}
label.auto-reminder input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #1a6cff;
    cursor: pointer;
}
.table-search { width: min(360px, 100%); margin: 0 0 12px; }
.table-search-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.table-search-row .table-search { margin: 0; flex: 1 1 180px; }
.firm-name { display: flex; align-items: center; gap: 8px; }
.phone-saved { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.phone-saved label { margin-bottom: 4px; }
.modal-card { width: min(520px, 100%); display: grid; gap: 8px; position: relative; }
.modal-card > label { margin-top: 4px; }
.modal-card > label:first-of-type { margin-top: 0; }
.modal > .card { position: relative; }
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #5a6570;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.06); color: #1a1f2a; }
.login-captcha-card { position: relative; }
.login-captcha-card .modal-close { top: 8px; right: 8px; }
.service-dates {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
    margin-top: 4px;
}
.service-dates > div { display: grid; gap: 6px; min-width: 0; }
.service-dates label { margin: 0; }
.service-dates input { width: 100%; box-sizing: border-box; min-width: 0; }
.modal-card h2, .modal > .card > h2 { margin: 0 0 4px; padding-right: 36px; font-family: inherit; font-weight: 650; font-size: 28px; letter-spacing: -0.02em; }
.firm-title { display: flex; align-items: center; gap: 16px; }
.firm-page-logo { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; }
.firm > span { display: flex; align-items: center; gap: 8px; min-width: 0; }
.firm-pill {
    display: inline-block;
    background: #E8E8ED;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    white-space: nowrap;
}

.firm-clients { margin-top: 28px; }

.role-firm [data-nav="settings"],
.role-firm [data-nav="meetings"],
.role-firm [data-nav="blocks"],
.role-firm #firms,
body:not(.role-firm) [data-nav="customers"] { display: none; }

.pay-stats-card { max-width: 100%; overflow: hidden; }
.pay-stats-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.pay-stats-toggle h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 650;
}
.pay-stats-card.is-open .pay-stats-toggle {
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}
.pay-stats-card.is-open .pay-stats-toggle .plan-firm-chevron { transform: rotate(225deg); }
.pay-stats-card.is-collapsed .pay-stats-body { display: none; }
.firm-panel .pay-stats-toggle {
    padding: 0;
}
.firm-panel.is-open .pay-stats-toggle {
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}
.firm-panel.is-open .pay-stats-toggle .plan-firm-chevron { transform: rotate(225deg); }
.firm-panel.is-collapsed .firm-panel-body { display: none; }
.firm-panel-body { display: grid; gap: 10px; }
.firm-list-toggle h2 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.firm-list-toggle .sub { margin: 4px 0 0; }
.firm-list-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6em;
    padding: 0 7px;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--ink);
    font-size: 0.85em;
    font-weight: 700;
}
.client-jump-stats { margin-bottom: 16px; }
.pay-stats-toolbar { margin-bottom: 12px; }
.pay-stats-actions { flex-wrap: wrap; }
.pay-stats-actions select { max-width: 100%; }
.pay-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.pay-table { width: 100%; min-width: 0; }
.meeting-filters {
    margin-bottom: 16px;
    max-width: 100%;
    overflow: hidden;
}
.meeting-filter-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.meeting-filter-row label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.meeting-filter-row label > span:first-child {
    color: var(--muted);
    font-size: 12px;
}
.meeting-filter-control {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    border-radius: 12px;
}
.meeting-filter-control input,
.meeting-filter-control input[type="date"],
.meeting-filter-control input[type="search"] {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}
.meeting-filter-control input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    min-width: 0;
}
@media (max-width: 800px) {
    .meeting-filter-row { grid-template-columns: minmax(0, 1fr); }
    .meeting-filters.card { overflow: hidden; }
    .meeting-filter-control input[type="date"] {
        max-width: 100%;
        width: 100%;
        min-width: 0;
    }
    .meeting-card .meeting-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }
}
.meetings-list { display: grid; gap: 12px; }
.meeting-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px;
}
.meeting-card.is-done { opacity: 0.72; }
.meeting-card .meeting-top {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}
.meeting-card.is-open .meeting-top { margin-bottom: 10px; }
.meeting-card .meeting-when {
    font-weight: 700;
    flex: 1 1 auto;
    min-width: 0;
    gap: 10px;
}
.meeting-card .meeting-when span:first-child {
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: left;
}
.meeting-card.is-open .meeting-when .plan-firm-chevron { transform: rotate(225deg); }
.meeting-card.is-collapsed .meeting-card-body { display: none; }
.meeting-card-body { display: grid; gap: 10px; }
.meeting-card .meeting-status {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}
.meeting-card .meeting-status.open { color: var(--accent); font-weight: 700; }
.meeting-card .meeting-grid {
    display: grid;
    gap: 6px 16px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin: 0 0 10px;
}
.meeting-card .meeting-grid > div {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.meeting-card .meeting-grid span { color: var(--muted); font-size: 12px; display: block; }
.meeting-card .meeting-grid a {
    display: inline;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}
.meeting-card .meeting-msg {
    white-space: pre-wrap;
    margin: 0 0 12px;
    line-height: 1.45;
}
.meeting-card .meeting-actions { display: flex; flex-wrap: wrap; gap: 8px; }

nav { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }

nav button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: #D2D2D7;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
}

nav button.active, nav button:hover { background: var(--forest-2); color: white; }

.aside-note {
    margin-top: auto;
    color: #A1A1A6;
    font-size: 13px;
    line-height: 1.45;
}

main { padding: 48px 36px 64px; width: 100%; min-width: 0; }

h1 {
    font-family: inherit;
    font-weight: 650;
    font-size: 40px;
    letter-spacing: -0.02em;
    margin: 0;
}

.sub { color: var(--muted); margin: 8px 0 0; max-width: 62ch; line-height: 1.5; }

.top {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-end;
    margin-bottom: 24px;
}

.deal {
    margin-bottom: 16px;
}

.deal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-top: 16px;
}

.deal-sum {
    font-family: inherit;
    font-weight: 650;
    letter-spacing: -0.03em;
    font-size: 42px;
    line-height: 1;
    margin: 6px 0 8px;
}

.deal-sum span { font-size: 22px; }

.deal p { margin: 0; color: var(--muted); line-height: 1.45; }

.period, .paid { display: flex; gap: 8px; align-items: center; }
.when { display: flex; gap: 8px; }
.when input { width: auto; flex: 1; }
.paid input { width: 120px; }
.account { width: 260px; }

.deal-note {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.card {
    background: var(--card);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    padding: 20px;
}

.money {
    font-family: inherit;
    font-weight: 650;
    letter-spacing: -0.03em;
    font-size: 64px;
    line-height: 0.95;
    margin: 8px 0;
}

.money span { font-size: 28px; }

.formula { color: var(--muted); margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; overflow: visible; }
.stats > *:hover, .stats > *:focus-visible,
.client-stats > .stat:hover, .client-stats > .stat:focus-visible { z-index: 30; }
.stat b { display: block; font-size: 28px; margin-top: 4px; overflow-wrap: normal; word-break: normal; }
.period-stat b { display: flex; flex-direction: column; gap: 2px; font-size: 22px; line-height: 1.15; }
.period-stat b span { white-space: nowrap; }
.pack-row {
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px 16px;
}
.pack-row > div:first-child { flex: 0 1 auto; }
.pack-prices { flex: 0 0 auto; max-width: 100%; }
.stat span:not(.stat-tip) { color: var(--muted); font-size: 13px; }
.client-stats > .stat > span:not(.stat-tip) { color: var(--ink); font-size: 14px; font-weight: 650; line-height: 1.25; }
button.stat-jump, .has-tip { position: relative; overflow: visible; }
button.stat-jump { width: 100%; text-align: left; cursor: pointer; }
button.stat-jump:hover { border-color: #c9bba6; }
.stat-tip,
.stat span.stat-tip {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 40;
    width: max(100%, 220px);
    background: var(--ink);
    color: white;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: 10px;
    text-align: left;
    pointer-events: none;
    box-shadow: var(--shadow);
}
button.stat-jump:hover .stat-tip,
button.stat-jump:focus-visible .stat-tip,
.has-tip:hover .stat-tip,
.has-tip:focus-visible .stat-tip { display: block; }
.stats > :last-child .stat-tip { left: auto; right: 0; }
.client-stats > .stat:nth-child(5) .stat-tip,
.client-stats > .stat:nth-child(4) .stat-tip { left: auto; right: 0; }
.firm-jump-lists {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}
.firm-jump-target { overflow: visible; }
#firm-clients,
#firm-clients-people,
#firm-clients-services,
.firm-jump-target { scroll-margin-top: 20px; }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.split > * { min-width: 0; max-width: 100%; }
.split .card { overflow: hidden; }
.split .person, .split .row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    max-width: 100%;
}
.split .who, .split .meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pack-list { display: grid; gap: 0; align-content: start; }
.pack-list.is-open .pay-stats-toggle {
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}
.pack-list.is-open .pay-stats-toggle .plan-firm-chevron { transform: rotate(225deg); }
.pack-list.is-collapsed .pack-list-body { display: none; }
.pack-list-body .pack-row:first-child { padding-top: 12px; }
.pack-row {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    border-top: 0;
}
.pack-row:last-child { border-bottom: 0; padding-bottom: 0; }
.pack-row:first-child { padding-top: 0; }
.pack-row.active .who { color: var(--green); }
.pack-prices { text-align: right; }
.pack-prices s { color: var(--muted); margin-left: 6px; font-weight: 500; }
.row, .person {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.row:first-of-type, .person:first-of-type { border-top: 0; }

.who { font-weight: 650; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.logs-path { flex: 1 1 12rem; min-width: 0; }
.logs-path code { display: inline; word-break: break-all; }
.person > div:first-child, .row > div:first-child { min-width: 0; flex: 1 1 180px; }
.person .btn, .row .btn { flex: 0 0 auto; margin-left: auto; }
.pill { flex-shrink: 0; }

.pill {
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}
.DUE { background: var(--amber-soft); color: var(--amber); }
.REMINDED { background: var(--blue-soft); color: var(--blue); }
.SENT_UNBOOKED { background: #F3E8E0; color: #9A4D2E; }
.BOOKED { background: var(--green-soft); color: var(--green); }
.next-booked { color: var(--green); font-weight: 700; }
.WAITING { background: #E8E8ED; color: var(--muted); }
.DONE { background: var(--green-soft); color: var(--green); }

.name-btn { background: none; border: 0; padding: 0; font-weight: 650; cursor: pointer; color: inherit; text-align: left; }

.btn, .btn-ghost, .chip {
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 10px 14px;
    cursor: pointer;
}

.btn { background: var(--accent); color: white; font-weight: 600; font-size: 17px; border-radius: 12px; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-ghost, .chip { background: transparent; border-color: var(--line); }
.chip { padding: 6px 10px; }

.icon-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; flex: 0 0 auto; }
.icon-btn svg { pointer-events: none; }
.tip-btn { position: relative; }
.tip-text {
    display: none;
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--ink);
    color: white;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 8px;
    white-space: nowrap;
    z-index: 6;
    pointer-events: none;
    box-sizing: border-box;
}
.icon-btn:hover .tip-text,
.icon-btn:focus-visible .tip-text,
.icon-btn:focus .tip-text,
.tip-btn:hover .tip-text,
.tip-btn:focus-visible .tip-text,
.tip-btn:focus .tip-text { display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.clients-table td.actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.clients-table td.actions .btn-ghost:not(.icon-btn) {
    height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
}

table { width: 100%; border-collapse: collapse; }
.firm-table { max-width: 100%; overflow: hidden; }
.firm-table table { width: 100%; min-width: 0; table-layout: auto; }
.firm-table .firm-key { white-space: nowrap; font-variant-numeric: tabular-nums; }
.firm-table .row-actions { width: 96px; white-space: nowrap; text-align: right; box-shadow: none; }
.firm-table .row-actions .icon-btn + .icon-btn { margin-left: 4px; }
.firm-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-width: 0;
}
.firm-row-head .name-btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    overflow-wrap: anywhere;
}
.firm-row-toggle {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.plan-form select { width: 100%; min-width: 0; max-width: 100%; }
.plan-table-card { overflow: hidden; max-width: 100%; }
.plan-table-wrap {
    margin: 0;
    padding: 0;
    max-width: 100%;
    /* ~10 collapsed firm rows (52px) + 9 gaps (12px) */
    max-height: calc(10 * 52px + 9 * 12px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
/* One field per row — avoids crushed multi-column cards on phone + sidebar */
.plan-table { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; }
.plan-table thead { display: none; }
.plan-table tbody { display: grid; gap: 12px; }
.plan-table tbody tr {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    background: #fff;
    min-width: 0;
    max-width: 100%;
}
.plan-table td {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 0;
    padding: 8px 0;
    min-width: 0;
    max-width: 100%;
}
.plan-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex: 0 1 42%;
    min-width: 0;
    overflow-wrap: anywhere;
}
.plan-table td > * { min-width: 0; max-width: 100%; }
.plan-table td.plan-name-cell {
    display: block;
    font-weight: 650;
    font-size: 16px;
    padding: 0;
    margin: 0;
    border-bottom: 0;
}
.plan-table td.plan-name-cell::before { display: none; }
.plan-firm-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 650;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
}
.plan-firm-name { min-width: 0; overflow-wrap: anywhere; }
.plan-firm-chevron {
    flex: 0 0 auto;
    width: 0.55em;
    height: 0.55em;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}
.plan-table tbody tr.is-open .plan-firm-chevron { transform: rotate(225deg); }
.plan-table tbody tr.is-open .plan-name-cell {
    padding-bottom: 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}
.plan-table tbody tr.is-collapsed td:not(.plan-name-cell) { display: none; }
.plan-table .plan-num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 15px;
    text-align: right;
}
.plan-table .plan-period {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
}
.plan-table .plan-period input[type="date"] {
    width: auto;
    max-width: 100%;
    flex: 1 1 8rem;
    min-width: 0;
    padding: 8px 10px;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}
.plan-table td.plan-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: 10px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
}
.plan-table td.plan-actions::before {
    flex: none;
    width: 100%;
}
.plan-table .plan-topup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    width: 100%;
}
.plan-table .plan-actions .btn,
.plan-table .plan-actions .btn-ghost {
    width: 100%;
    white-space: normal;
    padding: 8px 12px;
    font-size: 13px;
}
.plan-table .plan-actions .meta {
    white-space: normal;
    overflow-wrap: anywhere;
}
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.sort-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.sort-arrow { font-size: 11px; letter-spacing: 0; }
button.stat-jump.active, .stat.active { border-color: var(--forest); }

label { display: block; font-size: 15px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #FFFFFF;
    border-radius: 12px;
    padding: 10px 12px;
    color: var(--ink);
    font-size: 17px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52, 120, 246, 0.14);
}
textarea { min-height: 120px; resize: vertical; }

.form-grid, .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }

.slot-row { display: grid; grid-template-columns: 1fr 140px auto; gap: 8px; margin-bottom: 8px; }

.inbox-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.inbox-clients {
    min-height: 0;
    height: fit-content;
    max-height: calc(100vh - 140px);
    overflow: auto;
    align-self: start;
}
.inbox-board { display: grid; gap: 12px; min-width: 0; align-content: start; align-items: start; }
.inbox-window:not(.inbox-thread) { min-height: 180px; overflow: visible; }
.inbox-clients > .client-check:first-child { position: sticky; top: 0; background: var(--card); z-index: 1; }
.client-check { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 8px 0; border-bottom: 1px solid var(--line); }
.client-check input { width: auto; margin-top: 4px; flex: 0 0 auto; }
.client-check button { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; text-align: left; cursor: pointer; }
.client-check.on { background: #f6f1e8; margin: 0 -8px; padding: 8px; border-radius: 10px; }
.inbox-window h2, .inbox-filter h2 { font-size: 18px; margin: 0 0 8px; }
.inbox-thread { display: flex; flex-direction: column; height: 400px; min-height: 400px; max-height: 400px; overflow: hidden; box-sizing: border-box; }
.inbox-thread.is-collapsed {
    height: auto;
    min-height: 0;
    max-height: none;
}
.inbox-thread.is-open .pay-stats-toggle {
    padding-bottom: 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
    flex: none;
}
.inbox-thread.is-open .pay-stats-toggle .plan-firm-chevron { transform: rotate(225deg); }
.inbox-thread.is-collapsed .inbox-thread-body { display: none; }
.inbox-thread .pay-stats-toggle h2 { font-size: 18px; margin: 0; }
.inbox-thread-body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.inbox-thread .thread-head { height: 44px; min-height: 44px; max-height: 44px; overflow: hidden; flex: none; }
.inbox-thread .message-scroll { height: 270px; min-height: 270px; max-height: 270px; margin: 0; overflow-x: hidden; overflow-y: auto; flex: none; }
.service-text { white-space: pre-wrap; margin: 0; }
.inbox-compose { display: grid; gap: 8px; overflow: visible; }
.inbox-compose.card { overflow: visible; }
.inbox-board { overflow: visible; }
.inbox-compose textarea { min-height: 140px; }
.inbox-compose-field { position: relative; overflow: visible; }
.inbox-compose-field textarea { width: 100%; }
.inbox-compose-field:focus-within .stat-tip,
.inbox-compose-field:hover .stat-tip { display: block; }
.inbox-compose-field .stat-tip {
    left: 0;
    right: auto;
    top: auto;
    bottom: calc(100% + 8px);
    width: min(340px, 100%);
    max-width: 340px;
    white-space: normal;
    z-index: 50;
}
.inbox-compose .btn { width: auto; }
.inbox-send-wrap {
    position: relative;
    justify-self: end;
    display: inline-flex;
    overflow: visible;
    z-index: 2;
}
.inbox-send-wrap .stat-tip {
    left: auto;
    right: 0;
    top: auto;
    bottom: calc(100% + 8px);
    width: max-content;
    max-width: min(340px, 70vw);
    white-space: normal;
    z-index: 50;
}
.sms-options { overflow: visible; }
.sms-options .check.has-tip {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-top: 8px;
    cursor: help;
}
.sms-options .check.has-tip input { width: auto; margin-top: 3px; flex: none; }
.sms-options .stat-tip {
    width: min(340px, 85vw);
    max-width: 340px;
    white-space: normal;
}
.sms-parts { margin: 0; font-weight: 650; color: var(--ink); }
.inbox-compose .btn:disabled { cursor: not-allowed; opacity: 0.45; }
.inbox-filter { display: grid; gap: 8px; margin-bottom: 16px; max-width: 100%; }
.inbox-filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inbox-filter-row > select, .inbox-filter-row > input { flex: 1 1 140px; width: auto; min-width: 0; max-width: 240px; }
.inbox-filter-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; flex: 0 0 auto; }
.inbox-filter select, .inbox-filter input, .inbox-filter-actions .btn, .inbox-filter-actions .btn-ghost { height: 42px; box-sizing: border-box; }
.inbox-filter-actions .btn, .inbox-filter-actions .btn-ghost { width: auto; padding: 0 16px; white-space: nowrap; flex: 0 0 auto; }
.inbox-board > .card + .card { margin-top: 0; }
.inbox-filter-row > select, .inbox-filter-row > input { width: auto; }
.inbox-filter select { text-transform: capitalize; }
.inbox-tools { display: grid; gap: 8px; margin-bottom: 12px; }
.inbox-tools .table-search { margin: 0; }
.thread { display: flex; flex-direction: column; }
.bubbles { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.bubble { max-width: 460px; padding: 12px 14px; border-radius: 14px; line-height: 1.45; white-space: pre-wrap; }
.OUT { margin-left: auto; background: #123d2c; color: white; }
.IN { background: white; border: 1px solid var(--line); }
.composer { display: flex; gap: 8px; margin-top: auto; }
.composer input { flex: 1; }

.booking-card { background: var(--green-soft); border-radius: 12px; padding: 12px 14px; }

#toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--ink);
    color: white;
    padding: 12px 14px;
    border-radius: 12px;
    opacity: 0;
    transform: translateY(8px);
    transition: 0.2s ease;
    pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

.empty { color: var(--muted); padding: 12px 0; }

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cal-head strong { text-transform: capitalize; }
.cal-jump { display: flex; gap: 8px; flex: 1; justify-content: center; min-width: 0; }
.cal-jump select { width: auto; text-transform: capitalize; padding: 8px 10px; }
.cal-jump select[data-cal-year] { width: 6.5em; }
.cal-head .btn-ghost { flex: 0 0 auto; width: auto; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month .dow { color: var(--muted); font-size: 12px; text-align: center; padding: 4px 0; }
.month .pad { min-height: 52px; }
.month .day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-height: 72px;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 10px;
    text-align: left;
    padding: 8px;
    cursor: pointer;
}
.day-label { white-space: nowrap; }
.month .day.off { opacity: 0.45; }
.day-count { font-weight: 700; color: var(--amber); }
.month .day-plus { margin-top: auto; }
.day-tip {
    display: none;
    position: absolute;
    z-index: 6;
    left: 0;
    bottom: calc(100% + 6px);
    width: 240px;
    background: var(--ink);
    color: white;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.45;
    box-shadow: var(--shadow);
}
.day-tip span { display: block; margin-top: 6px; }
.day-tip span:first-child { margin-top: 0; }
.day-open:hover .day-tip { display: block; }
.month .day.busy { background: var(--amber-soft); }
.month .day.part-busy { background: var(--blue-soft); }
.month .day.selected { outline: 2px solid var(--forest); }
.meeting-day-modal { width: min(520px, 100%); }
.meeting-day-modal .row { align-items: flex-start; }
.cal-list { margin-top: 16px; }
.key-chip { font-size: 32px; letter-spacing: 0.22em; font-variant-numeric: tabular-nums; margin: 4px 0 16px; }
.visit-key { font-size: 28px; letter-spacing: 0.28em; text-align: center; }
section .card + .card { margin-top: 16px; }
.stats > .card + .card,
.split > .card + .card,
.client-board > .card + .card,
.client-stats > .card + .card,
.client-forms > .card + .card,
.inbox > .card + .card { margin-top: 0; }
.client-board {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}
.client-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}
.client-forms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}
/* section .card + .card { margin-top } breaks equal grid rows */
.client-stats > .card,
.client-forms > .card {
    margin-top: 0;
    min-width: 0;
}
.client-stats > .stat {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.client-forms > .card {
    display: flex;
    flex-direction: column;
}
.client-forms > .card > form {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.client-forms #csv,
.client-forms textarea[name="csv"] {
    flex: 1;
    min-height: 140px;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
}
.client-board .actions { margin-top: auto; padding-top: 12px; }
.split { align-items: start; }
#busy-form .when, #phone-form input, #busy-form select { margin-bottom: 12px; }
.visit { max-width: 560px; margin: 48px auto; padding: 0 16px 48px; }
.visit-cal { max-width: 820px; }
.visit h1 { font-family: inherit; font-weight: 650; font-size: 40px; margin: 0 0 8px; }
.visit a { color: inherit; }
.visit-cal .month .day { min-height: 78px; display: flex; flex-direction: column; align-items: stretch; }
.visit-cal .month .day.off { opacity: 0.38; }
.day-picks { border: 0; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.day-picks legend { width: 100%; padding: 0; margin-bottom: 2px; font-size: 13px; color: var(--muted); }
.day-pick { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.visit-cal .month .day.free { background: var(--green-soft); }
.visit-cal .times { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.slot-time {
    border: 0;
    background: white;
    color: var(--green);
    border-radius: 6px;
    padding: 3px 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.confirm-card { margin-top: 16px; }
.confirm-card h2 { margin: 0 0 8px; font-family: inherit; font-weight: 650; }
.day-open { cursor: pointer; }
.day-plus { position: relative; z-index: 1; margin-top: 8px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: white; font-weight: 700; cursor: pointer; }
.day-plus.meeting-day-toggle {
    width: auto;
    min-width: 0;
    height: auto;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
}
.day-plus.meeting-day-toggle.is-busy {
    background: var(--amber-soft);
    border-color: #e0c49a;
    color: var(--amber);
}
.day-note { display: block; margin-top: 4px; font-size: 11px; line-height: 1.3; color: var(--ink); }
.firm-home { display: grid; justify-items: center; gap: 8px; padding-top: 24px; text-align: center; }
.firm-home h1 { font-size: clamp(40px, 8vw, 68px); margin: 8px 0 0; }
.firm-home img, .firm-home .mark { width: 148px; height: 148px; border-radius: 32px; object-fit: cover; display: grid; place-items: center; }
.firm-home .mark { background: var(--forest); color: white; font-family: inherit; font-weight: 650; font-size: 72px; }
.pack-choice { display: grid; gap: 8px; margin: 8px 0 16px; }
.time-list { display: flex; flex-wrap: wrap; gap: 8px; }
.time-list button { width: auto; }
.slots { display: grid; gap: 8px; }
.slots button { text-align: left; }

@media (max-width: 900px) {
    .plan-table-wrap {
        /* ~5 collapsed firm rows + 4 gaps */
        max-height: calc(5 * 52px + 4 * 12px);
    }
    .firms {
        /* ~5 firm rows + gaps */
        max-height: calc(5 * (16px + 1.25em) + 4 * 4px);
    }
    .app { grid-template-columns: minmax(0, 1fr); width: 100%; }
    aside, main, nav, .firms { min-width: 0; max-width: 100%; }
    aside {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 4;
        max-height: 100vh;
        overflow-y: auto;
        padding: 12px 16px 12px;
        gap: 10px;
    }
    .brand { padding-right: 52px; align-items: center; }
    aside::after { content: ""; display: block; height: 26px; flex: 0 0 26px; }
    .burger {
        display: block;
        position: fixed;
        top: 8px;
        right: 8px;
        z-index: 6;
        margin-left: 0;
        background: var(--forest);
    }
    .langs {
        top: 18px;
        right: 14px;
        left: auto;
        max-width: calc(100vw - 72px);
        flex-wrap: nowrap;
        justify-content: flex-end;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 10px;
        scrollbar-width: none;
    }
    .langs::-webkit-scrollbar { display: none; }
    .langs button { flex: 0 0 auto; font-size: 13px; }
    .app:not(.is-hidden) ~ .langs {
        top: 92px;
        left: 14px;
        right: 14px;
        max-width: none;
        justify-content: flex-start;
        gap: 12px;
        z-index: 6;
        padding: 6px 0 8px;
        background: linear-gradient(to bottom, var(--forest) 70%, transparent);
    }
    aside.menu-open #firms {
        margin-top: 40px;
    }
    .role-firm aside.menu-open nav {
        margin-top: 40px;
    }
    .app.is-hidden ~ .langs {
        top: 16px;
        right: 16px;
        left: auto;
        max-width: calc(100vw - 32px);
        gap: 10px;
    }
    .app.is-hidden ~ .langs button { color: var(--muted); }
    .app.is-hidden ~ .langs button.active {
        color: var(--ink);
        font-weight: 800;
        border-bottom-color: currentColor;
    }
    .firms, nav { display: none; }
    aside.menu-open .firms,
    aside.menu-open nav { display: flex; flex-direction: column; }
    .role-firm aside.menu-open #firms { display: none; }
    .firms button, nav button {
        width: 100%;
        flex: none;
        text-align: left;
        white-space: normal;
    }
    .aside-note { display: none; }
    main { padding: 148px 16px 48px; width: 100%; }
    #firm-clients,
    #firm-clients-people,
    #firm-clients-services,
    .firm-jump-target { scroll-margin-top: 148px; }
    .app:not(.is-hidden) ~ .langs button { color: #A1A1A6; }
    .app:not(.is-hidden) ~ .langs button.active {
        color: white;
        font-weight: 800;
        border-bottom-color: currentColor;
    }
    .hero, section.split, .inbox, .form-grid, .settings-grid, .deal-grid, .pay-methods, .term-choice, .pack-choice { grid-template-columns: minmax(0, 1fr); }
    .client-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .client-forms { grid-template-columns: 1fr; gap: 8px; }
    .client-stats > .stat { min-width: 0; padding: 10px 6px; overflow: visible; text-align: left; }
    section.split .card { overflow: hidden; }
    .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .stats > * { min-width: 0; margin: 0; padding: 12px; text-align: left; overflow: visible; }
    .stat span:not(.stat-tip) { display: block; font-size: 13px; line-height: 1.25; hyphens: manual; -webkit-hyphens: manual; overflow-wrap: normal; word-break: normal; }
    .stats .stat b, .client-stats .stat b { font-size: 22px; }
    .pack-row {
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 6px;
    }
    .pack-row > div:first-child { flex: none; width: 100%; }
    .pack-prices { text-align: left; width: 100%; }
    .card { padding: 14px; }
    .span-2 { grid-column: auto; }
    .top { flex-direction: column; align-items: stretch; }
    .top .btn, .card .btn, .pay-methods .btn { width: 100%; }
    .inbox-compose .btn, .inbox-filter-actions .btn, .inbox-filter-actions .btn-ghost { width: auto; }
    .person .btn, .row .btn, .person .btn-ghost, .row .btn-ghost { width: auto; flex: 0 0 auto; }
    h1 { font-size: 32px; }
    .stat b { overflow-wrap: normal; word-break: normal; }
    .period-stat b { font-size: 18px; }
    .money { font-size: 42px; }
    .inbox { min-height: 0; }
    .card { max-width: 100%; }
    .card[style*="overflow"], .table-wrap, .pay-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 0; }
    .pay-stats-actions { width: 100%; }
    .pay-stats-actions select,
    .pay-stats-actions .btn { width: 100%; }
    .pay-table-wrap { overflow: visible; }
    .pay-table, .pay-table thead, .pay-table tbody, .pay-table tr, .pay-table th, .pay-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }
    .pay-table thead { display: none; }
    .pay-table tbody tr {
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 12px;
        margin-bottom: 10px;
        background: #fff;
    }
    .pay-table tbody tr:last-child { margin-bottom: 0; }
    .pay-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        border: 0;
        padding: 6px 0;
        text-align: left;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    .pay-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 650;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        flex: 0 1 42%;
    }
    .pay-table .pay-empty-row td {
        display: block;
        text-align: center;
        color: var(--muted);
    }
    .pay-table .pay-empty-row td::before { display: none; }
    .pay-table .pay-total-row {
        background: var(--paper);
    }
    .pay-table .pay-total-row td[colspan]::before { display: none; }
    .firm-table { overflow: visible; }
    .firm-table table, .firm-table thead, .firm-table tbody, .firm-table tr, .firm-table th, .firm-table td { display: block; width: 100%; min-width: 0; }
    .firm-table thead { display: none; }
    .firm-table tbody tr {
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 12px;
        margin-bottom: 10px;
        background: #fff;
    }
    .firm-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        border: 0;
        padding: 6px 0;
        overflow-wrap: normal;
        word-break: normal;
        white-space: normal;
    }
    .firm-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 650;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        flex: 0 1 48%;
    }
    .firm-table td.firm-name-cell {
        display: block;
        padding-bottom: 0;
        margin-bottom: 0;
        border-bottom: 0;
    }
    .firm-table tbody tr.is-open td.firm-name-cell {
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--line);
    }
    .firm-table td.firm-name-cell::before { display: none; }
    .firm-table td.firm-name-cell .name-btn { font-size: 17px; font-weight: 650; }
    .firm-row-toggle { display: inline-grid; place-items: center; }
    .firm-table tbody tr.is-open .firm-row-toggle .plan-firm-chevron { transform: rotate(225deg); }
    .firm-table tbody tr.is-collapsed td:not(.firm-name-cell) { display: none; }
    .firm-table td.row-actions {
        display: flex;
        justify-content: flex-end;
        width: auto;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px solid var(--line);
    }
    .firm-table td.row-actions::before { display: none; }
    .firm-table .firm-key { white-space: nowrap; }
    .clients-table, .clients-table thead, .clients-table tbody, .clients-table tr, .clients-table td, .clients-table th { display: block; width: 100%; min-width: 0; }
    .clients-table thead tr { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
    .clients-table th, .clients-table td { border: 0; padding: 4px 0; }
    .clients-table tbody tr { border-top: 1px solid var(--line); padding: 10px 0; }
    .clients-table td.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; position: relative; overflow: visible; }
    .clients-table .btn, .clients-table .btn-ghost { width: auto; padding: 7px 10px; font-size: 13px; }
    .clients-table .icon-btn { width: 34px; height: 34px; }
    .clients-table td.actions .btn-ghost:not(.icon-btn) { height: 34px; }
    .icon-btn .tip-text,
    .tip-btn .tip-text {
        right: auto;
        left: 50%;
        top: calc(100% + 6px);
        bottom: auto;
        transform: translateX(-50%);
        max-width: min(220px, calc(100vw - 48px));
        white-space: normal;
        text-align: center;
    }
    .clients-table td.actions .icon-btn:first-child .tip-text,
    .clients-table td.actions > .icon-btn:first-of-type .tip-text {
        left: 0;
        transform: none;
        text-align: left;
    }
    .clients-table td.actions .icon-btn:last-child .tip-text,
    .clients-table td.actions > .icon-btn:last-of-type .tip-text,
    .clients-table td.actions .auto-reminder .tip-text {
        left: auto;
        right: 0;
        transform: none;
        text-align: right;
    }
    .service-dates { grid-template-columns: 1fr; }
    .period, .paid, .when, .term { flex-wrap: wrap; }
    .term b, .term small { white-space: normal; }
    .paid input, .account, .firm-page-form input { width: 100%; max-width: 100%; }
    .firm-title { align-items: flex-start; }
    .bubble { max-width: 100%; }
    .slot-row { grid-template-columns: 1fr; }
    .plan-table .plan-period {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
    }
    .plan-table td:has(.plan-period) {
        flex-direction: column;
        align-items: stretch;
    }
    .plan-table td:has(.plan-period)::before { flex: none; }
    .plan-table .plan-period input[type="date"] {
        width: 100%;
        flex: none;
    }
}

@media (max-width: 640px) {
    aside { padding: 12px 12px 10px; }
    .visit { margin: 16px auto; padding: 56px 12px 32px; }
    .visit h1 { font-size: 32px; }
    .firm-home { padding-top: 8px; }
    .firm-home img, .firm-home .mark { width: 96px; height: 96px; border-radius: 24px; font-size: 48px; }
    .login-logo { width: 96px; height: 96px; border-radius: 22px; }
    .login-card { transform: none; }
    .app.is-hidden ~ .langs { right: 12px; top: 14px; gap: 8px; }
    .app.is-hidden ~ .langs button { font-size: 12px; }
    .firm-page-logo { width: 56px; height: 56px; }
    .month { gap: 3px; }
    .month .dow { font-size: 10px; }
    .month .day, .visit-cal .month .day { min-height: 52px; padding: 4px; border-radius: 8px; }
    .day-plus { width: 22px; height: 22px; margin-top: 4px; }
    .day-tip { width: min(220px, 70vw); }
    .modal { padding: 12px; }
    .modal-card h2 { font-size: 26px; }
    main:has(.inbox-layout) { display: block; min-height: 0; padding-bottom: 48px; }
    .inbox-layout { grid-template-columns: 1fr; grid-template-rows: none; flex: none; align-items: start; }
    .inbox-clients {
        min-height: 0;
        height: fit-content;
        max-height: 45vh;
        overflow: auto;
    }
    .inbox-filter-row > select, .inbox-filter-row > input { flex-basis: 100%; max-width: none; }
    .inbox-compose .btn { width: auto; justify-self: end; }
    .deal-sum { font-size: 32px; }
    .login-card, .renew, .modal-card { width: 100%; }
}
