/* =====================================================================
   Оформление магазина. Тёмная и светлая тема наследуются от Telegram,
   поверх лежит собственная система отступов, шрифтовых размеров и форм.
   ===================================================================== */

:root {
    /* поверхности */
    --bg: var(--tg-theme-bg-color, #0f1520);
    --surface: var(--tg-theme-section-bg-color, #182130);
    --surface-2: var(--tg-theme-secondary-bg-color, #131b28);
    --hairline: rgba(255, 255, 255, .07);
    --hairline-strong: rgba(255, 255, 255, .12);

    /* текст */
    --text: var(--tg-theme-text-color, #eef2f7);
    --text-2: var(--tg-theme-hint-color, #8b98a9);
    --text-3: rgba(139, 152, 169, .62);

    /* акцент */
    --accent: var(--tg-theme-button-color, #2f81f7);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);

    --positive: #2ea86a;
    --warning: #d99327;
    --negative: #e0524b;

    /* геометрия */
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-pill: 999px;

    --pad: 16px;
    --gap: 10px;

    --nav-h: 58px;
    --bar-h: 56px;

    --tg-safe-bottom: 0px;
    --safe-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--tg-safe-bottom));

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .18);
    --shadow-2: 0 8px 28px rgba(0, 0, 0, .28);

    --ease: cubic-bezier(.2, .7, .3, 1);
}

/* светлая тема получает более плотные разделители */
@media (prefers-color-scheme: light) {
    :root {
        --hairline: rgba(16, 24, 36, .09);
        --hairline-strong: rgba(16, 24, 36, .16);
        --shadow-1: 0 1px 2px rgba(16, 24, 36, .06);
        --shadow-2: 0 10px 30px rgba(16, 24, 36, .12);
    }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Inter", sans-serif;
    font-size: 15px;
    line-height: 1.45;
    letter-spacing: -.01em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ── иконки ────────────────────────────────────────────────────────── */

.ic {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}
.ic--sm { width: 16px; height: 16px; stroke-width: 1.9; }
.ic--lg { width: 24px; height: 24px; stroke-width: 1.6; }
.ic--xl { width: 34px; height: 34px; stroke-width: 1.4; }

/* ── каркас ────────────────────────────────────────────────────────── */

#app {
    display: flex;
    flex-direction: column;
    height: var(--app-height-px, 100dvh);
    max-height: 100dvh;
    overflow: hidden;
}

/* ── верхняя панель ────────────────────────────────────────────────── */

.topbar {
    flex: none;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 var(--pad);
    background: var(--bg);
    border-bottom: 1px solid var(--hairline);
}

.topbar__user { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand__logo {
    width: 32px; height: 32px;
    border-radius: 9px;
    object-fit: cover;
    flex: none;
    background: var(--surface);
}
.brand__name {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 44vw;
}

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--surface);
    background-size: cover;
    background-position: center;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 650;
    color: var(--text-2);
    flex: none;
    border: 1px solid var(--hairline);
}

.topbar__info { min-width: 0; }
.topbar__name {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -.015em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 40vw;
}
.topbar__role { font-size: 11px; color: var(--text-3); letter-spacing: .01em; }
.topbar__role.is-staff { color: var(--accent); font-weight: 600; }

.balance-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 13px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--hairline);
    font-size: 14px;
    font-weight: 640;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s var(--ease);
}
.balance-chip:active { background: var(--surface-2); }
.balance-chip .ic { color: var(--text-2); }

/* ── прокручиваемая область ────────────────────────────────────────── */

.view {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 14px var(--pad) 28px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 640;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-3);
    margin: 22px 2px 10px;
}
.section-title:first-child { margin-top: 2px; }

/* ── карточки ──────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 14px 15px;
    margin-bottom: var(--gap);
}

.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; letter-spacing: 0; }
.bold { font-weight: 640; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
.mb8 { margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace; font-size: .92em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ── кнопки ────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: var(--accent-text);
    font-size: 15px;
    font-weight: 620;
    letter-spacing: -.01em;
    cursor: pointer;
    transition: transform .1s var(--ease), opacity .15s, background .15s;
}
.btn:active { transform: scale(.985); opacity: .9; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn--block { display: flex; width: 100%; }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--hairline); }
.btn--danger { background: var(--negative); color: #fff; }
.btn--success { background: var(--positive); color: #fff; }
.btn--orange { background: var(--warning); color: #1b1200; }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:active { background: var(--surface); }
.btn--sm { height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 9px; }
.btn .ic { width: 18px; height: 18px; }

/* ── поля ──────────────────────────────────────────────────────────── */

.field { margin-bottom: 13px; }
.field__label {
    display: block;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--text-2);
    margin-bottom: 6px;
    letter-spacing: -.005em;
}

