/* === Theme === */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --fg: #111827;
    --fg-muted: #6b7280;
    --fg-dim: #9ca3af;
    --accent: #2563eb;
    --accent-fg: #ffffff;
    --accent-soft: #dbeafe;
    --positive: #16a34a;
    --positive-soft: #dcfce7;
    --negative: #dc2626;
    --negative-soft: #fee2e2;
    --warning: #f59e0b;
    --slot-occupied-bg: #f3f4f6;
    --slot-occupied-fg: #9ca3af;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 -8px 32px rgba(0,0,0,0.12);
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* Глобально: атрибут [hidden] всегда скрывает элемент, даже если
   позже какой-то селектор задал display: flex / grid. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

button {
    font: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

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

/* === Header === */
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 0;
}
.title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.title-row h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.badge-dev { background: var(--warning); color: white; }
.badge-real { background: var(--positive); color: white; }

/* === Week nav === */
.week-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 4px;
}
.nav-arrow {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--fg);
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nav-arrow:active { background: var(--border); }
.week-label {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    text-transform: capitalize;
    user-select: none;
}
.nav-today {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.nav-today:active { background: var(--accent); color: var(--accent-fg); }
.nav-today[hidden] { display: none; }

/* === Week strip === */
.week-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    padding-bottom: 10px;
}
.day-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 6px;
    border-radius: var(--r-sm);
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.15s;
    position: relative;
}
.day-btn:active { background: var(--bg); }
.day-btn.today { color: var(--accent); }
.day-btn.selected {
    background: var(--accent);
    color: var(--accent-fg);
}
.day-btn .dow {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.7;
    text-transform: lowercase;
}
.day-btn .num {
    font-size: 16px;
    font-weight: 600;
    margin-top: 2px;
}
.day-btn .count-dot {
    position: absolute;
    bottom: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}
.day-btn.selected .count-dot { background: var(--accent-fg); }

/* === Content === */
.content {
    padding: 12px 16px calc(96px + var(--safe-bottom));
}
.empty {
    text-align: center;
    color: var(--fg-muted);
    margin: 48px 16px;
    line-height: 1.6;
}

