:root {
  --bg: #0f1115;
  --panel-bg: #1a1d24;
  --accent: #ff5a5f;
  --accent-dim: #c9484c;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #2a2e37;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(15,17,21,0.95), rgba(15,17,21,0.75));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { flex: 0 0 auto; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: 0.5px; }
.topbar h1::before { content: "📍 "; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.search {
  position: relative;
  flex: 1 1 280px;
  max-width: 520px;
  display: flex;
  gap: 6px;
}
#search-input {
  flex: 1;
  background: #12141a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
}
#search-input:focus { outline: none; border-color: var(--accent); }
#search-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 0 14px;
  font-size: 15px;
  cursor: pointer;
}
#search-btn:hover { background: var(--accent-dim); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1200;
}
.search-results.hidden { display: none; }
.search-results li {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.search-results li:hover, .search-results li.active { background: #262a33; }
.search-results li .sub { display: block; color: var(--muted); font-size: 11px; }
.search-results li.info { color: var(--muted); cursor: default; }

#map {
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
}

.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  z-index: 1100;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
  padding: 18px 20px;
  overflow-y: auto;
  transform: translateX(0);
  transition: transform 0.22s ease;
}
.panel.hidden { transform: translateX(105%); }

.panel-close {
  position: absolute;
  top: 10px; right: 14px;
  background: none; border: none;
  color: var(--muted);
  font-size: 28px; line-height: 1;
  cursor: pointer;
}
.panel-close:hover { color: var(--text); }

.panel h2 { margin: 4px 40px 2px 0; font-size: 20px; }
.panel-meta { margin: 0 0 16px; color: var(--muted); font-size: 13px; text-transform: capitalize; }
.panel h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 18px 0 8px; }

.upload-section form { display: flex; flex-direction: column; gap: 8px; }
.upload-section .row { display: flex; gap: 8px; }
input[type="file"], input[type="number"], textarea {
  width: 100%;
  background: #12141a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
}
input[type="file"] { padding: 7px; }
textarea { resize: vertical; }

button#upload-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button#upload-btn:hover { background: var(--accent-dim); }
button#upload-btn:disabled { opacity: 0.5; cursor: default; }

.status { margin: 4px 0 0; font-size: 13px; min-height: 16px; }
.status.error { color: var(--accent); }
.status.ok { color: #4caf86; }

.count { color: var(--accent); font-weight: 700; }

.receipts-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }

.receipt-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #12141a;
}
.receipt-card a { display: block; }
.receipt-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.receipt-card .pdf {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: #1d2029;
}
.receipt-card .info { padding: 7px 9px; font-size: 12px; }
.receipt-card .amount { font-weight: 700; color: #4caf86; }
.receipt-card .note { color: var(--muted); margin: 2px 0 0; }
.receipt-card .date { color: var(--muted); font-size: 11px; margin-top: 3px; }

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: #2a2e37;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.hidden { display: none; }

/* Custom marker pins */
.pin {
  font-size: 22px;
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

/* "Locate me" map control */
.locate-btn {
  width: 40px;
  height: 40px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.locate-btn:hover { background: #262a33; }

/* Loading indicator while a new area is fetched/warmed */
.loading {
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.loading.hidden { display: none; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Always-on pin name labels */
.pin-label.leaflet-tooltip {
  background: rgba(255, 255, 255, 0.92);
  color: #1a1d24;
  border: none;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pin-label.leaflet-tooltip::before { display: none; } /* hide the little arrow */

.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content .pop-btn {
  display: inline-block;
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
