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

:root {
  --accent:    #0071e3;
  --accent-dk: #0059b3;
  --bg:        #fafafa;
  --surface:   #ffffff;
  --border:    #e0e0e0;
  --text:      #1d1d1f;
  --muted:     #6e6e73;
  --danger:    #d93025;
  --radius:    12px;
  --sidebar-w: 280px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px; font-size: 15px;
  font-weight: 500; cursor: pointer; border: none; transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); text-decoration: none; color: #fff; }
.btn-lg { padding: 14px 28px; font-size: 17px; border-radius: 10px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f0f0f0; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-google {
  background: #fff; color: #3c4043; border: 1px solid var(--border);
  width: 100%; justify-content: center; font-size: 15px; padding: 12px 20px;
  border-radius: 8px;
}
.btn-google:hover { background: #f8f8f8; }

.hidden { display: none !important; }

/* ── Landing ──────────────────────────────────────────────────────── */
body.landing { background: var(--bg); }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 40px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(250,250,250,.85);
  backdrop-filter: blur(12px); z-index: 100;
}

.logo { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -.5px; }

.hero {
  text-align: center; padding: 100px 20px 80px;
  max-width: 800px; margin: 0 auto;
}
.hero h1 {
  font-size: clamp(40px, 8vw, 76px); font-weight: 700;
  line-height: 1.05; letter-spacing: -2px; margin-bottom: 20px;
}
.subhead {
  font-size: 20px; color: var(--muted); line-height: 1.6; margin-bottom: 36px;
}

.features { padding: 60px 40px; background: var(--surface); }
.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px; max-width: 1000px; margin: 0 auto;
}
.feature-card {
  padding: 28px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg);
}
.feature-icon { font-size: 36px; display: block; margin-bottom: 12px; }
.feature-card h3 { font-size: 18px; margin-bottom: 8px; }
.feature-card p { color: var(--muted); font-size: 14px; line-height: 1.6; }