/* === List view (карточки) === */
.appointments {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === Agenda (главный дневник) === */
/* Каждая строка = 10 мин. Высота строки SLOT_H px. */
.agenda {
    /* высота одного слота (SLOT_MIN мин). 15-мин шаг → 18px = 72px на час */
    --slot-h: 18px;
    position: relative;
    display: grid;
    grid-template-columns: 48px 1fr;
    column-gap: 8px;
}
.agenda-hour-label {
    grid-column: 1;
    font-size: 11px;
    color: var(--fg-muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
    padding-right: 4px;
    border-top: 1px solid var(--border);
    line-height: 1;
    padding-top: 2px;
}
.agenda-hour-label.subhour {
    color: transparent;
    border-top: 1px dashed var(--border);
}
/* Свободные кликабельные ячейки (по 10 минут каждая) */
.agenda-slot {
    grid-column: 2;
    border-top: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 4px;
    margin-right: 4px;
}
.agenda-slot:hover { background: var(--accent-soft); }
.agenda-slot:active { background: var(--accent); opacity: 0.3; }

/* Блок записи поверх свободных ячеек */
.agenda-appt {
    grid-column: 2;
    position: relative;
    margin: 1px 4px 1px 0;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    overflow: hidden;
    cursor: pointer;
    line-height: 1.15;
    display: flex;
    flex-direction: column;
    justify-content: center;     /* короткие блоки выравниваются по центру */
    gap: 1px;
}
.agenda-appt.status-NEW       { background: var(--accent-soft);    border-left-color: var(--accent); }
.agenda-appt.status-CONFIRMED { background: var(--positive-soft);  border-left-color: var(--positive); }
.agenda-appt.status-COMPLETED { background: var(--bg);             border-left-color: var(--fg-muted); opacity: 0.85; }
.agenda-appt.status-CANCELLED { background: var(--negative-soft);  border-left-color: var(--negative); opacity: 0.5; text-decoration: line-through; }
.agenda-appt:active { filter: brightness(0.95); }

.agenda-appt .title {
    font-weight: 600;
    font-size: 12px;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.agenda-appt .meta {
    color: var(--fg-muted);
    font-size: 10.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.agenda-appt .phone {
    color: var(--fg-muted);
    font-size: 10.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Адаптация по высоте блока */
.agenda-appt.medium { justify-content: flex-start; padding-top: 4px; }
.agenda-appt.tall   { justify-content: flex-start; padding-top: 5px; }

/* === Old card (используется в модалке истории) === */
.card {
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--border-strong);
}
.card.status-NEW       { border-left-color: var(--accent); }
.card.status-CONFIRMED { border-left-color: var(--positive); }
.card.status-COMPLETED { border-left-color: var(--fg-muted); opacity: 0.85; }
.card.status-CANCELLED { border-left-color: var(--negative); opacity: 0.6; }
/* (.overdue стили убраны — функционал «незакрытые записи» в бэклоге) */

.card-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.card-time {
    font-size: 16px;
    font-weight: 700;
    min-width: 48px;
}
.card-status { font-size: 14px; }
.card-reminder { font-size: 14px; flex-shrink: 0; }
.card-name {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-cost {
    font-size: 14px;
    color: var(--fg-muted);
    font-variant-numeric: tabular-nums;
}
.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    color: var(--fg-muted);
    font-size: 13px;
}
.card-service-tag {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.card-phone {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.client-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--bg);
    border-radius: 999px;
    font-size: 12px;
    color: var(--fg-muted);
}
.client-chip:active { background: var(--border); }

.card-comment {
    margin-top: 6px;
    font-size: 13px;
    color: var(--fg-muted);
    font-style: italic;
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.action-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    background: var(--bg);
    color: var(--fg);
    transition: background 0.15s;
}
.action-btn:active { background: var(--border); }
.action-complete { background: var(--positive-soft); color: var(--positive); }
.action-cancel   { background: var(--negative-soft); color: var(--negative); flex: 0 0 auto; padding: 9px 14px; }

/* Inline-форма «Завершить» (в edit-form) */
.inline-complete {
    margin: 8px 0 12px;
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.inline-complete[hidden] { display: none !important; }
.inline-complete input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}
.inline-complete input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-color: var(--accent);
}
.inline-complete button#inline-complete-submit {
    padding: 10px 16px;
    background: var(--positive);
    color: white;
    border-radius: var(--r-sm);
    font-weight: 600;
}
.inline-complete button#inline-complete-submit:disabled { opacity: 0.5; }

/* Inline-подтверждение отмены */
.inline-cancel-confirm {
    margin: 8px 0 12px;
    padding: 10px 12px;
    background: var(--negative-soft);
    border-radius: var(--r-sm);
}
.inline-cancel-confirm[hidden] { display: none !important; }
.inline-cancel-confirm .confirm-text {
    display: block;
    color: var(--negative);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}
.inline-cancel-confirm .confirm-buttons {
    display: flex;
    gap: 8px;
}
.inline-cancel-confirm .confirm-buttons .action-btn { flex: 1; }

/* Предупреждение о завершении будущего визита: переиспользует разметку
   подтверждения отмены, но это предостережение, а не удаление — жёлтый, не красный. */
#future-complete-confirm { background: #fef3c7; }
#future-complete-confirm .confirm-text { color: #92400e; font-weight: 500; }

/* === Выход из статуса «Завершена» ===
   Показывается вместо .edit-actions у завершённых записей: раньше у них не было
   вообще никаких действий, и ошибка мастера становилась необратимой. */
.completed-actions { margin: 8px 0 12px; }
.completed-actions[hidden] { display: none !important; }
.action-uncomplete {
    width: 100%;
    background: var(--slot-occupied-bg);
    color: var(--fg);
}
.completed-actions-hint {
    margin: 8px 2px 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--fg-muted);
}

/* === FAB === */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(20px + var(--safe-bottom));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    box-shadow: var(--shadow-md);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}
.fab:active { transform: scale(0.94); }

