/* ═══ Base: Reset, Variables, Theme, Typography ═══ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

:root {
    --bg: #ece8ef;
    --card: rgba(255, 255, 250, .92);
    --text: #141414;
    --text2: #5e5b52;
    --border: rgba(20, 20, 20, .12);
    --primary: #e3e54f;
    --primary-light: rgba(227, 229, 79, .22);
    --primary-dark: #bdc026;
    --primary-contrast: #11110f;
    --grad: linear-gradient(135deg, #11110f 0%, #2f2d28 58%, #4a463c 100%);
    --shadow: 0 18px 38px rgba(17, 17, 15, .08);
    --radius: 16px;
    --tab-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px)
}

[data-theme="dark"] {
    --bg: #0d0d0b;
    --card: rgba(24, 24, 20, .96);
    --text: #f8f5e8;
    --text2: #b9b39f;
    --border: rgba(255, 255, 255, .1);
    --primary-light: rgba(227, 229, 79, .14);
    --shadow: 0 18px 38px rgba(0, 0, 0, .38)
}

/* System font stack — no external requests */
html,
body {
    min-height: 100%;
    background:
        radial-gradient(circle at top right, rgba(227, 229, 79, .16), transparent 26%),
        radial-gradient(circle at 14% 10%, rgba(17, 17, 15, .08), transparent 22%),
        linear-gradient(180deg, #d5cfda 0%, #ece8ef 42%, #f7f4ed 100%);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
    overflow-x: clip; /* iOS Safari слушается только clip */
}

body.booting {
    overflow: hidden
}

.boot-splash {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top right, rgba(227, 229, 79, .16), transparent 26%),
        radial-gradient(circle at 14% 10%, rgba(17, 17, 15, .08), transparent 22%),
        linear-gradient(180deg, #d5cfda 0%, #ece8ef 42%, #f7f4ed 100%);
    opacity: 1;
    visibility: visible;
    transition: opacity .25s ease, visibility .25s ease
}

.boot-splash.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none
}

.boot-splash-card {
    width: min(100%, 360px);
    border-radius: 24px;
    padding: 24px 22px;
    background: rgba(255, 255, 250, .92);
    border: 1px solid rgba(20, 20, 20, .12);
    box-shadow: 0 18px 38px rgba(17, 17, 15, .1);
    text-align: center
}

.boot-splash-title {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 8px
}

.boot-splash-text {
    font-size: .84rem;
    color: var(--text2)
}

.boot-splash-help {
    font-size: .76rem;
    line-height: 1.45;
    color: var(--text2);
    margin-top: 12px
}

.boot-splash-form {
    margin-top: 14px
}

.boot-splash-btn {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 13px 16px;
    background: var(--grad);
    color: var(--primary);
    font-size: .92rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(17, 17, 15, .16)
}


.app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: 0;
    padding-bottom: 0;
    overflow-x: clip;
    width: 100%;
    position: relative
}

.p-20 {
    padding: 20px
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    backdrop-filter: blur(14px)
}

.section-title {
    font-size: .7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text2);
    letter-spacing: 1px;
    margin-bottom: 12px;
    margin-top: 16px
}

.btn-main {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: var(--grad);
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .2s;
    box-shadow: 0 14px 24px rgba(17, 17, 15, .18)
}

.btn-main:active {
    opacity: .8
}

.btn-danger {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: #ff3b30;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text2)
}

.empty-state .emoji {
    font-size: 3rem;
    margin-bottom: 12px
}

.empty-state p {
    font-size: .85rem
}

/* ═══ Layout: Header, Views, Tab Bar, Modals ═══ */

.header {
    background: var(--grad);
    color: #fffceb;
    padding: 52px 20px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 800
}

.header .badge {
    background: rgba(255, 255, 255, .2);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: .7rem;
    font-weight: 600
}

.transfer-indicator {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
    width: min(560px, calc(100vw - 24px));
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 250, .9);
    border: 1px solid rgba(20, 20, 20, .08);
    box-shadow: 0 12px 24px rgba(17, 17, 15, .1);
    backdrop-filter: blur(16px);
    z-index: 96;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, 10px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease
}

.transfer-indicator-inline {
    margin-top: 0
}

.transfer-indicator.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0)
}

.transfer-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(17, 17, 15, .08);
    overflow: hidden
}

.transfer-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #11110f 0%, #5e5b52 45%, #e3e54f 100%);
    transition: width .18s ease
}

.transfer-indicator.indeterminate .transfer-fill {
    width: 34%;
    animation: transferPulse 1.1s linear infinite
}

.transfer-label {
    margin-top: 7px;
    font-size: .7rem;
    font-weight: 700;
    color: var(--text2);
    letter-spacing: .02em
}

@keyframes transferPulse {
    0% {
        transform: translateX(-120%)
    }

    100% {
        transform: translateX(260%)
    }
}

.view {
    display: none;
    padding-top: 88px;
    padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
    min-height: 100vh;
    min-height: 100dvh
}

.view.active {
    display: block
}

#viewAnketa {
    padding-bottom: calc(var(--tab-h) + var(--safe-b) + 80px)
}

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-h);
    padding-bottom: var(--safe-b);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 50;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .04)
}

.tab-bar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    color: var(--text2);
    font-size: .65rem;
    font-weight: 600;
    cursor: pointer;
    transition: color .2s
}

