:root {
    --bg1: #667eea;
    --bg2: #764ba2;
    --card: #ffffff;
    --text: #2d3748;
    --muted: #718096;
    --border: #e2e8f0;
    --primary: #667eea;
    --primary2: #764ba2;
    --success: #48bb78;
    --success-soft: #f0fff4;
    --danger: #e53e3e;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --t-fast: 140ms;
    --t-med: 220ms;
    --t-slow: 320ms;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
    min-height: 100vh;
    color: var(--text);
}

a {
    color: inherit;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
}

/* Чтобы кнопки в шапке не вылезали за рамки Mini App (без горизонтального скролла) */
.topbar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    min-width: 0;
}

.topbar-actions .pill {
    max-width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.brand-title {
    font-weight: 800;
    letter-spacing: 0.2px;
    font-size: 1.25rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--primary2);
    background: #eef2ff;
    padding: 10px 14px;
    border-radius: 999px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.25);
    transition: transform 0.2s ease, background 0.2s ease;
    white-space: nowrap;
}

.pill:hover {
    transform: translateY(-1px);
    background: #e0e7ff;
}

.topbar .pill {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.card {
    background: var(--card);
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.stack {
    display: grid;
    gap: 14px;
}

.hero {
    display: grid;
    gap: 8px;
}

.hero h1 {
    margin: 0;
    font-size: 1.65rem;
}

.muted {
    color: var(--muted);
    line-height: 1.45;
}

.hero-description {
    font-size: 1.05rem;
    color: var(--muted);
    line-height: 1.5;
    margin: 6px 0 0
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #edf2ff;
    border: 1px solid rgba(102, 126, 234, 0.25);
    color: #2d3748;
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.1;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.2;
    text-decoration: none;
    background: #f7fafc;
    color: var(--text);
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.18);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary2) 100%);
    color: #fff;
    border: none;
    box-shadow: 0 10px 22px rgba(102, 126, 234, 0.22);
}

.btn-primary:hover {
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.32);
}

.btn-danger {
    background: rgba(229, 62, 62, 0.08);
    border-color: rgba(229, 62, 62, 0.35);
    color: var(--danger);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-title h2 {
    margin: 0;
    font-size: 1.25rem;
}

.service-list {
    display: grid;
    gap: 10px;
}

.service-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 2px solid var(--border);
    background: #f7fafc;
    cursor: pointer;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.service-item:hover {
    transform: translateY(-1px);
    border-color: rgba(102, 126, 234, 0.55);
    box-shadow: 0 10px 22px rgba(102, 126, 234, 0.12);
}

.service-item.is-selected {
    border-color: var(--primary);
    background: #edf2ff;
}

.service-item.with-check {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 12px;
}

.service-body {
    display: grid;
    gap: 6px;
}

.service-check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: transparent;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.service-check::before {
    content: '✓';
}

.service-item.with-check:hover {
    border-color: rgba(72, 187, 120, 0.45);
    box-shadow: 0 10px 22px rgba(72, 187, 120, 0.12);
}

.service-item.with-check.is-selected {
    border-color: var(--success);
    background: var(--success-soft);
    box-shadow: 0 12px 26px rgba(72, 187, 120, 0.16);
}

.service-item.with-check.is-selected .service-check {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(72, 187, 120, 0.2);
}

.service-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.service-title strong {
    font-size: 1rem;
}

.service-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.93rem;
}

.search {
    width: 100%;
    display: flex;
    gap: 10px;
}

.input {
    width: 100%;
    padding: 14px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
}

/* iOS Safari иногда даёт date-input больше контейнера */
input[type="date"],
select,
input {
    max-width: 100%;
}

.date-input {
    max-width: 320px;
}

.input:focus {
    border-color: rgba(102, 126, 234, 0.75);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.18);
}

.bottom-bar {
    position: sticky;
    bottom: 0;
    z-index: 30;
    padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
    background: transparent;
}

.bottom-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(226, 232, 240, 0.92);
    background: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
    transition: box-shadow var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}

