:root {
  --brand: #28594f;
  --brand-dark: #1e463d;
  --brand-bright: #337a6b;
  --brand-tint: #eef4f1;
  --accent: #28594f;
  --ink: #1c1c1e;
  --muted: #767676;
  --border: #e6e6e6;
  --bg: #ffffff;
  --page: #f7f7f5;
  --danger: #c0392b;
  --warn-bg: #fff8e1;
  --warn-border: #ffe0a3;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-hover: 0 6px 20px rgba(0, 0, 0, .10);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.page { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 60px; }
.page > h1 { margin: 0 0 20px; font-size: 1.7rem; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 68px;
}
.logo { display: inline-flex; align-items: center; flex: 0 0 auto; }
.logo img { height: 42px; width: auto; display: block; }

.search {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  max-width: 640px;
}
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 11px 18px;
  font-size: .95rem;
  outline: none;
}
.search button {
  border: 0;
  background: transparent;
  padding: 0 16px;
  height: 42px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}
.search button:hover { color: var(--brand); }

.header-nav { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.nav-link {
  color: var(--ink);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: .92rem;
}
.nav-link:hover { background: var(--page); text-decoration: none; }

.cat-bar { border-top: 1px solid var(--border); background: #fff; }
.cat-bar .header-inner {
  height: 44px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-bar .header-inner::-webkit-scrollbar { display: none; }
.cat-bar a {
  color: var(--muted);
  font-size: .88rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.cat-bar a:hover { color: var(--brand); background: var(--brand-tint); text-decoration: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: .93rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { border-color: #cfcfcf; text-decoration: none; }
.btn-primary, .btn.buy, button.buy, button.accept {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover, .btn.buy:hover, button.buy:hover, button.accept:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}
.btn-secondary { background: #fff; color: var(--ink); }
.btn-danger, button.danger {
  background: #fff;
  color: var(--danger);
  border-color: #eccac5;
}
.btn-danger:hover, button.danger:hover { background: #fdf3f2; border-color: #e0b2ab; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
button { font: inherit; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 440px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink); }
.field input, .field select, .field textarea,
.input, select, textarea, input[type="text"], input[type="email"],
input[type="password"], input[type="number"], input[type="search"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #888 50%), linear-gradient(135deg, #888 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

/* ---------- hero ---------- */
.hero {
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-bright) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 44px 40px;
  margin-bottom: 32px;
}
.hero h1 { margin: 0 0 8px; font-size: 2rem; letter-spacing: -.02em; }
.hero p { margin: 0 0 20px; opacity: .92; font-size: 1.05rem; }
.hero .btn { background: #fff; color: var(--brand); border-color: #fff; }
.hero .btn:hover { background: #f1f1f1; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 16px; }
.section-head h2 { margin: 0; font-size: 1.25rem; }

/* ---------- item grid + cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}

.item-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
  display: flex;
  flex-direction: column;
}
.item-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); text-decoration: none; }
.item-media { position: relative; aspect-ratio: 3/4; background: #f0f0ee; overflow: hidden; }
.item-media img, .item-media .ph { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-media .ph { display: flex; align-items: center; justify-content: center; color: #bdbdbd; }
.item-media .ph::after { content: "sweep'd"; font-weight: 700; letter-spacing: .04em; }
.item-info { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.item-price { font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.item-title { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: .8rem; }
.item-cond { color: #9a9a9a; font-size: .78rem; }

/* ---------- browse ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 22px;
}
.filters input, .filters select { width: auto; flex: 1 1 160px; min-width: 140px; }
.filters .btn { flex: 0 0 auto; }

/* ---------- item detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 36px; }
.detail-photos { display: flex; flex-direction: column; gap: 10px; }
.detail-photos img, .detail-photos .placeholder.large {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: var(--radius);
  background: #f0f0ee;
}
.detail-info { padding-top: 4px; }
.detail-info h1 { margin: 0 0 4px; font-size: 1.5rem; }
.detail-brand { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.detail-meta { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.detail-price { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 6px; }
.detail-price .price { font-size: 2rem; font-weight: 800; }
.card-total { color: var(--muted); font-size: .85rem; }
.detail-desc { line-height: 1.6; color: #3a3a3a; margin: 14px 0; }
.detail-status { display: inline-block; font-size: .8rem; font-weight: 600; color: var(--brand); background: var(--brand-tint); border-radius: 999px; padding: 4px 12px; margin-bottom: 16px; }

.offer-box, .offers {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.offer-box h2, .offers h2 { margin: 0 0 12px; font-size: 1.05rem; }
.offer-box form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.offer-box input[type="number"] { max-width: 220px; }
.buy-note { color: var(--muted); font-size: .82rem; margin: 6px 0 0; }
.offer-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }

/* ---------- orders ---------- */
.order { max-width: 760px; }
.order-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.order-list li {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.order-status { color: var(--muted); }
.order-total { width: 100%; border-collapse: collapse; margin: 18px 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.order-total td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.order-total tr:last-child td { border-bottom: 0; font-weight: 700; }
.order-total td:last-child { text-align: right; }
.order-parties { color: var(--muted); font-size: .9rem; }
.order-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.order-events { list-style: none; padding: 0; }
.order-events li { padding: 8px 0; border-bottom: 1px solid var(--border); color: #444; font-size: .9rem; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 9px; border-radius: 999px; background: var(--page); color: var(--muted); }
.badge-active { background: var(--brand-tint); color: var(--brand); }
.badge-sold, .badge-removed { background: #f0f0f0; color: #888; }
.badge-disputed { background: #fdecea; color: var(--danger); }

/* ---------- admin tables ---------- */
.admin-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 12px; padding: 0; margin: 0 0 22px; }
.admin-stats li { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; font-weight: 700; }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: .9rem; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.admin-table th { background: var(--page); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table form { display: inline; }

/* ---------- flashes / empty ---------- */
.flashes { list-style: none; padding: 0; margin: 0 0 18px; }
.flashes li { background: var(--warn-bg); border: 1px solid var(--warn-border); padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.empty { color: var(--muted); padding: 30px 0; }

/* ---------- auth ---------- */
.auth-card { max-width: 420px; margin: 40px auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; }
.auth-card h1 { margin: 0 0 20px; }
.auth-card .form { max-width: none; }
.auth-alt { color: var(--muted); font-size: .9rem; margin-top: 16px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: #fff; margin-top: 40px; }
.site-footer .header-inner { height: auto; padding: 22px 20px; color: var(--muted); font-size: .85rem; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .header-inner { height: auto; flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .header-nav { margin-left: auto; }
  .cat-bar .header-inner { height: 40px; }
  .detail { grid-template-columns: 1fr; gap: 22px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .hero { padding: 30px 24px; }
  .hero h1 { font-size: 1.5rem; }
  .page { padding: 18px 14px 50px; }
}