.how { padding: 80px 40px; max-width: 700px; margin: 0 auto; }
.how h2 { font-size: 32px; font-weight: 700; margin-bottom: 40px; text-align: center; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 28px; }
.steps li { display: flex; align-items: flex-start; gap: 20px; }
.step-num {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.steps strong { display: block; font-size: 16px; margin-bottom: 4px; }
.steps p { color: var(--muted); font-size: 14px; line-height: 1.6; }

footer { text-align: center; padding: 32px; color: var(--muted); font-size: 14px; }
footer a { color: var(--muted); }

/* ── Auth screen ──────────────────────────────────────────────────── */
body.dashboard-page { background: var(--bg); height: 100vh; overflow: hidden; }

.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px;
  text-align: center; box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.logo-mark {
  width: 56px; height: 56px; border-radius: 14px; background: var(--accent);
  color: #fff; font-size: 28px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.auth-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.auth-desc { color: var(--muted); margin-bottom: 28px; }
.auth-note { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.5; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ── Dashboard ────────────────────────────────────────────────────── */
.dashboard { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  background: var(--surface); overflow: hidden;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px; border-bottom: 1px solid var(--border);
}
.tracker-list { flex: 1; overflow-y: auto; padding: 8px; }
.empty-state { color: var(--muted); font-size: 14px; line-height: 1.6; padding: 20px; text-align: center; }

.tracker-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background .1s;
}
.tracker-row:hover { background: #f0f4ff; }
.tracker-row.active { background: #e8f0fe; }
.tracker-icon { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }
.tracker-name { font-size: 14px; font-weight: 600; display: block; }
.tracker-status { font-size: 12px; color: var(--muted); display: block; margin-top: 1px; }

.map-container { flex: 1; }

/* ── Map marker ───────────────────────────────────────────────────── */
.map-marker {
  width: 36px; height: 36px; border-radius: 50%;
  background: white; border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav { padding: 12px 20px; }
  .hero { padding: 60px 20px 50px; }
  .features, .how { padding: 40px 20px; }
  .dashboard { flex-direction: column; }
  .sidebar { width: 100%; height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .map-container { flex: 1; }
}

/* ═══════════════════════════════════════════════════════════════════
   Light sage dashboard — db- prefix
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --db-bg:      #F2F7EE;
  --db-surface: #FFFFFF;
  --db-card:    rgba(0,0,0,0.03);
  --db-border:  rgba(0,0,0,0.08);
  --db-dark:    #141A13;
  --db-green:   #3DD68C;
  --db-green-dk:#28B874;
  --db-text:    #1A2018;
  --db-muted:   #617060;
  --db-red:     #E53935;
  --db-sidebar: 360px;
}

body.dashboard-page {
  background: var(--db-bg);
  height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--db-text);
}

/* ── Auth screen ──────────────────────────────────────────────── */
.db-auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--db-bg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.db-auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
}
.db-ag-1 {
  width: 500px; height: 500px;
  background: rgba(61,214,140,0.15);
  top: -120px; left: -100px;
}
.db-ag-2 {
  width: 400px; height: 400px;
  background: rgba(137,194,122,0.10);
  bottom: -80px; right: -80px;
}

.db-auth-card {
  position: relative; z-index: 1;
  background: var(--db-surface);
  border: 1px solid var(--db-border);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%; max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10);
}

.db-auth-logo-row {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; margin-bottom: 28px;
}
.db-auth-brand {
  font-size: 20px; font-weight: 700;
  color: var(--db-text); letter-spacing: -0.5px;
}

.db-logo-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.db-logo-mark-sm {
  width: 28px; height: 28px;
  border-radius: 7px;
}

.db-logo-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.db-auth-title {
  font-size: 24px; font-weight: 700;
  color: var(--db-text); margin-bottom: 8px;
  letter-spacing: -0.4px;
}
.db-auth-sub {
  font-size: 14px; color: var(--db-muted);
  line-height: 1.5; margin-bottom: 28px;
}

.db-google-btn {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--db-bg);
  border: 1px solid var(--db-border);
  color: var(--db-text);
  font-size: 15px; font-weight: 500;
  padding: 13px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.db-google-btn:hover {
  background: #EAF1E5;
  border-color: rgba(0,0,0,0.15);
}
.db-google-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.db-terms-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--db-border);
  border-radius: 10px;
  background: rgba(255,255,255,0.62);
  font-size: 12px;
  line-height: 1.45;
  color: var(--db-muted);
}
.db-terms-check input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--db-green-dk);
  flex: 0 0 auto;
}
.db-terms-check a {
  font-weight: 700;
  color: var(--db-green-dk);
}

.db-auth-note {
  font-size: 12px; color: var(--db-muted);
  margin-top: 14px; line-height: 1.5;
}
.db-error {
  color: var(--db-red); font-size: 13px; margin-top: 12px;
  padding: 10px 14px; border-radius: 8px;
  background: rgba(240,82,82,0.1); border: 1px solid rgba(240,82,82,0.2);
}

/* ── Dashboard shell ──────────────────────────────────────────── */
.db-shell {
  display: flex;
  height: 100vh;
  position: relative;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.db-sidebar {
  width: var(--db-sidebar);
  flex-shrink: 0;
  background: var(--db-surface);
  border-right: 1px solid var(--db-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.22s ease;
}

.db-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px;
  border-bottom: 1px solid var(--db-border);
}

.db-nav-logo {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--db-text);
  font-size: 16px; font-weight: 700; letter-spacing: -0.3px;
}
.db-nav-logo:hover { text-decoration: none; }

.db-icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--db-border);
  color: var(--db-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.db-icon-btn:hover {
  background: var(--db-bg);
  color: var(--db-text);
}

.db-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.db-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--db-muted);
  padding: 14px 16px 6px;
}
.db-section-label-inline { padding: 0; }

