* { box-sizing: border-box; margin: 0; }
:root {
  --bg: #fff; --ink: #121212; --muted: #757575;
  --line: #e5e5e5; --line-dark: #121212;
  --green: #e8f3ec; --green-ink: #1d6b40;
  --gray: #f0f0f0; --gray-ink: #616161;
  --red: #faeae7; --red-ink: #9c3524;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
}
body { background: var(--bg); color: var(--ink); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; letter-spacing: .01em; }
button { font: inherit; cursor: pointer; }
h1 { font-family: var(--serif); font-weight: 500; letter-spacing: .01em; }

.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 18px 36px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { cursor: pointer; line-height: 0; }
.brand img { height: 44px; width: auto; display: inline-block; }
.topbar-center { text-align: center; font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; font-size: 13.5px; }
.topbar-right .who { color: var(--muted); }
.btn-ghost { border: 1px solid var(--line-dark); background: #fff; color: var(--ink); padding: 7px 16px; border-radius: 0; font-size: 13px; }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn-solid { border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 0; font-size: 14px; letter-spacing: .03em; }
.btn-solid:hover { background: #333; }
.btn-solid:disabled { opacity: .5; cursor: default; }
.lang { display: flex; gap: 2px; color: var(--muted); font-size: 12.5px; }
.lang button { border: none; background: none; padding: 3px 5px; color: var(--muted); letter-spacing: .05em; }
.lang button.on { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

main { max-width: 1160px; margin: 0 auto; padding: 34px 36px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 70px 0; }

/* Auth / setup screens */
.gate { max-width: 430px; margin: 60px auto; text-align: center; }
.gate h1 { font-size: 30px; margin-bottom: 10px; }
.gate p { color: var(--muted); font-size: 14.5px; margin-bottom: 26px; }
.gate input { width: 100%; padding: 13px 14px; border: 1px solid var(--line-dark); border-radius: 0; font-size: 15px; margin-bottom: 12px; text-align: center; }
.gate input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.gate .btn-solid { width: 100%; }
.gate .err { color: var(--red-ink); font-size: 13.5px; margin-top: 12px; min-height: 1.3em; }
.gate .note { font-size: 12.5px; color: var(--muted); margin-top: 22px; line-height: 1.6; }
.gate ol { text-align: left; font-size: 13.5px; color: var(--muted); padding-left: 20px; display: grid; gap: 6px; margin-bottom: 22px; }
.gate code { background: var(--gray); padding: 1px 6px; font-size: 12.5px; }

/* Seller picker (admin) */
.picker { max-width: 460px; margin: 40px auto; }
.picker h1 { font-size: 26px; text-align: center; margin-bottom: 4px; }
.picker > p { color: var(--muted); font-size: 14px; margin-bottom: 18px; text-align: center; }
.picker input[type=search] { width: 100%; padding: 11px 13px; border: 1px solid var(--line-dark); border-radius: 0; font-size: 15px; margin-bottom: 12px; }
.seller-list { max-height: 380px; overflow-y: auto; border: 1px solid var(--line); }
.seller-list button { display: flex; justify-content: space-between; width: 100%; padding: 11px 15px; border: none; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 14.5px; }
.seller-list button:last-child { border-bottom: none; }
.seller-list button:hover { background: var(--gray); }
.seller-list .num { color: var(--muted); font-size: 13px; }
.picker label { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); cursor: pointer; }

/* Product list */
.list-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.list-head h1 { font-size: 28px; margin-right: auto; }
.list-head input[type=search] { padding: 10px 13px; border: 1px solid var(--line-dark); border-radius: 0; font-size: 14px; width: 250px; }
.chips { display: flex; gap: 0; border: 1px solid var(--line-dark); }
.chip { border: none; border-right: 1px solid var(--line-dark); background: #fff; padding: 8px 15px; font-size: 13px; letter-spacing: .02em; }
.chip:last-child { border-right: none; }
.chip.on { background: var(--ink); color: #fff; }
.count { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 26px 22px; }
.card { background: #fff; cursor: pointer; display: flex; flex-direction: column; }
.card .img { aspect-ratio: 1; background: #f6f6f4; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; overflow: hidden; }
.card .img img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.card:hover .img img { transform: scale(1.03); }
.card .body { padding: 12px 2px 0; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .title { font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.card:hover .title { text-decoration: underline; text-underline-offset: 3px; }
.card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; font-size: 14px; }
.card .price { font-weight: 600; }
.card .qty { color: var(--muted); font-size: 12.5px; }

/* List view */
.view-toggle { display: flex; border: 1px solid var(--line-dark); }
.view-toggle button { border: none; background: #fff; padding: 8px 13px; font-size: 15px; line-height: 1; }
.view-toggle button.on { background: var(--ink); color: #fff; }
.list-table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); background: #fff; }
.list-table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.list-table tr.row { cursor: pointer; }
.list-table tr.row:hover { background: #fafafa; }
.list-table tr.row:hover .lt-title { text-decoration: underline; text-underline-offset: 3px; }
.list-table .lt-img { width: 46px; height: 46px; object-fit: cover; background: #f6f6f4; display: block; }
.list-table .lt-noimg { width: 46px; height: 46px; background: #f6f6f4; }
.list-table .lt-id { color: var(--muted); font-size: 13px; white-space: nowrap; }

.badge { font-size: 11px; font-weight: 600; letter-spacing: .08em; padding: 4px 10px; text-transform: uppercase; }
.badge.ACTIVE { background: var(--green); color: var(--green-ink); }
.badge.DRAFT { background: var(--gray); color: var(--gray-ink); }
.badge.ARCHIVED { background: var(--red); color: var(--red-ink); }

/* Detail */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); background: none; border: none; font-size: 13.5px; letter-spacing: .03em; padding: 0; margin-bottom: 20px; }
.back:hover { color: var(--ink); }
.detail { display: grid; grid-template-columns: 420px 1fr; gap: 40px; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }

.gallery .main-img { aspect-ratio: 1; overflow: hidden; background: #f6f6f4; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.gallery .main-img img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs .thumb { position: relative; width: 66px; height: 66px; overflow: hidden; border: 1px solid var(--line); cursor: pointer; padding: 0; background: #f6f6f4; }
.thumbs .thumb.sel { border-color: var(--ink); }
.thumbs .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .del { position: absolute; top: 0; right: 0; width: 19px; height: 19px; border: none; background: rgba(18,18,18,.75); color: #fff; font-size: 11px; line-height: 1; display: none; }
.thumbs .thumb:hover .del { display: block; }
.upload-btn { width: 66px; height: 66px; border: 1px dashed var(--muted); background: none; color: var(--muted); font-size: 22px; }
.upload-btn:hover { border-color: var(--ink); color: var(--ink); }

.form .status-row { display: flex; justify-content: space-between; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.form .status-row .lbl { color: var(--muted); font-size: 13px; }
.field { margin-bottom: 18px; }
.field label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line-dark); border-radius: 0; font: inherit; font-size: 14.5px; background: #fff; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.field textarea { min-height: 170px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.save-state { font-size: 11.5px; font-weight: 500; text-transform: none; letter-spacing: .02em; }
.save-state.saving { color: var(--muted); }
.save-state.saved { color: var(--green-ink); }
.save-state.error { color: var(--red-ink); }
.save-state button { border: none; background: none; color: var(--red-ink); text-decoration: underline; font-size: 11.5px; padding: 0; }
.desc-preview { border: 1px solid var(--line); padding: 12px 14px; margin-top: 8px; font-size: 13.5px; max-height: 260px; overflow-y: auto; background: #fafafa; }
.desc-preview table { border-collapse: collapse; width: 100%; }
.desc-preview td { border-bottom: 1px solid var(--line); padding: 3px 6px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* New listing form */
.new-form { max-width: 720px; }
.new-form h1 { font-size: 28px; margin-bottom: 22px; }
.new-form .psf-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.new-form .psf-thumb { position: relative; }
.new-form .psf-thumb img { width: 90px; height: 90px; object-fit: cover; border: 1px solid var(--line); display: block; }
.new-form .psf-thumb .del { position: absolute; top: 0; right: 0; width: 19px; height: 19px; border: none; background: rgba(18,18,18,.75); color: #fff; font-size: 11px; line-height: 1; cursor: pointer; }
.new-form .form-actions { display: flex; gap: 12px; margin-top: 26px; }
.field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line-dark); border-radius: 0; font: inherit; font-size: 14.5px; background: #fff; }
.label-hint { display: block; font-weight: 400; font-size: 11.5px; letter-spacing: .02em; text-transform: none; color: var(--muted); margin-top: 2px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 20px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); z-index: 50; }
.toast.error { background: var(--red-ink); }
.sort-sel { padding: 9px 11px; border: 1px solid var(--line-dark); border-radius: 0; font: inherit; font-size: 13.5px; background: #fff; }
