:root {
    --bg: #1e2124;
    --panel: #2b2f33;
    --border: #3a3f44;
    --text: #dcddde;
    --muted: #9a9da2;
    --accent: #5865f2;
    --ok: #57f287;
    --off: #ed4245;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 14px;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.topnav-bar {
    display: flex;
    align-items: center;
}

.topnav .brand {
    font-weight: 700;
    margin-right: 12px;
}

.nav-toggle-btn {
    display: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
    flex: 1;
}

.topnav a {
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
}

.topnav a.active, .topnav a:hover {
    color: var(--text);
    background: rgba(255,255,255,0.06);
}

.account-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.account-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
}

.nav-spacer {
    flex: 1;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.nav-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.nav-user-name {
    font-size: 13px;
    color: var(--text);
}

.nav-logout, .nav-login, .nav-account {
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.nav-logout:hover, .nav-login:hover, .nav-account:hover, .nav-account.active {
    color: var(--text);
    background: rgba(255,255,255,0.06);
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

h1 { margin-top: 0; }

section {
    margin-bottom: 36px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.cards {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 16px 0;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 160px;
}

.card-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.card-value {
    font-size: 22px;
    font-weight: 700;
}

.card-value.small { font-size: 14px; }
.card-value.ok { color: var(--ok); }
.card-value.off { color: var(--off); }

.card-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.table th, .table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.table td.ok { color: var(--ok); }
.table td.off { color: var(--off); }

/* Чипы редкости — /catalog, страница предмета */
.rarity-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 12px;
}
.rarity-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 12px;
    text-decoration: none;
    line-height: 1.6;
}
.rarity-chip:hover { border-color: var(--accent); }
.rarity-chip.active {
    border-color: var(--accent);
    background: rgba(88, 101, 242, 0.18);
    font-weight: 600;
}
.rarity-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Под-навигация сгруппированных страниц (Деньги/Инструменты/
   Оповещения — см. web/templates/_nav_macros.html), тот же стиль
   .rarity-chip, что и квик-навигация на /kv. */
.kv-quicknav {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--bg);
    padding: 8px 0 14px;
    margin-bottom: 4px;
}

/* Настройка дашборда */
.dash-customize {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
}
.dash-customize .rarity-chip { cursor: pointer; }

/* Сравнение подписок — /account, раздел "О подписке" */
.cmp-table th:not(:first-child),
.cmp-table td:not(:first-child) {
    text-align: center;
    white-space: nowrap;
}
.cmp-table td:first-child { color: var(--text); }
.cmp-table .cmp-yes { color: var(--ok); font-weight: 600; }
.cmp-table .cmp-no { color: var(--off); }
.cmp-table .cmp-num { color: var(--text); font-weight: 600; }
.cmp-table col.cmp-highlight { background: rgba(88, 101, 242, 0.10); }
.cmp-table th.cmp-highlight { color: var(--accent); }

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
}

input[type=text], input[type=number] {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 6px;
}

select {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 6px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}

.btn {
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    cursor: pointer;
    font-weight: 600;
    color: white;
}

.btn-primary { background: var(--accent); }
.btn-danger { background: var(--off); }
.btn-secondary { background: var(--panel); border: 1px solid var(--border); color: var(--text); }
.btn-small { padding: 4px 8px; font-size: 12px; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.alert {
    background: rgba(237, 66, 69, 0.15);
    border: 1px solid var(--off);
    color: var(--off);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.note { color: var(--muted); font-size: 13px; }

.chart {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid var(--border);
}

.small { font-size: 12px; color: var(--muted); }

a { color: var(--accent); }

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap .table {
    min-width: 480px;
}

.settings-mobile { display: none; }

.settings-section-title {
    color: var(--accent);
    font-weight: 700;
    margin: 20px 0 8px;
}

.settings-field {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}

.settings-field label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.settings-field input {
    width: 100%;
}

.settings-field .small {
    margin: 6px 0 0;
}

code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: Consolas, monospace;
}

/* ============================================================
   ОБЗОР КАТАЛОГА — вкладки категорий + сетка карточек
   ============================================================ */

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.category-tab {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}

.category-tab:hover {
    border-color: var(--accent);
    color: var(--text);
}

.category-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.catalog-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    color: var(--text);
    transition: border-color 0.15s;
}

