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

:root {
  --bg: #0b0d0a;
  --bg-raised: #14170f;
  --bg-input: #10130c;
  --border: #232a1c;
  --text: #e9ecdf;
  --text-dim: #8b9482;
  --lime: #a3e635;
  --lime-dim: #7ab52a;
  --danger: #f87171;
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

a { color: var(--lime); }

button {
  font-family: var(--font-sans);
  cursor: pointer;
}

/* ---------- Nav ---------- */

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.brand-mark { width: 22px; height: 22px; color: var(--lime); }
.brand-mark.small { width: 20px; height: 20px; }

.topnav-links {
  display: flex;
  gap: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.topnav-links a {
  color: var(--text-dim);
  text-decoration: none;
  padding-bottom: 2px;
}

.topnav-links a.active,
.topnav-links a:hover {
  color: var(--lime);
  border-bottom: 1px solid var(--lime);
}

/* ---------- Auth pages ---------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--lime);
  margin-bottom: 0.25rem;
}

.auth-sub {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

.auth-form, .place-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-form label, .place-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

input, textarea {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
}

input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 1px;
}

.auth-form button, .place-form > button, .button {
  background: var(--lime);
  color: #0b0d0a;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  font-family: var(--font-sans);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.auth-form button:hover, .place-form > button:hover, .button:hover {
  background: var(--lime-dim);
}

.auth-error, .form-status.error {
  color: var(--danger);
  font-size: 0.85rem;
}

/* ---------- Admin pages ---------- */

.admin-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.admin-main h1 { font-family: var(--font-mono); }

.hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
}

.warn { color: #facc15; }

.import-form {
  margin-top: 1.5rem;
  align-items: flex-start;
}

.file-drop {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  width: 100%;
  cursor: pointer;
}

.file-drop input { display: none; }

.import-summary {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}

.file-list {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.add-place {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0 2rem;
}

.add-place h2 { margin-top: 0; font-family: var(--font-mono); font-size: 1rem; }

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row label { flex: 1; min-width: 140px; }

.form-status { font-size: 0.85rem; color: var(--text-dim); }

.list-heading {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  margin: 2rem 0 0.5rem;
  color: var(--lime);
}

.list-heading .count {
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 0.4rem;
}

.place-table { display: flex; flex-direction: column; gap: 0.4rem; }

.place-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.place-note { color: var(--text-dim); font-size: 0.85rem; margin: 0.2rem 0 0; }

.badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.badge.warn { background: #3a2f0a; color: #facc15; }

.place-row-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.place-row-actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 5px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.place-row-actions button:hover { border-color: var(--lime); color: var(--lime); }
.place-row-actions .delete-btn:hover { border-color: var(--danger); color: var(--danger); }

.empty-state { color: var(--text-dim); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.dialog-backdrop.hidden { display: none; }

.dialog {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
}

.dialog h2 { margin-top: 0; font-family: var(--font-mono); font-size: 1.05rem; }

.dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }

.dialog-actions button[type="button"] {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 0.6rem 1rem;
}

/* ---------- Map page ---------- */

.map-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.map-layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-search { padding: 0.9rem; border-bottom: 1px solid var(--border); }
.sidebar-search input { width: 100%; }

.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.list-filter {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  cursor: pointer;
}

.list-filter input { margin: 0; }

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--swatch-color, var(--lime));
}

.place-list { overflow-y: auto; flex: 1; padding: 0.4rem; }

.place-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.place-item:hover { background: var(--bg-input); }
.place-item.no-location { opacity: 0.5; cursor: default; }
.place-item.no-location:hover { background: transparent; }

.place-item .swatch { margin-top: 0.4rem; }

.place-item-list {
  display: block;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.loading, .empty-state { padding: 1rem; color: var(--text-dim); font-size: 0.85rem; }

#map { flex: 1; background: var(--bg); }

.pin {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 50% 0;
  background: var(--pin-color, var(--lime));
  transform: rotate(-45deg);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.5);
}

.map-popup {
  font-family: var(--font-sans);
  color: #0b0d0a;
  max-width: 220px;
}

.map-popup p { margin: 0.3rem 0; font-size: 0.85rem; }
.map-popup a { color: #3f7d0f; font-size: 0.8rem; }

.leaflet-popup-content-wrapper { background: var(--bg-raised); color: var(--text); border-radius: 8px; }
.leaflet-popup-content-wrapper .map-popup { color: var(--text); }
.leaflet-popup-content-wrapper .map-popup a { color: var(--lime); }
.leaflet-popup-tip { background: var(--bg-raised); }

@media (max-width: 720px) {
  .map-layout { flex-direction: column; }
  .sidebar { width: 100%; height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
  #map { height: 60%; }
}