.db-greeting {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--db-border);
}

.db-greeting-text {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 650;
  color: var(--db-text);
}

.db-greeting-name {
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 750;
  color: var(--db-green-dk);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-greeting p {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--db-muted);
}

.db-overview {
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--db-border);
}

.db-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.db-stat {
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  background: var(--db-card);
}

.db-stat span {
  display: block;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  color: var(--db-text);
  margin-bottom: 6px;
}

.db-stat small {
  font-size: 11px;
  color: var(--db-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.db-pair-card {
  padding: 12px 16px;
  border-bottom: 1px solid var(--db-border);
}

.db-pair-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.db-pair-header p {
  font-size: 12px;
  color: var(--db-muted);
  line-height: 1.4;
  margin-top: 4px;
}

.db-pair-toggle-open {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
}

.db-pair-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.db-pair-form label {
  display: grid;
  gap: 5px;
}

.db-pair-form label span {
  font-size: 11px;
  font-weight: 600;
  color: var(--db-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.db-pair-form input,
.db-pair-form select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  background: var(--db-surface);
  color: var(--db-text);
  font: inherit;
  font-size: 14px;
}

.db-pair-form input:focus,
.db-pair-form select:focus {
  outline: 2px solid rgba(61,214,140,0.28);
  border-color: rgba(61,214,140,0.55);
}

.db-primary-btn {
  min-height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--db-green-dk);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.db-primary-btn:hover { background: #219d63; }
.db-primary-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.db-pair-message {
  font-size: 12px;
  line-height: 1.4;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--db-muted);
  background: var(--db-card);
  border: 1px solid var(--db-border);
}

.db-pair-message.success {
  color: var(--db-green-dk);
  background: rgba(61,214,140,0.10);
  border-color: rgba(61,214,140,0.28);
}

.db-pair-message.error {
  color: var(--db-red);
  background: rgba(229,57,53,0.08);
  border-color: rgba(229,57,53,0.22);
}

.db-secondary-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  background: var(--db-surface);
  color: var(--db-text);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.db-secondary-btn:hover {
  background: var(--db-bg);
}

.db-tracker-list {
  flex: 1; overflow-y: auto; padding: 8px;
}

.db-sidebar-footer {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--db-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.db-tracker-list::-webkit-scrollbar { width: 4px; }
.db-tracker-list::-webkit-scrollbar-track { background: transparent; }
.db-tracker-list::-webkit-scrollbar-thumb { background: var(--db-border); border-radius: 2px; }

/* Tracker row */
.db-tracker-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid transparent;
}
.db-tracker-row:hover { background: rgba(61,214,140,0.06); }
.db-tracker-row.active {
  background: rgba(61,214,140,0.12);
  border-color: rgba(61,214,140,0.25);
}

.db-tracker-emoji {
  position: relative;
  font-size: 20px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--db-card);
  border: 1px solid var(--db-border);
  border-radius: 8px; flex-shrink: 0;
}
.db-tracker-device:empty { display: none; }
.db-tracker-device {
  position: absolute;
  right: -5px; bottom: -5px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--db-card);
  border: 1px solid var(--db-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1;
}

.db-tracker-info { flex: 1; min-width: 0; }
.db-tracker-name {
  font-size: 14px; font-weight: 600;
  color: var(--db-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.db-tracker-code {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--db-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-tracker-status {
  font-size: 12px; color: var(--db-muted);
  display: flex; align-items: center; gap: 5px;
  margin-top: 2px;
}
.db-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--db-muted); flex-shrink: 0;
}
.db-status-dot.live { background: var(--db-green); box-shadow: 0 0 0 2px rgba(52,208,88,0.2); }
.db-status-dot.stale { background: var(--db-red); }

.db-tracker-unpair {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--db-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s, color 0.1s, border-color 0.1s;
}
.db-tracker-row:hover .db-tracker-unpair,
.db-tracker-row.active .db-tracker-unpair { opacity: 1; }
.db-tracker-unpair:hover {
  background: rgba(224,74,74,0.12);
  border-color: rgba(224,74,74,0.3);
  color: var(--db-red);
}

/* Empty state */
.db-empty {
  text-align: center; padding: 40px 20px;
  color: var(--db-muted);
}
.db-empty-ico {
  display: inline-block; margin-bottom: 12px;
  padding: 16px; background: var(--db-card);
  border: 1px solid var(--db-border); border-radius: 14px;
}
.db-empty p { font-size: 14px; font-weight: 600; color: var(--db-text); margin-bottom: 6px; }
.db-empty span { font-size: 12px; line-height: 1.5; }

/* ── Map ──────────────────────────────────────────────────────── */
.db-map {
  flex: 1;
  min-width: 0;
}

.db-map-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-map-action-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--db-border);
  border-radius: 10px;
  background: rgba(255,255,255,0.96);
  color: var(--db-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(15,23,42,0.14);
  backdrop-filter: blur(10px);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

.db-map-action-btn:hover,
.db-map-action-btn.active {
  background: var(--db-green);
  border-color: var(--db-green);
  color: white;
}

.db-map-action-btn:active {
  transform: translateY(1px);
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
}

.leaflet-control-zoom a {
  width: 44px !important;
  height: 44px !important;
  line-height: 44px !important;
  font-size: 20px;
}

.leaflet-control-zoom-in {
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}

.leaflet-control-zoom-out {
  border-bottom-left-radius: 10px !important;
  border-bottom-right-radius: 10px !important;
}

.db-map-message {
  position: absolute;
  left: calc(var(--db-sidebar) + 18px);
  bottom: 18px;
  z-index: 1000;
  max-width: min(360px, calc(100vw - var(--db-sidebar) - 36px));
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15,23,42,0.9);
  color: white;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(15,23,42,0.22);
}

.db-map-message.error {
  background: rgba(185,28,28,0.94);
}

/* ── Settings / diagnostics drawer ────────────────────────────── */
.db-drawer {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1100;
  width: min(420px, calc(100vw - 24px));
  height: 100%;
  overflow-y: auto;
  background: var(--db-surface);
  border-left: 1px solid var(--db-border);
  box-shadow: -10px 0 30px rgba(0,0,0,0.14);
}

.db-drawer-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  background: rgba(255,255,255,0.94);
  border-bottom: 1px solid var(--db-border);
  backdrop-filter: blur(12px);
}

.db-drawer-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--db-muted);
  margin-bottom: 4px;
}

