:root {
    --bg: #08050f;
    --surface: rgba(28, 18, 56, 0.55);
    --stroke: rgba(154, 108, 255, 0.22);
    --stroke-strong: rgba(168, 128, 255, 0.45);
    --violet: #8b5cf6;
    --violet-bright: #a78bfa;
    --magenta: #d946ef;
    --text: #ece7ff;
    --text-dim: #9a90bf;
    --safe-top: 0px;
    --safe-bottom: 0px;
    --gutter: clamp(14px, 4.5vw, 32px);
    --app-h: 100dvh;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: var(--app-h, 100dvh);
    min-height: var(--app-h, 100dvh);
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.35;
    user-select: none;
    -webkit-user-select: none;
}

.bg-grid,
.bg-glow {
    position: fixed;
    pointer-events: none;
    z-index: 0;
}

.bg-grid {
    inset: 0;
    background-image:
        linear-gradient(rgba(139, 92, 246, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139, 92, 246, 0.07) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 20%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 20%, transparent 85%);
}

.bg-glow {
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.5;
}

.bg-glow--one {
    top: -180px;
    left: -140px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.85), transparent 68%);
}

.bg-glow--two {
    bottom: -220px;
    right: -160px;
    background: radial-gradient(circle, rgba(217, 70, 239, 0.55), transparent 68%);
}

.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    min-height: var(--app-h, 100dvh);
    height: var(--app-h, 100dvh);
    padding-top: var(--safe-top);
}

.screens {
    flex: 1;
    min-height: 0;
    padding: 10px var(--gutter) calc(72px + var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen { display: none; animation: fade-up 0.28s ease; }
.screen--active { display: block; }

@keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 12px;
}

.section-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.section-count {
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    font-size: 12px;
    font-weight: 700;
    color: var(--violet-bright);
    background: rgba(139, 92, 246, 0.14);
}

.tabbar--hidden {
    opacity: 0;
    transform: translateY(28px);
    pointer-events: none;
}

.tabbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    justify-content: center;
    padding: 0 28px calc(10px + var(--safe-bottom));
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.32s ease;
}

.tabbar__glass {
    pointer-events: auto;
    display: flex;
    width: min(236px, calc(100% - 48px));
    padding: 3px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--stroke-strong);
}

.tabbar__glass.has-admin {
    width: min(288px, calc(100% - 36px));
}

.tabbar__btn {
    appearance: none;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 40px;
    padding: 4px 10px 5px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 9px;
    font-weight: 700;
}

.tabbar__btn svg { width: 16px; height: 16px; }
.tabbar__btn.is-active { color: var(--violet-bright); }
.tabbar__btn[hidden] { display: none !important; }

.userbot-card {
    padding: 18px 16px 20px;
    border-radius: 18px;
    border: 1px solid var(--stroke);
    background: rgba(12, 8, 26, 0.55);
}

.userbot-card + .userbot-card { margin-top: 12px; }

.userbot-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 8px 8px 16px;
}

.userbot-status__name {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
}

.userbot-status__meta {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
}

.userbot-hint {
    margin: 10px 0 0;
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.45;
}

.field + .userbot-hint,
.card-switch + .userbot-hint,
.watch-add + .userbot-hint,
.watch-chips + .userbot-hint {
    margin-top: 8px;
}

.userbot-hint ~ .btn {
    margin-top: 12px;
}

.userbot-hint ~ .btn + .btn {
    margin-left: 8px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field__label {
    padding-left: 2px;
    font-size: 12px;
    color: var(--text-dim);
}

.field__input {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: rgba(12, 8, 26, 0.6);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    outline: none;
}

.field__input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.field__input:focus {
    border-color: var(--violet-bright);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.field__phone {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.field__prefix {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: rgba(12, 8, 26, 0.6);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.field__input--phone {
    flex: 1 1 auto;
    letter-spacing: 1.5px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid var(--stroke-strong);
    border-radius: 15px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--text);
    background: var(--surface);
}

.btn--line {
    background: transparent;
    box-shadow: none;
}

.btn--danger {
    border-color: transparent;
    background: rgba(239, 68, 68, 0.92);
}

.btn--sm {
    min-height: 40px;
    font-size: 14px;
    border-radius: 12px;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.45;
    pointer-events: none;
}

.btn:active { transform: scale(0.95); }

.form > button[type="submit"] {
    align-self: center;
    min-width: 168px;
}

.card-switch {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: rgba(12, 8, 26, 0.85);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 650;
}

.card-switch__track {
    position: relative;
    width: 36px;
    height: 20px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: rgba(167, 139, 250, 0.42);
    border: 1px solid rgba(167, 139, 250, 0.55);
}

.card-switch__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ece7ff;
    transition: transform 0.18s ease;
}

.card-switch.is-on .card-switch__track {
    background: #a855f7;
    border-color: transparent;
}

.card-switch.is-on .card-switch__track::after {
    transform: translateX(16px);
    background: #1a1028;
}

.watch-add {
    display: flex;
    gap: 8px;
}

.watch-add .field__input { flex: 1 1 auto; }

.watch-add .btn {
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
    padding: 0;
}

.watch-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.watch-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 6px 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--stroke-strong);
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}

