:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #5b8cff;
  --accent-2: #3a6df0;
  --chip: #2a3344;
  --green: #6ee7a8;
  --wa: #25d366;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Auth gate ── */
.auth-gate {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.auth-logo { font-size: 36px; color: var(--accent); margin-bottom: 12px; }
.auth-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 24px; }
.auth-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
  -webkit-appearance: none;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-card button {
  width: 100%;
  padding: 12px;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.auth-card button:active { opacity: .85; }
.auth-error { color: #ff6b6b; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 48px;
}
.topbar h1 { font-size: 17px; font-weight: 700; flex: 1; }
.stats { color: var(--muted); font-size: 12px; white-space: hidden; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.topbar-actions { display: flex; gap: 2px; }

.btn {
  padding: 8px 14px;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: .8; }
.btn.icon {
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  padding: 4px 8px;
  line-height: 1;
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 100%;
  padding: 10px;
}
.btn.ghost:active { border-color: var(--accent); color: var(--text); }

/* ── Layout ── */
.layout { display: flex; flex-direction: column; }

/* ── Filters ── */
.filters {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: none;
}
.filters.open { display: block; }
.drawer-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.filters-inner { display: flex; flex-direction: column; gap: 10px; }
.field label, .check {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.check { margin: 2px 0 4px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.field.row { display: flex; gap: 10px; }
.field.row > div { flex: 1; }

input, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input.search-input {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239aa3b2' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

/* ── Results ── */
.results { padding: 12px 12px calc(20px + var(--safe-bottom)); flex: 1; }
.result-count { color: var(--muted); font-size: 13px; margin-bottom: 10px; padding: 0 4px; }

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

/* ── Card ── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
.card:active { border-color: var(--accent); }
.card .thumb {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--panel-2);
  display: block;
}
.card .no-thumb {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 24px;
}
.card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 11.5px;
  color: var(--muted);
  padding-top: 4px;
}
.price { color: var(--green); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.chip { background: var(--chip); color: #c5d3ec; border-radius: 20px; padding: 2px 7px; font-size: 10.5px; }

/* Card action buttons */
.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.btn-call, .btn-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  text-decoration: none;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
.btn-call { background: var(--accent-2); }
.btn-wa { background: var(--wa); }
.btn-call:active, .btn-wa:active { opacity: .7; transform: scale(.95); }

/* ── Infinite scroll ── */
.sentinel { height: 1px; }
.loading-more, .end-reached { text-align: center; padding: 20px; color: var(--muted); font-size: 13px; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  padding-bottom: var(--safe-bottom);
}
.modal-close {
  position: sticky;
  top: 10px;
  float: right;
  margin-right: 10px;
  background: rgba(0,0,0,.5);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  background: #000;
}
.gallery img {
  height: 300px;
  width: auto;
  scroll-snap-align: start;
  object-fit: cover;
  flex-shrink: 0;
  cursor: zoom-in;
}
.modal-content { padding: 16px 20px 24px; }
.modal-content h2 { font-size: 18px; margin-bottom: 4px; }
.modal-content .desc { color: var(--muted); font-size: 14px; margin-bottom: 16px; line-height: 1.45; }
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.kv dd { font-size: 14px; word-break: break-word; }
.kv dd a { color: var(--accent); text-decoration: none; }
.kv .chips { margin-top: 0; }

.phone-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phone-row a { color: var(--text); text-decoration: none; }
.btn-wa-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--wa);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn-wa-sm:active { opacity: .8; }

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

/* ── Fullscreen image viewer ── */
.fullscreen {
  position: fixed; inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fullscreen.hidden { display: none; }
.fullscreen img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}
.fs-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.fs-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 44px;
  height: 60px;
  font-size: 28px;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.fs-prev { left: 0; border-radius: 0 8px 8px 0; }
.fs-next { right: 0; border-radius: 8px 0 0 8px; }
.fs-nav:active { background: rgba(255,255,255,.3); }
.fs-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.5);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 2;
}

/* ── Desktop ── */
@media (min-width: 700px) {
  .topbar { padding: 12px 20px; }
  .layout { flex-direction: row; }
  .filters {
    display: block !important;
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    border-bottom: none;
    height: calc(100vh - 48px);
    position: sticky;
    top: 48px;
    overflow-y: auto;
    padding: 16px;
  }
  .drawer-handle { display: none; }
  .results { padding: 16px 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .modal { align-items: center; padding: 20px; }
  .modal-card { border-radius: 16px; max-height: 88vh; }
  .gallery img { height: 340px; }
  .fs-nav { width: 50px; height: 80px; font-size: 32px; }
  #filterToggle { display: none; }
}

@media (min-width: 1000px) {
  .filters { width: 260px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ── Card stats & badges ── */
.card-stats { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10.5px; font-weight: 500; }
.badge-on { background: rgba(37, 211, 102, 0.15); color: var(--wa); }
.badge-off { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }

/* ── Detail modal extras ── */
.detail-subtitle { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.detail-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.stat-badge { display: inline-block; padding: 3px 8px; background: var(--chip); border-radius: 6px; font-size: 12px; color: #c5d3ec; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.detail-desc { margin: 12px 0; line-height: 1.5; white-space: pre-wrap; }
.detail-bio { margin: 8px 0; padding: 8px 12px; background: var(--panel-2); border-radius: 8px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.detail-langs, .detail-owner { font-size: 12px; color: var(--muted); margin: 4px 0; }
.detail-price-main { font-size: 18px; font-weight: 700; color: var(--green); margin: 8px 0; }
.detail-prices { margin: 12px 0; }
.detail-prices h3, .detail-services-section h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.price-table { width: 100%; border-collapse: collapse; }
.price-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.price-table td:last-child { text-align: right; font-weight: 600; color: var(--green); }
.detail-services { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.detail-services-section { margin: 12px 0; }
.detail-contact { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.btn-call-lg, .btn-wa-lg { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; }
.btn-call-lg { background: var(--accent-2); color: #fff; }
.btn-wa-lg { background: var(--wa); color: #fff; }
.detail-link { display: inline-block; margin: 8px 0; color: var(--accent); font-size: 13px; text-decoration: none; }
.detail-location { font-size: 13px; color: var(--muted); margin: 8px 0; }

.hidden { display: none !important; }
