:root {
  --green: #2e7d32; --green-d: #1b5e20; --leaf: #e8f3e8; --leaf-2: #d4ead5;
  --bg: #faf7f0; --card: #ffffff; --text: #262626; --muted: #6a6a6a; --line: #e6e1d6;
  --warn-bg: #fff5e0; --warn-line: #f0b14a; --warn-text: #7a4b00;
  --danger: #c62828; --danger-bg: #fdecec; --blue: #1565c0;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 18px/1.55 "Sarabun", system-ui, sans-serif; }
a { color: var(--green-d); }
img { max-width: 100%; display: block; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 56px; }
h1 { font-size: 26px; line-height: 1.3; margin: 12px 0 8px; }
h2 { font-size: 21px; margin: 22px 0 10px; }
h3 { font-size: 18px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.hide { display: none !important; }

/* header */
.top { background: var(--green); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; min-width: 0; flex: 1; }
.brand > span:last-child { min-width: 0; overflow: hidden; }
.brand b { display: block; font-size: 19px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-size: 13px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { font-size: 30px; }
#nav { display: flex; gap: 6px; flex-shrink: 0; }
#nav a { color: #fff; text-decoration: none; background: rgba(255,255,255,.16); padding: 7px 12px; border-radius: 999px; font-size: 16px; font-weight: 600; white-space: nowrap; position: relative; }
#nav a.sell { background: #ffd54f; color: #3b2a00; }
#nav .dot { position: absolute; top: -4px; right: -4px; background: #e53935; color: #fff; font-size: 12px; border-radius: 999px; padding: 0 6px; line-height: 18px; }
@media (max-width: 420px) { #nav a { padding: 7px 10px; font-size: 15px; } .logo { font-size: 26px; } }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--green); color: #fff; min-height: 50px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { display: flex; width: 100%; }
.btn.big { font-size: 20px; min-height: 58px; }
.btn.light { background: var(--leaf); color: var(--green-d); }
.btn.white { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.warn { background: #ffb300; color: #3b2a00; }
.btn.danger { background: var(--danger); }
.btn.line { background: #06c755; }
.btn.sm { padding: 6px 12px; min-height: 38px; font-size: 15px; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer; padding: 6px 0; }
label.f { display: block; margin: 14px 0 4px; font-weight: 600; }
label.f small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid #cfc8b8; border-radius: 12px; background: #fff; color: var(--text); min-height: 52px; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--leaf-2); border-color: var(--green); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: 16px; }
.check input { width: 24px; height: 24px; flex-shrink: 0; margin-top: 2px; }
.form-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px 22px; max-width: 560px; margin: 16px auto; }
.err { color: var(--danger); background: var(--danger-bg); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; font-size: 16px; }

/* home */
.hero { padding: 18px 0 6px; }
.hero h1 { margin: 0 0 4px; }
.search { display: flex; gap: 8px; margin: 12px 0; }
.search input { flex: 1; min-width: 0; }
.search .btn { flex-shrink: 0; }
.safe-strip { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); border-radius: 12px; padding: 10px 14px; font-size: 16px; margin: 8px 0 12px; }
.safe-strip a { color: var(--warn-text); font-weight: 600; }
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 16px; cursor: pointer; color: var(--text); text-decoration: none; white-space: nowrap; }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.filter-row select { max-width: 260px; min-height: 44px; padding: 8px 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.card .ph { aspect-ratio: 1 / 1; background: var(--leaf); }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card .t { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .price { color: var(--green-d); font-weight: 700; font-size: 19px; }
.card .meta { color: var(--muted); font-size: 14px; line-height: 1.35; }
.badge { display: inline-flex; align-items: center; gap: 3px; background: #e3f2fd; color: var(--blue); border-radius: 999px; padding: 1px 8px; font-size: 13px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.badge.new { background: #f3f3f3; color: var(--muted); }
.more { margin: 18px auto; display: flex; }

/* listing page */
.back { display: inline-block; margin: 12px 0 4px; text-decoration: none; font-size: 16px; }
.detail { display: grid; gap: 16px; }
@media (min-width: 860px) { .detail { grid-template-columns: 1.1fr 1fr; align-items: start; } }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: var(--radius); background: var(--leaf); }
.gallery img { flex: 0 0 100%; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; scroll-snap-align: start; }
.dots { text-align: center; color: var(--muted); font-size: 14px; margin-top: 4px; }
.price-big { font-size: 28px; font-weight: 700; color: var(--green-d); margin: 2px 0 6px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; background: #fff; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); }
.seller-box { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 14px 0; text-decoration: none; color: inherit; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--leaf-2); color: var(--green-d); display: grid; place-items: center; font-size: 24px; font-weight: 700; flex-shrink: 0; }
.seller-box .who { min-width: 0; }
.seller-box .who b { font-size: 19px; }
.contact { display: grid; gap: 10px; margin: 12px 0; }
.warn { background: var(--warn-bg); border: 1.5px solid var(--warn-line); color: var(--warn-text); border-radius: 14px; padding: 12px 14px; font-size: 16px; }
.warn > b:first-child { display: block; font-size: 17px; margin-bottom: 2px; }
.warn ul { margin: 6px 0 0; padding-left: 20px; }
.share { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* dashboard */
.status-card { border-radius: 14px; padding: 14px 16px; margin: 12px 0; border: 1.5px solid var(--line); background: #fff; }
.status-card.pending { background: #fff8e1; border-color: #ffca28; }
.status-card.ok { background: var(--leaf); border-color: #a5d6a7; }
.status-card.bad { background: var(--danger-bg); border-color: #ef9a9a; }
.my-item { display: flex; gap: 12px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 10px; margin: 10px 0; }
.my-item img { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--leaf); }
.my-item .info { flex: 1; min-width: 0; }
.my-item .t { font-weight: 600; overflow-wrap: anywhere; }
.st { display: inline-block; font-size: 14px; font-weight: 600; border-radius: 999px; padding: 1px 10px; margin: 2px 0; }
.st.active { background: var(--leaf); color: var(--green-d); }
.st.review { background: #fff3cd; color: #7a5a00; }
.st.sold { background: #eee; color: #555; }
.st.hidden, .st.expired { background: var(--danger-bg); color: var(--danger); }
.tips { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin: 16px 0; }
.tips li { margin: 4px 0; }

/* new listing */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos .p { position: relative; aspect-ratio: 1/1; border-radius: 12px; overflow: hidden; background: var(--leaf); }
.photos .p img { width: 100%; height: 100%; object-fit: cover; }
.photos .p button { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 18px; cursor: pointer; }
.photos .p .cover { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; border-radius: 6px; padding: 0 6px; }
.photos .add { aspect-ratio: 1/1; border: 2px dashed #b9b19f; border-radius: 12px; display: grid; place-items: center; text-align: center; color: var(--muted); cursor: pointer; background: #fff; font-size: 15px; }
.photos .add span { font-size: 30px; display: block; }
.cat-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cat-pick label { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; cursor: pointer; font-size: 16px; }
.cat-pick input { width: 20px; height: 20px; }
.cat-pick label:has(input:checked) { border-color: var(--green); background: var(--leaf); font-weight: 600; }
.price-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* pay */
.qr { background: #fff; border-radius: 14px; padding: 12px; max-width: 300px; margin: 10px auto; border: 1px solid var(--line); }
.qr svg { width: 100%; height: auto; display: block; }
.pp-head { background: #0e3d6b; color: #fff; text-align: center; border-radius: 10px 10px 0 0; padding: 6px; font-weight: 700; margin: -12px -12px 8px; }
.months { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* admin */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.tabs a { flex-shrink: 0; text-decoration: none; color: var(--text); background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 16px; }
.tabs a.on { background: var(--green-d); color: #fff; border-color: var(--green-d); }
.tabs .n { background: #e53935; color: #fff; border-radius: 999px; padding: 0 7px; font-size: 13px; margin-left: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 30px; color: var(--green-d); }
.stat.alert b { color: #e53935; }
.box { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; margin: 10px 0; }
.box .row { display: flex; gap: 12px; }
.box .row img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.box .row .info { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.box .btn-row { margin-top: 10px; }
.kv { font-size: 15px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }
.mismatch { color: var(--danger); font-weight: 700; }
.slip { max-height: 420px; width: auto; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
table.audit { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.audit td, table.audit th { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.tbl-wrap { overflow-x: auto; border-radius: 12px; box-shadow: var(--shadow); }
.setting-help { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .overlay { align-items: center; } }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px 22px; }
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal h2 { margin-top: 0; }
.radio-list label { display: flex; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 17px; }
.radio-list input { width: 22px; height: 22px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%); background: #263238; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 60; max-width: calc(100% - 32px); transition: transform .25s; font-size: 16px; text-align: center; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }

.foot { color: var(--muted); font-size: 14px; padding-top: 24px; padding-bottom: 32px; margin-top: 24px; border-top: 1px solid var(--line); }
.foot a { color: var(--muted); }
.page-text { max-width: 720px; }
.page-text li { margin: 6px 0; }