.input, .select, .textarea {
    width: 100%;
    height: 46px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    padding: 0 14px;
    outline: none;
    transition: border-color .15s, background .15s;
}
.textarea { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b98a9' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 9.5 12 15.5 18 9.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 17px;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.file-drop {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px dashed var(--hairline-strong);
    border-radius: var(--r-md);
    padding: 16px;
    color: var(--text-2);
    font-size: 13.5px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.file-drop.is-filled { border-color: var(--positive); border-style: solid; color: var(--positive); }
.file-drop input { display: none; }

.check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    font-size: 14.5px;
    cursor: pointer;
    border-bottom: 1px solid var(--hairline);
}
.check-row:last-child { border-bottom: 0; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* ── фильтры ───────────────────────────────────────────────────────── */

.chips {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 2px 0 6px;
    margin: 0 calc(var(--pad) * -1) 12px;
    padding-left: var(--pad);
    padding-right: var(--pad);
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--hairline);
    font-size: 13.5px;
    font-weight: 550;
    color: var(--text-2);
    white-space: nowrap;
    cursor: pointer;
    transition: all .15s var(--ease);
}
.chip.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}
.chip .ic { width: 16px; height: 16px; }

/* ── витрина ───────────────────────────────────────────────────────── */

.services { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }
@media (min-width: 560px) { .services { grid-template-columns: repeat(3, 1fr); } }

.service {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    cursor: pointer;
    transition: transform .12s var(--ease), border-color .15s;
}
.service:active { transform: scale(.985); border-color: var(--hairline-strong); }

.service__icon {
    width: 38px; height: 38px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 9px;
    background: var(--accent-soft);
    color: var(--accent);
}
.service__icon .ic { width: 21px; height: 21px; }

.service__name { font-weight: 620; font-size: 14.5px; letter-spacing: -.015em; }
.service__meta { font-size: 12px; color: var(--text-3); }
.service__price {
    margin-top: 11px;
    font-weight: 680;
    font-size: 15.5px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}
.service__old {
    font-size: 12px; color: var(--text-3);
    text-decoration: line-through; margin-left: 6px; font-weight: 450;
}
.service__badge {
    position: absolute; top: 12px; right: 12px;
    height: 20px; padding: 0 7px;
    display: inline-flex; align-items: center;
    border-radius: 6px;
    background: var(--negative);
    color: #fff;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
}

/* ── списки ────────────────────────────────────────────────────────── */

.list {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    overflow: hidden;
    margin-bottom: var(--gap);
}

.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--hairline);
    cursor: pointer;
    transition: background .12s;
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--surface-2); }

.list-item__icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-2);
    font-size: 14px; font-weight: 620;
    flex: none;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}
.list-item__title { font-weight: 600; font-size: 14.5px; letter-spacing: -.012em; }
.list-item__sub { font-size: 12.5px; color: var(--text-2); }
.list-item__right { margin-left: auto; text-align: right; flex: none; }
.list-item__chevron { color: var(--text-3); margin-left: 2px; }

/* ── метки ─────────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 21px;
    padding: 0 8px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--text-2) 14%, transparent);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 620;
    white-space: nowrap;
    letter-spacing: -.005em;
}
.badge--green { background: color-mix(in srgb, var(--positive) 16%, transparent); color: var(--positive); }
.badge--orange { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.badge--red { background: color-mix(in srgb, var(--negative) 16%, transparent); color: var(--negative); }
.badge--blue { background: var(--accent-soft); color: var(--accent); }

/* ── показатели ────────────────────────────────────────────────────── */

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }
.stat {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 14px 15px;
}
.stat__icon { color: var(--text-3); margin-bottom: 9px; }
.stat__value {
    font-size: 21px; font-weight: 680;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.stat__label { font-size: 12px; color: var(--text-2); margin-top: 3px; }

.bar { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 7px; }
.bar__fill { height: 100%; background: var(--accent); border-radius: 3px; }

/* ── баланс ────────────────────────────────────────────────────────── */

.balance-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    padding: 20px;
    margin-bottom: var(--gap);
    overflow: hidden;
}
.balance-card::after {
    content: '';
    position: absolute; inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent 70%);
}
.balance-card__label {
    font-size: 12px; color: var(--text-2);
    text-transform: uppercase; letter-spacing: .07em; font-weight: 600;
}
.balance-card__value {
    font-size: 31px; font-weight: 700;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums;
    margin: 7px 0 16px;
}
.balance-card__row { display: flex; gap: 22px; font-size: 12.5px; color: var(--text-2); }
.balance-card__row b { color: var(--text); font-weight: 600; }

/* ── реквизиты ─────────────────────────────────────────────────────── */

.card-item {
    background: var(--surface);
    border: 1.5px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 15px;
    margin-bottom: 9px;
    cursor: pointer;
    transition: border-color .15s;
}
.card-item.is-selected { border-color: var(--accent); }
.card-item__number {
    font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .04em;
    margin: 9px 0 3px;
}

