:root {
  --brand: #0b5d46; --brand-2: #0e7a5b; --brand-ink: #063a2c;
  --accent: #f5b700; --accent-ink: #3a2a00;
  --bg: #f3f5f4; --card: #fff; --ink: #1b2420; --muted: #66726d; --line: #dfe5e2;
  --danger: #c0392b; --ok: #1e8e3e;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.hidden { display: none !important; }
main { min-height: 60vh; padding-top: 20px; padding-bottom: 40px; outline: none; }

/* Header */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 1.25rem; font-weight: 600; }
.logo:hover { text-decoration: none; } .logo b { color: var(--accent); }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a, .nav button { color: #e6f2ee; padding: 8px 10px; border-radius: 6px; font-size: .95rem; background: none; border: 0; cursor: pointer; font: inherit; }
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; margin-left: 4px; }
.catbar { background: var(--brand-ink); overflow-x: auto; }
.catbar-in { display: flex; gap: 2px; white-space: nowrap; }
.catbar a { color: #cfe3dc; padding: 9px 12px; font-size: .9rem; }
.catbar a.active, .catbar a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; white-space: nowrap; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn-accent { background: var(--accent); color: var(--accent-ink); } .btn-accent:hover { background: #ffc626; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); } .btn-ghost:hover { background: #f0f3f2; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f0c9c4; } .btn-danger:hover { background: #fdf0ee; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .6; cursor: default; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; color: #33403b; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #c9d3cf; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--brand); }
textarea { min-height: 140px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { width: auto; margin-top: 3px; }
.error { background: #fdecea; color: #8a1f14; border: 1px solid #f5c6c0; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.notice { background: #fff8e1; border: 1px solid #f3dd97; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.narrow { max-width: 460px; margin: 20px auto; }
.mid { max-width: 820px; margin: 0 auto; }

/* Hero */
.hero { background: linear-gradient(135deg, var(--brand) 0%, #0f7d5e 100%); color: #fff; border-radius: 14px; padding: 32px 24px; margin-bottom: 24px; }
.hero h1 { font-size: 1.9rem; } .hero p { color: #d7ece5; margin-top: 0; }
.hero-search { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; margin-top: 16px; }
.hero-search input, .hero-search select { border: 0; padding: 13px 14px; }
.tabs { display: flex; gap: 6px; margin-top: 18px; }
.tabs button { background: rgba(255,255,255,.14); color: #fff; border: 0; padding: 8px 14px; border-radius: 999px; font: inherit; cursor: pointer; }
.tabs button.on { background: #fff; color: var(--brand-ink); font-weight: 600; }

/* Category tiles */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 28px; }
.cat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 12px; text-align: center; color: var(--ink); }
.cat:hover { text-decoration: none; outline: 2px solid var(--accent); }
.cat .ico { font-size: 1.8rem; } .cat .nm { font-weight: 600; margin-top: 4px; } .cat .ct { font-size: .8rem; color: var(--muted); }
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 0 12px; }

/* Listing cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.ad { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--ink); display: flex; flex-direction: column; position: relative; }
.ad:hover { text-decoration: none; box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.ad .ph { aspect-ratio: 4/3; background: #e7ecea; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: #9bb0a8; overflow: hidden; }
.ad .ph img { width: 100%; height: 100%; object-fit: cover; }
.ad .bd { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ad .tt { font-weight: 600; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ad .pr { font-size: 1.15rem; font-weight: 700; color: var(--brand-ink); }
.ad .meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ad .ft { font-size: .78rem; color: var(--muted); margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; }
.pill { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: #eef3f1; color: #3b4a44; font-weight: 600; }
.pill.trade { background: #e3effa; color: #1f4f7a; } .pill.sold { background: #fdecea; color: var(--danger); }
.pill.active { background: #e6f4ea; color: var(--ok); } .pill.pending_payment, .pill.expired { background: #fff4d6; color: #7a5a00; }
.ad .cnt { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: 2px 7px; border-radius: 6px; }

/* Results layout */
.results { display: grid; grid-template-columns: 270px 1fr; gap: 20px; align-items: start; }
.filters { position: sticky; top: 76px; max-height: calc(100vh - 90px); overflow-y: auto; }
.filters h3 { margin-top: 4px; }
.res-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.res-head select { width: auto; }
.pager { display: flex; justify-content: center; gap: 6px; margin-top: 22px; }
.filter-toggle { display: none; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }

/* Ad detail */
.detail { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.gallery .main { aspect-ratio: 4/3; background: #1d2522; border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 5rem; color: #6f857c; position: relative; }
.gallery .main img { width: 100%; height: 100%; object-fit: contain; }
.gallery .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.5); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 1.3rem; cursor: pointer; }
.gallery .prev { left: 10px; } .gallery .next { right: 10px; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.thumbs img { width: 84px; height: 63px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .7; border: 2px solid transparent; }
.thumbs img.on { opacity: 1; border-color: var(--accent); }
.price-big { font-size: 1.8rem; font-weight: 800; color: var(--brand-ink); }
.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.spec { background: #f4f7f6; border-radius: 8px; padding: 10px 12px; }
.spec .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; } .spec .v { font-weight: 600; }
.desc { white-space: pre-wrap; }
.side > .card { margin-bottom: 14px; }
.seller-name { font-weight: 700; font-size: 1.05rem; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Tables (my ads, admin) */
.table { width: 100%; border-collapse: collapse; background: #fff; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; color: var(--muted); background: #f8faf9; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat .n { font-size: 1.6rem; font-weight: 800; color: var(--brand-ink); }
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.subtabs a { padding: 7px 12px; border-radius: 999px; background: #fff; color: var(--ink); box-shadow: var(--shadow); font-size: .9rem; }
.subtabs a.on { background: var(--brand); color: #fff; }

/* Messages */
.convs { display: flex; flex-direction: column; gap: 8px; }
.conv { display: flex; gap: 12px; align-items: center; background: #fff; padding: 12px; border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); }
.conv:hover { text-decoration: none; outline: 2px solid var(--accent); }
.conv .th { width: 64px; height: 48px; border-radius: 6px; background: #e7ecea; flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.conv .th img { width: 100%; height: 100%; object-fit: cover; }
.conv .mid2 { flex: 1; min-width: 0; } .conv .last { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; padding: 6px 2px; margin-bottom: 12px; }
.bubble { max-width: 75%; padding: 9px 12px; border-radius: 12px; background: #fff; box-shadow: var(--shadow); white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: #dff1ea; }
.bubble .tm { font-size: .7rem; color: var(--muted); margin-top: 3px; }

/* Photo manager */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 10px 0; }
.photo { position: relative; border-radius: 8px; overflow: hidden; background: #e7ecea; aspect-ratio: 4/3; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .ctl { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.photo .ctl button { font-size: .72rem; border: 0; border-radius: 4px; padding: 3px 6px; cursor: pointer; }
.photo .cover { position: absolute; top: 4px; left: 4px; }
.dropzone { border: 2px dashed #b5c4be; border-radius: var(--radius); padding: 26px; text-align: center; background: #fafcfb; cursor: pointer; }
.dropzone.drag { border-color: var(--brand); background: #eef7f3; }
.steps { display: flex; gap: 8px; margin-bottom: 16px; font-size: .85rem; }
.steps span { padding: 5px 11px; border-radius: 999px; background: #e4ebe8; color: var(--muted); }
.steps span.on { background: var(--brand); color: #fff; }

/* Footer, toast, modal */
.footer { background: #17201c; color: #c7d3ce; padding: 30px 0; margin-top: 40px; }
.footer-in { display: grid; gap: 14px; }
.footer a { color: #e7efe9; } .footer .muted { color: #8fa199; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
#toast { visibility: hidden; position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: #17201c; color: #fff; padding: 11px 18px; border-radius: 8px; transition: transform .25s; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { visibility: visible; transform: translateX(-50%) translateY(0); }
.gallery .main.noimg { background: #e7ecea; aspect-ratio: 16/7; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 440px; }
.prose { max-width: 760px; } .prose h2 { margin-top: 1.4em; }
.spinner { text-align: center; padding: 60px; color: var(--muted); }

@media (max-width: 900px) {
  .results { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; display: none; }
  .filters.open { display: block; }
  .filter-toggle { display: inline-flex; }
  .detail { grid-template-columns: 1fr; }
  .hero-search { grid-template-columns: 1fr 1fr; }
  .hero-search input { grid-column: 1 / -1; }
  .hero-search .btn { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .nav .hide-sm { display: none; }
  .logo span { display: none; }
  .post-btn { padding: 8px 10px; font-size: .9rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .hero { padding: 22px 16px; } .hero h1 { font-size: 1.45rem; }
  .ad .pr { font-size: 1rem; }
}
