*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #B31B1B;
  --primary-light: #f5ecec;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e0db;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Navigation ── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; color: var(--primary); font-size: 17px; text-decoration: none; letter-spacing: -0.3px; }
nav a { color: var(--text); text-decoration: none; font-size: 14px; }
nav a:hover { color: var(--primary); }
#auth-link { display: flex; gap: 20px; align-items: center; }

/* ── Layout ── */
main { max-width: 1140px; margin: 0 auto; padding: 28px 20px; }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  align-items: center;
}
.filter-bar .spacer { flex: 1; }

/* ── Form controls — ALL input types included ── */
select,
input[type="number"],
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
  height: 42px;
}
textarea { height: auto; }
select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b6b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ── Listing grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.09); transform: translateY(-2px); }

.card-img {
  width: 100%;
  aspect-ratio: 1;
  background: #eeece8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.placeholder { font-size: 44px; opacity: 0.5; }

.card-body { padding: 12px; }

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.badge-category { background: var(--primary-light); color: var(--primary); }
.badge-sold { background: #f0fdf4; color: #15803d; margin-left: 4px; }

.card-body h3 { font-size: 14px; font-weight: 500; margin-bottom: 4px; line-height: 1.4; }
.price { font-size: 17px; font-weight: 700; color: var(--primary); }
.condition-tag { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Forms ── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
  max-width: 560px;
  margin: 0 auto;
}
.form-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.4px; }
.form-card .subtitle { color: var(--muted); font-size: 14px; margin-bottom: 28px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { height: 110px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 7px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  line-height: 1;
  height: 42px;
}
.btn:active { transform: scale(0.98); }
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #dc2626; color: white; }
.btn-sm { padding: 7px 14px; font-size: 13px; height: auto; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Image upload ── */
.image-upload { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.image-preview { width: 76px; height: 76px; border-radius: 7px; object-fit: cover; border: 1px solid var(--border); }
.upload-btn {
  width: 76px; height: 76px;
  border: 2px dashed var(--border);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 22px; color: var(--muted);
  background: none; transition: all 0.15s;
}
.upload-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.img-wrap { position: relative; }
.img-remove {
  position: absolute; top: -6px; right: -6px;
  background: #dc2626; color: white; border: none;
  border-radius: 50%; width: 18px; height: 18px;
  cursor: pointer; font-size: 11px; line-height: 18px;
  text-align: center; padding: 0;
}

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 7px; font-size: 14px; margin-bottom: 18px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

/* ── Empty state ── */
.empty { text-align: center; color: var(--muted); padding: 72px 0; font-size: 16px; }
.empty a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ── Page header ── */
.page-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }

/* ── Listing detail ── */
.listing-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}
.img-main {
  width: 100%; aspect-ratio: 1;
  object-fit: cover; border-radius: 12px;
  border: 1px solid var(--border);
  background: #eeece8;
  display: flex; align-items: center; justify-content: center;
  font-size: 72px;
}
img.img-main { display: block; }
.img-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumb {
  width: 68px; height: 68px; border-radius: 7px;
  object-fit: cover; border: 2px solid transparent;
  cursor: pointer; transition: border-color 0.15s;
}
.thumb.active { border-color: var(--primary); }
.detail-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin: 10px 0 4px; }
.detail-price { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 12px; }
.detail-meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-bottom: 20px; flex-wrap: wrap; }
.detail-desc { font-size: 15px; line-height: 1.75; white-space: pre-wrap; margin-bottom: 24px; }
.contact-box {
  background: var(--primary-light);
  border: 1px solid #e8d0d0;
  border-radius: 10px;
  padding: 18px 20px;
}
.contact-box .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--primary); margin-bottom: 4px; }
.contact-box .value { font-size: 17px; font-weight: 500; }
.owner-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ── Back link ── */
.back-link { color: var(--muted); text-decoration: none; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 20px; }
.back-link:hover { color: var(--primary); }

/* ── Responsive ── */
@media (max-width: 680px) {
  .listing-layout { grid-template-columns: 1fr; gap: 24px; }
  .detail-title { font-size: 22px; }
  .detail-price { font-size: 26px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .form-card { padding: 24px 18px; }
}
