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

:root {
  --bg: #f6f8fc;
  --card: #fff;
  --text: #1a1a1a;
  --text-light: #5e6470;
  --border: #d8e0ea;
  --accent: #2b6cb0;
  --accent-dark: #1e4d7b;
  --accent-light: #5a8fd6;
  --success: #27ae60;
  --warning: #e67e22;
  --danger: #e74c3c;
  --shadow: 0 4px 14px rgba(0,0,0,0.08);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #f6f8fc 0%, #eaf0f8 100%);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  padding: 18px 24px;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

header h1 { font-size: 22px; font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 14px; opacity: 0.95; }
.logout-btn {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,0.25); }

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2 { color: var(--accent); margin-bottom: 14px; font-size: 18px; }

.hidden { display: none !important; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--text-light); margin-bottom: 4px; }

input[type="email"], input[type="password"], input[type="text"], input[type="url"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fafbfd;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}
textarea { resize: vertical; min-height: 60px; }

button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
  color: white;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(43,108,176,0.25); }
button.secondary { background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%); }
button.danger { background: linear-gradient(135deg, var(--danger) 0%, #c0392b 100%); }
button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }
.status { color: var(--text-light); font-size: 13px; margin-top: 6px; min-height: 16px; }

/* Add form */
.add-form { display: flex; flex-direction: column; gap: 10px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }
.add-row button { white-space: nowrap; }

.preview {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 200px 1fr;
  background: #fafbfd;
}
.preview-image-wrap {
  background: #e0e6ee;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.preview-image-wrap img { width: 100%; height: 100%; object-fit: cover; }
.preview-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preview-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preview-actions { display: flex; gap: 8px; margin-top: 4px; }

/* Feed */
.feed-controls { padding: 0 4px; }
.feed-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  background: white;
  color: var(--accent);
  border: 1px solid var(--border);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
}
.tab:hover { background: #eaf2ff; transform: none; box-shadow: none; }
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }

#listings { display: flex; flex-direction: column; gap: 14px; }

.listing {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.listing.status-liked { border-color: var(--success); border-width: 2px; }
.listing.status-rejected { opacity: 0.55; }

.listing-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #e0e6ee;
  display: block;
  object-fit: cover;
}
.listing-no-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #e0e6ee 0%, #cbd5e1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.listing-body { padding: 14px 16px; }
.listing-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.listing-title a { color: inherit; text-decoration: none; }
.listing-title a:hover { color: var(--accent); }
.listing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
}
.listing-meta .pill {
  background: #eaf2ff;
  color: var(--accent-dark);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.listing-description {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
  white-space: pre-wrap;
  max-height: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.listing-notes {
  font-size: 13px;
  color: var(--text-light);
  background: #fff8e1;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-style: italic;
}
.listing-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-light);
}
.listing-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.listing-actions button {
  font-size: 12px;
  padding: 6px 12px;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.listing-actions button:hover {
  background: #eaf2ff;
  transform: none;
  box-shadow: none;
}
.listing-actions button.like.active {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.listing-actions button.reject.active {
  background: var(--text-light);
  color: white;
  border-color: var(--text-light);
}
.listing-actions button.delete:hover { background: #ffe5e5; color: var(--danger); border-color: var(--danger); }

/* Comments modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-content {
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { color: var(--accent); font-size: 16px; }
.icon-btn {
  background: transparent;
  color: var(--text-light);
  font-size: 16px;
  padding: 4px 10px;
  border: 0;
}
.icon-btn:hover { background: #eef2f5; transform: none; box-shadow: none; }

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comment {
  background: #f6f8fc;
  border-radius: 10px;
  padding: 10px 14px;
  border-right: 3px solid var(--accent-light);
}
.comment.own { background: #eaf2ff; border-right-color: var(--accent); }
.comment-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.comment-author { font-weight: 700; color: var(--accent-dark); }
.comment-text { font-size: 14px; color: var(--text); white-space: pre-wrap; }
.comment-delete {
  background: transparent;
  color: var(--text-light);
  font-size: 11px;
  padding: 2px 6px;
  border: 0;
}
.comment-delete:hover { color: var(--danger); transform: none; box-shadow: none; }

.comment-form {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.comment-form textarea { flex: 1; min-height: 40px; max-height: 120px; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* Ratings */
.ratings-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ratings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}
.ratings-row .ratings-label {
  color: var(--text-light);
  font-weight: 600;
}
.my-rating .stars-input {
  display: inline-flex;
  gap: 2px;
  direction: ltr;
}
.my-rating .star-btn {
  background: transparent;
  border: 0;
  padding: 0 2px;
  font-size: 20px;
  color: #d1d5db;
  cursor: pointer;
  line-height: 1;
}
.my-rating .star-btn:hover { transform: none; box-shadow: none; color: #f59e0b; }
.my-rating .star-btn.filled { color: #f59e0b; }
.my-rating .clear-rating {
  background: transparent;
  color: var(--text-light);
  border: 0;
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
}
.my-rating .clear-rating:hover { color: var(--danger); transform: none; box-shadow: none; }

.others-ratings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-light);
}
.rater-chip {
  background: #eef2f5;
  border-radius: 999px;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rater-chip .rater-name { font-weight: 700; color: var(--text); }
.rater-chip .rater-stars { color: #f59e0b; direction: ltr; }

.rating-avg {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

/* Edit listing modal */
.edit-form {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.edit-form .field { margin-bottom: 8px; }
.edit-form textarea { min-height: 80px; }
.edit-form-actions {
  position: sticky;
  bottom: -14px;
  background: var(--card);
  padding: 12px 0;
  margin: 8px -18px -14px;
  padding-inline: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  z-index: 2;
}

/* Attachments gallery */
.attachments-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.attachments-title {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}
.attachment-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #e0e6ee;
  cursor: pointer;
}
.attachment-tile img,
.attachment-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-tile .video-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  color: white;
  font-size: 32px;
  pointer-events: none;
}
.attachment-tile .attachment-uploader {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  font-size: 10px;
  padding: 12px 6px 4px;
  text-align: start;
  pointer-events: none;
}
.attachment-tile .attachment-delete {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  background: rgba(0,0,0,0.55);
  color: white;
  border: 0;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 12px;
  padding: 0;
  display: none;
  cursor: pointer;
}
.attachment-tile:hover .attachment-delete { display: inline-flex; align-items: center; justify-content: center; }

.link-btn {
  background: transparent;
  color: var(--accent);
  border: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover {
  color: var(--accent-dark);
  transform: none;
  box-shadow: none;
  filter: none;
}

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  background: #fafbfd;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-light);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.upload-area:hover, .upload-area.drag-over {
  background: #eaf2ff;
  border-color: var(--accent);
  color: var(--accent-dark);
}
.upload-area input[type="file"] { display: none; }
.upload-status { font-size: 12px; color: var(--text-light); margin-top: 6px; min-height: 14px; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.lightbox-content {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-content img,
.lightbox-content video {
  max-width: 100%;
  max-height: 90vh;
  display: block;
  border-radius: 6px;
}
.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(255,255,255,0.15);
  color: white;
  border: 0;
  font-size: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close { top: 16px; inset-inline-end: 16px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); }
.lightbox-prev { inset-inline-end: 16px; }
.lightbox-next { inset-inline-start: 16px; }
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,0.3); transform: none; box-shadow: none; }
.lightbox-nav:hover { transform: translateY(-50%); }
@media (max-width: 600px) {
  .lightbox-nav { width: 36px; height: 36px; font-size: 18px; }
}

/* Bulk action bar */
.bulk-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: 10px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 6px;
  z-index: 30;
}
.bulk-count { font-weight: 700; color: #92400e; }
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bulk-btn { font-size: 13px; padding: 6px 14px; }
.bulk-btn.secondary { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }
.bulk-btn.danger { background: linear-gradient(135deg, #e74c3c, #c0392b); }

/* Selection checkboxes */
.row-checkbox-cell, .head-checkbox-cell {
  width: 36px;
  text-align: center;
  padding: 0 6px !important;
}
.row-checkbox, .head-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  vertical-align: middle;
}
.listings-table tbody tr.selected { background: rgba(245, 158, 11, 0.1); }
.listings-table tbody tr.selected:hover { background: rgba(245, 158, 11, 0.18); }
.listings-table tbody tr.row-archived td { opacity: 0.85; }

/* Listings table */
.table-wrap {
  padding: 8px;
  overflow-x: auto;
}
.listings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 750px;
}
.listings-table th,
.listings-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid #eef2f5;
  vertical-align: middle;
}
.listings-table th {
  background: #eaf2ff;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 12px;
  position: sticky;
  top: 0;
}
.th-sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease;
  white-space: nowrap;
}
.th-sortable:hover { background: #d8e6ff; }
.th-sort-active { background: var(--accent) !important; color: white !important; }
.listings-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}
.listings-table tbody tr:hover { background: #f6f9fd; }
.listings-table tbody tr.row-status-liked { background: rgba(39, 174, 96, 0.06); }
.listings-table tbody tr.row-status-liked:hover { background: rgba(39, 174, 96, 0.12); }
.listings-table tbody tr.row-status-rejected { opacity: 0.6; }

.cell-address { text-align: start; }
.cell-address-main { font-weight: 700; color: var(--accent-dark); }
.cell-address-sub {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-price { white-space: nowrap; color: var(--accent); font-weight: 600; }
.cell-contact { font-size: 12px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-avg { font-weight: 700; }
.rating-cell { color: #f59e0b; direction: ltr; font-size: 12px; white-space: nowrap; }
.rating-cell.empty { color: var(--text-light); }
.rating-cell .rating-num { color: var(--text); margin-inline-start: 4px; font-weight: 600; font-size: 11px; }

/* Detail modal */
.modal-content-large {
  max-width: 760px;
  max-height: 92vh;
  width: 100%;
}
#detail-body {
  overflow-y: auto;
  padding: 0 18px 18px;
}
.detail-content { display: flex; flex-direction: column; gap: 12px; }
.detail-section .listing-title { font-size: 18px; margin-bottom: 6px; }
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  background: #f6f9fd;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.info-row { display: flex; flex-direction: column; }
.info-label { font-size: 11px; color: var(--text-light); font-weight: 600; margin-bottom: 2px; }
.info-value { font-size: 14px; color: var(--text); font-weight: 600; }
.youtube-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}
.youtube-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.youtube-link {
  text-align: center;
  padding: 14px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: 10px;
  border: 1px solid #f59e0b;
}
.youtube-link a {
  color: #92400e;
  font-weight: 700;
  text-decoration: none;
  font-size: 16px;
}
.youtube-link a:hover { text-decoration: underline; }

.listing-description-full {
  font-size: 14px;
  color: var(--text);
  margin-top: 8px;
  white-space: pre-wrap;
  padding: 10px 12px;
  background: #fafbfd;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Mobile responsiveness */
@media (max-width: 600px) {
  header h1 { font-size: 18px; }
  main { padding: 14px 10px; }
  .add-row { flex-direction: column; }
  .preview { grid-template-columns: 1fr; }
  .preview-image-wrap { aspect-ratio: 16 / 9; }
  .listing-meta { font-size: 12px; }
}