.tab-bar button.active {
    color: var(--primary)
}

.tab-bar button .icon {
    font-size: 1.4rem
}

/* Modal */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 60;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s, visibility .25s
}

.modal-bg.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto
}

#detailModal {
    z-index: 45
}

.modal-sheet {
    background: var(--card);
    width: 100%;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1)
}

.modal-bg.show .modal-sheet {
    transform: translateY(0)
}

#detailModal .modal-sheet {
    margin-bottom: calc(var(--tab-h) + var(--safe-b));
    max-height: calc(100dvh - var(--tab-h) - var(--safe-b) - 8px) !important
}

#detailModal .modal-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text2);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center
}

.detail-back-btn {
    border: none;
    background: none;
    color: var(--primary);
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    padding: 8px 12px;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    border-radius: 10px;
    transition: background .2s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0
}

.detail-back-btn:active {
    background: var(--primary-light)
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0
}

/* ═══ Auth Screen ═══ */

#authScreen {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px
}

#authScreen.hidden {
    display: none
}

.auth-box {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border-radius: 20px;
    padding: 32px 24px;
    box-shadow: var(--shadow)
}

.auth-box h1 {
    text-align: center;
    font-size: 1.6rem;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px
}

.auth-box .sub {
    text-align: center;
    color: var(--text2);
    font-size: .85rem;
    margin-bottom: 24px
}

.auth-box input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    margin-bottom: 12px;
    outline: none;
    transition: border .2s
}

.auth-box input:focus {
    border-color: var(--primary)
}

.auth-box .btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: var(--grad);
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px;
    transition: opacity .2s
}

.auth-box .btn-primary:active {
    opacity: .8
}

.auth-box .switch {
    text-align: center;
    margin-top: 16px;
    color: var(--text2);
    font-size: .85rem
}

.auth-box .switch a {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none
}

.privacy-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: .82rem;
    color: var(--text2)
}

.privacy-check input[type=checkbox] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary)
}

.privacy-check a {
    color: var(--primary)
}

.auth-error {
    color: #ff3b30;
    font-size: .82rem;
    text-align: center;
    margin-bottom: 8px;
    min-height: 20px
}

/* ═══ Calendar ═══ */

.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px
}

.cal-header h2 {
    font-size: 1.1rem;
    font-weight: 700
}

.cal-nav {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center
}

.cal-nav:hover {
    background: var(--primary-light)
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 8px 16px
}

.cal-grid .dow {
    text-align: center;
    font-size: .65rem;
    font-weight: 700;
    color: var(--text2);
    padding: 4px 0
}

.cal-grid .day {
    text-align: center;
    padding: 6px 0 4px;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: background .15s, color .15s;
    min-height: 48px;
    display: flex;
    align-items: flex-start;
    justify-content: center
}

.cal-grid .day-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%
}

.cal-grid .day-num {
    line-height: 1
}

.cal-grid .day-markers {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 8px
}

.day-marker {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block
}

.day-marker-ext {
    background: #e3e54f
}

.day-marker-corr {
    background: #6d675e
}

.day-marker-rem {
    background: #d89a2d
}

.day-marker-col {
    background: #c7bf77
}

.day-marker-cons {
    background: #9aa35a
}

.day-marker-custom {
    background: #7d8695
}

.day-marker-more {
    min-width: 8px;
    font-size: .58rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text2)
}

.cal-grid .day:hover {
    background: var(--primary-light)
}

.cal-grid .day.today {
    font-weight: 800;
    color: var(--primary)
}

.cal-grid .day.selected {
    background: var(--primary);
    color: var(--primary-contrast);
    font-weight: 700
}

.cal-grid .day.has-event::after {
    content: none
}

.day-info {
    padding: 8px 20px
}

.day-info .label {
    font-size: .8rem;
    color: var(--text2);
    font-weight: 600
}

.appt-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    box-shadow: var(--shadow)
}

.appt-card .left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0
}

.appt-card .time-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap
}

.appt-card .name {
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere
}

.appt-card .svc {
    font-size: .75rem;
    color: var(--text2);
    line-height: 1.45;
    overflow-wrap: anywhere
}

.appt-card .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 4px;
    font-size: .72rem;
    color: var(--text2);
    line-height: 1.4
}

.appt-card .sync-note {
    font-weight: 700
}

.appt-card .del {
    color: #ff3b30;
    border: none;
    background: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px
}

.add-appt-btn {
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: none;
    color: var(--primary);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    margin-top: 8px;
    transition: background .2s
}

.add-appt-btn:hover {
    background: var(--primary-light)
}

/* Range results */
.range-block {
    padding: 8px 20px
}

.range-header {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px
}

.range-card {
    padding: 12px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center
}

/* Calendar filter */
.cal-filter-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text2);
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s
}

.cal-filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary)
}

.cal-filter-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none
}

.cal-filter-bar::-webkit-scrollbar {
    display: none
}

/* Client link in appt modal */
.client-search-dropdown {
    position: relative
}

.client-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 0 0 12px 12px;
    z-index: 10;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .1)
}

.client-dropdown-list.show {
    display: block
}

.client-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: .85rem;
    border-bottom: 1px solid var(--border)
}

.client-dropdown-item:hover {
    background: var(--primary-light)
}

