/* app.css — starter styles (expanded with the map UI in Task 7). */
:root { --brand: #c8102e; --brand-2: #1f2d3d; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #1f2d3d;
  background: #f7f7f8;
}

/* ---- auth page ---- */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: #fff7f2; }
.login-card {
  width: min(92vw, 400px);
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 6px 24px rgba(0,0,0,.06);
  text-align: center;
}
.login-logo { max-width: 120px; max-height: 80px; margin-bottom: 10px; }
.login-card h1 { color: var(--brand); font-size: 1.4rem; margin: 6px 0 2px; }
.subtext { color: #666; font-size: .9rem; margin: 0 0 16px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input, .login-card button { padding: 13px 14px; border-radius: 8px; font-size: 1rem; }
.login-card input { border: 1px solid #ccc; }
.login-card button { border: 0; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
.login-card button:active { transform: translateY(1px); }
.error { color: #b00020; background: #fde7ea; border-radius: 8px; padding: 9px 12px; font-size: .9rem; margin: 0 0 12px; }
.note { color: #999; font-size: .75rem; margin: 14px 0 0; line-height: 1.4; }

/* ---- top bar (authed pages) ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--brand); color: #fff;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
.topbar .brand img { max-height: 28px; }
.topnav a { color: #fff; text-decoration: none; margin-left: 16px; font-size: .95rem; opacity: .92; }
.topnav a:hover { opacity: 1; text-decoration: underline; }

/* ---- map shell ---- */
.map-shell { position: relative; height: calc(100vh - 49px); width: 100%; }
#map { position: absolute; inset: 0; }

.map-controls {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 5;
  display: flex; gap: 8px; align-items: center; pointer-events: none;
}
.map-controls > * { pointer-events: auto; }
#round-select {
  padding: 9px 12px; border-radius: 8px; border: 1px solid #ccc; background: #fff;
  font-size: .95rem; box-shadow: 0 1px 4px rgba(0,0,0,.15); max-width: 60%;
}
.chip {
  padding: 9px 12px; border-radius: 999px; border: 1px solid #ccc; background: #fff;
  font-size: .9rem; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.15); white-space: nowrap;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.quick-links {
  position: absolute; top: 56px; left: 10px; right: 10px; z-index: 5;
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; pointer-events: none;
}
.quick-links .chip { pointer-events: auto; }

/* flyer basket pill */
.basket-pill {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: 18px; z-index: 6; background: var(--brand-2, #1f2d3d); color: #fff;
  padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: .95rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; white-space: nowrap;
}
.basket-pill.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* bottom sheet */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 7;
  background: #fff; border-radius: 16px 16px 0 0; padding: 18px 18px 26px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.18); transform: translateY(110%);
  transition: transform .22s ease; max-width: 520px; margin: 0 auto;
}
.sheet.open { transform: translateY(0); }
.sheet-close {
  position: absolute; top: 10px; right: 12px; border: 0; background: none;
  font-size: 1.6rem; line-height: 1; color: #888; cursor: pointer;
}
.sheet h2 { margin: 2px 0 4px; font-size: 1.15rem; }
.sheet-dwellings { margin: 0 0 10px; color: #666; font-size: .95rem; }
.sheet-status {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .8rem;
  font-weight: 600; background: #eee; color: #444;
}
.sheet-status.s-pending { background: #fbe6cc; color: #8a5212; }
.sheet-status.s-pending.mine { background: #e8870c; color: #fff; }
.sheet-status.s-completed { background: #cde9d6; color: #1c5e34; }
.sheet-status.s-completed.mine { background: #1f7a3d; color: #fff; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1; padding: 14px; border-radius: 10px; border: 0; font-size: 1rem;
  font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: #f0f0f2; color: #333; }
.btn:active { transform: translateY(1px); }

/* multi-select action bar */
.sel-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 8;
  background: #fff; border-top: 1px solid #e6e6e6;
  padding: 12px 14px 20px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 -2px 12px rgba(0,0,0,.12);
  max-width: 520px; margin: 0 auto;
}
.sel-bar[hidden] { display: none; }
#sel-count { flex: 1; font-size: .9rem; color: #555; }
.sel-actions { display: flex; gap: 8px; }
.sel-btn { flex: none; padding: 10px 14px; font-size: .88rem; border-radius: 8px; white-space: nowrap; }
.map-shell.select-mode .basket-pill { bottom: 78px; }

/* toast */
.toast {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 80px; z-index: 9;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: .9rem;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 88%; text-align: center;
}
.toast.show { opacity: .96; }

/* admin tables */
.admin-wrap { max-width: 920px; margin: 0 auto; padding: 18px; }
.admin-wrap h1 { font-size: 1.3rem; }
.cards { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0; }
.card { background: #fff; border: 1px solid #e6e6e6; border-radius: 10px; padding: 14px 18px; min-width: 130px; }
.card .n { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.card .l { font-size: .8rem; color: #666; }
table.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eee; font-size: .92rem; }
table.grid th { background: #f4f4f6; }
.lb-cols { display: flex; gap: 18px; flex-wrap: wrap; }
.lb-cols > div { flex: 1; min-width: 240px; }
.btn-sm { padding: 7px 12px; border-radius: 7px; border: 0; background: var(--brand); color: #fff; cursor: pointer; font-size: .85rem; }
.btn-sm.ghost { background: #eee; color: #333; }
form.inline { display: inline; }
.flash { background: #e7f6ec; color: #1c5e34; padding: 9px 12px; border-radius: 8px; margin: 10px 0; font-size: .9rem; }
.muted { color: #888; font-size: .85rem; }


/* ================= improvements: progress, notes, leaderboard, settings ================= */

/* round progress (collective) */
.progress-banner {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 5;
  display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 999px;
  padding: 7px 14px; box-shadow: 0 2px 10px rgba(0,0,0,.18); font-size: .82rem; color: #333;
  max-width: calc(100% - 24px); white-space: nowrap;
}
.progress-banner[hidden] { display: none; }
.progress-track { display: inline-block; width: 90px; height: 7px; border-radius: 999px; background: #e6e6e9; overflow: hidden; flex: none; }
.progress-fill { display: block; height: 100%; width: 0%; background: #1f7a3d; border-radius: 999px; transition: width .35s ease; }
.progress-text { font-weight: 600; }
.basket-pill { bottom: 60px; }                       /* sit above the progress pill */
.map-shell.select-mode .progress-banner { display: none; }

/* block delivery notes (in sheet) */
.sheet-note { margin: 4px 0 0; }
.note-input {
  width: 100%; box-sizing: border-box; border: 1px solid #d5d5da; border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: .9rem; resize: vertical; min-height: 42px;
}
.note-save { margin-top: 6px; }
.note-read {
  margin: 4px 0 0; background: #fff8e1; border: 1px solid #f2e2b3; border-radius: 8px;
  padding: 8px 10px; font-size: .88rem; color: #6b5300; white-space: pre-wrap;
}

/* leaderboard modal */
.modal {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end;
  justify-content: center; background: rgba(0,0,0,.4);
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff; width: 100%; max-width: 480px; border-radius: 16px 16px 0 0;
  padding: 18px 18px 26px; box-shadow: 0 -4px 24px rgba(0,0,0,.25);
  max-height: 80%; overflow-y: auto; position: relative;
}
@media (min-width: 560px) { .modal { align-items: center; } .modal-card { border-radius: 16px; } }
.modal-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 1.6rem; line-height: 1; color: #888; cursor: pointer; }
.modal-title { margin: 2px 0 12px; font-size: 1.2rem; }
.lb-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.lb-tab { flex: 1; padding: 9px; border: 1px solid #ddd; background: #f6f6f8; border-radius: 8px; font-size: .9rem; font-weight: 600; cursor: pointer; color: #555; }
.lb-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-bottom: 1px solid #f0f0f2; }
.lb-row.me { background: #fff5e9; border-radius: 8px; }
.lb-rank { width: 34px; text-align: center; font-size: 1.05rem; }
.lb-name { flex: 1; font-size: .95rem; }
.lb-name em { color: var(--brand); font-style: normal; font-weight: 600; font-size: .8rem; }
.lb-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-empty { color: #888; padding: 16px 8px; text-align: center; font-size: .9rem; }

/* admin branding form */
.settings-form { max-width: 480px; display: flex; flex-direction: column; gap: 16px; background: #fff; border: 1px solid #e6e6e6; border-radius: 10px; padding: 18px; }
.settings-form > label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; color: #333; }
.settings-form input[type=text], .settings-form input[type=number] { padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font: inherit; }
.settings-form input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid #ccc; border-radius: 8px; background: #fff; cursor: pointer; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > label { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; }
.field-set { border: 1px solid #e6e6e6; border-radius: 8px; padding: 12px 14px; margin: 0; }
.field-set legend { font-size: .82rem; color: #666; padding: 0 6px; }
.current-logo { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.current-logo img { max-height: 42px; max-width: 120px; border: 1px solid #eee; border-radius: 6px; padding: 4px; background: #fafafa; }

/* ================= canvassing (per-address notes) ================= */
.canvass-wrap { max-width: 920px; margin: 0 auto; padding: 18px; }
.canvass-wrap h1 { font-size: 1.3rem; }
.canvass-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.canvass-controls select { padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font: inherit; background: #fff; }
#cv-street { flex: 1; min-width: 180px; }
.cv-legend { display: flex; gap: 14px; font-size: .8rem; color: #666; margin: 8px 0 14px; flex-wrap: wrap; }
.cv-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; border: 1px solid #ccc; }
.cv-swatch.plain { background: #fff; }
.cv-swatch.noted { background: #1f7a3d; border-color: #1f7a3d; }
.cv-swatch.followup { background: #e8870c; border-color: #e8870c; }
.cv-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cv-box { min-width: 52px; padding: 10px 8px; border: 1px solid #ccc; border-radius: 8px; background: #fff; font-size: .9rem; font-weight: 600; cursor: pointer; text-align: center; color: #333; }
.cv-box.noted { background: #1f7a3d; color: #fff; border-color: #1f7a3d; }
.cv-box.followup { background: #e8870c; color: #fff; border-color: #e8870c; }   /* follow-up wins over noted */
.cv-box:active { transform: translateY(1px); }
.cv-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.cv-form > label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: #333; }
.cv-form textarea, .cv-form input[type=text], .cv-form input[type=email] { padding: 9px 11px; border: 1px solid #ccc; border-radius: 8px; font: inherit; font-size: .92rem; }
.cv-form textarea { resize: vertical; }
.cv-check { flex-direction: row !important; align-items: center; gap: 8px !important; }
.cv-check input { width: auto; }

/* searchable street combobox (canvass) */
.cv-combo { position: relative; flex: 1; min-width: 200px; }
#cv-street-search { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font: inherit; }
.cv-street-list {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid #ddd;
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.14); max-height: 320px; overflow-y: auto;
}
.cv-street-list[hidden] { display: none; }
.cv-street-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: .92rem; }
.cv-street-item:hover { background: #f2f4f7; }
.cv-street-count { color: #888; font-size: .8rem; font-variant-numeric: tabular-nums; }

/* jump-to-area modal */
#area-level, #area-search { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font: inherit; margin-bottom: 8px; background: #fff; }
.area-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.area-list .cv-street-item { border-bottom: 1px solid #f0f0f2; border-radius: 0; }

/* admin operating-area */
.op-current { background: #eef4ff; border: 1px solid #cddcff; border-radius: 8px; padding: 12px 14px; font-size: .92rem; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* admin: live activity feed */
.activity { list-style: none; margin: 4px 0 0; padding: 0; }
.activity li { padding: 8px 10px; border-bottom: 1px solid #f0f0f2; font-size: .9rem; }
.activity code { background: #f2f2f4; padding: 1px 5px; border-radius: 4px; font-size: .85em; }
.act-ico { margin-right: 2px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #1f7a3d; vertical-align: middle; animation: livepulse 2s infinite; }
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* mobile: keep all map controls on one row (they were overflowing off-screen) */
@media (max-width: 480px) {
  .map-controls { gap: 6px; }
  #round-select { max-width: 118px; padding: 9px 8px; font-size: .9rem; }
  .map-controls .chip { padding: 9px 11px; }
  .topnav a { margin-left: 12px; }
}

/* data overlay control (bottom-left) */
.overlay-ctrl { position: absolute; left: 10px; bottom: 16px; z-index: 5; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.overlay-btn { padding: 8px 12px; border-radius: 999px; border: 1px solid #ccc; background: #fff; font-size: .82rem; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); white-space: nowrap; }
.overlay-legend { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 8px; padding: 5px 8px; font-size: .72rem; color: #444; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.overlay-legend[hidden] { display: none; }
.legend-bar { display: inline-block; width: 70px; height: 8px; border-radius: 4px; background: linear-gradient(90deg,#eef7ff,#c6dbef,#6baed6,#3182bd,#08519c); }
.map-shell.select-mode .overlay-ctrl { display: none; }

/* "I'm here" one-tap claim button */
.fab-here { position: absolute; right: 10px; bottom: 150px; z-index: 6; padding: 11px 15px; border-radius: 999px; border: 0; background: var(--brand); color: #fff; font-weight: 600; font-size: .9rem; box-shadow: 0 3px 12px rgba(0,0,0,.3); cursor: pointer; white-space: nowrap; }
.fab-here:active { transform: translateY(1px); }
.map-shell.select-mode .fab-here { display: none; }
