:root {
    --bg: #101116;
    --panel: #191b23;
    --panel2: #222530;
    --border: #303340;
    --text: #f5f5f7;
    --muted: #9296a5;
    --gold: #e6a23c;
    --green: #35bd83;
    --red: #ed6262;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
}

button, input, textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 9px;
    padding: 12px 17px;
    font-weight: 700;
}

.hidden {
    display: none !important;
}

/* Login */

.login-screen {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 38px;
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
}

.logo {
    width: 65px;
    height: 65px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    border-radius: 17px;
    background: var(--gold);
    color: #171717;
    font-size: 25px;
    font-weight: 900;
}

.login-card h1 {
    font-size: 23px;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-card form {
    display: grid;
    gap: 13px;
}

/* Inputs */

input, textarea {
    width: 100%;
    padding: 13px 14px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #11131a;
    color: white;
    outline: none;
}

input:focus, textarea:focus {
    border-color: var(--gold);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.primary {
    background: var(--gold);
    color: #171717;
}

.primary:hover {
    background: #f0b65b;
}

.secondary {
    background: var(--panel2);
    color: white;
    border: 1px solid var(--border);
}

.error {
    color: var(--red);
    font-size: 13px;
    margin-top: 8px;
}

/* Layout */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 245px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 25px 17px;
}

.brand {
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 45px;
}

.brand span {
    background: var(--gold);
    color: #171717;
    padding: 10px;
    border-radius: 9px;
}

.menu-title {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 1px;
    margin: 20px 10px 12px;
}

.nav {
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
    background: transparent;
    color: var(--muted);
}

.nav.active {
    color: var(--gold);
    background: #30291f;
}

.sidebar-bottom {
    position: absolute;
    bottom: 25px;
    color: var(--muted);
    font-size: 11px;
}

.main {
    margin-left: 245px;
    padding: 35px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

header h1 {
    margin: 0 0 7px;
    font-size: 29px;
}

header p {
    margin: 0;
    color: var(--muted);
}

/* Statistics */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 17px;
    margin-bottom: 25px;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 23px;
}

.stat span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 12px;
}

.stat strong {
    font-size: 28px;
}

/* Catalog */

