:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --ink: #17161a;
  --ink-2: #55524b;
  --ink-3: #8a867c;
  --line: #e6e2d8;
  --accent: #b4530a;
  --accent-ink: #ffffff;
  --good: #1d7a46;
  --good-bg: #e3f3ea;
  --warn: #9a6200;
  --warn-bg: #fbf0d9;
  --bad: #b3261e;
  --bad-bg: #fbe5e3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 22, 26, 0.04), 0 6px 20px rgba(23, 22, 26, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131211;
    --surface: #1c1a18;
    --surface-2: #26231f;
    --ink: #f2efe8;
    --ink-2: #b9b5aa;
    --ink-3: #85817a;
    --line: #2f2c27;
    --accent: #e8893f;
    --accent-ink: #1a1308;
    --good: #5fd08f;
    --good-bg: #17301f;
    --warn: #f0b94d;
    --warn-bg: #332712;
    --bad: #ff8a80;
    --bad-bg: #371a18;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 460px; margin: 0 auto; }
.mid { max-width: 720px; margin: 0 auto; }
main { padding: 28px 0 72px; min-height: 60vh; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { height: 24px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding-top: 6px; padding-bottom: 6px; gap: 8px 16px; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: -0.03em; text-decoration: none; font-size: 1.15rem; display: flex; gap: 8px; align-items: center; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--ink); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border-radius: 2px; background: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav a, .nav button.link { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 0.95rem; background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav a:hover, .nav button.link:hover, .nav a.active { color: var(--ink); background: var(--surface-2); }
.nav form { margin: 0; }
.pip { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; font-weight: 700; line-height: 18px; text-align: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: 0.95rem; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: transform 0.05s, background 0.15s, border-color 0.15s; line-height: 1.2; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--accent)); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink-3); }
.btn-danger { background: transparent; border-color: var(--line); color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 8px; }
.btn-block { width: 100%; }
form.inline { display: inline; margin: 0; }

/* alerts */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 0.95rem; border: 1px solid transparent; }
.alert-success { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert ul { margin: 0; padding-left: 18px; }

/* hero */
.hero { padding: 48px 0 36px; display: grid; gap: 18px; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); max-width: 16ch; margin: 0; }
.hero p { font-size: 1.15rem; color: var(--ink-2); max-width: 52ch; margin: 0; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 8px; }
.stats b { font-size: 1.5rem; letter-spacing: -0.02em; display: block; }
.stats span { color: var(--ink-3); font-size: 0.85rem; }

/* sections */
.section { margin-top: 44px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; gap: 12px; }
.section-head h2 { margin: 0; }
.section-head a { color: var(--ink-2); font-size: 0.9rem; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-size: 0.9rem; color: var(--ink-2); }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip small { opacity: 0.6; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; box-shadow: var(--shadow); transition: transform 0.15s, border-color 0.15s; }
a.card:hover { transform: translateY(-2px); border-color: var(--ink-3); }
.card-img { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-img .badge { position: absolute; top: 10px; left: 10px; }
.card-body { padding: 14px 16px 16px; }
.card-body h3 { margin: 0 0 2px; font-size: 1rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-body .sub { color: var(--ink-2); font-size: 0.875rem; margin: 0; min-height: 1.3em; }
.card-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 0.82rem; color: var(--ink-3); gap: 8px; }
.price { font-weight: 700; color: var(--ink); font-size: 0.95rem; }
.flat { padding: 20px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; background: var(--ink); color: var(--bg); }
.badge-selling { background: var(--good); color: #fff; }
.badge-sold { background: var(--ink-3); color: #fff; }
.badge-keeper { background: var(--ink); color: var(--bg); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 0.76rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.tag-good { background: var(--good-bg); color: var(--good); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-bad { background: var(--bad-bg); color: var(--bad); }

.cat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.cat-tile { padding: 18px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cat-tile:hover { border-color: var(--ink); }
.cat-tile small { color: var(--ink-3); font-weight: 500; }

/* item detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 36px; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; gap: 22px; } }
.detail-img { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.detail-img img { width: 100%; height: auto; max-height: 78vh; object-fit: contain; margin: 0 auto; }
.spec { display: grid; grid-template-columns: 130px 1fr; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); margin: 18px 0; }
.spec dt, .spec dd { padding: 11px 16px; margin: 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.spec dt { color: var(--ink-3); background: var(--surface-2); }
.spec dt:last-of-type, .spec dd:last-of-type { border-bottom: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel h2, .panel h3 { margin-top: 0; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }

/* forms */
.field { margin-bottom: 18px; }
label, .label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=file] { font: inherit; width: 100%; padding: 14px; border: 1.5px dashed var(--line); border-radius: 10px; background: var(--surface); }
.help { color: var(--ink-3); font-size: 0.82rem; margin-top: 5px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; padding: 9px 20px; cursor: pointer; font-weight: 600; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: var(--ink); color: var(--bg); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.preview { margin-top: 12px; max-height: 240px; border-radius: 10px; border: 1px solid var(--line); }
.filters { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; margin-bottom: 22px; }
@media (max-width: 720px) { .filters { grid-template-columns: 1fr 1fr; } .filters input[type=search] { grid-column: 1 / -1; } }
.filters.admin { grid-template-columns: 1.4fr repeat(3, auto) auto; }
@media (max-width: 860px) { .filters.admin { grid-template-columns: 1fr 1fr; } .filters.admin input[type=search] { grid-column: 1 / -1; } }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-3); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; display: block; }
a.tile:hover { border-color: var(--ink-3); }
.tile b { font-size: 1.8rem; letter-spacing: -0.03em; display: block; line-height: 1.1; }
.tile span { color: var(--ink-3); font-size: 0.85rem; }
.tile.hot { border-color: var(--accent); }

.subnav { display: flex; gap: 6px; margin-bottom: 26px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.subnav a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 0.93rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subnav a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* offers */
.offer { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: start; padding: 16px 0; border-bottom: 1px solid var(--line); }
.offer:last-child { border-bottom: 0; }
.offer.unread { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%); margin: 0 -22px; padding-left: 22px; padding-right: 22px; }
.offer .amt { font-weight: 800; font-size: 1.1rem; }
.offer blockquote { margin: 8px 0 0; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.offer .btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .offer { grid-template-columns: 48px 1fr; } .offer .btns { grid-column: 1 / -1; justify-content: flex-start; } }
.note { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; font-size: 0.93rem; }
.note:last-child { border-bottom: 0; }
.note.unread { font-weight: 600; }

/* pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-size: 0.9rem; background: var(--surface); }
.pagination .cur { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pagination .off { opacity: 0.4; }

.empty { text-align: center; padding: 56px 20px; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--ink-2); }
.empty h3 { color: var(--ink); }

.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: 1.6rem; flex: none; }

footer.site-footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--ink-3); font-size: 0.875rem; }
footer.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.error-page { text-align: center; padding: 70px 0; }
.error-page .code { font-size: 5rem; font-weight: 800; letter-spacing: -0.05em; color: var(--ink-3); line-height: 1; }

@media (max-width: 640px) {
  .site-header { position: static; }
  .site-header .container { flex-direction: column; align-items: flex-start; padding-top: 12px; padding-bottom: 8px; }
  .nav { justify-content: flex-start; margin-left: -12px; }
  .nav a, .nav button.link { padding: 6px 10px; font-size: 0.9rem; }
  main { padding-top: 18px; }
}