.db-drawer-header h2 {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.4px;
}

.db-diagnostics-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 18px 8px;
}

#diagnostics-status {
  margin: 8px 18px 0;
}

.db-diagnostics-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--db-border);
}

.db-diagnostics-section h3 {
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--db-text);
}

.db-diagnostics-list {
  display: grid;
  grid-template-columns: minmax(112px, 42%) minmax(0, 1fr);
  gap: 8px 12px;
  font-size: 12px;
}

.db-diagnostics-list dt {
  color: var(--db-muted);
}

.db-diagnostics-list dd {
  color: var(--db-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  text-align: right;
}

.db-diagnostics-events {
  display: grid;
  gap: 8px;
}

.db-diagnostics-empty {
  font-size: 12px;
  color: var(--db-muted);
}

/* ── Beta signups (owner-only) ─────────────────────────────────── */
.db-beta-count { color: var(--db-muted); font-weight: 500; font-size: 13px; }
.db-beta-list { display: grid; gap: 10px; margin-top: 10px; }
.db-beta-item {
  padding: 12px;
  border: 1px solid var(--db-border);
  border-radius: 10px;
  background: var(--db-card);
}
.db-beta-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 6px;
}
.db-beta-name { font-size: 14px; font-weight: 600; color: var(--db-text); }
.db-beta-email { font-size: 13px; color: var(--db-green); text-decoration: none; word-break: break-all; }
.db-beta-email:hover { text-decoration: underline; }
.db-beta-field {
  font-size: 13px; color: var(--db-text); line-height: 1.5;
  margin-top: 6px; white-space: pre-wrap; word-break: break-word;
}
.db-beta-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--db-muted); margin-bottom: 2px;
}
.db-beta-when { font-size: 11px; color: var(--db-muted); margin-top: 8px; }