/* === Bottom sheet === */
.sheet {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.sheet[hidden] { display: none; }
.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    animation: fadeIn 0.18s ease;
}
.sheet-body {
    position: relative;
    background: var(--surface);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
    animation: slideUp 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
    border-bottom: 1px solid var(--border);
}
.sheet-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--fg-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sheet-content {
    overflow-y: auto;
    padding: 16px;
}

@keyframes fadeIn { from {opacity:0;} to {opacity:1;} }
@keyframes slideUp { from {transform: translateY(100%);} to {transform: translateY(0);} }

/* === Sheet steps === */
.sheet-steps {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 0;
}
.step-pill {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--fg-muted);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.step-pill.active { background: var(--accent); color: var(--accent-fg); }
.step-pill.done { background: var(--positive); color: white; }
.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
}

/* === Form fields === */
.field {
    display: block;
    margin-bottom: 14px;
}
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg-muted);
    margin-bottom: 6px;
}
.hint-inline {
    font-weight: 400;
    color: var(--fg-dim);
    font-size: 12px;
}
/* Поле имени с dropdown — для абсолютного позиционирования */
.name-field-wrap {
    position: relative;
}

.field input:not([type="radio"]):not([type="checkbox"]),
.field textarea,
.field select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 15px;
}
.field select { appearance: auto; }
.field input:not([type="radio"]):not([type="checkbox"]):focus,
.field textarea:focus,
.field select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 60px; }

.hint {
    font-size: 13px;
    margin: -8px 0 14px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    background: var(--accent-soft);
    color: var(--accent);
}
.hint.muted { background: var(--bg); color: var(--fg-muted); }

/* Dropdown поиска клиентов по имени */
.name-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    max-height: 280px;
    overflow-y: auto;
    z-index: 10;
}
.name-dropdown[hidden] { display: none !important; }
.name-dropdown-header {
    padding: 6px 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--fg-muted);
    background: var(--bg);
}
.name-dropdown-item {
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}
.name-dropdown-item:first-child { border-top: none; }
.name-dropdown-item:hover { background: var(--bg); }
.name-dropdown-item:active { background: var(--accent-soft); }
.name-dropdown-item .primary {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
}
.name-dropdown-item .primary mark {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0 2px;
    border-radius: 3px;
}
.name-dropdown-item .secondary {
    font-size: 12px;
    color: var(--fg-muted);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.name-dropdown-empty {
    padding: 10px;
    text-align: center;
    color: var(--fg-muted);
    font-size: 13px;
}
.name-dropdown-new .primary { color: var(--accent); }
.name-dropdown-new .secondary { color: var(--fg-muted); }

/* === Плашка подписки клиента === */
.subscribe-plate {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font-size: 13px;
}
.subscribe-plate.ok {
    background: var(--positive-soft);
    color: var(--positive);
}
.subscribe-plate.warn {
    background: #fff7ed;
    color: #b45309;
}
.subscribe-text { flex: 1; }
.subscribe-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    border: none;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.subscribe-btn:active { opacity: 0.8; }
.subscribe-btn:disabled { opacity: 0.5; }

/* === Лист приглашения клиента === */
.invite-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.invite-tab {
    flex: 1;
    padding: 9px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    color: var(--fg-muted);
    cursor: pointer;
}
.invite-tab.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}
.invite-qr {
    display: flex;
    justify-content: center;
    padding: 12px 0;
}
.invite-qr img {
    width: 230px;
    height: 230px;
    image-rendering: pixelated;
    background: #fff;
    border-radius: var(--r-sm);
}
.invite-hint { font-size: 13px; color: var(--fg-muted); margin: 0 0 12px; }
.invite-text {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 12px;
}
#invite-copy-btn { width: 100%; }

