* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
#map { position: absolute; inset: 52px 0 0 0; background: #eef3ee; }

/* Top bar */
.bar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 1000;
  background: #16241c; color: #fff; display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
}
.bar__title { font-weight: 800; font-size: 1rem; white-space: nowrap; }
.bar__stats { flex: 1; font-size: .82rem; color: #bfe0cc; text-align: right; }
.bar__btn { background: #24382b; border: 0; color: #fff; font-size: 1rem; width: 36px; height: 36px; border-radius: 10px; }
.bar__btn--sched { width: auto; padding: 0 12px; font-size: .9rem; font-weight: 700; background: #2e9e4f; white-space: nowrap; }

/* Legend */
.legend {
  position: fixed; top: 60px; right: 10px; z-index: 1001; width: 240px;
  background: #fff; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25); padding: 14px 16px;
  font-size: .86rem;
}
.legend__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.legend__head button { border: 0; background: none; font-size: 1rem; }
.legend__sub { margin: 10px 0 4px; font-weight: 700; color: #5d6f64; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.legend__row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.sw { width: 16px; height: 16px; border-radius: 4px; flex: 0 0 16px; }
.legend__sync { margin-top: 10px; font-size: .76rem; color: #8a978d; }

/* Bottom sheet */
/* Mobile: full-screen detail (below the top bar) so the route panel can't bleed in */
.sheet {
  position: fixed; left: 0; right: 0; top: 52px; bottom: 0; z-index: 1003;
  background: #fff; box-shadow: 0 -6px 30px rgba(0,0,0,.18);
  padding: 4px 18px 28px; animation: rise .18s ease;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__top { position: sticky; top: 0; z-index: 5; background: #fff; margin: 0 -18px; padding: 2px 18px 4px; }
.sheet__grip { width: 42px; height: 5px; background: #d6ddd8; border-radius: 3px; margin: 6px auto 8px; }
.sheet__x {
  position: absolute; top: 4px; right: 12px;
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: #eef3ee; color: #2b3b32; font-size: 1.1rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.sheet__x:active { background: #dde7e0; }
.sheet__addr { font-weight: 800; font-size: 1.15rem; color: #16241c; }
.sheet__meta { color: #5d6f64; font-size: .9rem; margin-top: 2px; }
.sheet__price { color: #1f7a3c; font-weight: 800; font-size: 1.02rem; margin: 6px 0 10px; }
.sheet__statuses { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.sheet__statuses button {
  border: 1.5px solid #e4ece6; background: #f7faf7; border-radius: 11px; padding: 10px 10px;
  font-size: .88rem; font-weight: 600; color: #2b3b32; text-align: left; display: flex; align-items: center; gap: 8px;
}
.sheet__statuses button.active { border-color: #1f7a3c; background: #eaf6ee; box-shadow: 0 0 0 2px #cde6d4; }
.sheet__statuses button .dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 14px; }
.sheet__close { margin-top: 14px; width: 100%; background: #16241c; color: #fff; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 1rem; }

/* due-count badge on the Today button */
.bar__btn { position: relative; }
.badge {
  position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px;
  background: #ff3b3b; color: #fff; border-radius: 9px; font-size: .68rem;
  font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* booking panel inside the sheet (clients only) */
.book { margin-top: 12px; padding-top: 14px; border-top: 1px solid #e4ece6; }
.book__row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.book__row label { font-weight: 600; color: #2b3b32; }
.book__row input {
  flex: 1; font: inherit; font-weight: 700; padding: 10px 12px;
  border: 1.5px solid #e4ece6; border-radius: 10px; background: #f7faf7;
}
.book__lbl { font-weight: 600; color: #2b3b32; font-size: .9rem; }
.freqs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 12px; }
.freq {
  border: 1.5px solid #e4ece6; background: #f7faf7; border-radius: 10px;
  padding: 10px 4px; font-size: .82rem; font-weight: 600; color: #2b3b32;
}
.freq.active { border-color: #1f7a3c; background: #1f7a3c; color: #fff; }
.book__due { font-weight: 700; color: #1f7a3c; margin-bottom: 10px; }
.book__contact { display: flex; gap: 10px; margin: -2px 0 12px; }
.book__contact a {
  flex: 1; text-align: center; padding: 11px; border-radius: 11px;
  background: #eaf6ee; color: #1f7a3c; font-weight: 700; border: 1.5px solid #cfe6d6;
}
.book__actions { display: flex; gap: 8px; }
.book__cut {
  flex: 1; background: #eaf6ee; border: 1.5px solid #1f7a3c; color: #1f7a3c;
  border-radius: 12px; padding: 13px; font-weight: 700; font-size: .95rem;
}
.book__clear {
  background: #f5f0f0; border: 1.5px solid #dcc8c8; color: #9a5a5a;
  border-radius: 12px; padding: 13px 18px; font-weight: 700; font-size: .92rem;
}
.book__clear:active { background: #ecdede; }
.book__last { margin-top: 8px; font-size: .82rem; color: #8a978d; }
.book__proof { font-size: .8rem; color: #8a6d1f; background: #fff7e6; border: 1px solid #f4d488; border-radius: 8px; padding: 7px 10px; margin: 2px 0 8px; }
.photos { display: flex; gap: 10px; margin: 8px 0 12px; }
.photo {
  flex: 1; aspect-ratio: 4 / 3; border: 1.5px dashed #cfe6d6; border-radius: 12px;
  background: #f7faf7; display: flex; align-items: center; justify-content: center;
  color: #1f7a3c; font-weight: 700; font-size: .9rem; overflow: hidden; cursor: pointer; position: relative;
}
.photo.has { border-style: solid; border-color: #1f7a3c; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.book__ref {
  width: 100%; background: #fff7e6; border: 1.5px solid #f4d488; color: #8a6d1f;
  border-radius: 12px; padding: 12px; font-weight: 700; font-size: .92rem; margin-top: 2px; cursor: pointer;
}
.book__ref.done { background: #eaf6ee; border-color: #1f7a3c; color: #1f7a3c; }

/* Today's route panel */
.today {
  position: fixed; left: 0; right: 0; top: 52px; bottom: 0; z-index: 1003;
  background: #fff; box-shadow: 0 -6px 30px rgba(0,0,0,.18);
  display: flex; flex-direction: column; animation: rise .18s ease;
}
/* .today sets display:flex, which would override the [hidden] attribute — restore it */
.today[hidden] { display: none; }
.today__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid #eef3ee;
}
.today__head strong { font-size: 1.1rem; color: #16241c; }
.today__head button { border: 0; background: none; font-size: 1.1rem; }
/* day strip */
.sched__days { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px; border-bottom: 1px solid #eef3ee; -webkit-overflow-scrolling: touch; }
.sched__day {
  flex: 0 0 auto; width: 60px; border: 1.5px solid #e4ece6; border-radius: 12px;
  padding: 7px 4px 6px; background: #f7faf7; text-align: center; cursor: pointer;
}
.sched__day.sel { border-color: #16241c; background: #16241c; }
.sched__day .dn { font-weight: 800; font-size: .82rem; color: #2b3b32; }
.sched__day .dd { font-size: 1.05rem; font-weight: 800; color: #16241c; line-height: 1.1; }
.sched__day .dc { font-size: .68rem; color: #5d6f64; min-height: .9em; }
.sched__day.sel .dn, .sched__day.sel .dd { color: #fff; }
.sched__day.sel .dc { color: #bfe0cc; }
.sched__day .load { height: 4px; border-radius: 2px; margin-top: 5px; background: transparent; }
.sched__day .load.lo { background: #9bd49e; }
.sched__day .load.md { background: #f4b740; }
.sched__day .load.hi { background: #e0563f; }
.sched__sum { font-weight: 700; color: #16241c; padding: 6px 8px 10px; border-bottom: 1px dashed #e4ece6; margin-bottom: 6px; }

.today__list { overflow-y: auto; padding: 8px 12px 20px; }
.today__empty { text-align: center; color: #5d6f64; padding: 30px; }
.today__row {
  display: flex; align-items: center; gap: 10px; padding: 12px 8px;
  border-bottom: 1px solid #f0f4f1;
}
.today__row.od { background: #fff4f2; }
.today__num {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%;
  background: #16241c; color: #fff; font-size: .8rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.today__addr { flex: 1; font-weight: 600; color: #16241c; display: flex; flex-direction: column; }
.today__addr small { font-weight: 500; color: #8a978d; font-size: .78rem; }
.today__price { font-weight: 800; color: #1f7a3c; }
.today__cut {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px;
  border: 1.5px solid #1f7a3c; background: #eaf6ee; color: #1f7a3c; font-weight: 800;
}

/* ---- Desktop / wide screens: dock panels as a card instead of full-width ---- */
@media (min-width: 640px) {
  .sheet, .today {
    left: auto; right: 18px; bottom: 18px; top: auto; width: 390px;
    border-radius: 18px;
  }
  .sheet { padding: 10px 22px 22px; max-height: 82vh; box-shadow: 0 12px 40px rgba(0,0,0,.28); }
  .today { max-height: 78vh; box-shadow: 0 12px 40px rgba(0,0,0,.28); }
  .sheet__grip { display: none; }
  .sheet__top { margin: 0 -22px; padding: 2px 22px 4px; }
  .legend { width: 270px; }
}

/* friendlier text sizes (kept compact so the sheet doesn't cover the map) */
.bar__stats { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet__addr { font-size: 1.2rem; }
.sheet__meta { font-size: .92rem; }
.freq { font-size: .85rem; padding: 10px 4px; }
.today__addr { font-size: .98rem; }
.today__addr small { font-size: .82rem; }

/* Leads inbox rows */
.lead { padding: 12px 8px; border-bottom: 1px solid #f0f4f1; }
.lead.done { opacity: .55; }
.lead__top { display: flex; justify-content: space-between; align-items: baseline; }
.lead__top strong { color: #16241c; font-size: 1.02rem; }
.lead__top span { color: #8a978d; font-size: .8rem; }
.lead__meta { color: #5d6f64; font-size: .88rem; margin-top: 2px; }
.lead__msg { color: #5d6f64; font-size: .9rem; font-style: italic; margin-top: 6px; }
.lead__actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.lead__btn { flex: 1; text-align: center; padding: 10px; border-radius: 10px; background: #eaf6ee; color: #1f7a3c; font-weight: 700; border: 1.5px solid #cfe6d6; }
.lead__done { padding: 10px 14px; border-radius: 10px; border: 1.5px solid #e4ece6; background: #f7faf7; font-weight: 700; color: #2b3b32; }
.lead__handled { color: #1f7a3c; font-weight: 700; font-size: .85rem; }

/* Login gate */
.login { position: fixed; inset: 0; z-index: 2000; background: #16241c; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login[hidden] { display: none; }
.login__card { width: 100%; max-width: 340px; background: #fff; border-radius: 18px; padding: 30px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.4); text-align: center; }
.login__logo { font-size: 1.5rem; font-weight: 800; color: #16241c; }
.login__sub { color: #5d6f64; margin: 6px 0 20px; font-size: .95rem; }
.login input { width: 100%; font: inherit; padding: 13px 14px; border: 1.5px solid #e4ece6; border-radius: 12px; margin-bottom: 12px; background: #f7faf7; }
.login input:focus { outline: none; border-color: #2e9e4f; }
.login__btn { width: 100%; background: #2e9e4f; color: #fff; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 1rem; cursor: pointer; }
.login__err { color: #c0392b; font-size: .85rem; min-height: 1.1em; margin-top: 10px; }
.legend__signout { margin-top: 10px; width: 100%; background: #f5f0f0; border: 1.5px solid #dcc8c8; color: #9a5a5a; border-radius: 10px; padding: 9px; font-weight: 700; cursor: pointer; }

.leaflet-container { font: inherit; }