.db-diagnostics-event {
  padding: 10px;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  background: var(--db-card);
}

.db-diagnostics-event > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.db-diagnostics-event strong {
  font-size: 11px;
  color: var(--db-green-dk);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.db-diagnostics-event span,
.db-diagnostics-event time {
  font-size: 12px;
  color: var(--db-text);
}

.db-diagnostics-event time {
  display: block;
  color: var(--db-muted);
}

.db-diagnostics-event code {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--db-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Light Leaflet popup */
.leaflet-popup-content-wrapper {
  background: var(--db-surface) !important;
  border: 1px solid var(--db-border) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12) !important;
  color: var(--db-text) !important;
}
.leaflet-popup-tip { background: var(--db-surface) !important; }
.leaflet-popup-content { margin: 12px 14px !important; font-size: 13px; line-height: 1.6; }
.leaflet-popup-content strong { color: var(--db-text); font-weight: 600; }
.leaflet-popup-content .pop-meta { color: var(--db-muted); margin-top: 4px; }
.leaflet-popup-content .pop-live { color: var(--db-green-dk); font-weight: 500; }
.leaflet-popup-content .pop-stale { color: var(--db-red); }
.leaflet-popup-close-button { color: var(--db-muted) !important; }

/* Map marker pin */
.db-map-pin {
  display: flex; flex-direction: column; align-items: center;
}
.db-pin-circle {
  position: relative;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--db-green);
  border: 3px solid white;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 12px rgba(61,214,140,0.45);
}
.db-pin-badge {
  position: absolute;
  right: -6px; bottom: -4px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: white;
  border: 1.5px solid var(--db-green);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.db-pin-circle.stale .db-pin-badge { border-color: #999; }
.db-pin-circle.stale {
  background: #999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.db-pin-tail {
  width: 2px; height: 8px;
  background: white;
  border-radius: 0 0 2px 2px;
}

/* ── History panel ────────────────────────────────────────────── */
.db-history-panel,
.db-alerts-panel {
  position: absolute;
  top: 16px;
  right: 74px;
  z-index: 1000;
  width: min(380px, calc(100vw - var(--db-sidebar) - 106px));
  max-height: min(72vh, 560px);
  border: 1px solid var(--db-border);
  border-radius: 12px;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 16px 40px rgba(15,23,42,0.18);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.db-history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--db-border);
  flex-shrink: 0;
}

.db-history-close {
  background: none; border: none; cursor: pointer;
  color: var(--db-muted); font-size: 13px; padding: 2px 6px;
  border-radius: 4px; line-height: 1;
}
.db-history-close:hover { background: var(--db-card); color: var(--db-text); }

.db-history-list {
  overflow-y: auto; flex: 1; padding: 6px 8px;
}
.db-history-list::-webkit-scrollbar { width: 3px; }
.db-history-list::-webkit-scrollbar-thumb { background: var(--db-border); border-radius: 2px; }

.db-history-loading,
.db-history-empty {
  font-size: 12px; color: var(--db-muted);
  text-align: center; padding: 20px;
}

.db-history-row {
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  transition: background 0.1s; margin-bottom: 2px;
}
.db-history-row:hover { background: rgba(99,102,241,0.07); }

.db-history-date {
  font-size: 13px; font-weight: 600; color: var(--db-text);
  margin-bottom: 3px;
}

.db-history-meta {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--db-muted); flex-wrap: wrap;
}

.db-history-sep { opacity: 0.4; }

