:root {
    --bg: #eef2f7;
    --card: #ffffff;
    --border: rgba(15, 23, 42, 0.10);
    --text: #0f172a;
    --muted: #6b7280;

    --blue1: #2f76ff;
    --blue2: #1e56ff;

    --danger: #d3272a;
    --ok: #0b8a3c;

    --shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] {
    --bg: #0f141b;
    --card: #151c24;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e6edf3;
    --muted: #8b98a5;

    --blue1: #3b82f6;
    --blue2: #2563eb;

    --danger: #ff5c5c;
    --ok: #22c55e;

    --shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    max-width: 520px;
    margin: 0 auto;
}

.page-pad {
    padding: 12px;
}

.notice {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: var(--shadow);
    font-weight: 700;
    font-size: 13px;
}

.notice.err {
    border-color: rgba(211, 39, 42, 0.35);
    color: var(--danger);
}

.notice.ok {
    border-color: rgba(11, 138, 60, 0.35);
    color: var(--ok);
}

hr.sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

/* Header like screenshot */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.userbar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: linear-gradient(135deg, #c7d2fe, #93c5fd);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: #0b1b3a;
    flex: 0 0 auto;
    overflow: hidden;
}

.username {
    font-weight: 900;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balancebar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.balance-pill {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    font-weight: 900;
}

.star {
    width: 16px;
    height: 16px;
    display: inline-block;
    background: url("./stars_2.png") center / contain no-repeat;
}

.plusbtn {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-weight: 900;
    cursor: pointer;
}

/* Tabs row */
.tabs {
    display: flex;
    gap: 8px;
    padding: 12px;
}

.tab {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 900;
    text-align: center;
    box-shadow: var(--shadow);
}

.tab.active {
    border-color: rgba(47, 118, 255, 0.35);
}

/* Lots grid */
.lots-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.lot-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);

    display: flex;
    flex-direction: column;
    height: 100%;
}

.lot-body {
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto; /* занимает всё пространство */
    justify-content: flex-end;
}

.lot-header {
    padding: 10px 10px 0 10px;
}


.lot-footer {
    margin-top: auto;
    padding: 10px;
}