.content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 22px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.toolbar h2 {
    font-size: 19px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

th {
    text-align: left;
    padding: 15px 12px;
    color: var(--muted);
    font-size: 11px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 17px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.status {
    display: inline-block;
    padding: 6px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.status.good {
    background: #15382d;
    color: var(--green);
}

.status.empty {
    background: #3b2024;
    color: var(--red);
}

.status.off {
    background: #30313a;
    color: var(--muted);
}

.action {
    background: var(--panel2);
    color: white;
    padding: 8px 11px;
    margin: 2px;
    font-size: 12px;
}

#message {
    margin-bottom: 12px;
    color: var(--green);
    font-size: 13px;
}

/* Modal */

.modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: #000b;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal-card {
    width: 100%;
    max-width: 450px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 17px;
    padding: 25px;
    display: grid;
    gap: 13px;
}

.modal-card h2 {
    margin: 0 0 8px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.check input {
    width: auto;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

/* Mobile */

@media (max-width: 850px) {
    .sidebar {
        position: static;
        width: 100%;
        padding: 15px;
    }

    .brand {
        margin-bottom: 10px;
    }

    .menu-title, .sidebar-bottom {
        display: none;
    }

    .nav {
        width: auto;
    }

    .main {
        margin-left: 0;
        padding: 20px 14px;
    }

    header {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat {
        padding: 17px;
    }

    .content {
        padding: 14px;
    }
}

/* ===== ЛОЯЛЬНОСТЬ ===== */

.loyalty-search {
    display: flex;
    gap: 12px;
    margin: 22px 0;
    max-width: 650px;
}

.loyalty-search input,
.loyalty-user-edit select {
    min-width: 0;
    padding: 13px 15px;
    border: 1px solid var(--border, #333);
    border-radius: 10px;
    background: var(--card, #171717);
    color: inherit;
    font: inherit;
}

.loyalty-search input {
    flex: 1;
}

.loyalty-user {
    display: grid;
    grid-template-columns: 1fr 1.3fr 1.3fr;
    gap: 20px;
    align-items: center;
    padding: 22px;
    margin: 14px 0;
    border: 1px solid var(--border, #333);
    border-radius: 14px;
    background: var(--card, #171717);
}

.loyalty-user-info,
.loyalty-user-stats,
.loyalty-user-edit {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 0;
}

.loyalty-user-info span,
.loyalty-user-stats span,
.loyalty-user-edit label {
    font-size: 13px;
    opacity: .75;
}

.loyalty-user-info strong {
    font-size: 16px;
}

.loyalty-user-edit select {
    width: 100%;
}

.loyalty-user-edit button {
    width: 100%;
}

#loyaltyMessage {
    margin: 12px 0;
}

@media (max-width: 900px) {
    .loyalty-user {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .loyalty-search {
        flex-direction: column;
    }
}


/* ===== ПОЛЬЗОВАТЕЛИ ===== */

.users-platform-switch {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.users-message {
    min-height: 22px;
    margin: 10px 0 16px;
    font-size: 14px;
}

.users-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.5fr);
    gap: 18px;
    align-items: start;
}

.users-list-panel,
.users-details-panel,
.user-detail-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border, #333);
    border-radius: 14px;
    background: var(--card, #171717);
}

.users-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.users-list-heading h3,
.user-detail-heading h3 {
    margin: 0;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-list-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 13px;
    border: 1px solid var(--border, #333);
    border-radius: 10px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.user-list-item:hover,
.user-list-item.selected {
    border-color: var(--accent, #888);
    background: rgba(128, 128, 128, .10);
}

.user-list-name {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.user-list-subtitle,
.user-list-meta {
    font-size: 12px;
    opacity: .72;
    overflow-wrap: anywhere;
}

.users-empty {
    padding: 18px 8px;
    opacity: .7;
    text-align: center;
}

.user-detail-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.user-status {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 12px;
}

.user-status.is-active {
    background: rgba(40, 160, 90, .15);
}

.user-status.is-banned {
    background: rgba(210, 65, 65, .18);
}

.user-identifiers,
.user-current-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.user-identifiers > div,
.user-current-stats > div {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    padding: 12px;
    border-radius: 9px;
    background: rgba(128, 128, 128, .08);
}

.user-identifiers span,
.user-current-stats span {
    font-size: 12px;
    opacity: .7;
}

.user-identifiers strong,
.user-current-stats strong {
    overflow-wrap: anywhere;
}

.user-edit-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border, #333);
}

.user-edit-block h4 {
    margin: 0;
}

.user-edit-block p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    opacity: .72;
}

.user-edit-block input,
.user-edit-block select {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--border, #333);
    border-radius: 9px;
    background: var(--card, #171717);
    color: inherit;
    font: inherit;
}

.user-edit-block button {
    align-self: flex-start;
}

.user-edit-block button.danger {
    background: #a83232;
    color: white;
}

.ban-description {
    padding: 10px;
    border-radius: 8px;
    background: rgba(210, 65, 65, .10);
}

.adjustments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.adjustment-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--border, #333);
    border-radius: 8px;
}

.adjustment-row > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.adjustment-row span,
.adjustment-row small {
    font-size: 12px;
    opacity: .72;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .users-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .users-platform-switch {
        flex-direction: column;
    }

    .user-identifiers,
    .user-current-stats {
        grid-template-columns: 1fr;
    }

    .adjustment-row {
        flex-direction: column;
    }
}

/* Удаление товара */
.action.danger {
    background: #8f3038;
    color: #ffffff;
}

.action.danger:hover {
    background: #ad3943;
}

/* Изображения категорий */

.category-images-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.category-image-card {
    min-width: 0;
    padding: 16px;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 13px;
}

.category-image-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-image-info strong {
    font-size: 16px;
    color: white;
}

.category-image-preview,
.category-image-placeholder {
    width: 100%;
    height: 170px;
    border-radius: 10px;
    object-fit: cover;
    background: #171717;
}

.category-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    font-size: 14px;
}

.category-image-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.category-image-controls input[type="file"] {
    width: 100%;
    min-width: 0;
    font-size: 12px;
}

.category-image-controls button {
    width: 100%;
}



/* CHICAGO SHOP — статистика */

.shop-stats-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 22px;
}

.shop-stats-filters select,
.shop-stats-filters input {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    max-width: 230px;
}

.shop-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
    margin: 20px 0 28px;
}

.shop-stats-grid .stat strong {
    font-size: clamp(18px, 2vw, 28px);
    overflow-wrap: anywhere;
}

#statisticsSection h3 {
    margin: 30px 0 12px;
}

#statisticsSection .table-wrap {
    margin-bottom: 24px;
}

#statisticsSection table {
    min-width: 500px;
}

@media (max-width: 700px) {
    .shop-stats-grid {
        grid-template-columns: 1fr;
    }
}


/* CHICAGO SHOP — промокоды */

#promosSection .promo-panel {
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin: 20px 0;
}

#promosSection .promo-panel h3 {
    margin: 0 0 18px;
}

.promo-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.promo-fields label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.promo-fields input,
.promo-fields select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
}

