/* ── Reset / base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: #0f1115;
    color: #e6e8ec;
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
    font: inherit; color: inherit;
    background: #1a1d24;
    border: 1px solid #2a2f3a;
    border-radius: 8px;
    padding: 8px 10px;
    width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #3b82f6; outline-offset: 0; }
code { background: #1a1d24; padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }
small { color: #8a8f9c; }

/* ── Topbar ───────────────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; gap: 24px;
    padding: 14px 24px;
    border-bottom: 1px solid #1f2330;
    background: #12141a;
    position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
    padding: 8px 16px; border-radius: 8px; color: #8a8f9c;
    transition: background .15s, color .15s;
}
.tab:hover { color: #e6e8ec; background: #1a1d24; }
.tab.active { color: #fff; background: #2a2f3a; }
.refbadge { margin-left: auto; }
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: #1f2937;
    color: #93c5fd;
    font-size: 12px;
}

/* ── Layout ───────────────────────────────────────────────────────── */
.content { padding: 20px 24px; }
.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
}

/* ── Filters ──────────────────────────────────────────────────────── */
.filters {
    position: sticky; top: 70px;
    align-self: start;
    background: #141821;
    border: 1px solid #1f2330;
    border-radius: 12px;
    padding: 16px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}
.filter-block { margin-bottom: 14px; }
.filter-block .lbl {
    display: block; font-size: 12px; color: #8a8f9c;
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px;
}
.range { display: flex; gap: 8px; }
.range input[type=range] { padding: 0; background: transparent; border: none; }
.range-vals { display: flex; justify-content: space-between; font-size: 12px; color: #8a8f9c; margin-top: 4px; }

/* ── Dropdown filter ──────────────────────────────────────────────── */
.dropdown { position: relative; margin-bottom: 10px; }
.dd-toggle {
    width: 100%;
    display: flex; align-items: center; gap: 8px;
    background: #1a1d24;
    border: 1px solid #2a2f3a;
    color: #e6e8ec;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, border-color .15s;
    text-align: left;
}
.dd-toggle:hover { background: #20242e; border-color: #353b48; }
.dd-toggle.active { background: #1e2733; border-color: #3b82f6; }
.dd-label { flex: 1; }
.dd-counter {
    background: #3b82f6; color: #fff;
    font-size: 11px; font-weight: 700;
    padding: 1px 7px; border-radius: 999px;
    min-width: 18px; text-align: center;
}
.dd-arrow { color: #8a8f9c; font-size: 11px; transition: transform .15s; }
.dd-toggle.active .dd-arrow { transform: rotate(180deg); color: #93c5fd; }

.dd-panel {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #161a23;
    border: 1px solid #2a2f3a;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
    z-index: 30;
    overflow: hidden;
    display: flex; flex-direction: column;
}
.dd-search {
    background: #1a1d24;
    border: none;
    border-bottom: 1px solid #2a2f3a;
    border-radius: 0;
    padding: 9px 12px;
    font-size: 13px;
}
.dd-search:focus { outline: none; }
.dd-search::placeholder { color: #6b7280; }
.dd-list {
    max-height: 260px;
    overflow-y: auto;
}
.dd-list::-webkit-scrollbar { width: 8px; }
.dd-list::-webkit-scrollbar-track { background: transparent; }
.dd-list::-webkit-scrollbar-thumb { background: #2a2f3a; border-radius: 4px; }

.dd-item {
    padding: 8px 12px;
    font-size: 13px;
    color: #c5cad4;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: background .1s;
}
.dd-item:hover { background: #20242e; color: #fff; }
.dd-item.active {
    background: #1e3a5f;
    color: #93c5fd;
}
.dd-item .dd-check {
    width: 16px; height: 16px; border-radius: 4px;
    border: 1px solid #353b48;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.dd-item.active .dd-check {
    background: #3b82f6;
    border-color: #3b82f6;
}
.dd-item.active .dd-check::after {
    content: ""; width: 4px; height: 8px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px,-1px);
}
.dd-empty {
    padding: 14px; text-align: center; color: #8a8f9c; font-size: 12.5px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: #1a1d24; border: 1px solid #2a2f3a;
    color: #e6e8ec; padding: 6px 10px; border-radius: 999px; font-size: 12.5px;
    transition: background .15s, border-color .15s;
}
.chip.active { background: #1e3a5f; border-color: #3b82f6; color: #93c5fd; }
.chip:hover { background: #232732; }

/* ── Grid ─────────────────────────────────────────────────────────── */
.grid-wrap { min-height: 50vh; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.grid-status {
    padding: 24px; text-align: center; color: #8a8f9c; font-size: 13px;
}

.card-gift {
    background: #141821;
    border: 1px solid #1f2330;
    border-radius: 12px;
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: transform .15s, border-color .15s;
    cursor: pointer;
}
.card-gift:hover { transform: translateY(-2px); border-color: #2a2f3a; }
.card-gift .thumb {
    aspect-ratio: 1 / 1;
    background: #0b0d12 center/contain no-repeat;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%231a1d24'/%3E%3C/svg%3E");
}
.card-gift .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-gift .meta { padding: 8px 10px 4px; font-size: 12.5px; color: #c5cad4; }
.card-gift .meta .title { font-weight: 600; color: #fff; }
.card-gift .meta .sub { color: #8a8f9c; font-size: 11.5px; }
.card-gift .row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px 10px;
    gap: 8px;
}
.card-gift .price {
    background: #1f2937; color: #93c5fd;
    padding: 6px 10px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
.card-gift .buy {
    background: #3b82f6; color: #fff; border: none;
    padding: 6px 14px; border-radius: 8px; font-weight: 600;
}
.card-gift .buy:hover { background: #2563eb; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 8px;
    padding: 9px 14px; font-weight: 600;
    background: #2a2f3a; color: #e6e8ec;
    transition: background .15s;
}
.btn:hover { background: #353b48; }
.btn.primary { background: #3b82f6; color: #fff; }
.btn.primary:hover { background: #2563eb; }
.btn.ghost { background: transparent; border: 1px solid #2a2f3a; }
.btn.ghost:hover { background: #1a1d24; }
.btn.danger { background: #b91c1c; color: #fff; }
.btn.danger:hover { background: #991b1b; }
.btn.full { width: 100%; }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: #141821;
    border: 1px solid #1f2330;
    border-radius: 16px;
    max-width: 920px; width: calc(100% - 32px);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 24px;
}
.modal-content.narrow { max-width: 440px; }
.modal-close {
    position: absolute; top: 12px; right: 14px;
    width: 32px; height: 32px;
    border-radius: 999px;
    background: #1a1d24; border: none; color: #e6e8ec;
    font-size: 22px; line-height: 1;
}
.modal-close:hover { background: #2a2f3a; }

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 720px) { .modal-grid { grid-template-columns: 1fr; } }
.modal-anim {
    width: 100%; aspect-ratio: 1 / 1;
    background: #0b0d12;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.modal-info h2 { margin: 0 0 12px; }
.attrs { list-style: none; padding: 0; margin: 0 0 16px; font-size: 13px; }
.attrs li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #1f2330; }
.attrs .k { color: #8a8f9c; }
.attrs .v { color: #e6e8ec; }
.price-line { margin: 12px 0 16px; }
.price-line .price {
    background: #1f2937; color: #93c5fd;
    padding: 8px 14px; border-radius: 10px;
    font-size: 16px; font-weight: 700;
}

/* Buy modal */
.buy-price {
    font-size: 22px; font-weight: 700; color: #fff;
    text-align: center; margin: 12px 0 4px;
}
.buy-meta {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    text-align: center; color: #8a8f9c; margin-bottom: 14px;
}
.buy-code-label { display: block; font-size: 12px; color: #8a8f9c; margin-bottom: 14px; }
.buy-code-row   { display: flex; gap: 8px; margin-top: 6px; }
.buy-code-row input {
    flex: 1; padding: 11px 14px;
    background: #1f2330; border: 1px solid #2a2f3c; border-radius: 8px;
    color: #fff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 18px; font-weight: 700; letter-spacing: 2px; text-align: center;
}
.buy-code-label small { display: block; margin-top: 6px; color: #8a8f9c; }
.buy-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 13px; }
.alert.ok    { background: #064e3b; color: #6ee7b7; }
.alert.error { background: #7f1d1d; color: #fecaca; }

/* ── Admin ────────────────────────────────────────────────────────── */
.admin-wrap { max-width: 980px; margin: 0 auto; }
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.admin-head h1 { margin: 0; }
.card {
    background: #141821; border: 1px solid #1f2330;
    border-radius: 14px; padding: 20px; margin: 16px 0;
}
.card h2 { margin-top: 0; }
.grid-form {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.grid-form .full { grid-column: 1 / -1; }
.grid-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #8a8f9c; }
.grid-form label input, .grid-form label select { color: #e6e8ec; }
.mt { margin-top: 20px; }
.inline { display: inline; }
.muted { color: #8a8f9c; text-align: center; padding: 14px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid #1f2330; text-align: left; vertical-align: middle; }
.tbl th { color: #8a8f9c; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.tbl .ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
input[readonly] { opacity: .7; cursor: not-allowed; }

.grid-form .subhead {
    color: #8a8f9c;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 8px 0 -4px;
    padding-top: 10px;
    border-top: 1px solid #1f2330;
}
.grid-form .subhead small { text-transform: none; letter-spacing: 0; margin-left: 6px; }

.auth-wrap { max-width: 360px; margin: 80px auto; }
.auth-form { background: #141821; border: 1px solid #1f2330; padding: 28px; border-radius: 14px; }
.auth-form h1 { margin-top: 0; font-size: 20px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #8a8f9c; margin: 12px 0; }

/* ── Misc ─────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
