:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

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

a { color: var(--primary); text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

main.container { flex: 1; padding-top: 20px; padding-bottom: 40px; }

.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.nav-search {
  flex: 1;
  max-width: 500px;
  display: flex;
}

.nav-search input {
  flex: 1;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.nav-search input:focus { border-color: var(--primary); }

.nav-search button {
  padding: 8px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.nav-search button:hover { background: var(--primary-dark); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.nav-links a { color: var(--text); font-weight: 500; font-size: 0.9rem; }

.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary { background: var(--primary); color: white !important; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text) !important; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary) !important; }

.btn-full { width: 100%; display: block; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

.btn-danger { background: var(--danger); color: white !important; }
.btn-danger:hover { background: #dc2626; }

.btn-save {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  margin-top: 10px;
  transition: all 0.2s;
}

.btn-save:hover { border-color: var(--primary); color: var(--primary); }

.hero {
  text-align: center;
  padding: 60px 20px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: var(--radius);
  margin-bottom: 40px;
  color: white;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 30px;
}

.hero-search {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
}

.hero-search input {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 1rem;
  outline: none;
}

.hero-search button {
  padding: 14px 30px;
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.hero-search button:hover { background: #d97706; }

.categories-grid { margin-bottom: 40px; }
.categories-grid h2 { margin-bottom: 16px; font-size: 1.3rem; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  background: var(--card);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  transition: all 0.2s;
  text-align: center;
}

.cat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cat-icon { font-size: 2rem; margin-bottom: 8px; }
.cat-name { font-weight: 600; font-size: 0.85rem; color: var(--text); }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 { font-size: 1.3rem; }
.view-all { font-weight: 600; font-size: 0.9rem; }

.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.listing-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.2s;
  display: block;
  color: var(--text);
}

.listing-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.listing-image {
  height: 200px;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.listing-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.9rem;
}

.listing-category-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.listing-info { padding: 14px; }

.listing-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-price { margin-bottom: 8px; }

.price { font-size: 1.1rem; font-weight: 700; color: var(--success); }
.price.free { color: var(--primary); }
.price-type { font-size: 0.8rem; color: var(--text-light); margin-left: 4px; }

.listing-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-light);
}

.auth-page {
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  background: var(--card);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
}

.auth-card h2 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-card > p { color: var(--text-light); margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: var(--card);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.auth-switch { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--text-light); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.form-page { max-width: 700px; margin: 0 auto; }
.form-page h2 { margin-bottom: 24px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.listing-form { background: var(--card); padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow); }

.location-picker {
  align-items: end;
}

.location-picker select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.location-picker select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.existing-images { margin-top: 10px; }
.image-preview-row { display: flex; gap: 8px; margin-top: 8px; }
.preview-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 2px solid var(--border); }

.listing-detail { max-width: 1000px; margin: 0 auto; }

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--primary); }

.listing-layout { display: grid; grid-template-columns: 1fr 340px; gap: 30px; }

.image-gallery { margin-bottom: 24px; }

.main-image {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.main-image img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
}

.image-thumbnails {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.thumb {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color 0.2s;
}

.thumb.active, .thumb:hover { border-color: var(--primary); }

.listing-body h1 {
  font-size: 1.6rem;
  margin-bottom: 16px;
  line-height: 1.3;
}

.listing-description {
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.7;
  font-size: 0.95rem;
}

.price-card, .contact-card, .seller-card {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.detail-price { font-size: 1.8rem; font-weight: 800; color: var(--success); }
.detail-price.free { color: var(--primary); }

.contact-card h3, .seller-card h3 { font-size: 0.9rem; margin-bottom: 12px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }

.contact-card .btn { margin-bottom: 8px; }

.seller-name { font-weight: 700; font-size: 1rem; }
.seller-location { color: var(--text-light); font-size: 0.85rem; margin-top: 2px; }
.seller-joined { color: var(--text-light); font-size: 0.8rem; margin-top: 4px; }

.listing-stats {
  display: flex;
  justify-content: space-between;
  color: var(--text-light);
  font-size: 0.8rem;
  padding: 0 4px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 { font-size: 1.5rem; }

.sort-controls { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; }
.sort-controls span { color: var(--text-light); }
.sort-controls a {
  padding: 4px 12px;
  border-radius: 20px;
  color: var(--text-light);
  transition: all 0.2s;
}
.sort-controls a.active, .sort-controls a:hover { background: var(--primary); color: white; }

.page-layout { display: grid; grid-template-columns: 220px 1fr; gap: 30px; }

.sidebar { position: sticky; top: 80px; align-self: start; }

.cat-list { list-style: none; }
.cat-list li a {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  border-radius: 8px;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.cat-list li a:hover { background: var(--border); }
.cat-list li a.active { background: var(--primary); color: white; font-weight: 600; }

.search-filters {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.search-filters .form-row {
  display: flex;
  gap: 10px;
  align-items: end;
}

.search-filters .form-group { margin-bottom: 0; }

.result-count { color: var(--text-light); font-size: 0.9rem; margin-bottom: 16px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state h3 { color: var(--text); margin-bottom: 8px; }
.empty-state .btn { margin-top: 16px; }

.dashboard { max-width: 900px; margin: 0 auto; }

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dash-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-light);
  transition: all 0.2s;
}

.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.dash-list { display: flex; flex-direction: column; gap: 12px; }

.dash-item {
  display: flex;
  gap: 16px;
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  align-items: center;
}

.dash-item-image {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}

.dash-item-image img { width: 100%; height: 100%; object-fit: cover; }

.no-image-sm {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-light);
}

.dash-item-info { flex: 1; }
.dash-item-info h3 { font-size: 1rem; margin-bottom: 4px; }
.dash-item-info h3 a { color: var(--text); }

.dash-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-light);
  flex-wrap: wrap;
}

.dash-price { font-weight: 600; color: var(--success); }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 4px;
}

.status-active { background: #d1fae5; color: #065f46; }
.status-sold { background: #fee2e2; color: #991b1b; }

.dash-item-actions { display: flex; gap: 8px; flex-shrink: 0; }
.dash-item-actions form { margin: 0; }

.error-page {
  text-align: center;
  padding: 80px 20px;
}

.error-page h1 {
  font-size: 3rem;
  margin-bottom: 12px;
}

.error-page p {
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: 1.1rem;
}

.footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
  margin-top: auto;
}

.payment-result {
  display: flex;
  justify-content: center;
  padding: 60px 20px;
}

.payment-card {
  background: var(--card);
  padding: 50px 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.payment-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 20px;
  background: #d1fae5;
  color: var(--success);
}

.cancelled-icon {
  background: #fee2e2;
  color: var(--danger);
}

.payment-card h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.payment-card p {
  color: var(--text-light);
  margin-bottom: 24px;
  line-height: 1.6;
}

.payment-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.listing-fee-notice {
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.fee-amount {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}

.fee-text {
  font-size: 0.9rem;
  color: var(--text);
}

.fee-text strong {
  color: var(--primary);
}

@media (max-width: 768px) {
  .nav-search { display: none; }
  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 40px 16px; }
  .listings-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .listing-layout { grid-template-columns: 1fr; }
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .search-filters .form-row { flex-direction: column; }
  .dash-item { flex-direction: column; text-align: center; }
  .dash-item-actions { justify-content: center; }
}

.contact-form .form-group { margin-bottom: 10px; }
.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  box-sizing: border-box;
}
.contact-form textarea { resize: vertical; }
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.contact-status {
  margin-top: 10px;
  font-size: 0.9rem;
  text-align: center;
}
.contact-status.success { color: var(--success); }
.contact-status.error { color: var(--danger, #ef4444); }

.unread-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.75rem;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
}
.messages-list { display: flex; flex-direction: column; gap: 12px; }
.message-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.2s;
}
.message-item.unread {
  border-left: 4px solid var(--primary);
  background: #f0f6ff;
}
.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}
.message-from { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.message-email { color: var(--text-light); font-size: 0.85rem; }
.message-time { color: var(--text-light); font-size: 0.85rem; }
.new-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.message-about {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 8px;
}
.message-about a { color: var(--primary); }
.message-body {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.message-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-thumb-wrap {
  position: relative;
  display: inline-block;
}
.img-delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: 2px solid #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.img-delete-btn:hover { background: #dc2626; }
