:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f1f1f1);
    --text: #ffffff;
    --hint: rgba(255,255,255,0.75);
    --link: var(--tg-theme-link-color, #007aff);
    --btn: var(--tg-theme-button-color, #007aff);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --radius: 12px;
    --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { touch-action: manipulation; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-h) + 36px);
}

#bg-blur {
    position: fixed;
    inset: 0;
    z-index: -1;
}
#bg-blur canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.hidden { display: none !important; }

/* Loading */
#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 12px;
    color: var(--hint);
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--secondary-bg);
    border-top-color: var(--btn);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bottom nav */
#bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    height: var(--nav-h);
    width: max-content;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(40px) saturate(1.5);
    -webkit-backdrop-filter: blur(40px) saturate(1.5);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 30px;
    display: flex;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x;
}
#nav-slider {
    position: absolute;
    top: -1px;
    bottom: -1px;
    left: 0;
    border-radius: 30px;
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 24px;
    transition: color 0.25s;
    z-index: 1;
    white-space: nowrap;
}
.nav-btn svg { display: block; }
.nav-btn.active { color: #ffffff; font-weight: 600; }

/* Tab content */
.tab-content {
    padding: 12px 12px;
    padding-bottom: 8px;
}

/* Cards */
.card {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}
.card h2 { font-size: 18px; margin-bottom: 12px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }

/* Info row */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 7px 0;
    border-bottom: 1px solid rgba(0,0,0,.05);
    gap: 8px;
}
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: #ffffff; flex-shrink: 0; }
.info-row span:last-child { text-align: right; font-weight: 500; }
.info-row .tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.tag {
    background: var(--secondary-bg);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 12px;
}