.client-dropdown-item:last-child {
    border-bottom: none
}

/* ═══ Forms ═══ */

.form-group {
    margin-bottom: 16px;
    min-width: 0
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

.form-grid>*,
.selector-grid>*,
.selector-grid-wide>*,
.donor-grid>*,
.appt-time-grid>* {
    min-width: 0
}

.form-label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px
}

.form-input {
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 16px !important;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border .2s;
    min-width: 0
}

.form-input:focus {
    border-color: var(--primary)
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center
}

textarea.form-input {
    resize: vertical;
    min-height: 60px
}

.form-subinput {
    margin-top: 8px
}

.form-subinput-textarea {
    min-height: 72px;
    resize: vertical
}

.field-hint {
    margin-top: 8px;
    font-size: .73rem;
    line-height: 1.45;
    color: var(--text2)
}

.anketa-layout {
    display: flex;
    flex-direction: column;
    gap: 14px
}

.anketa-intro {
    padding: 18px;
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 250, .9), rgba(255, 255, 250, .82)),
        radial-gradient(circle at top right, rgba(227, 229, 79, .16), transparent 42%);
    border: 1px solid rgba(20, 20, 20, .08);
    box-shadow: var(--shadow)
}

.anketa-intro-kicker {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .16em;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 8px
}

.anketa-intro-title {
    font-size: 1.08rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 8px
}

.anketa-intro-text {
    font-size: .83rem;
    line-height: 1.55;
    color: var(--text2)
}

.anketa-step-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px
}

.anketa-step-chip {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(17, 17, 15, .05);
    color: var(--text);
    font-size: .74rem;
    font-weight: 700
}

.anketa-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden
}

.anketa-section summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    background:
        linear-gradient(180deg, rgba(255, 255, 250, .52), rgba(255, 255, 250, 0)),
        radial-gradient(circle at top right, rgba(227, 229, 79, .09), transparent 38%)
}

.anketa-section-static {
    overflow: visible
}

.anketa-section-static-head {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background:
        linear-gradient(180deg, rgba(255, 255, 250, .6), rgba(255, 255, 250, 0)),
        radial-gradient(circle at top right, rgba(227, 229, 79, .12), transparent 42%);
    border-bottom: 1px solid rgba(20, 20, 20, .06)
}

.anketa-section summary::-webkit-details-marker {
    display: none
}

.anketa-section summary::after {
    content: '▾';
    position: absolute;
    right: 18px;
    top: 18px;
    color: var(--primary);
    font-size: 1rem;
    transition: transform .2s ease
}

.anketa-section[open] summary::after {
    transform: rotate(180deg)
}

.anketa-section-kicker {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text2);
    font-weight: 700
}

.anketa-section-title {
    font-size: .96rem;
    font-weight: 800;
    color: var(--text)
}

.anketa-section-meta {
    font-size: .76rem;
    line-height: 1.45;
    color: var(--text2);
    max-width: calc(100% - 32px)
}

.anketa-section-body {
    padding: 0 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px
}

.anketa-subsection {
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 250, .58);
    border: 1px solid rgba(20, 20, 20, .08)
}

.anketa-subsection .section-title:first-of-type {
    margin-top: 0
}

.anketa-subsection .form-group:last-child {
    margin-bottom: 0
}

.anketa-subsection-accent {
    background:
        linear-gradient(180deg, rgba(255, 255, 250, .88), rgba(255, 255, 250, .72)),
        radial-gradient(circle at top right, rgba(227, 229, 79, .12), transparent 44%);
    border-color: rgba(227, 229, 79, .28)
}

.anketa-subsection-head {
    margin-bottom: 14px
}

.anketa-subsection-kicker {
    display: inline-block;
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .16em;
    color: var(--primary-dark);
    font-weight: 800;
    margin-bottom: 6px
}

.anketa-subsection-title {
    font-size: .96rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px
}

.anketa-subsection-text {
    font-size: .78rem;
    line-height: 1.5;
    color: var(--text2)
}

.section-collapse-btn {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--text2);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer
}

.selector-grid-wide {
    grid-template-columns: 1fr 1fr
}

.service-card {
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 12px
}

.service-card:last-child {
    margin-bottom: 0
}

.service-card-title {
    font-size: .82rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 12px
}

.pay-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer
}

.pay-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-dark)
}

.picker-shell {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 50px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    overflow: hidden;
    transition: border .2s, box-shadow .2s
}

.picker-shell:focus-within {
    border-color: var(--primary)
}

.picker-shell:focus-within::after {
    opacity: 0
}

.picker-shell.is-empty::after {
    content: attr(data-empty-label);
    position: absolute;
    left: 14px;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text2);
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none
}

.picker-shell .form-input,
.picker-shell input[type="date"],
.picker-shell input[type="time"] {
    width: 100%;
    border: none;
    background: transparent;
    box-shadow: none;
    padding-right: 42px;
    position: relative;
    z-index: 1
}

.picker-shell.is-empty input::-webkit-datetime-edit {
    color: transparent
}

.picker-shell .form-input:focus,
.picker-shell input[type="date"]:focus,
.picker-shell input[type="time"]:focus {
    border-color: transparent
}

.picker-shell-compact {
    min-height: 42px;
    flex: 1
}

