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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
h1 { font-size: 1.25rem; font-weight: 700; }
.count-label {
  font-size: 0.85rem;
  color: #888;
}

/* ── Filter bar ── */
.filter-bar {
  max-width: 1200px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid #ddd;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: #aaa; }
.filter-btn.active {
  background: #1a73e8;
  border-color: #1a73e8;
  color: #fff;
}

/* ── Grid ── */
.listings-grid {
  max-width: 1200px;
  margin: 20px auto 60px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px;
  color: #888;
  font-size: 1rem;
}

/* ── Card ── */
.card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

/* ── Photo carousel ── */
.carousel {
  position: relative;
  aspect-ratio: 4/3;
  background: #eee;
  overflow: hidden;
}
.carousel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.carousel img.active { display: block; }
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.carousel:hover .carousel-btn { opacity: 1; }
.carousel-btn.prev { left: 8px; }
.carousel-btn.next { right: 8px; }
.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
}
.carousel-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
}
.carousel-dots span.active { background: #fff; }
.no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #ccc;
}

/* ── Card body ── */
.card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-meta {
  font-size: 0.82rem;
  color: #555;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.meta-item { display: flex; align-items: center; gap: 4px; }

.card-district {
  font-size: 0.8rem;
  color: #888;
}

/* ── Status badge ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: flex-start;
}
.badge-applied  { background: #e6f4ea; color: #1e7e34; }
.badge-new      { background: #e8f0fe; color: #1a73e8; }
.badge-skipped  { background: #f5f5f5; color: #888; }
.badge-error    { background: #fce8e6; color: #c5221f; }
.badge-captcha_blocked { background: #fff3e0; color: #e65100; }

/* ── Card footer ── */
.card-footer {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-ad {
  display: block;
  text-align: center;
  padding: 8px;
  background: #1a73e8;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-ad:hover { background: #1558b0; }

.toggle-msg {
  background: none;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 7px;
  font-size: 0.82rem;
  color: #555;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s;
}
.toggle-msg:hover { border-color: #aaa; }

.message-box {
  display: none;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #333;
  white-space: pre-wrap;
}
.message-box.open { display: block; }

.applied-at {
  font-size: 0.75rem;
  color: #aaa;
  text-align: right;
}

/* ── Apply / Skip action buttons ── */
.action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-apply, .btn-skip {
  padding: 9px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn-apply:disabled, .btn-skip:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-apply {
  background: #1e7e34;
  color: #fff;
}
.btn-apply:hover:not(:disabled) { background: #155724; }
.btn-skip {
  background: #f5f5f5;
  color: #555;
  border: 1.5px solid #ddd;
}
.btn-skip:hover:not(:disabled) { background: #e8e8e8; }