.bottom-card .btn-primary {
    min-width: 170px;
    padding: 15px 24px;
    border-radius: 14px;
    background: linear-gradient(135deg, #7088f3 0%, #7b5bd1 100%);
    box-shadow: 0 12px 22px rgba(102, 126, 234, 0.26);
    border: 1px solid rgba(102, 126, 234, 0.28);
    font-size: 1.08rem;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}

.bottom-card .btn-primary:disabled {
    background: linear-gradient(135deg, #d5dcfb 0%, #d6ccf6 100%);
    color: #7483c2;
    border-color: rgba(116, 131, 194, 0.55);
    box-shadow: none;
}

.summary {
    display: grid;
    gap: 4px;
}

.summary strong {
    font-size: 0.98rem;
}

.summary span {
    color: var(--muted);
    font-size: 0.92rem;
}

.slots {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.slot {
    padding: 12px 10px;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: #f7fafc;
    cursor: pointer;
    font-weight: 800;
    text-align: center;
}

.slot.is-selected {
    border-color: var(--primary);
    background: #edf2ff;
}

.hr {
    height: 1px;
    background: var(--border);
    border: 0;
    margin: 6px 0;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal.is-open {
    display: flex;
}

/* prevent background scrolling when modal is open (Telegram/iOS) */
body.modal-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.sheet {
    width: 100%;
    max-width: 680px;
    background: #fff;
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
    /* allow scrolling inside sheet instead of the page behind it */
    max-height: calc(100vh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.sheet h3 {
    margin: 0;
    font-size: 1.2rem;
}

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

.sheet-actions {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.empty {
    text-align: center;
    padding: 18px 10px;
    color: var(--muted);
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .actions {
        grid-template-columns: 1fr;
    }

    .slots {
        grid-template-columns: repeat(2, 1fr);
    }
}

.tg-required {
    background: rgba(0,0,0,0.25);
    color: #fff;
    padding: 12px 14px;
    border-radius: 14px;
    margin: 12px 0;
    font-weight: 700;
}


.field {
    display: grid;
    gap: 8px;
}

.label {
    font-weight: 800;
    font-size: 0.95rem;
}

textarea.input {
    resize: vertical;
    min-height: 110px;
    line-height: 1.45;
}

.bottom-summary {
    color: var(--muted);
}

.skeleton {
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(90deg, rgba(226,232,240,0.55) 25%, rgba(226,232,240,0.95) 37%, rgba(226,232,240,0.55) 63%);
    background-size: 400% 100%;
    animation: dl_skeleton 1.2s ease-in-out infinite;
    color: rgba(45,55,72,0.85);
    font-weight: 800;
}

@keyframes dl_skeleton {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.client {
    display: grid;
    gap: 10px;
}

.client-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f7fafc;
}

.booking-list {
    display: grid;
    gap: 10px;
}

.booking-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: #f7fafc;
}

.booking-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
}

.booking-sub {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
}

.booking-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-small {
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 0.95rem;
}

.confirm {
    display: grid;
    gap: 10px;
}

.confirm-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #f7fafc;
}

.confirm-services {
    display: grid;
    gap: 6px;
}

.error {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(229, 62, 62, 0.35);
    background: rgba(229, 62, 62, 0.08);
    color: var(--danger);
    font-weight: 800;
    display: none;
}

.error.is-visible {
    display: block;
}

.success-icon {
    font-size: 2.2rem;
}

.success-title {
    margin: 10px 0 0;
    font-size: 1.55rem;
}

code {
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(102,126,234,0.12);
}

@media (max-width: 520px) {
    .client-row,
    .confirm-row {
        grid-template-columns: 1fr;
    }
}


.bottom-card .btn-primary:hover {
    box-shadow: 0 14px 26px rgba(102, 126, 234, 0.32);
    transform: translateY(-1px);
}

.bottom-card .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 10px 18px rgba(102, 126, 234, 0.24);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Admin availability UI --- */

#availability-content .field,
#availability-content .input {
    min-width: 0;
}

/* Make quick dates look consistent on different devices (no odd single column) */
#availability-content .chips {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 420px) {
    #availability-content .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 720px) {
    #availability-content .chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.chip {
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.72);
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}

#availability-content .chip {
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* iOS date inputs sometimes overflow their container */
#availability-content .field {
    overflow: hidden;
}

#availability-content input[type="date"] {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(0,0,0,0.10);
}

.chip.is-active {
    /* активная дата должна быть заметной */
    border-color: rgba(40, 167, 69, 0.60);
    background: linear-gradient(135deg, rgba(51, 187, 98, 0.92) 0%, rgba(26, 152, 83, 0.92) 100%);
    color: #fff;
    box-shadow: 0 12px 22px rgba(40, 167, 69, 0.20);
}

.time-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

@media (max-width: 520px) {
    .time-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.time-btn {
    border: 1px solid var(--border);
    /* по умолчанию считаем слот выключенным (закрыт) */
    border-color: rgba(220, 53, 69, 0.28);
    background: rgba(220, 53, 69, 0.07);
    color: rgba(154, 28, 38, 0.95);
    padding: 10px 10px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}

.time-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(0,0,0,0.10);
}

.time-btn.is-on {
    /* включенный слот (доступен) */
    border-color: rgba(40, 167, 69, 0.55);
    background: rgba(40, 167, 69, 0.18);
    color: rgba(15, 110, 55, 0.98);
    box-shadow: 0 10px 18px rgba(40, 167, 69, 0.16);
}