.picker-shell-compact input {
    padding: 8px 10px 8px 12px;
    font-size: .82rem !important
}

.appt-time-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px
}

.payment-summary {
    display: flex;
    flex-direction: column;
    gap: 10px
}

.payment-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    align-items: center
}

.payment-row .left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0
}

.payment-row .label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    white-space: normal;
    overflow-wrap: anywhere
}

.payment-row .value {
    font-size: .9rem;
    font-weight: 800;
    color: var(--text)
}

.payment-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #d84b46
}

.payment-dot.paid {
    background: #8ca13d
}

.payment-total-box {
    padding: 14px;
    border-radius: 16px;
    background: var(--grad);
    color: #fff8df;
    display: grid;
    gap: 8px
}

.payment-total-box strong {
    color: var(--primary)
}

.payment-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(17, 17, 15, .08);
    color: var(--text2);
    font-size: .76rem;
    font-weight: 800;
    margin-bottom: 12px
}

.payment-status-pill.paid {
    background: rgba(52, 199, 89, .14);
    color: #21864d
}

.total-sub {
    font-size: .72rem;
    color: var(--text2);
    margin-top: 2px
}

/* Radio group */
.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.radio-group label {
    flex: 1;
    min-width: 90px;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    text-align: center;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    color: var(--text2)
}

.radio-group input {
    display: none
}

.radio-group input:checked+label {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary)
}

/* Hair Selectors */
.selector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px
}

.selector-group {
    margin-bottom: 0
}

.selector-group .form-label {
    margin-bottom: 4px
}

.mini-radio {
    display: flex;
    gap: 4px;
    flex-wrap: wrap
}

.mini-radio label {
    padding: 6px 8px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text2);
    transition: all .2s;
    text-align: center;
    flex: 1;
    min-width: 0
}

.mini-radio input {
    display: none
}

.mini-radio input:checked+label {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary)
}

.service-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px
}

.service-chip {
    cursor: pointer
}

.service-chip input {
    display: none
}

.service-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: var(--card);
    color: var(--text2);
    font-size: .76rem;
    font-weight: 700
}

.service-chip input:checked+span {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-contrast)
}

/* Sort/Filter bar */
.filter-bar {
    display: flex;
    gap: 8px;
    padding: 0 20px 8px;
    align-items: center;
    flex-wrap: wrap
}

.filter-bar input[type="date"] {
    flex: 1;
    padding: 8px 10px;
    font-size: .82rem;
    color: var(--text);
    outline: none
}

.filter-bar select {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: .82rem;
    background: var(--card);
    color: var(--text);
    outline: none;
    appearance: none
}

.filter-all-btn {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer
}

.filter-all-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-contrast)
}

/* ═══ Anketa: Zones, Rows, Head Diagram, Custom Zones, Extras ═══ */

/* Zone tabs */
.zone-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px
}

.zone-tab {
    flex: 1;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    text-align: center;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg);
    color: var(--text2);
    transition: all .2s
}

.zone-tab.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary)
}

.zone-content {
    display: none
}

.zone-content.active {
    display: block
}

.row-item {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px
}

.row-item-zone {
    display: grid;
    grid-template-columns: minmax(54px, auto) minmax(0, 1fr) minmax(0, 1fr) 32px;
    align-items: center
}

.row-item input {
    flex: 1;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: .9rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    text-align: center
}

.row-item input:focus {
    border-color: var(--primary)
}

.row-item .del-row {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #ffe5e5;
    color: #ff3b30;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0
}

.add-row-btn {
    width: 100%;
    padding: 10px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    background: none;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px
}

/* Row label */
.row-item .row-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 42px;
    text-align: center;
    flex-shrink: 0
}

/* Extras */
.extras-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px
}

.extras-grid .form-group {
    margin-bottom: 0
}

/* Extras qty×price */
.extras-calc {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px
}

.extras-row {
    display: grid;
    /* Было auto, стало minmax */
    grid-template-columns: minmax(70px, max-content) 1fr 20px 1fr;
    gap: 6px;
    align-items: center
}

.extras-row .elabel {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text2);
    white-space: nowrap
}

.extras-row input {
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: .9rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    text-align: center;
    width: 100%
}

.extras-row .ex {
    font-size: .8rem;
    color: var(--text2);
    text-align: center
}

/* Zone row counter */
.zone-summary {
    display: flex;
    gap: 12px;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 8px
}

.zone-summary span {
    background: var(--primary-light);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 6px
}

/* Floating total bar */
.floating-total {
    position: fixed;
    bottom: calc(var(--tab-h) + var(--safe-b));
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    display: none;
    justify-content: space-between;
    align-items: center;
    z-index: 35;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .06)
}

.floating-total .total-label {
    font-size: .85rem;
    color: var(--text2);
    font-weight: 600
}

.floating-total .total-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary)
}

.service-total-inline {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    font-size: .84rem
}

.service-total-inline strong {
    color: var(--primary);
    font-size: .96rem
}

/* Maneken Head Diagram */
.head-diagram {
    position: relative;
    margin-bottom: 16px;
    border-radius: 16px;
    overflow: visible;
    background: var(--card);
    border: 1px solid var(--border);
}

.head-diagram img {
    width: 100%;
    height: auto;
    display: block;
    opacity: .85;
    filter: grayscale(20%);
    border-radius: 16px;
}

