* {
  box-sizing: border-box;
}

:root {
  --ink: #0d1117;
  --paper: #faf9f6;
  --warm: #f5f0e8;
  --gold: #c8963e;
  --rust: #b34a2c;
  --muted: #6b6560;
  --border: #e2ddd6;
}

body {
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  background: var(--paper);
  color: var(--ink);
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(250, 249, 246, 0.95);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
}

.brand {
  text-decoration: none;
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  color: var(--ink);
  font-weight: 900;
}

.brand span {
  color: var(--gold);
}

.app-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.app-nav a,
.link-btn {
  text-decoration: none;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.92rem;
}

.main-content {
  padding: 30px 0 60px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 22px;
}

.auth-card {
  max-width: 560px;
  margin: 30px auto;
}

.centered-card {
  text-align: center;
  max-width: 640px;
  margin: 50px auto;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.grid-form label:has(textarea),
.grid-form label:has(select) {
  width: 100%;
}

.grid-form textarea,
.grid-form label:has(textarea) {
  grid-column: 1 / -1;
}

.grid-form button {
  grid-column: 1 / -1;
}

input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 0.95rem;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.btn {
  border: none;
  padding: 11px 16px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
}

.btn-dark {
  background: var(--ink);
  color: #fff;
}

.btn-gold {
  background: var(--gold);
  color: var(--ink);
}

.subtle {
  color: var(--muted);
}

.flash {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
}

.flash-error {
  background: #ffe7e7;
  color: #8d1f1f;
}

.flash-success {
  background: #e5ffe8;
  color: #1f7a31;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.listing-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.listing-tile img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.listing-tile div {
  padding: 14px;
}

.owner-list-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-actions form {
  margin: 0;
}

.danger-link {
  border: none;
  background: transparent;
  color: #a00000;
  cursor: pointer;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

#map {
  width: 100%;
  height: 420px;
  border-radius: 12px;
}

.listing-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detail-image {
  width: 100%;
  height: 100%;
  max-height: 440px;
  object-fit: cover;
  border-radius: 10px;
}

.small {
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-form {
    grid-template-columns: 1fr 1fr;
  }

  .listing-detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .app-nav {
    flex-wrap: wrap;
  }

  .grid-form,
  .section-grid,
  .filter-form {
    grid-template-columns: 1fr;
  }

  .owner-list-row {
    flex-direction: column;
  }
}

/* ── Dashboard Tables ── */
.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-top: 12px;
}

.dashboard-table th,
.dashboard-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e8e3d9;
}

.dashboard-table th {
  font-weight: 600;
  background: #f8f5ef;
  color: #5a4a3a;
}