.watch-chip button {
    appearance: none;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1;
}

.watch-dialogs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(68vh, 720px);
    overflow-y: auto;
    margin-top: 12px;
    padding-bottom: 4px;
}

.watch-dialog {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 76px;
    padding: 10px 12px 10px 10px;
    text-align: left;
    border-radius: 18px;
    border: 1px solid var(--stroke);
    background: rgba(16, 10, 32, 0.55);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.watch-dialog.is-on {
    border-color: rgba(168, 128, 255, 0.7);
    background: rgba(139, 92, 246, 0.16);
}

.chat-ava {
    position: relative;
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
    border-radius: 50%;
    overflow: hidden;
    background: hsl(var(--hue, 260) 55% 42%);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.watch-dialog.is-on .chat-ava {
    box-shadow: 0 0 0 2px #a78bfa;
}

.chat-ava i {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-style: normal;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    letter-spacing: 0.02em;
}

.chat-ava img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.watch-dialog__mark {
    display: none;
}

.watch-dialog__text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.watch-dialog__text b {
    font-size: 16px;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.watch-dialog__text i {
    font-style: normal;
    font-size: 13px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.watch-dialog__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex: 0 0 auto;
}

.watch-dialog__kind {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
}

.watch-dialog.is-on .watch-dialog__kind {
    color: var(--violet-bright);
}

.watch-unread {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #a855f7;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: grid;
    place-items: center;
}

.watch-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--stroke-strong);
}

.watch-dialog.is-on .watch-check {
    border-color: transparent;
    background: #a855f7;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E");
    background-size: 12px;
    background-repeat: no-repeat;
    background-position: center;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: var(--surface);
    color: var(--violet-bright);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.account-wrap {
    position: relative;
}

.account-card {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 40px 14px 14px;
    text-align: left;
    border-radius: 18px;
    border: 1px solid var(--stroke);
    background: rgba(12, 8, 26, 0.55);
    color: var(--text);
    font-family: inherit;
}

.account-card__text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.account-card__text b {
    font-size: 18px;
    font-weight: 800;
}

.account-card__text i {
    font-style: normal;
    font-size: 13px;
    color: var(--text-dim);
}

.account-logout {
    appearance: none;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #f87171;
}

.account-logout svg {
    width: 15px;
    height: 15px;
}

.account-logout:active {
    background: rgba(239, 68, 68, 0.18);
}

.profile-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 12px 8px;
    text-align: center;
}

.profile-ava {
    position: relative;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #7c3aed, #d946ef);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.35), 0 12px 32px rgba(124, 58, 237, 0.35);
}

.profile-ava i {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-style: normal;
    font-weight: 800;
    font-size: 32px;
    color: #fff;
}

.profile-ava img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-hero h2 {
    margin: 10px 0 0;
    font-size: 22px;
    font-weight: 800;
}

.profile-hero p {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
}

.balance-card {
    margin-top: 16px;
    padding: 18px 16px;
    border-radius: 18px;
    border: 1px solid var(--stroke-strong);
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.22), rgba(12, 8, 26, 0.7));
}

.balance-card span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.balance-card b {
    display: block;
    margin-top: 6px;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.pay-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 8px;
}

.pay-chip {
    appearance: none;
    min-width: 64px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--stroke-strong);
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    font-weight: 750;
}

.pay-chip:active {
    transform: scale(0.96);
    border-color: var(--violet-bright);
    color: var(--violet-bright);
}

.admin-user {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 52px;
    margin-top: 8px;
    padding: 10px 12px;
    text-align: left;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: transparent;
    color: var(--text);
    font-family: inherit;
}

#adminUserList .userbot-hint {
    margin-top: 10px;
}

.admin-user b {
    display: block;
    font-size: 14px;
}

.admin-user i {
    display: block;
    font-style: normal;
    font-size: 12px;
    color: var(--text-dim);
}

.admin-user span {
    font-size: 14px;
    font-weight: 800;
    color: var(--violet-bright);
    white-space: nowrap;
}

.watch-live {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--text-dim);
}

.watch-live::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 8px #34d399;
    vertical-align: middle;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(32px + var(--safe-bottom));
    z-index: 40;
    max-width: 82vw;
    padding: 11px 18px;
    border-radius: 14px;
    border: 1px solid var(--stroke-strong);
    background: rgba(30, 18, 60, 0.95);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-open {
    opacity: 1;
    transform: translate(-50%, 0);
}
