/*
 * Стилі сайту.
 * Правило кольору: жовта «бірка» — це гроші, синій — дія, червоний — час спливає.
 */

@font-face {
    font-family: "Fira Sans";
    src: url("fonts/firasans-400.woff") format("woff");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Fira Sans";
    src: url("fonts/firasans-600.woff") format("woff");
    font-weight: 600 700;
    font-display: swap;
}

@font-face {
    font-family: "Bitter";
    src: url("fonts/bitter-700.woff") format("woff");
    font-weight: 700;
    font-display: swap;
}

:root {
    --ink: #172043;
    --paper: #eef0f5;
    --sheet: #ffffff;
    --tag: #ffc93c;
    --tag-dark: #eeb110;
    --cobalt: #2743d6;
    --cobalt-dark: #1c31a8;
    --alarm: #bd2238;
    --moss: #1a7045;
    --mute: #565e82;
    --line: #d8dce8;
    --field: #b9c0d6;
    --text: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --display: "Bitter", Georgia, "Times New Roman", serif;
    --radius: 8px;
    color-scheme: light;
}

/* ---------- Основа ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font: 400 1rem/1.5 var(--text);
}

img { display: block; max-width: 100%; }
a { color: var(--cobalt); text-underline-offset: 3px; }
a:hover { color: var(--cobalt-dark); }

h1, h2, h3 {
    margin: 0 0 .6em;
    font-family: var(--display);
    font-weight: 700;
    line-height: 1.22;
    text-wrap: balance;
    overflow-wrap: anywhere;
}
h1 { font-size: clamp(1.6rem, 3vw, 2.05rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .75em; }
section { margin-bottom: 32px; }
summary { cursor: pointer; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }

.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }
main.wrap { flex: 1; padding-block: 24px 40px; }

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.skip { position: absolute; left: -999px; top: 8px; z-index: 10; padding: 8px 14px; background: var(--sheet); }
.skip:focus { left: 8px; }
.muted { color: var(--mute); }
.block { display: block; }
.pre-line { white-space: pre-line; overflow-wrap: anywhere; }
.narrow { max-width: 760px; margin-inline: auto; }
.num { font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.plus { color: var(--moss); }
.minus { color: var(--alarm); }
.plain-row { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; padding: 0; list-style: none; }

/* ---------- Шапка ---------- */