/* Read-only форма (отменённые/завершённые записи) */
.time-summary:disabled {
    opacity: 0.6;
    cursor: default;
}
.time-summary:disabled .time-edit-hint { display: none; }
.field input:disabled,
.field textarea:disabled {
    opacity: 0.7;
    -webkit-text-fill-color: var(--fg);  /* iOS не делал текст бледным */
}

/* === Бейдж статуса записи в форме === */
.form-status-badge {
    padding: 10px 12px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}
.form-status-badge.cancelled {
    background: var(--negative-soft);
    color: var(--negative);
}
.form-status-badge.completed {
    background: var(--positive-soft);
    color: var(--positive);
}
.form-status-badge.confirmed {
    background: var(--accent-soft);
    color: var(--accent);
}

/* === Страница настроек === */
.settings-content { padding-bottom: 32px; }
.settings-row { display: flex; gap: 12px; }
.settings-row .field { flex: 1; }
#settings-save { width: 100%; margin-top: 8px; }
.settings-admin-link { width: 100%; margin-top: 20px; }

/* === Карточка баланса (в настройках) ===
   ВРЕМЕННО демонстрационная: логики списания нет, цифры статичные.
   Состояние задаётся классом на .billing-card — меняется только цвет рамки,
   сумма остаётся нейтральной (красная цифра тревожит даже когда всё хорошо). */
.billing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}
.billing-card.is-low  { border-color: var(--warning); }
.billing-card.is-zero { border-color: var(--negative); }

.billing-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.billing-name { font-size: 15px; font-weight: 600; }
.billing-subject { font-size: 13px; color: var(--fg-muted); }
/* Пометка «демо» — цифры выдуманные, а речь о деньгах: без неё мастер
   прочтёт карточку как реальный счёт. Убрать вместе с BILLING_DEMO,
   когда появится настоящий баланс. */
.billing-demo-badge { margin-left: auto; }

.billing-amount { font-size: 30px; font-weight: 600; line-height: 1; }
.billing-days { margin-top: 6px; font-size: 14px; color: var(--fg-muted); }
.billing-card.is-low  .billing-days { color: #b45309; }
.billing-card.is-zero .billing-days { color: var(--negative); }

.billing-topup { width: 100%; margin-top: 14px; }
.billing-rate {
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: var(--fg-dim);
}

/* === Обратная связь (в настройках) === */
.settings-feedback {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.settings-section-title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
}
.settings-section-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--fg-muted);
}
.settings-feedback #feedback-send { width: 100%; }

/* === Реферальная программа («Пригласить коллегу») === */
.settings-referral-btn { width: 100%; margin-top: 10px; }
.referral-status { text-align: center; margin-bottom: 14px; }
.referral-star {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 22px;
    margin-bottom: 6px;
}
.referral-star span { font-size: 14px; font-weight: 600; color: var(--fg); }
.referral-count { font-size: 15px; color: var(--fg); }
.referral-count b { font-size: 17px; }
.referral-next { margin-top: 4px; font-size: 13px; color: var(--fg-muted); }
#referral-copy-btn { width: 100%; }
#referral-qr-btn { width: 100%; margin-top: 8px; }
#referral-qr { margin-top: 12px; }

/* === Admin debug === */
.admin-debug {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.admin-debug .btn-secondary { width: 100%; }
.admin-debug-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--fg-muted);
}

/* === Buttons === */
.btn-primary {
    width: 100%;
    padding: 13px;
    background: var(--accent);
    color: var(--accent-fg);
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: 15px;
    transition: opacity 0.15s;
}
.btn-primary:disabled { opacity: 0.4; }
.btn-primary:active:not(:disabled) { opacity: 0.85; }