/* ── нижняя навигация ──────────────────────────────────────────────── */

.tabbar {
    flex: none;
    display: flex;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg);
    border-top: 1px solid var(--hairline);
}

.tab {
    flex: 1;
    min-width: 0;
    border: 0;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    color: var(--text-3);
    cursor: pointer;
    position: relative;
    transition: color .15s;
}
.tab .ic { width: 21px; height: 21px; stroke-width: 1.65; }
.tab__label {
    font-size: 9.5px;
    font-weight: 560;
    letter-spacing: -.005em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.tab.is-active { color: var(--accent); }
.tab.is-active .ic { stroke-width: 2; }

.tab__dot {
    position: absolute;
    top: 6px; left: 50%;
    transform: translateX(4px);
    min-width: 15px; height: 15px;
    border-radius: 8px;
    background: var(--negative);
    color: #fff;
    font-size: 9.5px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg);
}

/* ── шторка ────────────────────────────────────────────────────────── */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: flex-end;
    animation: fade .16s var(--ease);
}
.sheet {
    width: 100%;
    max-height: calc(var(--app-height-px, 100dvh) - 24px);
    overflow-y: auto;
    background: var(--bg);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-top: 1px solid var(--hairline-strong);
    padding: 8px var(--pad) calc(24px + var(--safe-bottom));
    animation: slideUp .26s var(--ease);
}
.sheet__handle {
    width: 34px; height: 4px;
    background: var(--hairline-strong);
    border-radius: 2px;
    margin: 5px auto 16px;
}
.sheet__title { font-size: 19px; font-weight: 680; letter-spacing: -.03em; }
.sheet__sub { font-size: 13px; color: var(--text-2); margin: 3px 0 16px; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(12%); opacity: .6 } to { transform: translateY(0); opacity: 1 } }

/* ── состояния ─────────────────────────────────────────────────────── */

.loader { display: flex; justify-content: center; padding: 56px 0; }
.spinner {
    width: 24px; height: 24px;
    border: 2.5px solid var(--hairline-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.empty { text-align: center; padding: 52px 24px; color: var(--text-2); }
.empty__icon {
    width: 58px; height: 58px;
    margin: 0 auto 14px;
    border-radius: var(--r-md);
    background: var(--surface);
    border: 1px solid var(--hairline);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
}
.empty .bold { color: var(--text); font-size: 15.5px; }

.toast {
    position: fixed;
    left: var(--pad); right: var(--pad);
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 9px;
    background: #10161f;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--r-sm);
    padding: 13px 15px;
    font-size: 14px;
    box-shadow: var(--shadow-2);
    animation: fade .18s var(--ease);
}
.toast--error { background: #3a1512; border-color: rgba(224, 82, 75, .4); }
.toast--success { background: #10261b; border-color: rgba(46, 168, 106, .4); }

.search { display: flex; gap: 8px; margin-bottom: 12px; }
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }

.skeleton {
    background: linear-gradient(100deg,
        var(--surface) 30%,
        color-mix(in srgb, var(--surface) 70%, var(--text-3)) 45%,
        var(--surface) 60%);
    background-size: 300% 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: var(--r-md);
    height: 68px;
    margin-bottom: 9px;
}
@keyframes shimmer { from { background-position: 150% 0 } to { background-position: -50% 0 } }

.kv { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--hairline); }
.kv__k { color: var(--text-2); flex: none; }
.kv__v { font-weight: 550; text-align: right; word-break: break-word; }

.copyable { cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.copyable:active { opacity: .55; }
.copyable .ic { width: 14px; height: 14px; color: var(--text-3); }

/* ── свёртки ───────────────────────────────────────────────────────── */

details.box {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 14px 15px;
    margin-bottom: 11px;
}
details.box > summary {
    cursor: pointer;
    font-weight: 620;
    font-size: 14.5px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 9px;
}
details.box > summary::-webkit-details-marker { display: none; }
details.box > summary .ic--chev { margin-left: auto; color: var(--text-3); transition: transform .2s var(--ease); }
details.box[open] > summary .ic--chev { transform: rotate(180deg); }
details.box > div { padding-top: 15px; }

/* ── выбор значка услуги ───────────────────────────────────────────── */

.icon-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icon-opt {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-sm);
    background: var(--surface);
    border: 1.5px solid var(--hairline);
    color: var(--text-2);
    cursor: pointer;
}
.icon-opt.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── логотип в настройках ──────────────────────────────────────────── */

.logo-box {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 14px;
    margin-bottom: 11px;
}
.logo-box__img {
    width: 58px; height: 58px;
    border-radius: var(--r-sm);
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    flex: none;
}
.logo-box__empty {
    width: 58px; height: 58px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px dashed var(--hairline-strong);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    flex: none;
}