.db-history-preview {
  width: 100%;
  height: 94px;
  margin-top: 8px;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--db-card);
}

.db-history-preview .leaflet-control-container {
  display: none;
}

.db-history-preview-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--db-muted);
  font-size: 11px;
  font-weight: 600;
}

.db-alerts-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.db-alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.db-alert-row:hover {
  background: rgba(37,99,235,0.08);
}

.db-alert-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(37,99,235,0.1);
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.db-alert-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.db-alert-copy strong {
  font-size: 13px;
  color: var(--db-text);
  overflow-wrap: anywhere;
}

.db-alert-copy span {
  font-size: 11px;
  color: var(--db-muted);
}

.db-history-platform {
  font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 10px; margin-left: 4px;
}
.db-history-platform.ios {
  background: rgba(59,130,246,0.1); color: #3b82f6;
}
.db-history-platform.watch {
  background: rgba(61,214,140,0.12); color: var(--db-green-dk);
}

/* History viewing banner (overlaid on map) */
.db-history-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000;
  display: flex; align-items: center; gap: 8px;
  background: rgba(99,102,241,0.92);
  color: white; font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: 20px;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.db-history-banner button {
  background: none; border: none; color: rgba(255,255,255,0.7);
  cursor: pointer; font-size: 14px; padding: 0 0 0 4px; line-height: 1;
}
.db-history-banner button:hover { color: white; }

/* ── Sidebar collapse ─────────────────────────────────────────── */
#sidebar-collapse-btn svg {
  transition: transform 0.22s ease;
}

.db-shell.sidebar-collapsed #sidebar-collapse-btn svg {
  transform: scaleX(-1);
}

.db-shell.sidebar-collapsed .db-sidebar {
  width: 60px;
  overflow: hidden;
}

.db-shell.sidebar-collapsed .db-greeting,
.db-shell.sidebar-collapsed .db-overview,
.db-shell.sidebar-collapsed .db-pair-card,
.db-shell.sidebar-collapsed .db-section-label,
.db-shell.sidebar-collapsed .db-tracker-info,
.db-shell.sidebar-collapsed .db-tracker-unpair {
  display: none;
}

.db-shell.sidebar-collapsed .db-nav-logo span {
  display: none;
}

.db-shell.sidebar-collapsed .db-nav-logo {
  padding: 0;
}

.db-shell.sidebar-collapsed .db-sidebar-header {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
}

.db-shell.sidebar-collapsed .db-header-actions {
  flex-direction: column;
  gap: 4px;
}

.db-shell.sidebar-collapsed .db-sidebar-footer {
  justify-content: center;
  padding: 10px 0;
}

.db-shell.sidebar-collapsed .db-tracker-row {
  justify-content: center;
  padding: 10px 0;
  cursor: pointer;
}

.db-shell.sidebar-collapsed .db-tracker-emoji {
  font-size: 20px;
}

.db-shell.sidebar-collapsed .db-tracker-list {
  padding: 6px 0;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .db-shell { flex-direction: column; }
  .db-sidebar { width: 100%; height: 48vh; border-right: none; border-bottom: 1px solid var(--db-border); }
  .db-overview { display: none; }
  .db-drawer {
    width: 100%;
    height: 100%;
  }
  .db-map { flex: 1; }
  .db-map-actions {
    top: calc(48vh + 12px);
    bottom: auto;
    right: 12px;
  }
  .db-map-action-btn {
    width: 40px;
    height: 40px;
  }
  .leaflet-control-zoom a {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
  }
  .db-history-panel,
  .db-alerts-panel {
    top: calc(48vh + 12px);
    left: 12px;
    right: 64px;
    width: auto;
    max-height: calc(52vh - 24px);
  }
  .db-map-message {
    left: 12px;
    right: 64px;
    bottom: 12px;
    max-width: none;
  }
  .db-auth-card { padding: 32px 24px; }
}