.btn-secondary {
    padding: 13px 18px;
    background: var(--bg);
    color: var(--fg);
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: 15px;
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.btn-row .btn-primary { flex: 1; }

/* === Form: время + длительность === */
.time-summary {
    width: 100%;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background 0.12s;
    border: none;
}
.time-summary:active { background: var(--accent); color: var(--accent-fg); }
.time-summary .dot { opacity: 0.5; }
.time-summary .time-edit-hint {
    margin-left: 6px;
    opacity: 0.5;
    font-size: 13px;
}

/* Time-picker (раскрывается под time-summary) */
.time-picker {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--r-md);
}
.time-picker[hidden] { display: none !important; }
.time-picker-hint {
    font-size: 12px;
    color: var(--fg-muted);
    margin-bottom: 8px;
    text-align: center;
}

/* Сетка длительности: часы (столбцы 0..5) × минуты (ряды :00 :15 :30 :45) */
.duration-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}
.duration-cell {
    padding: 9px 0;
    border-radius: var(--r-sm);
    background: var(--bg);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: background 0.12s;
    text-align: center;
}
.duration-cell:not(:disabled):active { background: var(--border); }
.duration-cell.selected { background: var(--accent); color: var(--accent-fg); }
.duration-cell:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    color: var(--fg-dim);
}

/* === Edit-actions (только в edit-режиме) === */
.edit-actions {
    display: flex;
    gap: 8px;
    margin: 8px 0 12px;
}
.edit-actions[hidden] { display: none; }
.edit-actions .action-btn { flex: 1; padding: 10px; }

/* === Date pills ===
   Лента дней в пикере даты формы: горизонтальный скролл на FORM_DATE_DAYS
   вперёд. Отрицательный margin — чтобы лента уходила под правый край
   контейнера и было видно, что она прокручивается. */
.date-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-right: -12px;
    padding-right: 12px;
    scrollbar-width: none;
}
.date-pills::-webkit-scrollbar { display: none; }
.date-pill {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    /* Не var(--bg): фон самого пикера тоже --bg, и таблетки слились бы с ним.
       Слоты времени внутри своей сетки читаются по позиции, а лента дней
       прокручивается — границы каждого дня должны быть видны. */
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    min-width: 56px;
}
.date-pill .dow { font-size: 10px; opacity: 0.7; text-transform: lowercase; }
.date-pill.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-fg);
}
.date-pill:active { background: var(--bg); }

/* === Time grid === */
.time-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    padding: 2px;
}
.slot {
    padding: 9px 0;
    border-radius: var(--r-sm);
    background: var(--bg);
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: background 0.12s;
}
.slot:active { background: var(--border); }
.slot.selected { background: var(--accent); color: var(--accent-fg); }
.slot.occupied {
    background: var(--slot-occupied-bg);
    color: var(--slot-occupied-fg);
    text-decoration: line-through;
    cursor: not-allowed;
}
/* Слот свободен, но выбранная длительность в него не помещается.
   Отличаем от занятого: без зачёркивания, просто приглушён. */
.slot.no-room {
    background: transparent;
    color: var(--fg-dim);
    opacity: .55;
    cursor: not-allowed;
}
/* Время уже прошло. Гасим сильнее, чем no-room: это не «не влезает сейчас»,
   а «выбрать нельзя в принципе» — запись задним числом запрещена. */
.slot.past {
    background: transparent;
    color: var(--fg-dim);
    opacity: .3;
    cursor: not-allowed;
}

/* === History list === */
.client-stats {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg);
    border-radius: var(--r-md);
    margin-bottom: 14px;
}
.stat {
    flex: 1;
    text-align: center;
}
.stat .num {
    font-size: 22px;
    font-weight: 700;
    color: var(--fg);
}
.stat .label {
    font-size: 11px;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.history-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.history-row:last-child { border-bottom: none; }
.history-row .h-date { min-width: 100px; color: var(--fg-muted); font-size: 13px; }
.history-row .h-status { font-size: 13px; }
.history-row .h-service { flex: 1; }
.history-row .h-cost { font-variant-numeric: tabular-nums; font-weight: 600; }

/* === Admin page (super-admin only) === */
.title-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-admin-btn,
.header-view-btn {
    width: 30px;
    height: 30px;
    font-size: 16px;
    background: var(--bg);
    color: var(--fg-muted);
}
.header-admin-btn:active,
.header-view-btn:active { background: var(--border); color: var(--fg); }

/* Бейдж просроченных был убран — функционал "незакрытые записи" в бэклоге */

.admin-page {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.admin-page[hidden] { display: none; }
@keyframes slideInRight {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.admin-page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}
.admin-page-header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    flex: 1;
}
.admin-back-btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
    background: transparent;
    color: var(--fg);
}
.admin-back-btn:active { background: var(--bg); }