.head-diagram .zone-overlay {
    position: absolute;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 12px;
    background: rgba(227, 229, 79, 0.14);
    transition: all .25s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
}

.head-diagram .zone-overlay:hover {
    background: rgba(227, 229, 79, 0.24);
    border-color: rgba(227, 229, 79, 0.42);
}

.head-diagram .zone-overlay.active {
    background: rgba(227, 229, 79, 0.34);
    border-color: var(--primary);
    box-shadow: 0 0 16px rgba(227, 229, 79, 0.28);
}

.head-diagram .zone-overlay .zone-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
    letter-spacing: .3px;
    pointer-events: none;
    text-align: center;
    line-height: 1.1;
}

.head-diagram .zone-overlay.active .zone-name {
    color: #fff8ad;
    text-shadow: 0 0 8px rgba(227, 229, 79, 0.55), 0 1px 4px rgba(0, 0, 0, .7);
}

/* Zone Mode Switcher */
.zone-mode-switch {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.zms-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: var(--card);
    color: var(--text2);
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.zms-btn:first-child {
    border-right: 1px solid var(--border);
}

.zms-btn.active {
    background: var(--primary);
    color: var(--primary-contrast);
}

.zms-btn:hover:not(.active) {
    background: var(--primary-light);
}

/* Custom Zone Drawing */
.diagram-toolbar {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.diagram-toolbar button {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.diagram-toolbar button:hover {
    background: var(--primary-light);
}

.diagram-toolbar button.active-tool {
    background: var(--primary);
    color: var(--primary-contrast);
    border-color: var(--primary);
}

.diagram-toolbar .sep {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.head-diagram.drawing-mode {
    cursor: crosshair;
}

.head-diagram .custom-zone {
    position: absolute;
    border: 2px solid #878073;
    border-radius: 6px;
    background: rgba(135, 128, 115, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
}

.head-diagram .custom-zone:hover {
    background: rgba(135, 128, 115, 0.34);
}

.head-diagram .custom-zone.active {
    border-color: var(--primary);
    background: rgba(227, 229, 79, 0.22);
    box-shadow: 0 0 12px rgba(227, 229, 79, 0.28);
}

.head-diagram .custom-zone .cz-label {
    font-size: 0.55rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
    pointer-events: none;
    text-align: center;
}

.head-diagram .draw-preview {
    position: absolute;
    border: 2px dashed #878073;
    border-radius: 4px;
    background: rgba(135, 128, 115, 0.16);
    pointer-events: none;
}

.custom-zones-list {
    margin-top: 8px;
}

.custom-zone-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: .8rem;
}

.custom-zone-row .cz-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #878073;
    flex-shrink: 0;
}

.custom-zone-row .cz-name {
    flex: 1;
    font-weight: 600;
}

.custom-zone-row button {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: .7rem;
    cursor: pointer;
}

/* Donor Hair Block */
.donor-block {
    background: var(--bg);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px
}

.donor-block .section-title {
    margin-bottom: 8px
}

.donor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px
}

.donor-grid-reordered {
    margin-bottom: 12px
}

/* ═══ Kartoteka: Search, Client Cards, Detail View ═══ */

.search-bar {
    padding: 12px 20px
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: .95rem;
    background: var(--card);
    color: var(--text);
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='6.5' cy='6.5' r='5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3Cline x1='10' y1='10' x2='14' y2='14' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center
}

.client-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 0 20px 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .1s
}

.client-card:active {
    transform: scale(.98)
}

.client-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0
}

.client-info {
    flex: 1;
    min-width: 0
}

.client-info .name {
    font-weight: 700;
    font-size: .92rem;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35
}

.client-info .meta {
    font-size: .75rem;
    color: var(--text2);
    margin-top: 2px;
    overflow-wrap: anywhere
}

.client-price {
    font-weight: 800;
    color: var(--primary);
    font-size: 1rem;
    white-space: nowrap
}

.sync-badge {
    display: inline-flex;
    align-items: center;
    font-size: .64rem;
    padding: 3px 7px;
    border-radius: 999px;
    font-weight: 700;
    margin-left: 6px;
    white-space: nowrap;
    vertical-align: middle
}

.sync-ok {
    background: #d4edda;
    color: #155724
}

.sync-local {
    background: #fff3cd;
    color: #856404
}

.sync-photo-pending {
    background: rgba(10, 132, 255, .14);
    color: #0a84ff
}

.sync-photo-uploading {
    background: rgba(10, 132, 255, .14);
    color: #0a84ff
}

.sync-photo-local {
    background: rgba(255, 159, 10, .16);
    color: #b06200
}

.client-photo-status {
    margin-top: 5px;
    font-size: .71rem;
    color: var(--text2);
    line-height: 1.35
}

.reminder-badge {
    background: #fff0f0;
    color: #ff3b30;
    font-size: .7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    margin-top: 4px;
    display: inline-block
}

/* Detail view */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px
}

.detail-item {
    background: var(--bg);
    padding: 12px;
    border-radius: 12px
}

.detail-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px
}

.detail-section {
    background: var(--bg);
    border-radius: 14px;
    padding: 14px
}

.detail-section h4 {
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text2);
    margin-bottom: 10px
}

.detail-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
    align-items: flex-start
}