.catalog-card:hover {
    border-color: var(--accent);
}

.catalog-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
}

.catalog-card-top-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.catalog-card-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
}

.op-session {
    margin-bottom: 24px;
}

.op-session-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.op-gear-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
}

.item-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.item-detail-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.catalog-card-category {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 7px;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.catalog-card-discount {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
    background: rgba(87, 242, 135, 0.18);
    color: var(--ok);
    white-space: nowrap;
}

.cat-artefact { background: rgba(155, 89, 217, 0.2); color: #b98af7; }
.cat-craft { background: rgba(87, 242, 135, 0.15); color: var(--ok); }
.cat-weapon { background: rgba(237, 66, 69, 0.15); color: var(--off); }
.cat-armor { background: rgba(88, 101, 242, 0.2); color: #8b97f7; }
.cat-attachment { background: rgba(250, 166, 26, 0.18); color: #faa61a; }
.cat-other { background: rgba(255,255,255,0.08); color: var(--muted); }

.catalog-card-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
    /* длинные названия не разваливают сетку */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.6em;
}

.catalog-card-price-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
}

.catalog-card-price-row strong {
    color: var(--text);
    font-weight: 700;
}

.catalog-card-more {
    display: block;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--accent);
    text-decoration: none;
}

.catalog-card-more:hover {
    text-decoration: underline;
}

textarea {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    resize: vertical;
}

input[type=color] {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 44px;
    height: 38px;
    padding: 2px;
    cursor: pointer;
}

.format-example {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin: 14px 0;
}

.format-example-col {
    flex: 1 1 280px;
    min-width: 240px;
}

.format-example-code {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    margin: 6px 0 0;
}

.format-preview-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    white-space: pre-wrap;
    min-height: 24px;
    font-size: 15px;
    line-height: 1.6;
    margin-top: 6px;
    color: var(--muted);
}

.palette-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
}

.palette-swatch {
    width: 64px;
    text-align: center;
    cursor: pointer;
}

.palette-swatch .swatch-color {
    width: 64px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.palette-swatch:hover .swatch-color {
    outline: 2px solid var(--accent);
}

.palette-swatch .swatch-code {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: 48px 20px 28px;
}

.empty-state-icon {
    font-size: 48px;
    opacity: 0.7;
    margin-bottom: 12px;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.empty-state .note {
    max-width: 420px;
    margin: 0 auto;
}

.player-header {
    margin-bottom: 16px;
}

.player-name {
    font-size: 26px;
    font-weight: 700;
}

.player-status {
    margin-top: 6px;
    line-height: 1.6;
    font-size: 13px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    white-space: pre-wrap;
}

/* ============================================================
   МОБИЛЬНЫЕ ЭКРАНЫ
   ============================================================ */

@media (max-width: 720px) {

    main {
        padding: 14px;
    }

    .topnav {
        flex-wrap: wrap;
        gap: 0;
        padding: 10px 16px;
    }

    .topnav-bar {
        width: 100%;
        justify-content: space-between;
    }

    .topnav .brand {
        margin-right: 4px;
    }

    .nav-toggle-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: none;
        border: 1px solid var(--border);
        border-radius: 6px;
        color: var(--text);
        font-size: 18px;
        cursor: pointer;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 2px;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }

    .nav-links.nav-links-open {
        display: flex;
    }

    .nav-spacer {
        display: none;
    }

    .topnav a {
        padding: 10px 12px;
        font-size: 15px;
        border-radius: 6px;
    }

    .nav-user {
        flex-wrap: wrap;
        padding-top: 8px;
        margin-top: 6px;
        border-top: 1px solid var(--border);
    }

    h1 {
        font-size: 20px;
    }

    section h2 {
        font-size: 16px;
    }

    .cards {
        gap: 10px;
    }

    .card {
        flex: 1 1 calc(50% - 10px);
        min-width: 0;
        padding: 12px 14px;
    }

    .card-value {
        font-size: 18px;
    }

    .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-row input[type=text],
    .form-row input[type=number],
    .form-row input[type=date],
    .form-row select,
    .form-row button {
        width: 100%;
    }

    /* iOS сам зумит страницу при фокусе на инпут с
       шрифтом мельче 16px — держим не меньше 16px. */
    input, select, button {
        font-size: 16px;
    }

    .btn {
        padding: 12px 16px;
    }

    .btn-small {
        padding: 8px 10px;
        font-size: 13px;
    }

    .settings-desktop { display: none; }
    .settings-mobile { display: block; }
}

/* ============================================================
   ТИР-ЛИСТЫ
   ============================================================ */

.tierlist-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.tierlist-readonly-banner {
    background: color-mix(in srgb, var(--accent) 12%, var(--panel));
    border-color: var(--accent);
}

.tierlist-owner {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.tierlist-rename-form {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tierlist-name-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    padding: 5px 8px;
    width: 160px;
}

.badge-published {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #57f287;
    background: rgba(87, 242, 135, 0.15);
    border-radius: 10px;
    padding: 2px 8px;
}

.rating-summary {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.rating-widget {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 8px;
}

.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--border);
    padding: 2px;
    line-height: 1;
}

.star-btn:hover {
    color: #f5d13d;
}

.star-filled {
    color: #f5d13d;
}

.tierlist-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #ed4245;
    color: #ed4245;
}

