* { box-sizing: border-box; }

:root {
  --bg: #fff;
  --surface: #fff;
  --surface-alt: #f8f9fa;
  --border: #e5e7eb;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --primary: #1a1a1a;
  --primary-fg: #fff;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--surface-alt);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; font-size: 18px; }
.env {
  font-size: 11px;
  text-transform: uppercase;
  background: var(--surface-alt);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.card h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }

form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  position: relative;
}

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: #6b7280; }

.row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 12px;
}

button {
  font: inherit;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-fg);
  cursor: pointer;
  transition: opacity 0.15s;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.suggestions {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 280px;
  overflow-y: auto;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}
.suggestions li {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover { background: var(--surface-alt); }
.suggestions li .secondary { color: var(--text-muted); font-size: 12px; }

.selected {
  margin: 8px 0 14px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.selected strong { display: block; margin-bottom: 4px; font-size: 14px; }

.status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}
.status.success { color: var(--success); }
.status.error { color: var(--danger); }

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.list-header h2 { margin: 0; }
.list-header select { width: 200px; }
.list-actions { display: flex; gap: 10px; align-items: center; }

.rating {
  font-size: 12px;
  font-weight: 600;
  color: #f59e0b;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 999px;
}
.rating.muted { color: #9ca3af; background: #f3f4f6; font-weight: 500; }
.rating .rating-count {
  color: #92400e;
  font-weight: 500;
  margin-left: 2px;
}
.rating.muted .rating-count { color: inherit; }

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

.place-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.place-row .thumb {
  width: 80px; height: 60px;
  background: var(--surface-alt);
  border-radius: 6px;
  background-size: cover;
  background-position: center;
}
.place-row .meta .name { font-weight: 600; font-size: 15px; }
.place-row .meta .addr { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.place-row .meta .badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge.ok { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.badge.warn { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.badge.muted { opacity: 0.6; }
.place-row .actions { display: flex; gap: 6px; }
.place-row .actions button { padding: 6px 12px; font-size: 12px; }

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

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--primary-fg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 200;
  max-width: calc(100% - 48px);
  text-align: center;
}

.place-row .actions { flex-wrap: wrap; justify-content: flex-end; max-width: 360px; }
.place-row .actions button { cursor: pointer; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  padding: 0 4px;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal-loading {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}
.modal-form label {
  margin-bottom: 14px;
}

.detail-rating {
  font-size: 16px;
  font-weight: 700;
  color: #f59e0b;
  margin-top: 6px;
}
.detail-rating span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.detail-meta { font-size: 14px; margin-bottom: 14px; }
.detail-meta strong { font-weight: 500; color: var(--text); }
.detail-coords { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.detail-links { margin-top: 8px; display: flex; gap: 14px; }
.detail-links a { color: #2563eb; text-decoration: none; font-size: 13px; }
.detail-links a:hover { text-decoration: underline; }

.detail-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin: 16px 0;
}
.detail-photo {
  aspect-ratio: 4/3;
  background: var(--surface-alt);
  background-size: cover;
  background-position: center;
  border-radius: 6px;
}

.detail-section { margin-top: 18px; }
.detail-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.md { line-height: 1.55; font-size: 14px; }
.md h2, .md h3, .md h4 { margin: 14px 0 6px; font-size: 15px; font-weight: 600; }
.md p { margin: 0 0 10px; }
.md ul { margin: 0 0 10px; padding-left: 20px; }
.md li { margin-bottom: 4px; }
.md sup { color: var(--text-muted); font-size: 10px; padding: 0 1px; }
.md strong { font-weight: 600; }

@media (max-width: 700px) {
  .row { grid-template-columns: 1fr; }
  .container { padding: 0 12px; }
  .card { padding: 14px; }
  .place-row { grid-template-columns: 60px 1fr; }
  .place-row .actions { grid-column: 1 / -1; }
  .place-row .thumb { width: 60px; height: 45px; }
}

/* Category tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 14px;
  overflow-x: auto;
}
.tabs button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tabs button:hover:not(:disabled) {
  color: var(--text);
}
.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}
.tabs button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.tabs .tab-count {
  font-size: 11px;
  margin-left: 6px;
  padding: 1px 7px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 500;
}
.tabs button.active .tab-count {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

/* Search bar */
.search-bar {
  margin-bottom: 14px;
}
.search-bar input {
  width: 100%;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pagination button {
  padding: 6px 14px;
  font-size: 13px;
}
.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 200px;
  text-align: center;
}
.pagination select {
  padding: 6px 10px;
  font-size: 13px;
  width: auto;
}

/* Per-category visual hint on rows */
.place-row[data-cat="restaurants"] .meta .name::before {
  content: "🏠 ";
  font-size: 13px;
}
.place-row[data-cat="places"] .meta .name::before {
  content: "📍 ";
  font-size: 13px;
}