.detail-line:last-child {
    border-bottom: none;
    padding-bottom: 0
}

.detail-line .line-label {
    color: var(--text2);
    overflow-wrap: anywhere
}

.detail-line .line-value {
    color: var(--text);
    font-weight: 700;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 58%
}

.detail-item .label {
    font-size: .65rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text2);
    letter-spacing: 1px;
    margin-bottom: 4px
}

.detail-item .value {
    font-weight: 700;
    font-size: .9rem;
    color: var(--text)
}

.detail-full {
    grid-column: 1/-1
}

.detail-photos {
    display: flex;
    gap: 12px;
    margin-bottom: 16px
}

.detail-photo-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 12px;
    margin-bottom: 12px
}

.detail-photo {
    flex: 1;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    position: relative;
}

.detail-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover
}

.detail-photo .photo-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: .65rem;
    font-weight: 700;
    padding: 3px 0;
    background: rgba(0, 0, 0, .55);
    color: #fff;
}

.detail-photo .empty {
    color: var(--text2);
    font-size: .75rem;
    text-align: center;
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    padding: 14px
}

.detail-photo-empty {
    border: 1.5px dashed rgba(17, 17, 15, .18);
    background:
        linear-gradient(180deg, rgba(255, 255, 250, .9), rgba(255, 255, 250, .76)),
        radial-gradient(circle at top, rgba(227, 229, 79, .18), transparent 60%)
}

.detail-photo .empty-title {
    font-size: .82rem;
    font-weight: 800;
    color: var(--text)
}

.detail-photo .empty-sub {
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--primary-dark)
}

.detail-payment-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem
}

.detail-payment-row:last-child {
    border-bottom: none
}

.zone-detail {
    margin-bottom: 16px
}

.zone-detail h4 {
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary)
}

.zone-detail .row-info {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem
}

/* Service Color Dots */
.svc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    flex-shrink: 0
}

.svc-dot-ext {
    background: #e3e54f
}

.svc-dot-corr {
    background: #6d675e
}

.svc-dot-rem {
    background: #d89a2d
}

.svc-dot-col {
    background: #c7bf77
}

.svc-dot-cons {
    background: #9aa35a
}

.svc-dot-custom {
    background: #7d8695
}

/* Visit Status Badge */
.visit-badge {
    font-size: .65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700
}

.visit-new {
    background: rgba(227, 229, 79, .2);
    color: #6f7121
}

.visit-repeat {
    background: rgba(17, 17, 15, .08);
    color: #37352e
}

/* ═══ Stats & Dashboard ═══ */

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 20px;
    margin-bottom: 16px
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px
}

.stat-card .stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary)
}

.stat-card .stat-label {
    font-size: .7rem;
    color: var(--text2);
    font-weight: 600;
    margin-top: 2px
}

.chart-section {
    padding: 0 20px;
    margin-bottom: 20px
}

.chart-title {
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 12px
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px
}

.bar-label {
    width: 50px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text2);
    text-align: right;
    flex-shrink: 0
}

.bar-track {
    flex: 1;
    height: 28px;
    background: var(--bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative
}

.bar-fill {
    height: 100%;
    background: var(--grad);
    border-radius: 8px;
    transition: width .5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    min-width: 30px
}

.svc-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px
}

.svc-name {
    flex: 1;
    font-size: .85rem;
    font-weight: 600
}

.svc-count {
    font-size: .85rem;
    font-weight: 800;
    color: var(--primary)
}

.svc-bar {
    width: 80px;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden
}

.svc-bar-fill {
    height: 100%;
    background: var(--grad);
    border-radius: 3px
}

/* Dashboard */
.dash-section {
    padding: 0 20px;
    margin-bottom: 20px
}

.dash-section-title {
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px
}

.dash-upcoming {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.dash-appt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow)
}

.dash-appt .da-time {
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap
}

.dash-appt .da-info {
    flex: 1;
    min-width: 0
}

.dash-appt .da-name {
    font-weight: 700;
    font-size: .9rem
}

.dash-appt .da-svc {
    font-size: .75rem;
    color: var(--text2)
}

.dash-finance {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px
}

.dash-fin-card {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: var(--shadow)
}

.dash-fin-card .df-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary)
}

.dash-fin-card .df-label {
    font-size: .68rem;
    color: var(--text2);
    font-weight: 600;
    margin-top: 2px
}

@media (max-width: 640px) {
    .form-grid,
    .selector-grid,
    .selector-grid-wide,
    .donor-grid,
    .appt-time-grid {
        grid-template-columns: 1fr
    }

    .anketa-section summary {
        padding: 15px 16px 16px
    }

    .anketa-subsection {
        padding: 14px
    }

    .picker-shell.is-empty::after {
        right: 34px
    }

    .row-item-zone {
        grid-template-columns: repeat(2, minmax(0, 1fr)) 32px
    }

    .row-item-zone .row-label {
        grid-column: 1 / -1;
        text-align: left;
        min-width: 0
    }

    .row-item-zone .del-row {
        grid-column: 3;
        justify-self: end
    }
}

/* ═══ Profile ═══ */

.profile-card {
    margin: 20px;
    padding: 24px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center
}

.profile-avatar-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px
}