.dashboard-table td .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Status Badges ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-pending   { background: #fff3cd; color: #856404; }
.badge-confirmed { background: #d1e7dd; color: #0f5132; }
.badge-approved  { background: #d1e7dd; color: #0f5132; }
.badge-cancelled { background: #f8d7da; color: #842029; }
.badge-rejected  { background: #f8d7da; color: #842029; }

@media (max-width: 700px) {
  .dashboard-table thead { display: none; }
  .dashboard-table tr    { display: block; margin-bottom: 12px; border: 1px solid #e8e3d9; border-radius: 8px; }
  .dashboard-table td    { display: block; border-bottom: none; padding: 6px 12px; }
}

/* ── Listing Detail (show page) ── */
/* ── Photo Gallery ── */
.gallery-wrap {
  width: 100%;
  background: #111;
}

.gallery-main {
  position: relative;
  width: 100%;
  height: 500px;
  overflow: hidden;
}

.gallery-hero {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background 0.15s;
}

.gallery-nav:hover { background: rgba(0,0,0,0.7); }
.gallery-prev { left: 14px; }
.gallery-next { right: 14px; }

.gallery-counter {
  position: absolute;
  bottom: 12px;
  right: 16px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 12px;
}

.gallery-thumbs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  background: #1a1a1a;
  padding: 6px 6px;
  scrollbar-width: thin;
  scrollbar-color: #555 #1a1a1a;
}

.gallery-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 58px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.55;
  border: 2px solid transparent;
  transition: opacity 0.15s, border-color 0.15s;
}

.gallery-thumb.active,
.gallery-thumb:hover {
  opacity: 1;
  border-color: var(--gold);
}

/* ── Photo Upload Block ── */
.photo-upload-block {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.photo-upload-label {
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.photo-drop-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--warm);
  transition: border-color 0.15s, background 0.15s;
}

.photo-drop-area:hover,
.photo-drop-area.dragover {
  border-color: var(--gold);
  background: #fdf6ea;
}

.photo-drop-area svg { color: var(--muted); margin-bottom: 6px; }
.photo-drop-area p { margin: 4px 0; font-size: 0.9rem; }

.photo-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-thumb {
  position: relative;
  width: 100px;
  height: 75px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--border);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-cover-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(200,150,62,0.85);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.photo-remove-check {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(0,0,0,0.55);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: #fff;
}

.photo-remove-check input[type="checkbox"] {
  display: none;
}

.photo-thumb:has(input[type="checkbox"]:checked) {
  opacity: 0.35;
}

@media (max-width: 960px) {
  .gallery-main { height: 320px; }
  .gallery-thumb { width: 64px; height: 46px; }
}

@media (max-width: 600px) {
  .gallery-main { height: 230px; }
}

.ld-layout {
  width: min(1100px, 92%);
  margin: 32px auto 60px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
  align-items: start;
}

.ld-main {
  min-width: 0;
}

.ld-title-block {
  margin-bottom: 18px;
}

.ld-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink);
}

.ld-address {
  color: var(--muted);
  font-size: 0.93rem;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
}

.ld-stats {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 22px;
}

.ld-stat {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  font-size: 0.92rem;
  border-right: 1px solid var(--border);
}

.ld-stat:last-child {
  border-right: none;
}

.ld-stat svg {
  color: var(--gold);
  flex-shrink: 0;
}

.ld-section {
  margin-bottom: 20px;
}

.ld-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}

.ld-desc {
  line-height: 1.75;
  color: #3a3530;
  margin: 0;
  white-space: pre-line;
}

.ld-amenity-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ld-amenity-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--warm);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.85rem;
  color: var(--ink);
}

.ld-amenity-tag svg {
  color: var(--gold);
}

/* sidebar */
.ld-sidebar {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ld-price-card {
  text-align: center;
  padding: 22px;
}

.ld-sidebar-price {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
}

.ld-sidebar-price span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}

.ld-sidebar-stats {
  margin: 6px 0 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.ld-dot {
  margin: 0 4px;
}

.ld-sidebar-type {
  background: var(--warm);
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: capitalize;
}

.ld-sidebar-action h3 {
  margin-top: 0;
}

.ld-listed-by {
  padding: 14px 20px;
}

.ld-owner-name {
  font-weight: 600;
  margin: 2px 0 0;
  font-size: 0.97rem;
}

/* forms inside listing detail */
.ld-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ld-form input,
.ld-form select,
.ld-form textarea {
  width: 100%;
}

.ld-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* mobile: hide sidebar actions, show inline actions */
.ld-actions-mobile {
  display: none;
}

@media (max-width: 960px) {
  .ld-layout {
    grid-template-columns: 1fr;
  }

  .ld-sidebar {
    position: static;
  }

  .ld-stats {
    flex-wrap: wrap;
  }

  .ld-stat {
    flex: 1 1 45%;
  }

  /* swap: hide sidebar forms, show inline ones */
  .ld-sidebar .ld-sidebar-action {
    display: none;
  }

  .ld-actions-mobile {
    display: block;
  }
}

@media (max-width: 600px) {
  .ld-stat {
    flex: 1 1 100%;
  }

  .ld-price {
    font-size: 1.5rem;
  }
}