.lot-topline {
    padding: 10px 10px 0 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.lot-title {
    padding: 4px 10px 8px 10px;
    font-weight: 1000;
    font-size: 16px;

    /* NEW: clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;

    margin-top: 2px;
    line-height: 1.15;
    min-height: calc(1.15em * 2); /* фиксируем высоту под 2 строки */
}

.lot-imgwrap {
    margin: 0 10px;
    border-radius: 12px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    height: 110px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lot-imgwrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lot-imgwrap .ph {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.lot-meta {
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.meta-right {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 1000;
    min-width: 0; /* NEW */
    max-width: 48%; /* NEW: чтобы не выдавливало таймер */
    justify-content: flex-end; /* NEW */
}

.meta-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 900;
}

.meta-right .price {
    min-width: 0; /* NEW */
    overflow: hidden; /* NEW */
    text-overflow: ellipsis; /* NEW */
    white-space: nowrap; /* NEW */
}

.smalltag {
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.timer {
    font-weight: 1000;
    font-size: 16px;
}

.timer.danger {
    color: var(--danger);
}


.bidbtn {
    width: calc(100% - 20px);
    margin: 0 10px 10px 10px;
    border: none;
    border-radius: 12px;
    padding: 12px 10px;
    font-weight: 1000;
    color: #fff;
    background: linear-gradient(180deg, var(--blue1), var(--blue2));
    box-shadow: 0 10px 18px rgba(47, 118, 255, 0.25);
    cursor: pointer;
}

.bidbtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* Card sections */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.h2 {
    font-weight: 1000;
    font-size: 16px;
    margin: 0 0 8px 0;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 900;
    cursor: pointer;
}

.btn.primary {
    border: none;
    color: #fff;
    background: linear-gradient(180deg, var(--blue1), var(--blue2));
    box-shadow: 0 10px 18px rgba(47, 118, 255, 0.20);
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-weight: 800;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th, .table td {
    border-bottom: 1px solid var(--border);
    padding: 8px 6px;
    text-align: left;
}

.muted {
    color: var(--muted);
    font-weight: 700;
}

.footer-note {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
}

.lot-submeta {
    padding: 0 10px 10px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}

.lot-submeta b {
    font-weight: 1000;
    color: var(--text);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 999;
}

.modal-card {
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow);
}

/* Lot detail: same aspect as cards on main */
.lot-imgwrap--detail {
    margin: 0 10px; /* как в карточке */
    height: 110px; /* как в карточке */
}

@media (max-width: 360px) {
    .lot-title {
        -webkit-line-clamp: 1;
        min-height: calc(1.15em * 1);
    }
}

/* Two-line meta (timer first line, price second line) */
/* Two-line meta (timer first line, price second line) */
.lot-meta--stack {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    min-height: 54px;
    align-items: flex-start;
    /* text-align можно убрать, он не нужен */
}

.lot-meta--stack .meta-line {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
}

/* ✅ ВАЖНО: вернуть “типографику” мета-зоны */
.lot-meta--stack .meta-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 900; /* как было в .meta-left */
}

.lot-meta--stack .timer {
    font-weight: 1000; /* как было */
    font-size: 16px; /* как было */
}

.lot-meta--stack .meta-price {
    display: flex;
    align-items: baseline; /* вместо center */
    gap: 6px;
    font-weight: 1000; /* как было в .meta-right */
    margin-left: 9px;
}

.lot-meta--stack .price {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    font-weight: 900;
    color: var(--muted);
}

.badge.ok {
    border-color: rgba(11, 138, 60, 0.35);
    color: var(--ok);
}

/* Image sizes for different pages */
.lot-imgwrap--list {
    height: 160px; /* wins list: больше, чтобы подарок влезал */
}

.lot-imgwrap--detail {
    height: 220px; /* lot / win_lot / admin win lot: детальная карточка */
}

/* Archived lots look */
.lot-card.archived {
    opacity: 0.75;
}

.lot-card.archived .lot-imgwrap {
    filter: grayscale(1);
}

.lot-card.archived .bidbtn {
    background: #e5e7eb; /* темнее */
    color: #111827; /* почти чёрный текст */
    box-shadow: none;
    border: 1px solid rgba(15, 23, 42, 0.12);
}

.lot-card.archived .bidbtn:hover {
    background: #dbe1ea;
}

.lot-card.archived .bidbtn:active {
    background: #cfd8e5;
}

.lot-card .arch-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    margin: 0; /* убираем внешние отступы */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(248, 250, 252, 0.95);
    font-size: 12px;
    font-weight: 900;
    color: var(--muted);
    z-index: 2;
    pointer-events: none; /* чтобы не мешал кликам */
}

/* Dark theme tweaks: archive badge, placeholder bg, archived open button */
[data-theme="dark"] .lot-card .arch-badge {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.14);
    color: rgba(230, 237, 243, 0.88);
}

[data-theme="dark"] .lot-imgwrap {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] .lot-imgwrap .ph {
    color: rgba(230, 237, 243, 0.55);
}

[data-theme="dark"] .lot-card.archived .bidbtn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.16);
    color: rgba(230, 237, 243, 0.92);
}

[data-theme="dark"] .lot-card.archived .bidbtn:hover {
    background: rgba(255, 255, 255, 0.16);
}

[data-theme="dark"] .lot-card.archived .bidbtn:active {
    background: rgba(255, 255, 255, 0.20);
}

/* Dark theme: timer badge */
[data-theme="dark"] .smalltag {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.14);
    color: rgba(230, 237, 243, 0.85);
}

[data-theme="dark"] .timer.danger {
    color: #ff6b6b;
}


/* Placeholder card ("Soon") */
.lot-card.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    border-style: dashed;
    background: rgba(255, 255, 255, 0.6);
}

.lot-card.placeholder .soon {
    text-align: center;
    font-weight: 1000;
    color: var(--muted);
}

.lot-card.placeholder .soon .big {
    display: block;
    font-size: 16px;
    color: var(--text);
    margin-bottom: 6px;
}

/* Dark theme placeholder */
[data-theme="dark"] .lot-card.placeholder {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.10);
}