.admin-page-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px calc(96px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Форма создания инвайта */
.invite-create-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.invite-create-form[hidden] { display: none !important; }
.invite-create-form h3 { margin: 0; font-size: 15px; }

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}
.radio-group input[type="number"] {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    margin-left: 4px;
}
.radio-group input[type="number"]:disabled {
    background: var(--bg);
    color: var(--fg-dim);
}

/* Метка статуса инвайта */
.invite-name-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 2px;
}
.invite-usage-stats {
    font-size: 11px;
    color: var(--fg-muted);
    margin-top: 2px;
}

/* Раскрывающийся список использований инвайта */
.invite-usages {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--surface);
    border-radius: var(--r-sm);
    font-size: 12px;
}
.invite-usages[hidden] { display: none !important; }
.invite-usages .usage-row {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    color: var(--fg-muted);
}
.invite-usages .usage-row:last-child { border-bottom: none; }
.invite-usages .usage-row .name { color: var(--fg); font-weight: 500; }

.view-usages-btn {
    padding: 4px 10px;
    border-radius: var(--r-sm);
    background: var(--bg);
    font-size: 12px;
    color: var(--fg-muted);
}
.view-usages-btn:active { background: var(--border); }

.admin-block h3 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg-muted);
}
.admin-block .muted { font-weight: 400; }

.invite-row, .master-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg);
    border-radius: var(--r-sm);
    margin-bottom: 6px;
    font-size: 13px;
}
.invite-row .grow, .master-row .grow {
    flex: 1;
    min-width: 0;
}
.invite-row code {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--fg-muted);
    word-break: break-all;
}
.invite-link-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.invite-link {
    flex: 1;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 11px;
    padding: 6px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.copy-btn, .revoke-btn {
    padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 600;
}
.copy-btn { background: var(--accent-soft); color: var(--accent); }
.copy-btn:active { background: var(--accent); color: white; }
.revoke-btn { background: var(--negative-soft); color: var(--negative); }
.revoke-btn:active { background: var(--negative); color: white; }

.master-row .name { font-weight: 600; }
.master-row .meta { color: var(--fg-muted); font-size: 12px; }

.admin-archive {
    margin-top: 4px;
}
.admin-archive summary {
    cursor: pointer;
    color: var(--fg-muted);
    font-size: 13px;
    padding: 8px 0;
}
.archive-row {
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--r-sm);
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--fg-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.archive-row .status-tag {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--surface);
}
.archive-row.used .status-tag { background: var(--positive-soft); color: var(--positive); }
.archive-row.revoked .status-tag { background: var(--negative-soft); color: var(--negative); }

/* === Auth screen (для незарегистрированных) === */
.auth-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 60;
}
.auth-screen[hidden] { display: none; }
.auth-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 32px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-md);
}
.auth-emoji {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 16px;
}
.auth-card h2 {
    margin: 0 0 8px;
    font-size: 19px;
}
.auth-card p {
    margin: 0 0 20px;
    color: var(--fg-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* === Toast === */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--fg);
    color: var(--surface);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 100;
    animation: toastIn 0.2s ease;
    max-width: 90vw;
}
.toast.toast-error { background: var(--negative); }
.toast.toast-success { background: var(--positive); }
@keyframes toastIn { from {opacity:0; transform: translate(-50%, -10px);} to {opacity:1; transform: translate(-50%, 0);} }