.profile-avatar {
    width: 88px;
    height: 88px;
    margin: 0 auto;
    border-radius: 24px;
    background: var(--grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    position: relative;
    overflow: hidden
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover
}

.profile-avatar-btn {
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: .78rem;
    font-weight: 700;
    padding: 8px 12px;
    cursor: pointer
}

.profile-name {
    font-size: 1.2rem;
    font-weight: 700
}

.profile-username {
    margin-top: 4px;
    font-size: .8rem;
    color: var(--text2)
}

.profile-role {
    font-size: .8rem;
    color: var(--text2)
}

.profile-phone {
    margin-top: 8px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text)
}

.profile-panel,
.profile-install-card,
.profile-sync-card {
    margin: 0 20px 14px;
    padding: 18px;
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow)
}

.profile-panel-head,
.profile-install-head {
    margin-bottom: 14px
}

.profile-panel-kicker,
.profile-install-kicker {
    display: inline-block;
    margin-bottom: 6px;
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--primary-dark);
    font-weight: 800
}

.profile-panel h3,
.profile-install-card h3 {
    font-size: .98rem;
    color: var(--text);
    margin-bottom: 4px
}

.profile-panel p,
.profile-install-card p {
    font-size: .8rem;
    line-height: 1.5;
    color: var(--text2)
}

.profile-save-btn,
.profile-install-btn {
    width: 100%;
    margin-top: 4px
}

.profile-sync-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px
}

.profile-sync-title {
    font-size: .98rem;
    font-weight: 800;
    color: var(--text)
}

.profile-sync-sub,
.profile-sync-text {
    font-size: .8rem;
    line-height: 1.5;
    color: var(--text2)
}

.profile-sync-pill {
    padding: 8px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    background: rgba(17, 17, 15, .08);
    color: var(--text2);
    white-space: nowrap
}

.profile-sync-pill.online {
    background: rgba(52, 199, 89, .14);
    color: #21864d
}

.profile-sync-pill.pending {
    background: rgba(255, 159, 10, .16);
    color: #b06200
}

.profile-sync-pill.offline {
    background: rgba(255, 59, 48, .12);
    color: #bf3127
}

.profile-sync-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px
}

.profile-sync-stat {
    padding: 12px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    text-align: center
}

.profile-sync-stat strong {
    display: block;
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--primary)
}

.profile-sync-stat span {
    display: block;
    margin-top: 4px;
    font-size: .72rem;
    line-height: 1.35;
    color: var(--text2)
}

.profile-sync-btn {
    margin-top: 8px
}

.settings-list {
    margin: 0 20px
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer
}

.settings-item .left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: .9rem
}

.settings-item .left .s-icon {
    font-size: 1.2rem
}

.toggle {
    width: 44px;
    height: 26px;
    border-radius: 13px;
    border: none;
    background: var(--border);
    position: relative;
    cursor: pointer;
    transition: background .2s
}

.toggle.on {
    background: var(--primary)
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15)
}

.toggle.on::after {
    transform: translateX(18px)
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px
}

.status-dot.online {
    background: #34c759
}

.status-dot.offline {
    background: #ff3b30
}

.btn-logout {
    width: calc(100% - 40px);
    margin: 20px;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: #ff3b30;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer
}

/* ═══ Components: Toast, Confirm, Install, Photo Viewer, Collage ═══ */

/* Toast */
#toast {
    position: fixed;
    top: calc(60px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) scale(.9);
    width: min(420px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
    background: var(--card);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .15);
    z-index: 110;
    opacity: 0;
    transition: all .3s;
    pointer-events: none;
    font-size: .85rem;
    font-weight: 600;
    border: 1px solid var(--border);
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.4
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) scale(1)
}

/* Confirm Modal */
#confirmModal {
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s, visibility .2s
}

#confirmModal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto
}

#confirmModal .cm-box {
    background: var(--card);
    border-radius: 20px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .2);
    border: 1px solid var(--border);
    text-align: center;
    transform: scale(.9);
    transition: transform .2s
}

#confirmModal.show .cm-box {
    transform: scale(1)
}

#confirmModal .cm-icon {
    font-size: 2.5rem;
    margin-bottom: 8px
}

#confirmModal .cm-text {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text)
}

#confirmModal .cm-btns {
    display: flex;
    gap: 10px
}

#confirmModal .cm-cancel {
    flex: 1;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: none;
    color: var(--text2);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer
}

#confirmModal .cm-danger {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: #ff3b30;
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer
}

/* PWA Install Banner */
#installBanner {
    position: fixed;
    bottom: 90px;
    left: 16px;
    right: 16px;
    z-index: 200;
    background: var(--card);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    transform: translateY(120%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), visibility .4s;
}

#installBanner.show {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
}

#installBanner .ib-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
}

#installBanner .ib-body {
    flex: 1;
    min-width: 0;
}

#installBanner .ib-title {
    font-weight: 800;
    font-size: .95rem;
    color: var(--text);
    margin-bottom: 2px;
}

#installBanner .ib-sub {
    font-size: .78rem;
    color: var(--text2);
}

#installBanner .ib-btn {
    flex-shrink: 0;
    padding: 10px 18px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
}

#installBanner .ib-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
}

/* iOS Install Modal */
#iosInstallModal {
    position: fixed;
    inset: 0;
    z-index: 210;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s, visibility .2s;
}