.btn-danger-outline:hover {
    background: rgba(237, 66, 69, 0.12);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.btn.disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

.published-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.published-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    transition: border-color 0.1s ease;
}

.published-card:hover {
    border-color: var(--accent);
}

.published-card-link {
    display: block;
    text-decoration: none;
    color: var(--text);
}

.published-card-admin {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.published-card-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.published-card-owner {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}

.published-card-count {
    font-size: 12px;
    color: var(--muted);
}

.published-card-rating {
    font-size: 12px;
    color: #f5d13d;
    margin-top: 2px;
}

.live-lots-table th, .live-lots-table td {
    white-space: nowrap;
}

.lot-item-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid var(--border);
    padding-left: 8px;
}

.lot-item-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.lot-item-name {
    font-weight: 600;
    white-space: normal;
}

.badge-solo {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #ff9130;
    background: rgba(255, 145, 48, 0.15);
    border-radius: 10px;
    padding: 1px 7px;
    margin-top: 2px;
}

.badge-banned {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #ed4245;
    background: rgba(237, 66, 69, 0.15);
    border-radius: 10px;
    padding: 2px 8px;
}

.qlt-badge {
    display: inline-block;
    font-size: 12px;
    color: var(--accent);
    background: rgba(88, 101, 242, 0.15);
    border-radius: 10px;
    padding: 2px 8px;
}

.upgrade-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #f5d13d;
    background: rgba(245, 209, 61, 0.15);
    border-radius: 10px;
    padding: 2px 6px;
    margin-left: 4px;
}

.positive {
    color: #57f287;
    font-weight: 600;
}

.negative {
    color: #ed4245;
}

.rank-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 4px 0 14px;
}

.rank-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
}

.rank-legend-item i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.tier-row {
    display: flex;
    align-items: stretch;
    min-height: 64px;
    margin-bottom: 6px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.tier-label {
    flex: 0 0 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: #1a1a1a;
}

.tier-items {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    padding: 8px;
    background: var(--panel);
    min-height: 46px;
    transition: background 0.1s ease;
}

.tierlist-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    min-height: 60px;
    transition: background 0.1s ease;
}

.drop-zone-hover {
    background: color-mix(in srgb, var(--accent) 18%, var(--panel));
}

.drag-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 3px 8px 3px 4px;
    cursor: grab;
    user-select: none;
}

.drag-item.dragging {
    opacity: 0.4;
}

.drag-item:active {
    cursor: grabbing;
}

.tier-item-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    pointer-events: none;
}

.tier-item-name {
    font-size: 13px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.tier-item-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    padding: 0 2px;
}

.tier-item-remove:hover {
    color: var(--red, #ed4245);
}

.tierlist-pool .tier-item-remove {
    display: none;
}
