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

body {
    background: linear-gradient(145deg, #f0f5fa 0%, #e6ecf3 100%);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 18px;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    color: #0a2540;
}

.card {
    max-width: 480px;
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 32px;
    padding: 24px 18px;
    box-shadow:
        0 20px 40px -15px rgba(0, 20, 40, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.7);
    min-height: 500px;
    position: relative;
}

main {
    padding-top: 16px;
    border-top: 1px dashed rgba(30, 58, 95, 0.18);
}

/* --- Шапка --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.logo-link {
    display: inline-block;
    line-height: 0;
    text-decoration: none;
}

.logo-link img {
    max-height: 40px;
    width: auto;
    display: block;
}

.badge {
    background: linear-gradient(135deg, #1e3a5f, #143450);
    color: white;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 30px;
    white-space: nowrap;
}

.balance-btn {
    background: linear-gradient(135deg, #1e3a5f, #143450);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.balance-btn:hover {
    opacity: 0.85;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(30, 58, 95, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1e3a5f;
    text-decoration: none;
    transition: background 0.2s;
}
.icon-btn:hover {
    background: rgba(30, 58, 95, 0.08);
}
.admin-btn {
    color: #c62828;
}

/* --- Навигация --- */
.main-nav {
    display: flex;
    align-items: center;
    margin-right: auto;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: #314761;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 12px;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
}
.nav-link:hover,
.nav-link.active {
    color: #1e3a5f;
    background: rgba(30, 58, 95, 0.07);
    font-weight: 600;
}

.nav-link-icon {
    font-size: 0.9rem;
    color: #70829a;
}

.nav-link:hover .nav-link-icon,
.nav-link.active .nav-link-icon {
    color: #1e3a5f;
}

.admin-chat-tab-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #d93025;
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Кнопки --- */
.btn-primary {
    background: linear-gradient(135deg, #1e3a5f, #2d5a9e);
    color: white;
    border: none;
    border-radius: 18px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        opacity 0.2s,
        transform 0.1s,
        box-shadow 0.2s;
    box-shadow: 0 12px 2px -18px rgba(10, 31, 51, 0.2);
}
.btn-primary:hover {
    opacity: 0.9;
}
.btn-primary:active {
    transform: scale(0.98);
}
.btn-primary.btn-sm {
    padding: 7px 14px;
    font-size: 0.82rem;
    border-radius: 10px;
}
.btn-primary.btn-full {
    width: 100%;
    margin-top: 8px;
}

.auth-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(30, 58, 95, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1e3a5f;
    text-decoration: none;
    transition:
        background 0.2s,
        transform 0.1s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.auth-icon-btn:hover {
    background: rgba(30, 58, 95, 0.08);
}

.auth-icon-btn:active {
    transform: scale(0.97);
}

.chat-user-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(30, 58, 95, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1e3a5f;
    transition:
        background 0.2s,
        transform 0.1s,
        box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    position: relative;
}

.chat-user-btn:hover {
    background: rgba(30, 58, 95, 0.08);
}

.chat-user-btn:active {
    transform: scale(0.97);
}

.chat-btn-icon {
    font-size: 1rem;
}

.chat-user-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #d93025;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
}

.btn-secondary {
    background: rgba(30, 58, 95, 0.08);
    color: #1e3a5f;
    border: 1px solid rgba(30, 58, 95, 0.15);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-secondary:hover {
    background: rgba(30, 58, 95, 0.13);
}

.btn-danger {
    background: rgba(198, 40, 40, 0.08);
    color: #c62828;
    border: 1px solid rgba(198, 40, 40, 0.2);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-danger:hover {
    background: rgba(198, 40, 40, 0.15);
}

/* --- Формы --- */
.form-group {
    margin-bottom: 12px;
}
.form-group label {
    display: block;
    font-size: 0.75rem;
    color: #2c3e50;
    margin-bottom: 6px;
    margin-left: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 24px;
    font-size: 0.95rem;
    color: #0a2540;
    background: white;
    outline: none;
    transition: box-shadow 0.2s;
    box-shadow:
        0 4px 12px rgba(0, 32, 64, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.02);
}
input:focus,
select:focus,
textarea:focus {
    box-shadow:
        0 4px 15px rgba(30, 58, 95, 0.2),
        0 0 0 3px rgba(30, 58, 95, 0.2);
}
input.error {
    box-shadow:
        0 4px 12px rgba(198, 40, 40, 0.06),
        0 0 0 2px rgba(198, 40, 40, 0.35);
}
.field-error {
    font-size: 0.78rem;
    color: #c62828;
    margin-top: 6px;
    margin-left: 6px;
}

/* --- Модальные окна --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
}

.modal-box {
    position: relative;
    background: white;
    border-radius: 24px;
    padding: 28px 24px 24px;
    width: 90%;
    max-width: 380px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.modal-close:hover {
    color: #555;
}

.modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}
.modal-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
}
.modal-tab.active {
    color: #1e3a5f;
    border-bottom-color: #1e3a5f;
}

.modal-error {
    color: #c62828;
    font-size: 0.82rem;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(198, 40, 40, 0.06);
    border-radius: 8px;
}
.modal-success {
    color: #1b7a3d;
    font-size: 0.88rem;
    margin-bottom: 8px;
    padding: 10px 12px;
    background: rgba(27, 122, 61, 0.07);
    border-radius: 8px;
    line-height: 1.5;
}
.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0a2540;
    margin-bottom: 16px;
}
.modal-text {
    font-size: 0.88rem;
    color: #5a6a7a;
    line-height: 1.6;
    margin-bottom: 16px;
}

.support-chat-box {
    max-width: 420px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.support-chat-header {
    padding: 14px 20px;
    background: #1e3a5f;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.92rem;
    flex-shrink: 0;
}

.support-chat-close {
    position: static;
    color: rgba(255, 255, 255, 0.72);
}

.support-chat-close:hover {
    color: white;
}

.support-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f8fc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 180px;
    max-height: 320px;
}

.support-chat-empty {
    text-align: center;
    color: #97a3b1;
    font-size: 0.82rem;
    padding: 20px 0;
}

.support-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 78%;
}

.support-chat-bubbles {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.support-chat-message.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.support-chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.support-chat-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
}

.support-chat-message.admin .support-chat-bubble {
    background: white;
    color: #0a2540;
    border: 1px solid rgba(30, 58, 95, 0.12);
    border-bottom-left-radius: 4px;
}

.support-chat-message.user .support-chat-bubble {
    background: #1e3a5f;
    color: white;
    border-bottom-right-radius: 4px;
}

.support-chat-time {
    font-size: 0.68rem;
    color: #97a3b1;
    margin-top: 3px;
    padding: 0 2px;
}

.support-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(30, 58, 95, 0.1);
    flex-shrink: 0;
}

.support-chat-input-area input {
    flex: 1;
    border: 1px solid rgba(30, 58, 95, 0.15);
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 0.88rem;
    outline: none;
    box-shadow: none;
}

.support-chat-input-area input:focus {
    box-shadow: none;
    border-color: #2d5a9e;
}

.support-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e3a5f;
    border: none;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    flex-shrink: 0;
    transition:
        opacity 0.2s,
        transform 0.1s;
}

.support-chat-send-btn:hover {
    opacity: 0.88;
}

.support-chat-send-btn:active {
    transform: scale(0.97);
}

/* --- Футер --- */
.footer {
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid rgba(30, 58, 95, 0.14);
    text-align: center;
}
.footer-socials {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 12px;
}
.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 10px;
}
.footer-links a {
    color: #60758b;
    font-size: 0.76rem;
    text-decoration: none;
    border-bottom: 1px dotted rgba(96, 117, 139, 0.3);
}
.footer-links a:hover {
    border-bottom-color: #60758b;
}
.footer-icon {
    color: #1e3a5f;
    transition:
        color 0.2s,
        opacity 0.2s;
    font-size: 22px;
    line-height: 1;
}
.footer-icon:hover {
    color: #1e3a5f;
}
.footer-icon-text {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}
.footer-copy {
    font-size: 0.75rem;
    color: #93a0ae;
}

/* --- Утилиты --- */
.hidden {
    display: none !important;
}
.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7a8d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 16px 0 10px;
}

/* --- Бургер --- */
.burger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.burger-btn:hover {
    background: rgba(30, 58, 95, 0.07);
}
.burger-btn span {
    display: block;
    height: 2px;
    background: #1e3a5f;
    border-radius: 2px;
    transition: all 0.25s;
    transform-origin: center;
}
.burger-btn.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.burger-btn.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.burger-btn.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* --- Навигация --- */
.main-nav {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}
.nav-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.nav-overlay {
    display: none;
}

/* --- Кнопка закрытия внутри мобильного меню --- */
.nav-close {
    display: none;
    position: absolute;
    top: 12px;
    right: 16px;
    background: rgba(30, 58, 95, 0.07);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    color: #1e3a5f;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* --- Мобиль (< 600px) --- */
@media (max-width: 599px) {
    .burger-btn {
        display: flex;
    }
    .nav-close {
        display: flex;
    }
    .main-nav {
        display: block;
        position: absolute;
        top: calc(100% + 12px);
        left: 0;
        right: 0;
        background: white;
        border-radius: 24px;
        box-shadow: 0 8px 32px rgba(0, 20, 40, 0.18);
        padding: 52px 16px 16px;
        z-index: 500;
        transform: translateY(-8px);
        opacity: 0;
        pointer-events: none;
        transition:
            transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.2s;
    }
    .header-right {
        margin-left: 0;
    }
    .nav-inner {
        flex-direction: column;
        gap: 2px;
    }
    .nav-link {
        padding: 11px 14px;
        border-radius: 12px;
        font-size: 0.95rem;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .main-nav.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 499;
    }
    .nav-overlay.open {
        display: block;
    }

    .card {
        position: relative;
        overflow: visible;
    }
}

/* --- Планшет --- */
@media (min-width: 600px) {
    body {
        padding: 24px;
        align-items: flex-start;
    }
    .card {
        max-width: 880px;
        padding: 28px 24px;
    }
}

/* --- Десктоп --- */
@media (min-width: 1024px) {
    body {
        padding: 32px;
    }
    .card {
        max-width: 1200px;
        padding: 32px 40px;
        min-height: 600px;
    }

    /* Шапка */
    .header {
        margin-bottom: 8px;
        flex-wrap: nowrap;
    }
    .logo-link img {
        max-height: 48px;
    }
    .badge {
        font-size: 0.78rem;
        padding: 4px 10px;
    }
    .icon-btn {
        width: 42px;
        height: 42px;
    }
    .auth-icon-btn {
        width: 42px;
        height: 42px;
    }
    .balance-btn {
        font-size: 0.9rem;
        padding: 8px 16px;
    }

    .main-nav {
        display: flex !important;
        margin-left: 8px;
        margin-right: auto;
    }
    .nav-inner {
        gap: 2px;
        flex-wrap: nowrap;
    }
    .nav-link {
        font-size: 0.92rem;
        padding: 6px 8px;
        border-radius: 12px;
        color: #314761;
        transition:
            background 0.2s,
            color 0.2s;
    }
    .nav-link:hover {
        background: rgba(30, 58, 95, 0.06);
        color: #1e3a5f;
    }
    .nav-link.active {
        background: rgba(30, 58, 95, 0.08);
        color: #1e3a5f;
        font-weight: 600;
    }
}

/* --- Десктоп: кабинет и админка --- */
@media (min-width: 1024px) {
    /* Заказы кабинета — в 2 колонки */
    .orders-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .order-card {
        margin: 0;
    }

    /* Админка — заказы */
    .admin-orders {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .admin-order-card {
        margin: 0;
    }

    /* Пользователи — таблица */
    .users-list {
        gap: 8px;
    }
    .user-card {
        padding: 14px 20px;
    }

    /* Статистика */
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Пополнение баланса */
    .topup-amounts {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Страницы-заглушки */
    .faq-list,
    .contacts-list {
        max-width: 700px;
    }
}
