/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1e293b;
  background: #f8fafc;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: #1e293b;
  color: #f1f5f9;
  flex-shrink: 0;
}

.app-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── File-input disguised as a button ─────────────────────────── */
.file-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.file-button:hover {
  background: #1d4ed8;
}

.file-button input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── Generic button ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: #475569;
  color: #f1f5f9;
}

.btn-secondary:not(:disabled):hover {
  background: #334155;
}

/* ── Main content area ───────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0; /* allow flex children to shrink */
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #f1f5f9;
  border-right: 1px solid #cbd5e1;
  padding: 16px;
  overflow-y: auto;
}

.sidebar-heading {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

/* ── Stats list ──────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
}

.stats dt {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
  white-space: nowrap;
}

.stats dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  word-break: break-word;
}

/* ── Placeholder & error ─────────────────────────────────────── */
.placeholder {
  color: #94a3b8;
  font-style: italic;
  line-height: 1.6;
  margin: 0 0 12px;
}

.placeholder code {
  font-style: normal;
  background: #e2e8f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  line-height: 1.5;
  word-break: break-word;
}

/* ── Map ─────────────────────────────────────────────────────── */
#map {
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* ── Responsive: stack on narrow screens ────────────────────── */
@media (max-width: 699px) {
  .main {
    flex-direction: column;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #cbd5e1;
  }

  #map {
    height: 60vh;
    flex: none;
  }
}

/* ── Login overlay ───────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  max-width: 380px;
  width: 90%;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #0f172a;
}

.login-card p {
  margin: 0 0 24px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

.btn-login {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-login:hover {
  background: #1d4ed8;
}

.topbar .btn-logout {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #475569;
  padding: 4px 12px;
  font-size: 12px;
}

.topbar .btn-logout:hover {
  color: #f1f5f9;
  border-color: #94a3b8;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 13px;
}