/* Archive section header (full-width inside grid) */
.grid-section {
    grid-column: 1 / -1;
    margin-top: 2px;
    margin-bottom: -2px;
}

.grid-section .label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    font-weight: 1000;
    color: var(--muted);
    font-size: 12px;
}

.bid-main-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 1000;
}

.star-inline {
    width: 16px;
    height: 16px;
}

.bid-main-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(47, 118, 255, 0.28);
}

.table th {
    font-weight: 800;
    color: var(--muted);
}

.table td b {
    font-weight: 1000;
    font-size: 15px;
}

.onboarding-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(6px);
}

/* Light theme */
[data-theme="light"] .onboarding-overlay {
    background: rgba(0, 0, 0, 0.35);
}

/* Dark theme */
[data-theme="dark"] .onboarding-overlay {
    background: rgba(0, 0, 0, 0.65);
}

.onboarding-overlay.hidden {
    display: none;
}

.onboarding-card {
    width: 90%;
    max-width: 360px;
    padding: 24px;
    border-radius: 18px;
    background: var(--card-bg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: fadeInScale .25s ease;
    border: 1px solid var(--border-color);
}

/* Dark theme card */
[data-theme="dark"] .onboarding-card {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .onboarding-card {
    background: #ffffff;
}

.onboarding-emoji {
    font-size: 42px;
    margin-bottom: 12px;
}

.onboarding-title {
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 12px;
}

.onboarding-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 18px;
}

/* Light */
[data-theme="light"] .onboarding-text {
    color: #444;
}

/* Dark */
[data-theme="dark"] .onboarding-text {
    color: rgba(255, 255, 255, 0.8);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.stat-box {
    padding: 16px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: 13px;
    opacity: .7;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
}

.stat-box.highlight {
    grid-column: span 2;
    background: linear-gradient(135deg, #2b5876, #4e4376);
    color: white;
}

.full-width {
    width: 100%;
    justify-content: center;
}

.lot-card.archived {
    position: relative;
    border-radius: 16px;
    transition: 0.2s ease;
}

[data-theme="dark"] .lot-card.archived {
    background: #1a2633; /* светлее активной */
    border: 1px solid #253445;
    box-shadow: none;
}

[data-theme="light"] .lot-card.archived {
    background: #eef3f8;
    border: 1px solid #d3dde6;
    box-shadow: none;
}

[data-theme="dark"] .lot-card.archived .btn {
    background: #243242;
    border: 1px solid #344a60;
    color: #c7d4e0;
}

[data-theme="light"] .lot-card.archived .btn {
    background: #e9eef4;
    border: 1px solid #cfd9e2;
    color: #3f4f60;
}

.lot-card.archived::before {
    content: "Завершён";
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

[data-theme="dark"] .lot-card.archived::before {
    background: #2a3644;
    color: #9fb3c8;
}


[data-theme="light"] .lot-card.archived::before {
    background: #e2e7ed;
    color: #5f6e7c;
}

.lot-card.archived img {
    filter: grayscale(10%);
}

/* ===== LOT EXTRA INFO ===== */

.lot-extra {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lot-buy-price {
    font-weight: 600;
    font-size: 14px;
    opacity: 0.9;
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--border-color);
}

/* Dark theme */
[data-theme="dark"] .lot-buy-price {
    color: #cfe3ff;
}

/* Light theme */
[data-theme="light"] .lot-buy-price {
    color: #2c3e50;
}

.lot-topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
    position: absolute;
    top: 12px;
    right: 12px;
}

#lotCard {
    position: relative;
}

.lot-close {
    background: transparent;
    border: none;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    color: var(--muted);
}

.lot-close:hover {
    color: var(--text);
}

.lot-title-block {
    margin-bottom: 8px;
}

.lot-id {
    font-size: 13px;
    color: var(--muted);
    font-weight: 800;
}

.lot-name {
    font-size: 18px;
    font-weight: 1000;
    line-height: 1.2;
}

.userbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    transition: all .15s ease;
}

.userbar-btn:hover {
    background: rgba(47, 118, 255, 0.08);
    border-color: rgba(47, 118, 255, 0.35);
}

.userbar-btn:active {
    transform: scale(0.97);
}
