:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1d2433;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #ccfbf1;
  --accent: #f59e0b;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn-soft: #fef3c7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; min-height: 70vh; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 16px; align-items: center; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 20px; color: var(--brand); white-space: nowrap; }
.top-search { flex: 1; display: flex; min-width: 220px; max-width: 560px; }
.top-search input { flex: 1; border-radius: 8px 0 0 8px; }
.top-search button { border-radius: 0 8px 8px 0; }
.nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.btn { color: #fff; }
.nav a.btn:hover { background: var(--brand-dark); }
.nav .badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 12px; margin-left: 4px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px; border-top: 1px solid var(--line); }

/* forms & buttons */
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
label .req { color: var(--danger); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-weight: 400; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
button, .btn { font: inherit; font-weight: 600; cursor: pointer; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--brand); }
.btn-outline:hover { background: var(--brand-soft); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: #991b1b; }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); }
.alert-warn { background: var(--warn-soft); color: #92400e; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pill-ok { background: var(--ok-soft); color: #166534; border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: #92400e; border-color: transparent; }
.pill-bad { background: var(--danger-soft); color: #991b1b; border-color: transparent; }
.pill-brand { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }

/* home */
.hero { background: linear-gradient(135deg, var(--brand), #0e7490); color: #fff; border-radius: var(--radius); padding: 36px 28px; margin-bottom: 24px; }
.hero h1 { font-size: 30px; }
.hero p { opacity: .9; max-width: 640px; }
.hero .btn { background: #fff; color: var(--brand); border-color: #fff; }
.hero .btn-outline { background: transparent; color: #fff; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 28px; }
.cat-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); }
.cat-tile:hover { border-color: var(--brand); text-decoration: none; }
.cat-tile .icon { font-size: 28px; }
.cat-tile .name { font-weight: 700; margin-top: 6px; }
.cat-tile .sub { font-size: 12px; color: var(--muted); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 0 12px; }

/* listing grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.item:hover { border-color: var(--brand); text-decoration: none; }
.item .thumb { aspect-ratio: 4/3; background: #e5e7eb center/cover no-repeat; position: relative; }
.item .thumb .pill { position: absolute; top: 8px; left: 8px; }
.item .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.item .price { font-weight: 800; font-size: 18px; }
.item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; margin-top: auto; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* browse */
.browse { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
.filters { position: sticky; top: 78px; }
.filters h3 { font-size: 15px; margin-top: 4px; }
.filters .field { margin-bottom: 12px; }

/* listing detail */
.detail { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.gallery .main { aspect-ratio: 4/3; background: #111 center/contain no-repeat; border-radius: var(--radius); }
.gallery .thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.gallery .thumbs button { padding: 0; width: 72px; height: 56px; flex: none; background: #ddd center/cover no-repeat; border: 2px solid transparent; border-radius: 6px; }
.gallery .thumbs button.on { border-color: var(--brand); }
.price-big { font-size: 30px; font-weight: 800; }
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table th, .spec-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec-table th { width: 42%; color: var(--muted); font-weight: 500; }
.desc { white-space: pre-wrap; }
.defects { background: var(--warn-soft); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; }
.verify-list { list-style: none; padding: 0; margin: 0; }
.verify-list li { padding: 5px 0; display: flex; gap: 8px; }
.verify-list .yes { color: var(--ok); }
.verify-list .no { color: var(--muted); }
.seller-card .avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter > div { height: 100%; background: var(--ok); transition: width .3s; }

/* sell form */
.sell { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.sell .side { position: sticky; top: 78px; }
.step-title { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.step-title .num { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.step-title h2 { margin: 0; font-size: 18px; }
.cond-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cond-options label { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-weight: 600; }
.cond-options label small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.cond-options input { display: none; }
.cond-options label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; background: #ddd center/cover no-repeat; border-radius: 8px; }
.photo-grid .ph button { position: absolute; top: 4px; right: 4px; padding: 0 7px; background: rgba(0,0,0,.6); border: 0; font-size: 14px; }
.photo-grid .ph .cover { position: absolute; bottom: 4px; left: 4px; }
.photo-drop { border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; aspect-ratio: 1; cursor: pointer; color: var(--muted); text-align: center; font-size: 13px; font-weight: 500; }
.photo-drop:hover { border-color: var(--brand); color: var(--brand); }
.tips li { margin-bottom: 6px; }
.counter { font-size: 12px; color: var(--muted); text-align: right; }

/* inbox / chat */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-height: 560px; }
.conv-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 75vh; }
.conv-item { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.conv-item:hover, .conv-item.on { background: var(--bg); text-decoration: none; }
.conv-item .img { width: 52px; height: 52px; border-radius: 8px; background: #ddd center/cover no-repeat; flex: none; }
.conv-item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .l { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item > div:last-child { min-width: 0; flex: 1; }
.chat { display: flex; flex-direction: column; max-height: 75vh; }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-head .img { width: 48px; height: 48px; border-radius: 8px; background: #ddd center/cover no-repeat; flex: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #fafafa; }
.msg { flex: none; max-width: 72%; padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; }
.msg.mine { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.msg .time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg.system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; text-align: center; max-width: 90%; }
.offer { border: 2px solid var(--accent); background: #fffbeb; min-width: 220px; white-space: normal; }
.offer.mine { border-color: var(--brand); }
.offer .amt { font-size: 22px; font-weight: 800; }
.chat-foot { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-foot form { display: flex; gap: 8px; }
.chat-foot input { flex: 1; }
.deal-banner { margin: 12px 16px 0; }

/* tables / lists */
.list-row { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .img { width: 84px; height: 64px; border-radius: 8px; background: #ddd center/cover no-repeat; flex: none; }
.list-row .info { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.auth { max-width: 420px; margin: 24px auto; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }


/* promotions & plans */
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #d97706; }
.item.highlight { border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0; }
.thumb .tags { position: absolute; top: 8px; right: 8px; margin: 0; justify-content: flex-end; }
.tag { font-size: 11px; font-weight: 800; letter-spacing: .3px; padding: 2px 7px; border-radius: 4px; color: #fff; }
.tag-top { background: #dc2626; }
.tag-featured { background: #7c3aed; }
.tag-highlight { background: var(--accent); }
.tier { font-size: 10px; font-weight: 800; letter-spacing: .4px; padding: 1px 6px; border-radius: 4px; vertical-align: middle; }
.tier-pro { background: #1d4ed8; color: #fff; }
.tier-business { background: #111827; color: #fbbf24; }
.boost-box { margin-top: 14px; padding: 12px; border-radius: 8px; background: #fffbeb; border: 1px solid #fde68a; }
.promo-options { display: grid; gap: 8px; }
.promo-option, .dur-option { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; font-weight: 400; }
.promo-option input, .dur-option input { display: none; }
.promo-option:has(input:checked), .dur-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.dur-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.dur-option { display: flex; flex-direction: column; text-align: center; }
.dur-option span { font-size: 18px; font-weight: 800; }
.dur-option small { color: var(--muted); }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: stretch; }
.plan-grid .card + .card { margin-top: 0; }
.plan { position: relative; display: flex; flex-direction: column; }
.plan h2 { font-size: 18px; }
.plan-price { font-size: 30px; font-weight: 800; }
.plan-price small { font-size: 14px; font-weight: 500; color: var(--muted); }
.plan-features { list-style: none; padding: 0; margin: 14px 0; flex: 1; }
.plan-features li { padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.plan-popular { border: 2px solid var(--brand); }
.plan-current { background: #f0fdfa; }
.plan-ribbon { position: absolute; top: -11px; right: 16px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { width: 100%; max-width: 420px; }
.price-table th { width: auto; }
.price-table th:first-child { width: 40%; }
.price-table td { white-space: nowrap; }
.price-table td:first-child { white-space: normal; }


/* footer, legal pages, reporting, admin */
.footer-links { display: flex; gap: 6px 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.footer-links a { color: var(--muted); font-weight: 500; }
.legal { max-width: 860px; margin: 0 auto; }
.legal h2 { font-size: 18px; margin-top: 24px; }
.legal li { margin-bottom: 6px; }
.legal .spec-table th { width: 28%; color: var(--text); font-weight: 600; }
.report-btn { margin-top: 8px; color: var(--muted); border-color: transparent; }
.report-btn:hover { color: var(--danger); background: var(--danger-soft); }
.admin-box { margin-top: 12px; padding: 10px; border: 1px dashed var(--danger); border-radius: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.stat-grid .card + .card { margin-top: 0; }
.stat-value { font-size: 28px; font-weight: 800; }
.card.report { border-left: 4px solid var(--danger); }
.card.report p { margin: 8px 0; }
.admin-table th { width: auto; }

@media (max-width: 900px) {
  .browse, .detail, .sell { grid-template-columns: 1fr; }
  .filters, .sell .side { position: static; }
  .inbox { grid-template-columns: 1fr; }
  .conv-list { max-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .grid-2, .grid-3, .plan-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { padding: 10px 12px; }
  .top-search { order: 3; max-width: none; flex-basis: 100%; }
  .msg { max-width: 88%; }
}