.top { background: var(--ink); color: #fff; }
.top :focus-visible { outline-color: var(--tag); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding-block: 12px; }

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font: 700 1.55rem/1 var(--display);
    text-decoration: none;
}
.logo:hover { color: #fff; }
.tag-icon { flex: none; }
.tag-icon path { fill: var(--tag); }
.tag-icon circle { fill: var(--ink); }

.search { display: flex; flex: 1 1 220px; max-width: 480px; }
.search input { flex: 1; min-width: 0; padding: 10px 14px; border: 0; border-radius: var(--radius) 0 0 var(--radius); background: #fff; }
.search button {
    padding: 0 18px;
    border: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: #dde1f1;
    color: var(--ink);
    font: 600 1rem var(--text);
    cursor: pointer;
}
.search button:hover { background: #c9cfe8; }

.top-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-left: auto; }
.top-nav a:not(.btn), .top-nav .link { color: #fff; text-decoration: none; }
.top-nav a:not(.btn):hover, .top-nav .link:hover, .top-nav a:not(.btn)[aria-current] { text-decoration: underline; }
.counter {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 .4em;
    border-radius: 999px;
    background: var(--tag);
    color: var(--ink);
    font-size: .8rem;
    font-weight: 600;
    text-align: center;
}

.cats { background: var(--sheet); border-bottom: 1px solid var(--line); }
.cats-row { display: flex; gap: 0 24px; overflow-x: auto; scrollbar-width: thin; }
@media (min-width: 721px) {
    /* На широкому екрані рядок переноситься, а не ховає категорії за прокруткою */
    .cats-row { flex-wrap: wrap; overflow: visible; }
}
.cats a { flex: none; padding: 12px 0 9px; border-bottom: 3px solid transparent; color: var(--ink); text-decoration: none; }
.cats a:hover { border-bottom-color: var(--line); }
.cats a[aria-current] { border-bottom-color: var(--tag); font-weight: 600; }

.foot { padding-block: 24px; background: var(--ink); color: #c8cde6; font-size: .93rem; }
.foot strong { color: #fff; }
.foot p { margin: 0 0 4px; }

/* ---------- Кнопки ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 18px;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font: 600 1rem/1.25 var(--text);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn-primary { border-color: var(--cobalt); background: var(--cobalt); color: #fff; }
.btn-primary:hover { border-color: var(--cobalt-dark); background: var(--cobalt-dark); color: #fff; }
.btn-tag { border-color: var(--tag); background: var(--tag); color: var(--ink); }
.btn-tag:hover { border-color: var(--tag-dark); background: var(--tag-dark); color: var(--ink); }
.btn-light { border-color: #fff; background: #fff; color: var(--ink); }
.btn-light:hover { border-color: #dde1f1; background: #dde1f1; color: var(--ink); }
.btn-danger { border-color: var(--alarm); color: var(--alarm); }
.btn-danger:hover { background: var(--alarm); color: #fff; }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: .92rem; }
.btn-lg { min-height: 52px; padding: 12px 28px; font-size: 1.08rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.link { padding: 0; border: 0; background: none; color: var(--cobalt); font: inherit; cursor: pointer; }

/* ---------- Форми ---------- */

input, select, textarea { font: inherit; color: inherit; }
/* :where має нульову вагу, тож будь-який клас легко перевизначає ці стилі */
:where(input:not([type="checkbox"], [type="radio"], [type="file"]), select, textarea) {
    max-width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1.5px solid var(--field);
    border-radius: var(--radius);
    background: #fff;
}
textarea { width: 100%; resize: vertical; }
input[type="file"] {
    width: 100%;
    max-width: 100%;
    padding: 8px;
    border: 1.5px dashed var(--field);
    border-radius: var(--radius);
    background: #fff;
    color: var(--mute);
}
input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 7px 16px;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font: 600 .95rem/1.25 var(--text);
    cursor: pointer;
}
input[type="file"]:hover::file-selector-button { background: var(--ink); color: #fff; }

.form { display: flex; flex-direction: column; gap: 18px; margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child, legend { font-weight: 600; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 6px; padding: 0; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form > .btn { align-self: flex-start; }
.check { display: inline-flex; align-items: center; gap: 8px; }
.check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--cobalt); }
.hint { margin: 0; color: var(--mute); font-size: .9rem; }
.error { color: var(--alarm); font-size: .93rem; font-weight: 600; }
.warning { margin: 6px 0 0; color: var(--alarm); font-weight: 600; }
.note { margin: 0; padding: 12px 14px; border-radius: var(--radius); background: #fff3cf; }

.panel { padding: 24px; border-radius: 14px; background: var(--sheet); }
.panel + h2 { margin-top: 28px; }

.flash {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-left: 5px solid var(--cobalt);
    border-radius: var(--radius);
    background: var(--sheet);
    overflow-wrap: anywhere;
}
.flash-success { border-left-color: var(--moss); }
.flash-error { border-left-color: var(--alarm); }

/* ---------- Цінова бірка ---------- */

.tag {
    --notch: .8em;
    position: relative;
    display: inline-block;
    width: fit-content;
    margin: 0;
    padding: .4em .75em .4em calc(var(--notch) + .75em);
    border-radius: 0 6px 6px 0;
    background: var(--tag);
    color: var(--ink);
    font: 700 1.2rem/1.25 var(--display);
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
    clip-path: polygon(var(--notch) 0, 100% 0, 100% 100%, var(--notch) 100%, 0 50%);
}
.tag::before {
    content: "";
    position: absolute;
    top: 50%;
    left: calc(var(--notch) - .2em);
    width: .42em;
    height: .42em;
    margin-top: -.21em;
    border-radius: 50%;
    background: var(--sheet);
}
.tag-lg { font-size: 1.7rem; }
.tag-xl { font-size: clamp(2rem, 4vw, 2.6rem); }
/* Бірка гойдається, коли з'являється нова ставка */
.tag.is-swinging { animation: swing 1.1s ease-out; transform-origin: var(--notch) 50%; }
@keyframes swing {
    18% { transform: rotate(-7deg); }
    40% { transform: rotate(5deg); }
    62% { transform: rotate(-2.5deg); }
    82% { transform: rotate(1deg); }
}
@media (prefers-reduced-motion: reduce) {
    .tag.is-swinging { animation: none; }
}

.clock { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.clock.is-urgent { color: var(--alarm); }

/* ---------- Головний лот ---------- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    margin-bottom: 36px;
    overflow: hidden;
    border-radius: 18px;
    background: var(--ink);
    color: #fff;
}
.hero :focus-visible { outline-color: var(--tag); }
.hero-photo { position: relative; display: block; min-height: 340px; text-decoration: none; }
.hero-photo > img, .hero-photo > .no-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 18px;
    padding: clamp(22px, 4vw, 48px);
}
.hero-clock { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 0; color: #c8cde6; }
.hero-clock .clock { color: #fff; font: 700 clamp(2.9rem, 6.4vw, 5rem)/1 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.hero-clock .clock.is-urgent { color: #ff8f9c; }
.hero h2 { margin: 0; font-size: clamp(1.3rem, 2.3vw, 1.75rem); }
.hero h2 a { color: #fff; text-decoration: none; }
.hero h2 a:hover { text-decoration: underline; }
.hero-price { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.hero .tag::before { background: var(--ink); }

/* ---------- Каталог ---------- */

.catalog { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
.filters { padding: 20px; border-radius: 14px; background: var(--sheet); }
.filters summary { display: none; }
.filters form { display: flex; flex-direction: column; gap: 18px; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.range input { width: 100%; }
.results { min-width: 0; }
.results-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.results-head h1 { margin-bottom: 2px; }
.results-head p { margin: 0; }
.sort { display: flex; align-items: center; gap: 8px; }
.js [data-nojs] { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 32px 20px; }

.card { display: flex; flex-direction: column; min-width: 0; }
.card-photo { display: block; text-decoration: none; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 12px; background: var(--sheet); }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card .tag { z-index: 1; margin: -19px 0 8px 10px; }
.card-title { margin: 0 0 6px; font: 600 1.03rem/1.35 var(--text); }
.card-title a {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ink);
    text-decoration: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.card-title a:hover { color: var(--cobalt); text-decoration: underline; }
.card-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; margin: 0; color: var(--mute); font-size: .94rem; }
.card-buy { margin: 4px 0 0; color: var(--mute); font-size: .94rem; }

.no-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    background: #dfe2ee;
    color: var(--mute);
    font-size: .85rem;
}
.no-photo .tag-icon { width: 48px; height: 36px; }
.no-photo .tag-icon path { fill: #a4abc8; }
.no-photo .tag-icon circle { fill: #dfe2ee; }
.hero .no-photo { background: #25305c; color: #c8cde6; }
.hero .no-photo .tag-icon circle { fill: #25305c; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; margin-top: 32px; }

.empty { padding: 44px 24px; border-radius: 14px; background: var(--sheet); text-align: center; }
.empty p { max-width: 48ch; margin-inline: auto; color: var(--mute); }
.empty .btn { margin-top: 8px; }

/* ---------- Сторінка лота ---------- */

.lot {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "gallery panel" "about panel" "history panel";
    gap: 28px 36px;
    align-items: start;
}
.lot > section { margin: 0; }
.lot-gallery { grid-area: gallery; min-width: 0; }
.lot-about { grid-area: about; }
.lot-history { grid-area: history; }
.lot-panel {
    grid-area: panel;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 26px;
    border-radius: 16px;
    background: var(--sheet);
}
.lot-panel p, .lot-panel h1 { margin: 0; }
.lot-panel h1 { font-size: clamp(1.45rem, 2.4vw, 1.8rem); }

.lot-photo { display: block; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 16px; background: var(--sheet); }
.lot-photo img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.thumb { width: 86px; height: 66px; padding: 0; overflow: hidden; border: 3px solid transparent; border-radius: 10px; background: var(--sheet); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb[aria-pressed="true"] { border-color: var(--cobalt); }

.lot-time { padding-block: 14px; border-block: 1px solid var(--line); }
.lot-clock .clock { font: 700 clamp(2.2rem, 4.4vw, 3rem)/1.15 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.lot-price { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.state { font-weight: 600; }
.state-good { color: var(--moss); }
.state-bad { color: var(--alarm); }
.state-plain { color: var(--mute); }

.bid-form { display: flex; flex-direction: column; gap: 10px; }
.bid-form label { font-weight: 600; }
.bid-row { display: flex; flex-wrap: wrap; gap: 10px; }
.bid-row input { flex: 1 1 120px; width: 120px; min-height: 52px; font: 700 1.35rem var(--display); }
.bid-row .btn { flex: 1 0 auto; min-height: 52px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 14px; border: 1.5px solid var(--field); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-size: .93rem; cursor: pointer; }
.chip:hover { border-color: var(--cobalt); color: var(--cobalt); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions form { display: flex; flex-wrap: wrap; gap: 10px; }
.seller { padding-top: 14px; border-top: 1px solid var(--line); }
.admin-box form { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 10px; }
.admin-box .field { align-self: stretch; }

.facts { margin: 20px 0 0; }
.facts > div { display: grid; grid-template-columns: minmax(110px, 32%) minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--mute); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts.panel { margin: 0 0 24px; padding-block: 8px; }
.lot-about > .pre-line { max-width: 70ch; }

/* ---------- Таблиці, вкладки, позначки ---------- */

.table { width: 100%; margin-bottom: 16px; overflow: hidden; border-collapse: collapse; border-radius: 12px; background: var(--sheet); }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--mute); font-size: .92rem; font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .is-top td { background: #fff6da; font-weight: 600; }
.table td { overflow-wrap: anywhere; }
.table td.num { overflow-wrap: normal; }
.lot-cell { display: flex; align-items: center; gap: 12px; min-width: 180px; color: var(--ink); font-weight: 600; text-decoration: none; }
.lot-cell > img, .lot-cell > .no-photo { flex: none; width: 68px; height: 51px; border-radius: 8px; object-fit: cover; }
.lot-cell .no-photo > span { display: none; }
.lot-cell .no-photo .tag-icon { width: 28px; height: 21px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #e1e5f2; color: var(--ink); font-size: .84rem; font-weight: 600; white-space: nowrap; }
.badge-sold, .badge-completed, .badge-approved { background: #d9efe3; color: #125a36; }
.badge-cancelled, .badge-rejected { background: #fbdfe3; color: #911729; }
.badge-new, .badge-pending { background: #ffefbd; color: #644700; }
.badge-paid, .badge-shipped, .badge-active { background: #dce2fc; color: var(--cobalt-dark); }

.tabs { display: flex; gap: 24px; margin-bottom: 24px; overflow-x: auto; border-bottom: 1.5px solid var(--line); scrollbar-width: thin; }
.tabs a { flex: none; padding: 8px 0 9px; border-bottom: 3px solid transparent; color: var(--mute); text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { border-bottom-color: var(--cobalt); color: var(--ink); font-weight: 600; }

/* ---------- Кабінет, угода, профіль ---------- */

.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; align-items: start; }
.auth { max-width: 460px; margin-inline: auto; }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin-bottom: 8px; }

.balance { margin-bottom: 28px; }
.balance p:last-child { margin: 0; }
.balance-sum { margin-bottom: 6px; font: 700 2.8rem/1.15 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.balance-sum.is-negative { color: var(--alarm); }

.deal-price { margin: 16px 0; }
.next-step { padding: 12px 14px; border-radius: var(--radius); background: #e6eafd; }
.messages { display: flex; flex-direction: column; gap: 10px; max-height: 460px; margin-bottom: 16px; overflow-y: auto; }
.message { align-self: flex-start; max-width: 90%; padding: 10px 14px; border-radius: 14px; background: var(--sheet); }
.message.is-mine { align-self: flex-end; background: #dfe5fd; }
.message p { margin: 0; }
.message time { margin-left: 8px; font-size: .85rem; }
.problem { margin-bottom: 28px; }
.problem summary { margin-bottom: 12px; color: var(--alarm); font-weight: 600; }

.review { margin-bottom: 12px; padding: 14px 18px; border-radius: 12px; background: var(--sheet); }
.review p { margin: 0 0 4px; }
.rating-4, .rating-5 { color: var(--moss); }
.rating-1, .rating-2 { color: var(--alarm); }

.notices { margin: 0; padding: 0; list-style: none; }
.notices li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-bottom: 8px; padding: 14px 18px; border-radius: 12px; background: var(--sheet); overflow-wrap: anywhere; }
.notices li.is-new { box-shadow: inset 5px 0 0 var(--tag-dark); font-weight: 600; }
.notices time { font-size: .9rem; font-weight: 400; white-space: nowrap; }

.edit-images { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.edit-images label { display: flex; flex-direction: column; gap: 6px; }
.edit-images img { width: 120px; height: 90px; border-radius: 10px; object-fit: cover; }
.previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.previews img { width: 104px; height: 78px; border-radius: 10px; object-fit: cover; }

/* ---------- Адмін-панель ---------- */

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; }
.stats > div { display: flex; flex-direction: column-reverse; padding: 18px 22px; border-radius: 14px; background: var(--sheet); }
.stats dt { color: var(--mute); }
.stats dd { margin: 0; font: 700 1.85rem/1.3 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.todo { margin: 0 0 24px; padding: 0; list-style: none; }
.todo li { margin-bottom: 8px; padding: 12px 16px; border-radius: var(--radius); background: #ffefbd; }
.todo a { color: var(--ink); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar input[type="search"] { flex: 0 1 320px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.inline-form input { flex: 1 1 130px; min-width: 0; }
.category-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; border-bottom: 1px solid var(--line); }
.category-row .inline-form { flex: 1 1 420px; }
.category-row + h2 { margin-top: 32px; }
.inline-form input[type="number"] { flex: 0 0 96px; }

.debug { text-align: left; font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Вужчі екрани ---------- */

@media (min-width: 961px) and (min-height: 900px) {
    .lot-panel { position: sticky; top: 16px; }
}

@media (max-width: 960px) {
    .hero { grid-template-columns: 1fr; }
    .hero-photo { min-height: 0; aspect-ratio: 16 / 9; }
    .catalog { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .filters { padding: 0; }
    .filters summary { display: list-item; padding: 12px 16px; font-weight: 600; }
    .filters form { padding: 4px 16px 18px; }
    .lot {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas: "gallery" "panel" "about" "history";
    }
    .two-columns { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .search { order: 3; flex-basis: 100%; max-width: none; }
    .top-nav { gap: 8px 16px; }
    .form-row, .form-row-3 { grid-template-columns: minmax(0, 1fr); }
    .panel, .lot-panel { padding: 18px; }
    .facts.panel { padding-block: 6px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 12px; }
    .grid .card .tag { margin-left: 6px; font-size: 1.02rem; }
    .sort { width: 100%; }
    .sort select { flex: 1; }

    /* Таблиці стають картками: підпис стовпця ліворуч, значення праворуч від нього */
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table { background: none; border-radius: 0; }
    .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .table tr { margin-bottom: 10px; padding-block: 6px; overflow: hidden; border-radius: 12px; background: var(--sheet); }
    .table td { position: relative; padding: 3px 14px 3px 114px; border: 0; }
    .table .is-top td { background: none; }
    .table tr.is-top { background: #fff6da; }
    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 14px;
        top: 3px;
        width: 88px;
        color: var(--mute);
        font-size: .85rem;
        font-weight: 400;
        line-height: 1.75;
    }
    /* Комірки без підпису або з формами займають усю ширину картки */
    .table td[data-label="Лот"], .table td[data-label="Керування"], .table td[data-label="Рішення"] { padding-left: 14px; }
    .table td[data-label="Лот"]::before, .table td[data-label="Керування"]::before, .table td[data-label="Рішення"]::before { content: none; }
    .table td[data-label="Лот"] { padding-block: 6px; }
    .table .inline-form input { flex-basis: 100%; }

    /* Історія ставок: один рядок на ставку */
    .lot-history .table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: baseline; gap: 0 14px; margin-bottom: 6px; padding: 9px 14px; }
    .lot-history .table td { width: auto; padding: 0; }
    .lot-history .table td::before { content: none; }
}

@media (max-width: 480px) {
    .stats { grid-template-columns: minmax(0, 1fr); }
}