.promo-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
    margin-top: 22px;
}

.promo-actions {
    white-space: nowrap;
}

.promo-actions button {
    margin: 3px;
}

#promosSection .table-wrap {
    overflow-x: auto;
}

#promosSection table {
    min-width: 680px;
}

@media (max-width: 700px) {
    .promo-fields,
    .promo-summary {
        grid-template-columns: 1fr;
    }
}

/* CHICAGO SHOP: компактный предпросмотр товара */
#imagePreview.image-preview {
    display: block;
    width: 100%;
    max-width: 320px;
    height: 220px;
    object-fit: contain;
    box-sizing: border-box;
    padding: 8px;
    margin: 12px 0;
    border: 1px solid #7433b8;
    border-radius: 12px;
    background: #0b0b13;
}

#imagePreview.image-preview.hidden {
    display: none;
}



/* CHICAGO SHOP — оформление выбора категории */

#productCategory {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 11px 38px 11px 12px;
    box-sizing: border-box;

    color: #f3efff;
    background-color: #11131d;

    border: 1px solid #303446;
    border-radius: 9px;

    font: inherit;
    font-size: 14px;

    appearance: none;
    -webkit-appearance: none;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;

    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
}

#productCategory:focus {
    outline: none;
    border-color: #9b5cff;
    box-shadow: 0 0 0 2px rgba(155, 92, 255, .16);
}

#productCategory option {
    color: #f3efff;
    background: #11131d;
}



/* CHICAGO SHOP: PRODUCT SORTING */
.product-sort-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.product-sort-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #7041a8;
    border-radius: 8px;
    background: #171020;
    color: #d7b8ff;
    font-size: 17px;
    cursor: pointer;
}

.product-sort-btn:hover:not(:disabled) {
    background: #663399;
    color: #fff;
}

.product-sort-btn:disabled {
    opacity: .3;
    cursor: not-allowed;
}

#saveProductOrderButton:disabled {
    opacity: .45;
    cursor: not-allowed;
}

#productsBody tr.product-sort-changed {
    background: rgba(138, 43, 226, .08);
}

#productsBody tr.product-sort-dragging {
    opacity: .45;
}

#productsBody tr.product-sort-over {
    outline: 2px dashed #a855f7;
    outline-offset: -2px;
}

.product-drag-handle {
    cursor: grab;
    color: #c084fc;
    font-size: 20px;
    user-select: none;
    touch-action: none;
}


/* CHICAGO SHOP: BRAND CATEGORY SELECT V1 */

#brandsSection .brand-create-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    max-width: 480px;
    margin: 20px 0;
}

#brandsSection #brandName {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
}

#brandsSection .brand-category-field {
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
    min-width: 0;
}

#brandsSection .brand-category-field label {
    color: #c9b5ee;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .3px;
}

#brandsSection .brand-category-select-wrap {
    position: relative;
    width: 100%;
}

#brandsSection .brand-category-select-wrap::after {
    content: "";
    position: absolute;
    right: 19px;
    top: 50%;
    width: 9px;
    height: 9px;
    border-right: 2px solid #c49aff;
    border-bottom: 2px solid #c49aff;
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

#brandsSection #brandCategory {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 52px;
    padding: 0 48px 0 16px;
    border: 1px solid #8c42de;
    border-radius: 14px;
    background: #20172e;
    color: #f5edff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
}

#brandsSection #brandCategory:focus {
    outline: none;
    border-color: #c49aff;
    box-shadow: 0 0 0 3px rgba(151, 79, 239, .2),
                0 0 18px rgba(151, 79, 239, .15);
}

#brandsSection #brandCategory option {
    background: #20172e;
    color: #fff;
}

#brandsSection .brand-create-form button[type="submit"] {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
    font-weight: 700;
}

@media (max-width: 600px) {
    #brandsSection .brand-create-form {
        max-width: 100%;
    }
}