/* Buttons */
.btn-glass {
    display: block;
    width: 100%;
    padding: 13px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    text-align: center;
}
.btn-reset {
    opacity: 0.65;
    font-size: 14px;
    font-weight: 500;
}
.btn-pause {
    background: rgba(255, 149, 0, 0.15);
    border-color: rgba(255, 149, 0, 0.35);
    color: #ff9500;
    margin-bottom: 12px;
}
.btn-resume {
    background: rgba(52, 199, 89, 0.15);
    border-color: rgba(52, 199, 89, 0.35);
    color: #34c759;
    margin-bottom: 12px;
}
.btn-primary {
    display: block;
    width: 100%;
    padding: 13px;
    background: var(--btn);
    color: var(--btn-text);
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    text-align: center;
}
.btn-danger {
    display: block;
    width: 100%;
    padding: 13px;
    background: rgba(255, 59, 48, 0.18);
    color: #ff3b30;
    border: 1px solid rgba(255, 59, 48, 0.35);
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    text-align: center;
}
.btn-secondary {
    display: block;
    width: 100%;
    padding: 13px;
    background: var(--secondary-bg);
    color: var(--text);
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    text-align: center;
}
.btn-sm {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    background: var(--secondary-bg);
    color: var(--text);
}
.btn-sm.danger { background: #ff3b30; color: #fff; }
.btn-sm.primary { background: var(--btn); color: var(--btn-text); }

/* Form */
#edit-form label {
    display: block;
    color: #ffffff;
    font-size: 13px;
    margin: 14px 0 4px;
}
#edit-form input, #edit-form select, #edit-form textarea,
#msg-text, #broadcast-text {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.12);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    -webkit-appearance: none;
    box-sizing: border-box;
}
#edit-form input::placeholder, #edit-form textarea::placeholder,
#msg-text::placeholder, #broadcast-text::placeholder {
    color: rgba(255,255,255,0.4);
}
#edit-form select option { background: #1a1a2e; color: #ffffff; }
#edit-form input:focus, #edit-form select:focus, #edit-form textarea:focus,
#msg-text:focus, #broadcast-text:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.18);
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 20px 0 8px;
}
.hint { font-size: 12px; color: rgba(255,255,255,0.75); margin-bottom: 6px; }
.section-title.collapsible {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.cat-count { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: rgba(255,255,255,0.6); margin-left: 4px; }
.collapsed .collapse-arrow { transform: rotate(-90deg); }
.category-chevron {
    color: rgba(255, 255, 255, 0.35);
    transition: transform 0.25s ease, color 0.2s;
    flex-shrink: 0;
    transform: rotate(180deg);
}
.section-title.collapsible.collapsed .category-chevron {
    transform: rotate(0deg);
    color: rgba(255, 255, 255, 0.55);
}

/* Category grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.cat-chip {
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
    color: #ffffff;
}
.cat-chip.selected {
    background: rgba(52, 199, 89, 0.18);
    border-color: rgba(52, 199, 89, 0.6);
    color: #34c759;
}
.cat-chip.drag-hover {
    border-color: var(--btn);
    opacity: 0.7;
    transform: scale(0.97);
}

/* Dynamic profile fields */
.field-category-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 18px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.collapse-arrow {
    font-style: normal;
    font-size: 10px;
    transition: transform 0.2s;
    color: rgba(255,255,255,0.4);
}
.field-category-label.collapsed .collapse-arrow { transform: rotate(-90deg); }
.field-block { margin-bottom: 12px; }
.field-block label {
    display: block;
    color: var(--hint);
    font-size: 13px;
    margin-bottom: 4px;
}
.options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.opt-chip {
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    color: #ffffff;
}
.opt-chip.selected {
    background: rgba(52, 199, 89, 0.18);
    border-color: rgba(52, 199, 89, 0.6);
    color: #34c759;
}
/* Validation errors */
.chip-group-error {
    border: 1px solid rgba(255, 59, 48, 0.55);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12);
    animation: shake 0.3s ease;
}
.input-error {
    border-color: rgba(255, 59, 48, 0.7) !important;
    background: rgba(255, 59, 48, 0.08) !important;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12);
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-4px); }
    75%       { transform: translateX(4px); }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 200;
    display: flex;
    align-items: flex-end;
}
.modal-content {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.modal-small { max-height: 60vh; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(0,0,0,.08);
    flex-shrink: 0;
}
.modal-header h2 { font-size: 17px; }
.btn-close {
    background: var(--secondary-bg);
    border: none;
    border-radius: 50%;
    width: 30px; height: 30px;
    font-size: 16px;
    cursor: pointer;
    color: var(--hint);
    display: flex; align-items: center; justify-content: center;
}
.modal-body {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
}
.modal-body p { color: #ffffff; font-size: 13px; margin-bottom: 8px; }
.modal-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    border-top: 1px solid rgba(0,0,0,.06);
}
.modal-footer .btn-primary,
.modal-footer .btn-secondary {
    margin: 0;
    flex: 1;
    padding: 13px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: box-shadow 0.2s, background 0.2s;
}

.modal-footer .btn-secondary {
    background: rgba(255, 59, 48, 0.12);
    border: 1px solid rgba(255, 59, 48, 0.4);
    color: #ff3b30;
    box-shadow: 0 0 12px rgba(255, 59, 48, 0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.modal-footer .btn-secondary:active {
    background: rgba(255, 59, 48, 0.22);
    box-shadow: 0 0 20px rgba(255, 59, 48, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}

.modal-footer .btn-primary {
    background: rgba(52, 199, 89, 0.14);
    border: 1px solid rgba(52, 199, 89, 0.4);
    color: #34c759;
    box-shadow: 0 0 12px rgba(52, 199, 89, 0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.modal-footer .btn-primary:active {
    background: rgba(52, 199, 89, 0.25);
    box-shadow: 0 0 20px rgba(52, 199, 89, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* Admin tabs */
.admin-tabs {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow-x: auto;
}
.admin-tab-btn {
    flex-shrink: 0;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    background: var(--secondary-bg);
    color: var(--text);
    transition: all .15s;
}
.admin-tab-btn.active { background: var(--btn); color: var(--btn-text); }

/* User search */
.user-search-wrap { padding: 10px 0 4px; }
.user-search-wrap input[type="search"] {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 12px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}
.user-search-wrap input[type="search"]::placeholder { color: rgba(255,255,255,0.45); }

/* User card in admin */
.user-card {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}
.user-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.user-card-name { font-weight: 600; font-size: 16px; }
.user-card-role {
    font-size: 11px;
    font-weight: 600;
    color: var(--hint);
    background: rgba(255,255,255,0.12);
    padding: 3px 9px;
    border-radius: 8px;
    white-space: nowrap;
}
.user-card-role.admin { color: #4da3ff; background: rgba(77,163,255,0.18); }
.user-card-role.super { color: #ffd60a; background: rgba(255,214,10,0.18); }
.user-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.uc-chip {
    font-size: 12px;
    color: var(--hint);
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 3px 9px;
    border-radius: 8px;
    white-space: nowrap;
}
.uc-chip.ok { color: #30d158; background: rgba(48,209,88,0.15); border-color: rgba(48,209,88,0.25); }
.uc-chip.muted { color: #ff453a; background: rgba(255,69,58,0.15); border-color: rgba(255,69,58,0.25); }
.uc-chip.danger { color: #ff453a; background: rgba(255,69,58,0.15); border-color: rgba(255,69,58,0.25); }
.uc-chip.ref { color: #d6a4ff; background: rgba(191,90,242,0.18); border-color: rgba(191,90,242,0.3); font-weight: 600; }
.user-card-sub {
    font-size: 13px;
    color: var(--hint);
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.user-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Channel card */
.channel-card {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.channel-card-info { flex: 1; }
.channel-card-name { font-weight: 600; font-size: 14px; }
.channel-card-meta { font-size: 12px; color: #ffffff; }
.channel-card-actions { display: flex; gap: 6px; }

/* Add channel form */
.add-channel-form {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.add-channel-form input {
    width: 100%;
    padding: 9px 12px;
    background: var(--secondary-bg);
    color: var(--text);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

/* Stats */
#stats-text {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
}

/* Subscription page */
.sub-header-card {
    text-align: center;
    padding: 24px 16px 20px;
    margin-bottom: 10px;
}
.sub-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    margin: 0 auto 14px;
}
.sub-color-green { color: #34c759; }
.sub-color-yellow { color: #ffcc00; }
.sub-color-red { color: #ff3b30; }
.sub-header-icon.sub-color-green { background: rgba(52,199,89,.15); border: 1px solid rgba(52,199,89,.25); }
.sub-header-icon.sub-color-yellow { background: rgba(255,204,0,.12); border: 1px solid rgba(255,204,0,.25); }
.sub-header-icon.sub-color-red { background: rgba(255,59,48,.10); border: 1px solid rgba(255,59,48,.2); }
.sub-status-title {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 4px;
}
.sub-status-detail {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
}

.sub-plans-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.sub-plan-card {
    position: relative;
    padding: 14px 12px 16px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    overflow: hidden;
}
.sub-plan-best {
    border-color: rgba(255,204,0,.4);
    background: rgba(255,204,0,.05);
}
.sub-plan-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255,204,0,.2);
    border-bottom-left-radius: 8px;
    border-top-right-radius: var(--radius);
    color: #ffcc00;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-left: 1px solid rgba(255,204,0,.35);
    border-bottom: 1px solid rgba(255,204,0,.35);
}
.sub-plan-icon {
    color: rgba(255,255,255,0.5);
    margin-bottom: 6px;
}
.sub-plan-period {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    font-weight: 500;
}
.sub-plan-price {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.15;
}
.sub-plan-permonth {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
}
.sub-plan-hint {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}
.btn-pay {
    margin-top: 10px;
    width: 100%;
    padding: 7px 0;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-pay:active {
    background: rgba(255,255,255,0.32);
}

.sub-info-card {
    padding: 12px 14px;
    margin-bottom: 10px;
}
.sub-info-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 13px;
    color: rgba(255,255,255,0.65);
    line-height: 1.55;
}
.sub-info-row svg { flex-shrink: 0; margin-top: 1px; color: rgba(255,255,255,0.45); }
.sub-info-row b { color: #ffffff; }

.sub-benefits-card {
    padding: 14px 14px 10px;
    margin-bottom: 10px;
}
.sub-benefits-title {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.sub-benefit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    line-height: 1.4;
}
.sub-benefit-row:last-child { border-bottom: none; }
.sub-benefit-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sub-referral-card {
    padding: 14px 14px 12px;
    margin-bottom: 10px;
}
.sub-referral-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.sub-referral-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(10, 132, 255, 0.15);
    border: 1px solid rgba(10, 132, 255, 0.25);
    color: #0a84ff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sub-referral-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}
.sub-referral-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    margin-top: 2px;
}
.sub-referral-count {
    margin-left: auto;
    text-align: center;
    flex-shrink: 0;
}
.sub-referral-count-num {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: #0a84ff;
    line-height: 1.1;
}
.sub-referral-count-label {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
}
.sub-referral-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 0;
    font-size: 14px;
}

/* Profile header card */
.profile-header-card {
    display: flex;
    align-items: center;
    gap: 14px;
}
.profile-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--btn);
    color: var(--btn-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -1px;
    overflow: hidden;
}
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.profile-header-info { flex: 1; min-width: 0; }
.profile-display-name {
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-header-meta { font-size: 13px; color: #ffffff; margin-top: 2px; }

/* Status badges */
.badge {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    display: inline-block;
}
.badge-green { background: rgba(52,199,89,.15); color: #34c759; }
.badge-red   { background: rgba(255,59,48,.12); color: #ff3b30; }
.badge-yellow{ background: rgba(255,204,0,.15); color: #b8860b; }

/* Card section label */
.card-section-label {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 10px;
}
.hint-text { font-size: 12px; color: #ffffff; text-align: right; }

/* Collapsible category card in profile view */
.profile-cat-card {
    padding: 0;
    overflow: hidden;
}
.profile-cat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.15s;
    border-radius: var(--radius);
}
.profile-cat-header:active {
    background: rgba(255, 255, 255, 0.06);
}
.profile-cat-header * { pointer-events: none; }
.profile-cat-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.profile-cat-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0;
    text-transform: none;
}
.profile-cat-chevron {
    color: rgba(255, 255, 255, 0.35);
    transition: transform 0.25s ease, color 0.2s;
    flex-shrink: 0;
}
.profile-cat-card.expanded .profile-cat-chevron {
    transform: rotate(180deg);
    color: rgba(255, 255, 255, 0.7);
}
.profile-cat-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s ease;
}
.profile-cat-card.expanded .profile-cat-body {
    grid-template-rows: 1fr;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.profile-cat-body-inner {
    overflow: hidden;
    padding: 0 14px;
}
.profile-cat-card.expanded .profile-cat-body-inner {
    padding-top: 10px;
    padding-bottom: 10px;
}

/* Reply template editor */
.tpl-hint {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
    margin: 0 0 10px;
}
.tpl-textarea {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #ffffff;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.45;
    padding: 11px 12px;
    min-height: 96px;
    resize: vertical;
    -webkit-appearance: none;
}
.tpl-textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.35);
}
.tpl-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.tpl-actions .btn-glass {
    flex: 1;
    margin: 0;
}
.tpl-actions .btn-reset {
    opacity: 1;
    font-size: 15px;
    font-weight: 600;
}


/* Per-category profile sections */
.cat-profile-section {
    background: var(--secondary-bg);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}
.cat-profile-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--btn);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}
.pagination button {
    padding: 7px 18px;
    border-radius: 8px;
    border: none;
    background: var(--btn);
    color: var(--btn-text);
    font-size: 14px;
    cursor: pointer;
}
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination span { font-size: 13px; color: #ffffff; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.stat-card {
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius);
    padding: 14px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.stat-icon { font-size: 22px; flex-shrink: 0; }
.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
}
.stat-label {
    font-size: 11px;
    color: rgba(255,255,255,0.65);
    margin-top: 2px;
}
.stat-sub { opacity: 0.75; }
.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stat-row:last-child { border-bottom: none; }
.stat-row-label {
    font-size: 13px;
    color: #ffffff;
    width: 100px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-row-bar-wrap {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}
.stat-row-bar {
    height: 100%;
    background: rgba(255,255,255,0.55);
    border-radius: 3px;
    transition: width 0.6s ease;
}
.stat-row-val {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    text-align: right;
    flex-shrink: 0;
    min-width: 70px;
}
.stat-row.clickable { cursor: pointer; transition: background 0.15s; }
.stat-row.clickable:hover { background: rgba(255,255,255,0.07); }
.stat-row.clickable:active { background: rgba(255,255,255,0.12); }
.stat-card.clickable { cursor: pointer; transition: opacity 0.15s; }
.stat-card.clickable:active { opacity: 0.7; }
.vacancy-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.vacancy-item:last-child { border-bottom: none; }
.vacancy-meta { font-size: 12px; color: var(--hint); margin-bottom: 3px; }
.vacancy-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; }

.vacancy-card { padding: 12px 14px; }
.vacancy-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.vacancy-num {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    min-width: 28px;
}
.vacancy-channel {
    font-size: 12px;
    font-weight: 600;
    color: var(--link);
}
.vacancy-date {
    font-size: 11px;
    color: var(--hint);
    margin-left: auto;
}
.vacancy-link {
    font-size: 12px;
    color: var(--link);
    text-decoration: none;
    padding: 1px 6px;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 6px;
}
.vacancy-link:hover { background: rgba(255,255,255,0.08); }

/* Consent screen */
#consent-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.consent-card {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 20px;
    padding: 28px 22px;
    max-width: 420px;
    width: 100%;
}
.consent-icon {
    width: 64px;
    height: 64px;
    background: rgba(52, 199, 89, 0.15);
    border: 1px solid rgba(52, 199, 89, 0.35);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #34c759;
    margin: 0 auto 18px;
}
.consent-title {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 14px;
    color: #fff;
}
.consent-text {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    line-height: 1.5;
    margin-bottom: 10px;
}
.consent-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}
.consent-list li {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    padding: 4px 0 4px 18px;
    position: relative;
}
.consent-list li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: rgba(255,255,255,0.45);
}
.consent-laws {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    line-height: 1.4;
    margin-bottom: 18px;
}
.consent-btn-accept, .consent-btn-decline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
}
.consent-btn-accept {
    background: rgba(52, 199, 89, 0.16);
    border: 1px solid rgba(52, 199, 89, 0.5);
    color: #34c759;
    box-shadow: 0 0 16px rgba(52, 199, 89, 0.25), inset 0 1px 0 rgba(255,255,255,0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-top: 16px;
}
.consent-btn-accept:active {
    background: rgba(52, 199, 89, 0.28);
    box-shadow: 0 0 24px rgba(52, 199, 89, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}
.consent-btn-decline {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    color: rgba(255, 59, 48, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-top: 8px;
}

/* Subscription expiry banner */
.sub-banner {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.sub-banner-warn {
    background: rgba(255, 159, 10, 0.18);
    border-bottom: 1px solid rgba(255, 159, 10, 0.4);
    color: #ff9f0a;
}
.sub-banner-expired {
    background: rgba(255, 59, 48, 0.18);
    border-bottom: 1px solid rgba(255, 59, 48, 0.4);
    color: #ff453a;
}
.sub-banner-text { flex: 1; }
.sub-banner-icon { flex-shrink: 0; }
.sub-banner-chevron { flex-shrink: 0; opacity: 0.7; }

/* Manual subscription days adjust (admin) */
.sub-custom-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#sub-custom-days {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.12);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    text-align: center;
    -webkit-appearance: none;
    box-sizing: border-box;
}
#sub-custom-days::placeholder { color: rgba(255,255,255,0.4); }
#sub-custom-days:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
}
.sub-custom-row {
    display: flex;
    gap: 8px;
}
.sub-custom-row .sub-custom-btn {
    flex: 1;
    white-space: nowrap;
}

/* Legal documents */
.doc-link {
    color: #34c759;
    text-decoration: underline;
    cursor: pointer;
}
.app-footer {
    text-align: center;
    padding: 22px 16px 8px;
}
.app-footer .doc-link {
    font-size: 11px;
    color: rgba(255,255,255,0.32);
    text-decoration: none;
}
#documents-screen {
    position: fixed;
    inset: 0;
    z-index: 200;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    -webkit-overflow-scrolling: touch;
}
.documents-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.documents-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.06);
    color: #fff;
    cursor: pointer;
}
.documents-header-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}
.documents-body {
    padding: 16px;
    max-width: 560px;
    margin: 0 auto;
}
.documents-operator {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255,255,255,0.65);
    margin-bottom: 14px;
}
.doc-section {
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    overflow: hidden;
}
.doc-section > summary {
    list-style: none;
    cursor: pointer;
    padding: 16px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.doc-section > summary::-webkit-details-marker { display: none; }
.doc-chevron {
    color: rgba(255, 255, 255, 0.35);
    transition: transform 0.25s ease, color 0.2s;
    flex-shrink: 0;
}
.doc-section[open] > summary .doc-chevron {
    transform: rotate(180deg);
    color: rgba(255, 255, 255, 0.7);
}
.doc-content {
    padding: 0 16px 16px;
}
.doc-content p {
    font-size: 13.5px;
    line-height: 1.55;
    color: rgba(255,255,255,0.82);
    margin-bottom: 10px;
}
.doc-content strong { color: #fff; }

/* Support — thread list (admin) */
.support-threads-list {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}
.support-thread-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.15s;
}
.support-thread-card:active { background: rgba(255,255,255,0.07); }
.support-thread-avatar {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}
.support-thread-info {
    flex: 1;
    min-width: 0;
}
.support-thread-name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.support-thread-preview {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.thread-preview-admin { color: rgba(255,255,255,0.35); }
.support-thread-time {
    flex-shrink: 0;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}

/* Support — thread header (back button + name) */
.support-thread-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.support-back-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
}
.support-back-btn:active { background: rgba(255,255,255,0.2); }
.support-thread-username {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Support chat */
.support-chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-h) - 56px);
}
/* When the subscription banner is visible it occupies ~46px at the top of #main,
   so shrink the chat height to keep the input bar above the bottom nav. */
#sub-banner:not(.hidden) ~ #tab-support .support-chat {
    height: calc(100vh - var(--nav-h) - 56px - 46px);
}
.support-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 2px 12px;
}
.support-empty {
    margin: auto;
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    padding: 0 24px;
}
.support-msg {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    display: flex;
    flex-direction: column;
}
.support-msg-text { white-space: pre-wrap; }
.support-msg-time {
    align-self: flex-end;
    font-size: 10px;
    opacity: 0.6;
    margin-top: 3px;
}
.support-msg.from-user {
    align-self: flex-end;
    background: rgba(0, 122, 255, 0.18);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 122, 255, 0.4);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}
.support-msg.from-admin {
    align-self: flex-start;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom-left-radius: 4px;
}
.support-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-top: 8px;
}
.support-input {
    flex: 1;
    resize: none;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.3;
    max-height: 120px;
    -webkit-appearance: none;
}
.support-input::placeholder { color: rgba(255, 255, 255, 0.4); }
.support-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.18);
}
.support-send-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.support-send-btn:active {
    background: rgba(255, 255, 255, 0.2);
    opacity: 0.85;
}
/* The "send" glyph leans bottom-left, so nudge it slightly up-right to optically center. */
.support-send-btn svg { transform: translate(0.5px, -0.5px); }
