/* ============================================================================
   Member Map (share) - standalone styles
   Clean, modern, lightweight. Hand-written (no framework). ASCII only.
   Accent: MIAMI blue (#167bff). Map fills uses a ColorBrewer Blues ramp (in JS).
   ========================================================================== */

:root {
    --accent: #167bff;
    --accent-600: #0f63cc;
    --ink: #0f172a;
    --ink-soft: #475569;
    --ink-faint: #94a3b8;
    --line: #e5e8ee;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ---- App shell (full viewport) ---- */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand .dot { color: var(--accent); }
.badge {
    font-size: 12px; color: var(--ink-soft);
    background: #eef2f8; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.spacer { flex: 1 1 auto; }

/* Segmented toggle */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg button {
    appearance: none; border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: 13px; color: var(--ink-soft);
    padding: 6px 12px; border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: #f5f8fc; }
.seg button.active { background: var(--accent); color: #fff; }

/* Field (label + select) */
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-faint); }
.field select {
    appearance: none; font: inherit; font-size: 13px; color: var(--ink);
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 6px 26px 6px 10px; cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat; background-position: right 8px center;
}

/* Buttons */
.btn {
    appearance: none; font: inherit; font-size: 13px; cursor: pointer;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    border-radius: var(--radius); padding: 6px 12px; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: #f5f8fc; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: #f1f5f9; }
.link { color: var(--ink-faint); font-size: 12px; text-decoration: none; }
.link:hover { color: var(--accent); text-decoration: underline; }

.spin {
    width: 14px; height: 14px; border: 2px solid #cbd5e1; border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Stage: map + ranked panel ---- */
.stage { flex: 1 1 auto; display: flex; min-height: 0; }
#map { flex: 1 1 auto; min-width: 0; background: var(--bg); }

.rank {
    width: 280px; flex: 0 0 280px; background: var(--panel);
    border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
.rank-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.rank-title { font-weight: 600; font-size: 14px; }
.rank-sub { color: var(--ink-faint); font-size: 12px; margin-top: 2px; }
.rank-list { flex: 1 1 auto; overflow-y: auto; padding: 4px 0; }
.rank-row {
    display: flex; align-items: baseline; gap: 8px; padding: 4px 14px; cursor: pointer; font-size: 13px;
}
.rank-row:hover { background: #f1f5f9; }
.rank-num { width: 22px; text-align: right; color: var(--ink-faint); font-size: 12px; }
.rank-name { flex: 1 1 auto; }
.rank-cnt { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-sw { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.12); }

.foot { padding: 6px 16px; font-size: 11px; color: var(--ink-faint); background: var(--panel); border-top: 1px solid var(--line); }

/* ---- Leaflet overlays ---- */
.leaflet-container { font-family: var(--font); background: var(--bg); }
.zm-info, .zm-legend {
    background: rgba(255,255,255,0.94); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 8px 10px; font-size: 12px; line-height: 1.4; box-shadow: var(--shadow);
}
.zm-info h4 { margin: 0 0 4px; font-weight: 600; font-size: 12px; }
.zm-info .bd { color: var(--ink-soft); }
.zm-legend i { display: inline-block; width: 14px; height: 14px; margin-right: 6px; opacity: 0.9; vertical-align: -2px; }
.zm-legend .row { white-space: nowrap; }

.zm-label {
    background: none; border: 0; box-shadow: none; padding: 0; color: #fff;
    font-size: 10px; font-weight: 600; white-space: nowrap;
    text-shadow: 0 0 2px #000, 0 0 2px #000, 0 0 2px #000; pointer-events: none;
}
.zm-label::before { display: none !important; }
.zm-ziplabel {
    background: none; border: 0; box-shadow: none; padding: 0; color: #0f172a;
    font-size: 10px; font-weight: 600; white-space: nowrap;
    text-shadow: -1px -1px 0 #fff, 0 -1px 0 #fff, 1px -1px 0 #fff, -1px 0 0 #fff, 1px 0 0 #fff, -1px 1px 0 #fff, 0 1px 0 #fff, 1px 1px 0 #fff;
    pointer-events: none;
}
.zm-ziplabel::before { display: none !important; }

/* ---- Settings modal ---- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
    display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-card {
    background: #fff; border-radius: 12px; box-shadow: var(--shadow);
    width: 100%; max-width: 760px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-body p { margin: 0 0 10px; color: var(--ink-soft); font-size: 13px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.modal-msg { flex: 1 1 auto; font-size: 13px; }
.modal-msg.ok { color: #15803d; }
.modal-msg.err { color: #b91c1c; }
textarea.query {
    width: 100%; min-height: 320px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; line-height: 1.5; color: var(--ink); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 12px; background: #fbfcfe;
}

/* ---- Login page ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card {
    background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
    width: 100%; max-width: 360px; padding: 28px; text-align: center;
}
.login-brand { font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.login-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 18px; }
.login-input {
    width: 100%; font: inherit; font-size: 14px; padding: 10px 12px; margin-bottom: 12px;
    border: 1px solid var(--line); border-radius: var(--radius); background: #fbfcfe;
}
.login-input:focus { outline: 2px solid rgba(22, 123, 255, 0.35); border-color: var(--accent); }
.login-btn {
    width: 100%; font: inherit; font-size: 14px; font-weight: 600; padding: 10px 12px; cursor: pointer;
    border: 0; border-radius: var(--radius); background: var(--accent); color: #fff;
}
.login-btn:hover { background: var(--accent-600); }
.login-error {
    background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: var(--radius);
    padding: 10px 12px; font-size: 13px; margin-bottom: 12px; text-align: left;
}
.login-error code { background: #fff; padding: 1px 5px; border-radius: 4px; }

/* Responsive: stack the ranked panel under the map on narrow screens */
@media (max-width: 760px) {
    .stage { flex-direction: column; }
    .rank { width: auto; flex: 0 0 40vh; border-left: 0; border-top: 1px solid var(--line); }
}