#iosInstallModal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#iosInstallModal .ios-box {
    background: var(--card);
    border-radius: 20px;
    padding: 28px 24px;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .2);
    border: 1px solid var(--border);
    text-align: center;
}

#iosInstallModal .ios-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

#iosInstallModal .ios-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 12px;
}

#iosInstallModal .ios-step {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
    color: var(--text);
}

#iosInstallModal .ios-step:last-of-type {
    border-bottom: none;
}

#iosInstallModal .ios-step .step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .8rem;
    flex-shrink: 0;
}

#iosInstallModal .ios-close {
    margin-top: 16px;
    padding: 12px 28px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: none;
    color: var(--text2);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
}


/* Photo viewer modal */
#photoViewer {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, .9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s, visibility .2s
}

#photoViewer.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto
}

.photo-viewer-inner {
    width: min(100%, 560px);
    height: 100dvh;
    max-height: 100dvh;
    padding: max(12px, env(safe-area-inset-top)) 16px calc(16px + var(--safe-b));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px
}

.photo-viewer-media {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center
}

#photoViewer img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    object-fit: contain
}

#photoViewer .controls {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    position: sticky;
    bottom: 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, .66) 30%, rgba(0, 0, 0, .88) 100%)
}

#photoViewer button {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer
}

.btn-download {
    background: var(--primary);
    color: #fff
}

.btn-close-photo {
    background: rgba(255, 255, 255, .15);
    color: #fff
}

/* Crop modal */
#photoCropModal {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, .78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s, visibility .2s
}

#photoCropModal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto
}

.photo-crop-sheet {
    width: min(100%, 560px);
    max-height: min(92vh, 920px);
    padding: 16px;
    border-radius: 24px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 22px 48px rgba(0, 0, 0, .24);
    display: flex;
    flex-direction: column;
    gap: 14px
}

.photo-crop-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start
}

.photo-crop-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text)
}

.photo-crop-sub {
    margin-top: 4px;
    font-size: .78rem;
    line-height: 1.45;
    color: var(--text2)
}

.photo-crop-close {
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer
}

.photo-crop-stage {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 20px;
    overflow: hidden;
    background: #11110f
}

#photoCropCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none
}

.photo-crop-frame {
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, .34), inset 0 0 0 2px rgba(255, 255, 255, .78);
    border-radius: 20px
}

.photo-crop-frame.square {
    width: 72%;
    height: auto;
    aspect-ratio: 1;
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .34), 0 0 0 2px rgba(255, 255, 255, .78)
}

.photo-crop-controls {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.photo-crop-range {
    display: grid;
    gap: 8px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text)
}

.photo-crop-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px
}

.photo-crop-btn {
    min-height: 46px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer
}

.photo-crop-btn-ghost {
    background: transparent;
    color: var(--text)
}

.photo-crop-btn-primary {
    background: var(--grad);
    border-color: transparent;
    color: var(--primary)
}

@media (max-width: 640px) {
    .detail-photos {
        gap: 10px
    }

    .detail-photo {
        aspect-ratio: .82
    }

    .photo-viewer-inner {
        padding: max(10px, env(safe-area-inset-top)) 12px calc(12px + var(--safe-b))
    }

    #photoViewer .controls {
        grid-template-columns: 1fr
    }

    .profile-sync-grid {
        grid-template-columns: 1fr
    }

    .photo-crop-actions {
        grid-template-columns: 1fr
    }
}

/* Collage modal */
#collageModal {
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(0, 0, 0, .9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s, visibility .2s
}

#collageModal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto
}

#collageModal canvas {
    max-width: 95%;
    max-height: 60vh;
    border-radius: 14px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .32)
}

#collageModal .controls {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: min(100%, 720px)
}

.collage-btn {
    min-height: 50px;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
    font-weight: 800;
    font-size: .88rem;
    cursor: pointer;
    transition: transform .15s ease, opacity .15s ease, border-color .15s ease, background .15s ease
}

.collage-btn:active {
    transform: scale(.98)
}

.collage-btn-primary {
    background: linear-gradient(135deg, #f5f06a 0%, #d6d841 100%);
    color: #19180f;
    box-shadow: 0 14px 28px rgba(227, 229, 79, .22)
}

.collage-btn-secondary {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border-color: rgba(255, 255, 255, .16)
}

.collage-btn-ghost {
    background: rgba(255, 255, 255, .04);
    color: rgba(255, 255, 255, .84);
    border-color: rgba(255, 255, 255, .12)
}

@media (max-width: 640px) {
    #collageModal .controls {
        grid-template-columns: 1fr
    }
}

/* Photo upload */
.photo-upload {
    display: flex;
    gap: 12px
}

.photo-box {
    flex: 1;
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: border-color .2s;
    background: var(--bg)
}

.photo-box:hover {
    border-color: var(--primary)
}

.photo-box img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover
}

.photo-box .placeholder {
    text-align: center;
    color: var(--text2);
    font-size: .75rem
}

.photo-box .placeholder .emoji {
    font-size: 1.5rem;
    margin-bottom: 4px
}

/* Photo 3-slot + delete */
.photo-upload-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px
}

.photo-box .photo-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 59, 48, .9);
    color: #fff;
    border: none;
    font-size: .75rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2
}

.photo-box img~.photo-del {
    display: flex
}
