@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #fafafa;
  --surface: #fff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text2: #737373;
  --accent: #2563eb;
  --accent2: #3b82f6;
  --green: #16a34a;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 12px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

h1 { font-size: 1.25rem; font-weight: 700; }
.stats { font-size: 0.8rem; color: var(--text2); }

.controls {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 12px;
  align-items: center;
}

#search {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
#search:focus { border-color: var(--accent); }

.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.tab {
  padding: 8px 20px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text2);
  transition: all 0.2s;
}
.tab.active { background: var(--accent); color: #fff; }

.filters {
  max-width: 1200px;
  margin: 8px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
}

.filters select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  outline: none;
}

main { max-width: 1200px; margin: 16px auto; padding: 0 24px; }

.view { display: none; }
.view.active { display: block; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:hover { color: var(--accent); }
th[data-sort].asc::after { content: ' ↑'; }
th[data-sort].desc::after { content: ' ↓'; }

tbody tr { border-bottom: 1px solid #f0f0f0; transition: background 0.15s; }
tbody tr:hover { background: #f8faff; }
tbody tr:last-child { border-bottom: none; }
td { padding: 10px 16px; vertical-align: middle; }

.name-cell { font-weight: 500; cursor: pointer; }
.name-cell:hover { color: var(--accent); }

.rating { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.rating .stars { color: var(--yellow); }
.rating .count { color: var(--text2); font-weight: 400; font-size: 0.75rem; }
.rating-high { color: var(--green); }
.rating-mid { color: var(--yellow); }
.rating-low { color: var(--red); }

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  background: #f0f0f0;
  color: var(--text2);
}

.breakfast-badge { background: #fef3c7; color: #92400e; }

.vote-cell { display: flex; gap: 4px; align-items: center; }
.vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--text2);
  transition: color 0.15s, transform 0.15s;
}
.vote-btn:hover { transform: scale(1.15); }
.vote-btn.vote-up:hover, .vote-btn.vote-up.voted { color: var(--green); }
.vote-btn.vote-down:hover, .vote-btn.vote-down.voted { color: var(--red); }
.vote-btn svg { width: 18px; height: 18px; fill: none; }
.vote-btn.vote-up.voted svg { fill: var(--green); fill-opacity: 0.15; }
.vote-btn.vote-down.voted svg { fill: var(--red); fill-opacity: 0.15; }
.back { color: var(--text2); text-decoration: none; margin-right: 8px; font-weight: 400; }
.back:hover { color: var(--text); }

.links { display: flex; gap: 6px; }
.link-a { color: var(--accent); text-decoration: underline; font-size: 0.75rem; margin-right: 8px; }

/* Map */
#map { height: 70vh; border-radius: var(--radius); border: 1px solid var(--border); }

.map-popup h3 { font-size: 0.9rem; margin-bottom: 4px; }
.map-popup .mp-rating { font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; }
.map-popup .mp-meta { font-size: 0.7rem; color: var(--text2); margin-bottom: 6px; }
.map-popup .mp-link {
  display: inline-block;
  font-size: 0.7rem;
  margin-right: 8px;
  color: var(--accent);
  text-decoration: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}
.modal.open { display: flex; }

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text2);
}

.modal-content h2 { font-size: 1.1rem; margin-bottom: 4px; padding-right: 24px; }
#modalInfo { font-size: 0.8rem; color: var(--text2); margin-bottom: 16px; }

.comments-list { margin-bottom: 16px; }
.comment {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.comment:last-child { border-bottom: none; }
.comment-header { display: flex; justify-content: space-between; font-size: 0.75rem; margin-bottom: 4px; }
.comment-author { font-weight: 600; color: var(--accent); }
.comment-time { color: var(--text2); }
.comment-text { font-size: 0.85rem; }

#commentForm { display: flex; flex-direction: column; gap: 8px; }
#commentForm input, #commentForm textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  resize: vertical;
}
#commentForm input:focus, #commentForm textarea:focus { border-color: var(--accent); }
#commentForm button {
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
#commentForm button:hover { background: var(--accent2); }

@media (max-width: 768px) {
  .header-inner { flex-direction: column; gap: 8px; }
  .controls { flex-direction: column; }
  .filters { flex-wrap: wrap; }
  td, th { padding: 8px 10px; font-size: 0.78rem; }
  #map { height: 50vh; }
}
