:root{
  --bg:#070707;
  --panel:#111;
  --panel-2:#171717;
  --card:#fff;
  --text:#f7f7f7;
  --muted:#8f8f8f;
  --line:#2a2a2a;
  --black:#000;
  --white:#fff;
  --danger:#d93025;
  --warning:#f59e0b;
  --success:#16a34a;
  --radius:18px;
  --shadow:0 18px 50px rgba(0,0,0,.32);
}

*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--bg);color:var(--text);font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
button,input,textarea,select{font:inherit}
button{cursor:pointer}
.hidden{display:none!important}

.app-shell{height:100%;display:flex;flex-direction:column;overflow:hidden}
.topbar{
  height:68px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:10px 16px;
  background:#000;
  border-bottom:1px solid #1f1f1f;
  z-index:2000;
}
.brand{display:flex;align-items:center;gap:12px;min-width:210px}
.brand-mark{
  width:42px;height:42px;border:2px solid #fff;border-radius:14px;
  display:grid;place-items:center;font-weight:900;font-size:22px;
}
.brand strong{display:block;font-size:15px;letter-spacing:.08em}
.brand span{display:block;color:#cfcfcf;font-size:12px;margin-top:1px}

.top-tabs{
  display:flex;
  background:#151515;
  border:1px solid #2c2c2c;
  padding:4px;
  border-radius:999px;
}
.tab-btn{
  border:0;
  background:transparent;
  color:#aaa;
  padding:9px 18px;
  border-radius:999px;
  font-weight:800;
}
.tab-btn.active{background:#fff;color:#000}

.sync-pill{
  display:flex;align-items:center;gap:8px;
  border:1px solid #2c2c2c;
  border-radius:999px;
  padding:9px 12px;
  color:#d7d7d7;
  font-size:12px;
}
.sync-dot{width:9px;height:9px;border-radius:50%;background:var(--success);box-shadow:0 0 0 4px rgba(22,163,74,.12)}

main{flex:1;min-height:0}
.view{display:none;height:100%}
.view.active{display:flex}

.view-admin{background:#0a0a0a}
.admin-sidebar{
  width:390px;
  max-width:42vw;
  height:100%;
  overflow:auto;
  background:linear-gradient(180deg,#111,#080808);
  border-right:1px solid #242424;
  padding:16px;
  z-index:1000;
}
.panel-head h1{font-size:23px;margin:0 0 4px}
.panel-head p{margin:0;color:#aaa;font-size:13px}

.action-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin:16px 0;
}
.primary-btn,.secondary-btn,.danger-soft-btn,.map-btn,.success-btn,.warning-btn,.danger-btn,.wide-btn{
  border:0;border-radius:14px;padding:12px 14px;font-weight:900;
}
.primary-btn{background:#fff;color:#000}
.secondary-btn{background:#222;color:#fff;border:1px solid #333}
.danger-soft-btn{background:rgba(217,48,37,.13);color:#ffb2aa;border:1px solid rgba(217,48,37,.35)}

.route-summary{
  display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:16px;
}
.route-summary>div{
  background:#161616;border:1px solid #2a2a2a;border-radius:16px;padding:12px;
}
.route-summary span{display:block;color:#aaa;font-size:12px}
.route-summary strong{display:block;font-size:24px;margin-top:4px}

.panel-stack{display:flex;flex-direction:column;gap:12px}
.delivery-column{
  background:#101010;
  border:1px solid #262626;
  border-radius:18px;
  overflow:hidden;
}
.column-title{
  width:100%;border:0;background:#181818;color:#fff;
  padding:13px 14px;
  display:flex;justify-content:space-between;align-items:center;
  font-weight:900;text-align:left;
}
.column-title span{
  min-width:28px;height:24px;border-radius:999px;background:#fff;color:#000;
  display:grid;place-items:center;font-size:12px;
}
.column-body{padding:10px}
.cards-list{display:flex;flex-direction:column;gap:10px}

.delivery-card{
  background:#fff;color:#080808;border-radius:16px;padding:12px;
  box-shadow:0 10px 24px rgba(0,0,0,.16);
}
.delivery-card h3{margin:0 0 6px;font-size:15px}
.delivery-card p{margin:0 0 10px;color:#444;font-size:13px;line-height:1.35}
.card-meta{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px}
.tag{
  background:#f1f1f1;border-radius:999px;padding:5px 8px;font-size:11px;font-weight:800;color:#222;
}
.card-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.card-actions button{
  border:0;border-radius:11px;padding:9px;font-size:12px;font-weight:900;
}
.btn-dark{background:#000;color:#fff}
.btn-light{background:#eee;color:#000}
.btn-danger{background:#fee2e2;color:#991b1b}

.map-area{position:relative;flex:1;min-width:0}
.map{width:100%;height:100%;background:#1a1a1a}
.map-toolbar{
  position:absolute;top:14px;left:14px;right:14px;z-index:900;
  display:flex;gap:10px;justify-content:flex-end;pointer-events:none;
}
.map-toolbar .map-btn{pointer-events:auto}
.map-btn{background:#fff;color:#000;box-shadow:var(--shadow)}
.map-btn.solid{background:#000;color:#fff;border:1px solid #fff}

.floating-help{
  position:absolute;left:16px;bottom:18px;z-index:900;
  max-width:380px;background:rgba(0,0,0,.86);border:1px solid rgba(255,255,255,.18);
  color:#fff;padding:12px 14px;border-radius:16px;box-shadow:var(--shadow);
  font-size:13px;line-height:1.35;
}

.point-dialog{
  border:0;border-radius:22px;padding:0;max-width:420px;width:min(92vw,420px);
  box-shadow:var(--shadow);
}
.point-dialog::backdrop{background:rgba(0,0,0,.72)}
.point-dialog form{padding:20px;background:#fff;color:#000}
.point-dialog h2{margin:0 0 6px}
.point-dialog p{margin:0 0 18px;color:#555;line-height:1.4}
.point-dialog label{display:block;font-weight:900;margin-bottom:12px}
.point-dialog input,.point-dialog textarea,.point-dialog select{
  width:100%;margin-top:7px;border:1px solid #d6d6d6;border-radius:14px;padding:12px;
  outline:none;background:#fafafa;
}
.dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}

.view-driver{background:#000}
.driver-map-wrap{position:relative;flex:1;min-width:0}
.driver-status-bar{
  position:absolute;left:12px;right:12px;top:12px;z-index:800;
  display:flex;justify-content:space-between;gap:10px;pointer-events:none;
}
.driver-status-bar span{
  background:rgba(0,0,0,.82);border:1px solid rgba(255,255,255,.18);
  color:#fff;border-radius:999px;padding:8px 11px;font-size:12px;font-weight:800;
}
.driver-card{
  position:absolute;left:12px;right:12px;bottom:72px;z-index:850;
  background:#fff;color:#000;border-radius:24px;padding:16px;box-shadow:var(--shadow);
}
.driver-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}
.eyebrow{text-transform:uppercase;font-size:11px;font-weight:900;color:#777;letter-spacing:.08em}
.driver-card h2{margin:3px 0 0;font-size:20px}
.driver-card-head strong{
  background:#000;color:#fff;border-radius:14px;min-width:52px;height:42px;
  display:grid;place-items:center;
}
.driver-ref{color:#444;line-height:1.4;margin:12px 0}
.driver-actions{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-bottom:8px}
.success-btn{background:var(--success);color:#fff}
.warning-btn{background:var(--warning);color:#000}
.danger-btn{background:var(--danger);color:#fff}
.wide-btn{width:100%;background:#000;color:#fff}

.driver-list-drawer{
  position:absolute;left:12px;right:12px;bottom:10px;z-index:860;
}
.drawer-handle{
  width:100%;border:0;border-radius:16px;background:#000;color:#fff;
  border:1px solid rgba(255,255,255,.25);padding:12px;font-weight:900;
}
.driver-list{
  display:none;
  margin-top:8px;
  max-height:38vh;
  overflow:auto;
  background:#fff;color:#000;border-radius:18px;padding:10px;
}
.driver-list.open{display:block}
.driver-item{
  padding:10px;border-bottom:1px solid #eee;
  display:flex;justify-content:space-between;gap:12px;
}
.driver-item:last-child{border-bottom:0}
.driver-item strong{display:block}
.driver-item span{font-size:12px;color:#555}

.leaflet-control-layers{border-radius:14px!important;overflow:hidden!important}
.leaflet-popup-content-wrapper{border-radius:16px!important}
.point-marker{
  background:#000;color:#fff;border:2px solid #fff;border-radius:50%;
  width:30px;height:30px;display:grid;place-items:center;font-weight:900;
  box-shadow:0 8px 18px rgba(0,0,0,.35);
}
.driver-marker{
  background:#16a34a;color:#fff;border:3px solid #fff;border-radius:50%;
  width:26px;height:26px;box-shadow:0 0 0 8px rgba(22,163,74,.20);
}

@media (max-width: 860px){
  .topbar{height:62px;padding:8px 10px}
  .brand{min-width:auto}
  .brand span{display:none}
  .brand-mark{width:38px;height:38px}
  .tab-btn{padding:8px 12px}
  .sync-pill{display:none}

  .view-admin{flex-direction:column}
  .admin-sidebar{
    width:100%;
    max-width:none;
    height:43%;
    min-height:300px;
    order:2;
    border-right:0;
    border-top:1px solid #242424;
    padding:12px;
  }
  .map-area{height:57%;order:1;min-height:340px}
  .map-toolbar{
    left:8px;right:8px;top:8px;
    justify-content:center;
    flex-wrap:wrap;
  }
  .map-btn{padding:10px 11px;font-size:12px}
  .floating-help{left:8px;right:8px;bottom:8px;max-width:none;font-size:12px}
  .action-grid{grid-template-columns:1fr 1fr}
  .route-summary{grid-template-columns:repeat(3,1fr)}
  .panel-head h1{font-size:19px}

  .driver-card{bottom:66px;padding:14px;border-radius:22px}
  .driver-card h2{font-size:18px}
  .driver-actions button{padding:11px 8px;font-size:13px}
}


/* ===============================
   V1.1 — ENTREGADOR MOBILE FIRST
   =============================== */

.view-driver.active{
  display:block;
  height:100%;
  background:#000;
}

.driver-mobile-app{
  position:relative;
  width:100%;
  height:100%;
  overflow:hidden;
  background:#000;
}

.driver-map{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
}

.driver-mobile-top{
  position:absolute;
  left:max(10px, env(safe-area-inset-left));
  right:max(10px, env(safe-area-inset-right));
  top:max(10px, env(safe-area-inset-top));
  z-index:900;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  pointer-events:none;
}

.driver-top-chip,
.driver-top-status{
  background:rgba(0,0,0,.86);
  color:#fff;
  border:1px solid rgba(255,255,255,.18);
  box-shadow:0 12px 32px rgba(0,0,0,.25);
  backdrop-filter:blur(10px);
}

.driver-top-chip{
  border-radius:18px;
  padding:10px 12px;
}

.driver-top-chip strong{
  display:block;
  font-size:13px;
  letter-spacing:.03em;
}

.driver-top-chip span{
  display:block;
  color:#cfcfcf;
  font-size:11px;
  margin-top:2px;
}

.driver-top-status{
  border-radius:18px;
  padding:8px;
  display:flex;
  flex-direction:column;
  gap:6px;
  align-items:flex-end;
}

.driver-top-status span{
  display:block;
  padding:6px 8px;
  border-radius:999px;
  background:rgba(255,255,255,.1);
  font-size:11px;
  font-weight:900;
  white-space:nowrap;
}

.driver-floating-btn{
  position:absolute;
  right:max(12px, env(safe-area-inset-right));
  top:94px;
  z-index:850;
  border:0;
  border-radius:999px;
  background:#fff;
  color:#000;
  padding:10px 13px;
  font-size:12px;
  font-weight:900;
  box-shadow:0 14px 36px rgba(0,0,0,.28);
}

.driver-bottom-sheet{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  z-index:880;
  padding:8px 10px calc(10px + env(safe-area-inset-bottom));
  background:linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.85) 10%, #000 100%);
  max-height:58vh;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.sheet-grabber{
  width:46px;
  height:5px;
  background:rgba(255,255,255,.45);
  border-radius:999px;
  margin:0 auto 8px;
}

.view-driver .driver-card{
  position:static;
  left:auto;
  right:auto;
  bottom:auto;
  z-index:auto;
  background:#fff;
  color:#000;
  border-radius:24px;
  padding:15px;
  box-shadow:0 18px 50px rgba(0,0,0,.38);
}

.view-driver .driver-card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}

.view-driver .driver-card h2{
  margin:3px 0 0;
  font-size:clamp(18px, 5vw, 24px);
  line-height:1.08;
}

.view-driver .driver-ref{
  color:#333;
  font-size:15px;
  line-height:1.38;
  margin:12px 0;
}

.view-driver .driver-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:9px;
  margin-bottom:9px;
}

.view-driver .driver-actions .danger-btn{
  grid-column:1 / -1;
}

.view-driver .success-btn,
.view-driver .warning-btn,
.view-driver .danger-btn,
.view-driver .wide-btn{
  min-height:54px;
  border-radius:16px;
  font-size:15px;
  font-weight:950;
  letter-spacing:.01em;
}

.view-driver .wide-btn{
  min-height:50px;
}

.view-driver .drawer-handle{
  margin-top:9px;
  min-height:48px;
  border-radius:17px;
  background:#111;
  color:#fff;
  border:1px solid rgba(255,255,255,.24);
}

.view-driver .driver-list{
  max-height:34vh;
  margin-top:8px;
  background:#fff;
  color:#000;
  border-radius:20px;
  padding:8px;
  box-shadow:0 18px 50px rgba(0,0,0,.34);
}

.view-driver .driver-list.open{
  display:block;
}

.view-driver .driver-item{
  min-height:58px;
  align-items:center;
  border-bottom:1px solid #ececec;
}

.view-driver .driver-item strong{
  font-size:14px;
}

.view-driver .driver-item span{
  font-size:12px;
}

@media (min-width: 861px){
  .view-driver.active{
    max-width:430px;
    margin:0 auto;
    border-left:1px solid #222;
    border-right:1px solid #222;
    box-shadow:0 0 0 9999px #050505;
  }
}

@media (max-width: 420px){
  .driver-bottom-sheet{
    max-height:61vh;
    padding-left:8px;
    padding-right:8px;
  }

  .driver-top-status span{
    font-size:10px;
    padding:5px 7px;
  }

  .driver-floating-btn{
    top:88px;
    font-size:11px;
  }
}

/* Cloudflare/produção: evita zoom e quebra em controles no mobile */
@media (max-width: 860px){
  input, textarea, select{
    font-size:16px;
  }

  body{
    overscroll-behavior:none;
  }
}


/* ===============================
   V2.2 — STATUS COLORIDO NO ENTREGADOR
   =============================== */

.status-marker{
  color:#fff;
  border:3px solid #fff;
  border-radius:50%;
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  font-weight:950;
  font-size:13px;
  box-shadow:0 10px 22px rgba(0,0,0,.38);
}

.status-marker.waiting{ background:#f97316; }
.status-marker.in_route{ background:#2563eb; }
.status-marker.done{ background:#16a34a; }
.status-marker.problem,
.status-marker.cancelled{ background:#dc2626; }

.driver-status-legend{
  position:absolute;
  left:max(10px, env(safe-area-inset-left));
  right:max(10px, env(safe-area-inset-right));
  top:145px;
  z-index:845;
  display:flex;
  gap:6px;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  padding-bottom:4px;
  pointer-events:none;
}

.driver-status-legend span{
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:7px 9px;
  border-radius:999px;
  background:rgba(0,0,0,.78);
  color:#fff;
  border:1px solid rgba(255,255,255,.16);
  font-size:10px;
  font-weight:900;
  backdrop-filter:blur(8px);
}

.driver-status-legend i{
  width:9px;
  height:9px;
  border-radius:50%;
  display:inline-block;
}

.driver-status-legend .lg-waiting{ background:#f97316; }
.driver-status-legend .lg-route{ background:#2563eb; }
.driver-status-legend .lg-done{ background:#16a34a; }
.driver-status-legend .lg-problem{ background:#dc2626; }

.driver-item{
  border-left:6px solid #ddd;
  border-radius:14px;
  margin-bottom:7px;
  background:#fff;
}

.driver-item.status-waiting{ border-left-color:#f97316; }
.driver-item.status-in_route{ border-left-color:#2563eb; }
.driver-item.status-done{ border-left-color:#16a34a; opacity:.82; }
.driver-item.status-problem,
.driver-item.status-cancelled{ border-left-color:#dc2626; }

.driver-status-badge{
  display:inline-flex!important;
  width:auto!important;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  padding:5px 8px!important;
  color:#fff!important;
  font-size:10px!important;
  font-weight:950!important;
  white-space:nowrap;
}

.driver-status-badge.status-waiting{ background:#f97316; }
.driver-status-badge.status-in_route{ background:#2563eb; }
.driver-status-badge.status-done{ background:#16a34a; }
.driver-status-badge.status-problem,
.driver-status-badge.status-cancelled{ background:#dc2626; }

.delivery-card.status-waiting{ border-left:7px solid #f97316; }
.delivery-card.status-in_route{ border-left:7px solid #2563eb; }
.delivery-card.status-done{ border-left:7px solid #16a34a; }
.delivery-card.status-problem,
.delivery-card.status-cancelled{ border-left:7px solid #dc2626; }

@media (max-width: 420px){
  .driver-status-legend{
    top:136px;
  }

  .driver-status-legend span{
    font-size:9px;
    padding:6px 8px;
  }
}


/* ===============================
   V2.3 — SINCRONIZAÇÃO SUAVE
   =============================== */

.sync-pill{
  transition:background .18s ease, border-color .18s ease, transform .18s ease;
}

.sync-pill.sync-active{
  background:rgba(22,163,74,.12);
  border-color:rgba(22,163,74,.32);
}

.map{
  will-change:transform;
}

/* Evita sensação de salto visual no mobile quando a lista atualiza */
.driver-list,
.cards-list{
  scroll-behavior:smooth;
}


/* ===============================
   V2.4 — LOCALIZAÇÕES FIXAS
   =============================== */

.fixed-location-box{
  background:#101010;
  border:1px solid #262626;
  border-radius:18px;
  padding:12px;
  margin:0 0 16px;
}

.fixed-location-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.fixed-location-head h2{
  margin:0;
  font-size:16px;
}

.fixed-location-head p{
  margin:3px 0 0;
  color:#aaa;
  font-size:12px;
}

.fixed-location-head strong{
  min-width:32px;
  height:28px;
  border-radius:999px;
  background:#fff;
  color:#000;
  display:grid;
  place-items:center;
  font-size:12px;
}

.fixed-search{
  width:100%;
  border:1px solid #303030;
  background:#050505;
  color:#fff;
  border-radius:14px;
  padding:12px 13px;
  outline:none;
  margin-bottom:10px;
}

.fixed-search:focus{
  border-color:#fff;
}

.fixed-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:230px;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.fixed-item{
  background:#fff;
  color:#000;
  border-radius:15px;
  padding:11px;
  border-left:7px solid #111;
}

.fixed-item h3{
  margin:0 0 4px;
  font-size:14px;
}

.fixed-item p{
  margin:0 0 9px;
  color:#444;
  font-size:12px;
  line-height:1.35;
}

.fixed-item-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}

.fixed-item-actions button{
  border:0;
  border-radius:11px;
  padding:9px;
  font-size:12px;
  font-weight:900;
}

.type-choice{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin:8px 0 14px;
}

.type-card{
  border:1px solid #d6d6d6;
  border-radius:16px;
  padding:12px;
  background:#fafafa;
  cursor:pointer;
  margin:0!important;
}

.type-card input{
  width:auto!important;
  margin:0 0 8px!important;
}

.type-card strong{
  display:block;
  font-size:13px;
}

.type-card span{
  display:block;
  color:#666;
  font-size:11px;
  line-height:1.3;
  margin-top:3px;
}

.type-card.active{
  border-color:#000;
  background:#000;
  color:#fff;
}

.type-card.active span{
  color:#d7d7d7;
}

.tag-fixed{
  background:#111!important;
  color:#fff!important;
}

.tag-quick{
  background:#fff3e8!important;
  color:#9a3412!important;
}

@media (max-width:860px){
  .fixed-location-box{
    margin-bottom:12px;
  }

  .fixed-list{
    max-height:180px;
  }

  .type-choice{
    grid-template-columns:1fr;
  }
}


/* ===============================
   V2.5 — CORREÇÕES DE PRODUÇÃO E LAYOUT ADM
   =============================== */

.admin-sidebar{
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:16px;
}

.route-summary{
  margin-bottom:0;
}

.fixed-location-box{
  margin:0;
  background:linear-gradient(180deg,#151515,#0d0d0d);
  border:1px solid #303030;
  box-shadow:0 10px 28px rgba(0,0,0,.22);
}

.fixed-location-head h2{
  font-size:20px;
  letter-spacing:-.02em;
}

.fixed-search{
  height:44px;
  font-size:14px;
  background:#fff;
  color:#000;
  border-color:#fff;
}

.fixed-search::placeholder{
  color:#777;
}

.fixed-list{
  max-height:280px;
}

.fixed-item{
  border-left:7px solid #f97316;
  box-shadow:0 8px 18px rgba(0,0,0,.15);
}

.fixed-item h3{
  font-size:15px;
  line-height:1.2;
}

.fixed-item-actions button{
  min-height:38px;
}

.panel-stack{
  gap:14px;
}

.delivery-column{
  flex:0 0 auto;
}

.delivery-card p{
  word-break:break-word;
}

.map-toolbar{
  max-width:100%;
  overflow-x:auto;
  padding-bottom:4px;
}

.map-toolbar .map-btn{
  flex:0 0 auto;
}

.route-debug-pill{
  position:absolute;
  right:14px;
  bottom:14px;
  z-index:901;
  background:rgba(0,0,0,.82);
  color:#fff;
  border:1px solid rgba(255,255,255,.16);
  border-radius:999px;
  padding:8px 11px;
  font-size:11px;
  font-weight:900;
}

@media (max-width:860px){
  .admin-sidebar{
    gap:12px;
  }

  .fixed-location-head h2{
    font-size:17px;
  }

  .fixed-list{
    max-height:210px;
  }

  .map-toolbar{
    justify-content:flex-start;
  }
}


/* ===============================
   V2.6 — BUSCA DE FIXAS POR PALAVRA E SATÉLITE SEM SOBREPOSIÇÃO
   =============================== */

.fixed-empty-state{
  background:#fff;
  color:#000;
  border-radius:15px;
  padding:14px;
  border-left:7px solid #777;
}

.fixed-empty-state strong{
  display:block;
  font-size:14px;
  margin-bottom:4px;
}

.fixed-empty-state span{
  display:block;
  color:#555;
  font-size:12px;
  line-height:1.35;
}

.fixed-item mark{
  background:#fff176;
  color:#000;
  border-radius:5px;
  padding:0 3px;
}

.leaflet-control-layers{
  z-index:1200!important;
  box-shadow:0 12px 30px rgba(0,0,0,.25)!important;
}

#adminMap .leaflet-bottom.leaflet-right{
  right:16px;
  bottom:22px;
}

/* No ADM o controle de satélite fica no canto inferior direito para não ficar atrás do botão Organizar proximidade. */
.view-admin .leaflet-bottom.leaflet-right .leaflet-control-layers{
  margin-bottom:8px;
  margin-right:8px;
}

.map-toolbar{
  z-index:900;
}

@media (max-width:860px){
  #adminMap .leaflet-bottom.leaflet-right{
    right:8px;
    bottom:72px;
  }

  .view-admin .leaflet-bottom.leaflet-right .leaflet-control-layers{
    margin-bottom:4px;
    margin-right:4px;
  }
}


/* ===============================
   V2.7 — ENTREGADOR MOBILE PRO
   =============================== */

@media (max-width: 860px){
  body.driver-mode .topbar{
    height:62px;
    padding:7px 10px;
  }

  body.driver-mode .brand{
    gap:8px;
    min-width:0;
  }

  body.driver-mode .brand-mark{
    width:38px;
    height:38px;
    border-radius:14px;
    font-size:21px;
  }

  body.driver-mode .brand strong{
    font-size:14px;
    letter-spacing:.08em;
  }

  body.driver-mode .brand span{
    display:block;
    font-size:11px;
    color:#aaa;
  }

  body.driver-mode .top-tabs{
    padding:3px;
    flex-shrink:0;
  }

  body.driver-mode .tab-btn{
    padding:8px 12px;
    font-size:12px;
  }

  body.driver-mode .tab-btn[data-view="admin"]{
    opacity:.55;
  }

  .driver-mobile-top{
    top:max(8px, env(safe-area-inset-top));
    left:max(8px, env(safe-area-inset-left));
    right:max(8px, env(safe-area-inset-right));
    align-items:flex-start;
  }

  .driver-top-chip{
    padding:8px 10px;
    border-radius:16px;
    max-width:145px;
  }

  .driver-top-chip strong{
    font-size:13px;
  }

  .driver-top-chip span{
    font-size:10px;
  }

  .driver-top-status{
    padding:7px;
    border-radius:16px;
    gap:5px;
    max-width:185px;
  }

  .driver-top-status span{
    font-size:10px;
    padding:5px 7px;
  }

  .driver-floating-actions{
    position:absolute;
    right:max(10px, env(safe-area-inset-right));
    bottom:calc(214px + env(safe-area-inset-bottom));
    z-index:870;
    display:flex;
    gap:8px;
    align-items:center;
  }

  .driver-floating-btn{
    position:static;
    min-width:46px;
    min-height:42px;
    border-radius:999px;
    padding:9px 12px;
    font-size:13px;
    box-shadow:0 12px 32px rgba(0,0,0,.34);
  }

  .driver-floating-btn:first-child{
    width:46px;
    padding:0;
    font-size:22px;
    line-height:1;
  }

  .driver-floating-btn.status-toggle{
    background:#111;
    color:#fff;
    border:1px solid rgba(255,255,255,.24);
  }

  .driver-status-legend{
    top:112px;
    left:8px;
    right:8px;
    transition:opacity .18s ease, transform .18s ease, max-height .18s ease;
    max-height:60px;
  }

  .driver-status-legend.collapsed{
    opacity:0;
    transform:translateY(-8px);
    pointer-events:none;
    max-height:0;
    overflow:hidden;
  }

  .driver-bottom-sheet{
    max-height:52vh;
    padding:6px 10px calc(10px + env(safe-area-inset-bottom));
    background:linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.68) 12%, #000 100%);
  }

  .driver-bottom-sheet.no-delivery{
    max-height:34vh;
  }

  .driver-bottom-sheet.preview-delivery{
    max-height:40vh;
  }

  .sheet-grabber{
    width:42px;
    height:5px;
    margin-bottom:7px;
    opacity:.75;
  }

  .view-driver .driver-card{
    border-radius:25px;
    padding:15px;
  }

  .view-driver .driver-card h2{
    font-size:clamp(19px, 6vw, 25px);
    line-height:1.08;
  }

  .view-driver .driver-card-head strong{
    min-width:54px;
    height:48px;
    border-radius:16px;
    font-size:19px;
  }

  .view-driver .driver-ref{
    font-size:15px;
    margin:10px 0 12px;
  }

  .view-driver .driver-actions{
    grid-template-columns:1fr 1fr;
    gap:8px;
  }

  .view-driver .success-btn,
  .view-driver .warning-btn,
  .view-driver .danger-btn,
  .view-driver .wide-btn{
    min-height:50px;
    border-radius:16px;
    font-size:15px;
  }

  .driver-bottom-sheet.no-delivery .driver-actions,
  .driver-bottom-sheet.no-delivery .wide-btn,
  .driver-bottom-sheet.preview-delivery .driver-actions{
    display:none;
  }

  .driver-bottom-sheet.preview-delivery .wide-btn{
    display:block;
    margin-top:8px;
  }

  .driver-bottom-sheet.no-delivery .driver-card{
    padding:17px;
  }

  .driver-bottom-sheet.no-delivery .driver-card h2{
    font-size:22px;
  }

  .driver-bottom-sheet.no-delivery .driver-card-head strong{
    min-width:48px;
    height:44px;
    font-size:17px;
  }

  .view-driver .drawer-handle{
    min-height:46px;
    margin-top:8px;
    border-radius:18px;
    font-size:15px;
  }

  .view-driver .driver-list{
    max-height:32vh;
    border-radius:18px;
  }

  .driver-map .leaflet-control-zoom{
    margin-top:114px!important;
  }
}

@media (max-width:420px){
  .driver-floating-actions{
    bottom:calc(210px + env(safe-area-inset-bottom));
  }

  .driver-bottom-sheet{
    max-height:54vh;
    padding-left:9px;
    padding-right:9px;
  }

  .driver-bottom-sheet.no-delivery{
    max-height:32vh;
  }

  .driver-top-chip{
    max-width:132px;
  }

  .driver-top-status{
    max-width:170px;
  }
}


/* ===============================
   V2.8 — RESPONSIVIDADE AUTOMÁTICA POR APARELHO
   =============================== */

:root{
  --app-h: calc(var(--app-vh, 1vh) * 100);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);
}

html, body{
  height:var(--app-h);
  min-height:var(--app-h);
}

.app-shell{
  height:var(--app-h);
  min-height:var(--app-h);
}

/* Telefone pequeno */
body[data-size="phone-xs"] .topbar{height:54px;padding:6px 8px}
body[data-size="phone-xs"] .brand-mark{width:34px;height:34px;border-radius:12px;font-size:19px}
body[data-size="phone-xs"] .brand strong{font-size:12px}
body[data-size="phone-xs"] .brand span{font-size:10px}
body[data-size="phone-xs"] .tab-btn{padding:7px 9px;font-size:11px}
body[data-size="phone-xs"] .driver-top-chip,
body[data-size="phone-xs"] .driver-top-status{transform:scale(.92)}
body[data-size="phone-xs"] .driver-top-chip{transform-origin:top left}
body[data-size="phone-xs"] .driver-top-status{transform-origin:top right}
body[data-size="phone-xs"] .driver-bottom-sheet{max-height:56vh;padding-left:7px;padding-right:7px}
body[data-size="phone-xs"] .view-driver .driver-card{padding:12px;border-radius:21px}
body[data-size="phone-xs"] .view-driver .driver-card h2{font-size:19px}
body[data-size="phone-xs"] .view-driver .success-btn,
body[data-size="phone-xs"] .view-driver .warning-btn,
body[data-size="phone-xs"] .view-driver .danger-btn,
body[data-size="phone-xs"] .view-driver .wide-btn{min-height:45px;font-size:13px}

/* Telefone padrão */
body[data-size="phone-sm"] .driver-bottom-sheet{max-height:54vh}
body[data-size="phone-sm"] .driver-bottom-sheet.no-delivery{max-height:32vh}
body[data-size="phone-sm"] .view-driver .driver-card h2{font-size:clamp(20px,6vw,25px)}

/* Telefone grande */
body[data-size="phone-lg"] .driver-bottom-sheet{max-height:50vh;padding-left:14px;padding-right:14px}
body[data-size="phone-lg"] .view-driver .driver-card{padding:18px}
body[data-size="phone-lg"] .view-driver .driver-card h2{font-size:27px}
body[data-size="phone-lg"] .view-driver .driver-ref{font-size:16px}

/* Tela baixa */
body.is-short-screen .driver-bottom-sheet{max-height:49vh!important}
body.is-short-screen .driver-status-legend{top:96px}
body.is-short-screen .driver-top-chip span{display:none}
body.is-short-screen .sheet-grabber{margin-bottom:4px}
body.is-short-screen .view-driver .driver-card{padding:12px}
body.is-short-screen .view-driver .driver-actions{gap:6px}
body.is-short-screen .view-driver .success-btn,
body.is-short-screen .view-driver .warning-btn,
body.is-short-screen .view-driver .danger-btn,
body.is-short-screen .view-driver .wide-btn{min-height:44px}

/* Tablet vertical e horizontal */
body[data-size="tablet"] .view-driver.active,
body[data-size="tablet-wide"] .view-driver.active{max-width:none;width:100%;margin:0;border:0;box-shadow:none}

body[data-size="tablet"] .driver-bottom-sheet,
body[data-size="tablet-wide"] .driver-bottom-sheet{
  left:auto;right:18px;bottom:18px;width:min(430px,45vw);
  max-height:calc(var(--app-h) - 120px);padding:0;background:transparent
}
body[data-size="tablet"] .sheet-grabber,
body[data-size="tablet-wide"] .sheet-grabber{display:none}
body[data-size="tablet"] .driver-floating-actions,
body[data-size="tablet-wide"] .driver-floating-actions{right:calc(min(430px,45vw) + 32px);bottom:24px}
body[data-size="tablet"] .driver-status-legend,
body[data-size="tablet-wide"] .driver-status-legend{top:92px;right:calc(min(430px,45vw) + 42px);left:14px}

/* Paisagem: card lateral */
body.is-landscape.is-phone .topbar,
body.is-landscape.is-tablet .topbar{height:54px}

body.is-landscape.is-phone .driver-bottom-sheet,
body.is-landscape.is-tablet .driver-bottom-sheet{
  left:auto;right:10px;bottom:10px;width:min(390px,42vw);
  max-height:calc(var(--app-h) - 72px)!important;padding:0;background:transparent
}
body.is-landscape.is-phone .sheet-grabber,
body.is-landscape.is-tablet .sheet-grabber{display:none}
body.is-landscape.is-phone .view-driver .driver-card,
body.is-landscape.is-tablet .view-driver .driver-card{padding:12px;border-radius:20px}
body.is-landscape.is-phone .view-driver .driver-card h2,
body.is-landscape.is-tablet .view-driver .driver-card h2{font-size:18px}
body.is-landscape.is-phone .view-driver .driver-ref,
body.is-landscape.is-tablet .view-driver .driver-ref{font-size:13px;margin:7px 0}
body.is-landscape.is-phone .view-driver .success-btn,
body.is-landscape.is-phone .view-driver .warning-btn,
body.is-landscape.is-phone .view-driver .danger-btn,
body.is-landscape.is-phone .view-driver .wide-btn,
body.is-landscape.is-tablet .view-driver .success-btn,
body.is-landscape.is-tablet .view-driver .warning-btn,
body.is-landscape.is-tablet .view-driver .danger-btn,
body.is-landscape.is-tablet .view-driver .wide-btn{min-height:38px;font-size:12px}
body.is-landscape.is-phone .driver-floating-actions,
body.is-landscape.is-tablet .driver-floating-actions{right:calc(min(390px,42vw) + 22px);bottom:14px}
body.is-landscape.is-phone .driver-status-legend,
body.is-landscape.is-tablet .driver-status-legend{top:62px;left:10px;right:calc(min(390px,42vw) + 26px)}

/* Desktop */
body.is-desktop .view-driver.active{max-width:430px;margin:0 auto}
body.is-desktop .view-admin .admin-sidebar{width:clamp(360px,28vw,460px);max-width:460px}

/* ADM em aparelhos diferentes */
body.is-phone .view-admin{flex-direction:column}
body.is-phone .admin-sidebar{height:45%;min-height:310px}
body.is-phone .map-area{height:55%;min-height:320px}
body.is-tablet .admin-sidebar{width:360px;max-width:40vw}
body.is-tablet .map-toolbar{justify-content:flex-start;left:12px;right:12px}
body.is-tablet .map-btn{padding:10px 12px;font-size:12px}

body.is-phone .driver-mobile-app,
body.is-tablet .driver-mobile-app{height:calc(var(--app-vh,1vh) * 100)}

body[data-size="phone-xs"] .driver-item,
body.is-short-screen .driver-item{min-height:48px;padding:8px}
body[data-size="phone-xs"] .driver-item strong,
body.is-short-screen .driver-item strong{font-size:12px}

body.is-phone button,
body.is-tablet button{touch-action:manipulation}


/* ===============================
   V2.9 — MAPA PRO
   =============================== */

.map-layer-toggle{position:absolute;right:14px;top:72px;z-index:930;display:flex;gap:4px;padding:4px;border-radius:999px;background:rgba(0,0,0,.78);border:1px solid rgba(255,255,255,.2);box-shadow:0 12px 32px rgba(0,0,0,.28);backdrop-filter:blur(10px)}
.map-layer-toggle button{border:0;border-radius:999px;padding:9px 13px;background:transparent;color:#fff;font-size:12px;font-weight:950}
.map-layer-toggle button.active{background:#fff;color:#000}
.driver-floating-actions{flex-wrap:wrap;justify-content:flex-end}
.driver-floating-btn.layer-toggle,.driver-floating-btn.route-fit{background:#fff;color:#000}
.status-marker{width:36px;height:36px;font-size:13px;position:relative}.status-marker span{position:relative;z-index:2}
.status-marker.next-stop{width:44px;height:44px;font-size:16px;border-width:4px;box-shadow:0 0 0 10px rgba(37,99,235,.22),0 16px 34px rgba(0,0,0,.42)}
.status-marker.next-stop::after{content:'';position:absolute;inset:-9px;border:2px solid rgba(37,99,235,.45);border-radius:999px;animation:routePulse 1.4s infinite}
@keyframes routePulse{from{transform:scale(.76);opacity:.9}to{transform:scale(1.2);opacity:0}}
.driver-marker{animation:gpsPulse 1.6s infinite}@keyframes gpsPulse{0%{box-shadow:0 0 0 4px rgba(22,163,74,.28)}70%{box-shadow:0 0 0 16px rgba(22,163,74,0)}100%{box-shadow:0 0 0 4px rgba(22,163,74,0)}}
.map-popup-pro{min-width:210px;color:#111}.popup-title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;margin-bottom:7px}.popup-title-row strong{font-size:14px;line-height:1.2}.popup-status{flex:0 0 auto;border-radius:999px;padding:4px 7px;color:#fff;font-size:10px;font-weight:950}.popup-status.status-waiting{background:#f97316}.popup-status.status-in_route{background:#2563eb}.popup-status.status-done{background:#16a34a}.popup-status.status-problem,.popup-status.status-cancelled{background:#dc2626}.map-popup-pro p{margin:0 0 7px;line-height:1.35;font-size:12px;color:#333}.popup-meta{display:flex;flex-wrap:wrap;gap:5px}.popup-meta span{background:#f1f1f1;color:#222;border-radius:999px;padding:4px 7px;font-size:10px;font-weight:900}.leaflet-popup-content-wrapper{box-shadow:0 16px 42px rgba(0,0,0,.32)!important}.leaflet-popup-content{margin:12px!important}
.leaflet-control-layers{display:none!important}
@media (max-width:860px){.map-layer-toggle{right:8px;top:58px}.map-layer-toggle button{padding:8px 10px;font-size:11px}body.driver-mode .map-layer-toggle{display:none}.driver-floating-actions{max-width:240px}.driver-floating-btn{min-height:40px}.driver-floating-btn.route-fit,.driver-floating-btn.layer-toggle,.driver-floating-btn.status-toggle{font-size:12px;padding:8px 10px}}
@media (max-width:420px){.driver-floating-actions{max-width:220px;gap:6px}.driver-floating-btn.route-fit,.driver-floating-btn.layer-toggle,.driver-floating-btn.status-toggle{font-size:11px;padding:8px 9px}}
body.is-landscape.is-phone .driver-floating-actions,body.is-landscape.is-tablet .driver-floating-actions{max-width:260px}


/* ===============================
   V3.0 — SATÉLITE PRO / HÍBRIDO
   =============================== */

.map-layer-toggle{
  background:rgba(0,0,0,.84);
  border:1px solid rgba(255,255,255,.24);
}

.map-layer-toggle button{
  min-width:62px;
}

.map-layer-toggle button[data-layer="hybrid"].active{
  background:#2563eb;
  color:#fff;
}

.map.map-layer-satellite .leaflet-tile-pane,
.map.map-layer-hybrid .leaflet-tile-pane{
  filter:brightness(1.08) contrast(1.14) saturate(1.14);
}

.map.map-layer-hybrid .hybrid-labels{
  mix-blend-mode:screen;
  filter:contrast(1.4) brightness(1.15) grayscale(.15);
}

.route-halo-line{
  stroke:#fff;
  stroke-opacity:.96;
  paint-order:stroke;
  filter:drop-shadow(0 2px 4px rgba(0,0,0,.45));
}

.route-main-line{
  filter:drop-shadow(0 2px 5px rgba(0,0,0,.42));
}

.pro-marker{
  border:4px solid #fff;
  box-shadow:
    0 0 0 3px rgba(0,0,0,.22),
    0 12px 28px rgba(0,0,0,.48);
  text-shadow:0 1px 2px rgba(0,0,0,.5);
}

.pro-marker.next-stop{
  border:5px solid #fff;
  box-shadow:
    0 0 0 4px rgba(0,0,0,.22),
    0 0 0 12px rgba(37,99,235,.24),
    0 18px 38px rgba(0,0,0,.52);
}

.map.map-layer-satellite .leaflet-control-zoom a,
.map.map-layer-hybrid .leaflet-control-zoom a{
  background:#111!important;
  color:#fff!important;
  border-color:rgba(255,255,255,.22)!important;
}

.map.map-layer-satellite::after,
.map.map-layer-hybrid::after{
  content:'Satélite Pro';
  position:absolute;
  left:12px;
  bottom:12px;
  z-index:650;
  background:rgba(0,0,0,.68);
  color:#fff;
  border:1px solid rgba(255,255,255,.18);
  border-radius:999px;
  padding:6px 9px;
  font-size:10px;
  font-weight:900;
  pointer-events:none;
  backdrop-filter:blur(8px);
}

.map.map-layer-hybrid::after{
  content:'Híbrido: satélite + ruas';
}

.driver-floating-btn.layer-toggle{
  min-width:56px;
  background:#2563eb!important;
  color:#fff!important;
  border:1px solid rgba(255,255,255,.24)!important;
}

@media (max-width:860px){
  .map-layer-toggle{
    max-width:calc(100vw - 16px);
    overflow-x:auto;
  }

  .map-layer-toggle button{
    min-width:auto;
    padding-left:10px;
    padding-right:10px;
  }

  .map.map-layer-satellite::after,
  .map.map-layer-hybrid::after{
    left:8px;
    bottom:8px;
    font-size:9px;
  }
}


/* ===============================
   V3.1 — FOTO DO LOCAL / R2
   =============================== */

.driver-photo-wrap{
  margin:10px 0 8px;
}

.driver-photo-preview{
  width:100%;
  border:0;
  background:#111;
  color:#fff;
  border-radius:18px;
  padding:0;
  overflow:hidden;
  text-align:left;
  box-shadow:0 12px 30px rgba(0,0,0,.22);
}

.driver-photo-preview img{
  display:block;
  width:100%;
  height:138px;
  object-fit:cover;
  background:#222;
}

.driver-photo-preview span{
  display:block;
  padding:10px 12px;
  font-weight:950;
  font-size:13px;
}

.photo-action-btn{
  width:100%;
  min-height:46px;
  border:0;
  border-radius:16px;
  background:#111;
  color:#fff;
  font-weight:950;
  margin:0 0 9px;
}

.photo-action-btn.has-photo{
  background:#2563eb;
}

.driver-bottom-sheet.no-delivery .photo-action-btn{
  display:none;
}

.photo-viewer-dialog{
  border:0;
  padding:0;
  border-radius:24px;
  width:min(94vw,520px);
  max-width:520px;
  background:#000;
  color:#fff;
  box-shadow:0 22px 70px rgba(0,0,0,.55);
}

.photo-viewer-dialog::backdrop{
  background:rgba(0,0,0,.82);
}

.photo-viewer-dialog form{
  margin:0;
  padding:0;
}

.photo-viewer-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:13px 14px;
  border-bottom:1px solid rgba(255,255,255,.14);
}

.photo-close-btn{
  border:0;
  border-radius:999px;
  padding:8px 12px;
  background:#fff;
  color:#000;
  font-weight:950;
}

.photo-viewer-dialog img{
  display:block;
  width:100%;
  max-height:75vh;
  object-fit:contain;
  background:#050505;
}

.fixed-item.has-fixed-photo{
  padding-top:0;
  overflow:hidden;
}

.fixed-thumb{
  display:block;
  width:calc(100% + 22px);
  margin:-11px -11px 10px;
  height:96px;
  object-fit:cover;
  background:#222;
}

.map-popup-pro .popup-photo{
  width:100%;
  height:100px;
  object-fit:cover;
  border-radius:12px;
  margin-bottom:8px;
}

@media (max-width:420px){
  .driver-photo-preview img{
    height:118px;
  }

  body.is-short-screen .driver-photo-preview img{
    height:86px;
  }

  body.is-short-screen .photo-action-btn{
    min-height:40px;
    font-size:12px;
  }
}


/* ===============================
   V3.2 — CORREÇÃO MOBILE: OPÇÕES DO ENTREGADOR VISÍVEIS
   =============================== */

/* O problema visto no iPhone/DevTools era o card alto demais com foto,
   empurrando Entregue/Problema/Cancelar para fora da área visível. */

.view-driver .driver-bottom-sheet{
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}

.view-driver .driver-card{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.view-driver .driver-card-head{
  flex:0 0 auto;
}

.view-driver .driver-ref{
  flex:0 0 auto;
}

/* Foto mais baixa e operacional no mobile */
.driver-photo-wrap{
  margin:6px 0 4px;
}

.driver-photo-preview{
  border-radius:16px;
}

.driver-photo-preview img{
  height:92px;
}

.driver-photo-preview span{
  padding:7px 10px;
  font-size:12px;
}

/* Botão de foto compacto para não empurrar ações */
.photo-action-btn{
  min-height:40px;
  margin-bottom:6px;
  border-radius:14px;
  font-size:13px;
}

/* Ações sempre mais próximas e visíveis */
.view-driver .driver-actions{
  flex:0 0 auto;
  gap:7px;
  margin-bottom:6px;
}

.view-driver .success-btn,
.view-driver .warning-btn,
.view-driver .danger-btn,
.view-driver .wide-btn{
  min-height:44px;
  border-radius:14px;
  font-size:14px;
}

.more-actions-btn{
  display:none;
  width:100%;
  min-height:40px;
  border:0;
  border-radius:14px;
  background:#f1f1f1;
  color:#000;
  font-weight:950;
}

/* Em telas baixas, mostrar só as ações principais primeiro.
   O botão Mais opções revela mapa/foto/lista extra. */
body.is-short-screen .driver-bottom-sheet.active-delivery:not(.expanded-actions) .photo-action-btn,
body.is-short-screen .driver-bottom-sheet.active-delivery:not(.expanded-actions) .wide-btn{
  display:none;
}

body.is-short-screen .driver-bottom-sheet.active-delivery .more-actions-btn{
  display:block;
}

/* Em telas baixas, a foto vira faixa fina */
body.is-short-screen .driver-photo-preview img{
  height:68px;
}

body.is-short-screen .driver-photo-preview span{
  padding:6px 9px;
  font-size:11px;
}

body.is-short-screen .driver-bottom-sheet{
  max-height:58vh!important;
}

body.is-short-screen .view-driver .driver-card{
  padding:11px;
  gap:6px;
}

body.is-short-screen .view-driver .driver-card h2{
  font-size:18px;
}

body.is-short-screen .view-driver .driver-ref{
  font-size:12px;
  line-height:1.28;
  margin:3px 0 4px;
}

body.is-short-screen .view-driver .driver-card-head strong{
  min-width:44px;
  height:40px;
  font-size:15px;
}

/* iPhone/Android normal: reduz o excesso mas mantém tudo visível */
body[data-size="phone-sm"] .driver-photo-preview img,
body[data-size="phone-xs"] .driver-photo-preview img{
  height:78px;
}

body[data-size="phone-sm"] .driver-bottom-sheet.active-delivery,
body[data-size="phone-xs"] .driver-bottom-sheet.active-delivery{
  max-height:60vh!important;
}

body[data-size="phone-sm"] .view-driver .driver-card,
body[data-size="phone-xs"] .view-driver .driver-card{
  padding:12px;
}

body[data-size="phone-sm"] .view-driver .success-btn,
body[data-size="phone-sm"] .view-driver .warning-btn,
body[data-size="phone-sm"] .view-driver .danger-btn,
body[data-size="phone-sm"] .view-driver .wide-btn,
body[data-size="phone-xs"] .view-driver .success-btn,
body[data-size="phone-xs"] .view-driver .warning-btn,
body[data-size="phone-xs"] .view-driver .danger-btn,
body[data-size="phone-xs"] .view-driver .wide-btn{
  min-height:43px;
  font-size:13px;
}

/* Ajuste da lista: não deve roubar espaço do card principal */
.view-driver .driver-list.open{
  max-height:28vh;
}

body.is-short-screen .view-driver .driver-list.open{
  max-height:22vh;
}

/* Evita que a área inferior fique cortada atrás da barra do navegador */
.driver-bottom-sheet{
  padding-bottom:calc(10px + env(safe-area-inset-bottom))!important;
}

/* Em modo paisagem o card lateral pode ter rolagem interna */
body.is-landscape .driver-bottom-sheet{
  overflow-y:auto;
}

body.is-landscape .driver-photo-preview img{
  height:70px;
}


/* ===============================
   V3.3 — CORREÇÃO DE ZOOM DO MAPA
   =============================== */

/* O mapa precisa receber gesto de pinça/arrasto diretamente.
   Sem isso, alguns navegadores mobile tratam o gesto como rolagem da página/card. */
.map,
.leaflet-container,
.leaflet-pane,
.leaflet-map-pane,
.leaflet-tile-pane{
  touch-action:none!important;
  -ms-touch-action:none!important;
}

.leaflet-container{
  cursor:grab;
  user-select:none;
  -webkit-user-select:none;
  -webkit-tap-highlight-color:transparent;
}

.leaflet-container:active{
  cursor:grabbing;
}

/* Controles personalizados maiores para mobile */
.custom-zoom-control{
  position:absolute;
  z-index:955;
  display:flex;
  flex-direction:column;
  gap:6px;
  pointer-events:auto;
}

.custom-zoom-control button{
  width:46px;
  height:46px;
  border:0;
  border-radius:16px;
  background:#fff;
  color:#000;
  font-size:26px;
  line-height:1;
  font-weight:950;
  box-shadow:0 12px 32px rgba(0,0,0,.3);
}

.custom-zoom-control button:active{
  transform:scale(.96);
}

.admin-zoom-control{
  left:14px;
  top:74px;
}

.driver-zoom-control{
  left:max(10px, env(safe-area-inset-left));
  top:150px;
}

/* Em mobile, deixa zoom em área livre do mapa */
@media (max-width:860px){
  .admin-zoom-control{
    left:8px;
    top:104px;
  }

  .driver-zoom-control{
    left:8px;
    top:154px;
  }

  .custom-zoom-control button{
    width:42px;
    height:42px;
    border-radius:15px;
    font-size:24px;
  }

  /* O card inferior não deve capturar toque fora da área dele. */
  .driver-bottom-sheet{
    pointer-events:none;
  }

  .driver-bottom-sheet > *,
  .driver-card,
  .drawer-handle,
  .driver-list{
    pointer-events:auto;
  }

  /* Garante que a parte do mapa acima do card seja totalmente interativa. */
  .driver-map-wrap,
  .driver-mobile-app,
  .driver-map{
    touch-action:none!important;
  }
}

/* Em telas baixas, reposiciona para não conflitar com GPS/Status */
body.is-short-screen .driver-zoom-control{
  top:118px;
}

body.is-landscape .driver-zoom-control{
  top:72px;
  left:10px;
}

/* Mantém controles do Leaflet clicáveis, mas agora os personalizados são prioridade. */
.leaflet-control-zoom{
  display:none;
}

/* Desktop pode manter zoom nativo se quiser, mas deixamos o personalizado consistente. */
@media (min-width:861px){
  .leaflet-control-zoom{
    display:none;
  }
}


/* ===============================
   V3.4 — MAPA PREMIUM / BASEMAPS MELHORES
   =============================== */

.map-layer-toggle-premium{
  max-width:min(560px, calc(100vw - 28px));
  overflow-x:auto;
  scrollbar-width:none;
}

.map-layer-toggle-premium::-webkit-scrollbar{
  display:none;
}

.map-layer-toggle-premium button{
  min-width:auto;
  padding-left:12px;
  padding-right:12px;
}

.map-layer-toggle-premium button[data-layer="premium"].active{
  background:#000;
  color:#fff;
  outline:1px solid rgba(255,255,255,.35);
}

.map-layer-toggle-premium button[data-layer="light"].active{
  background:#e5e7eb;
  color:#000;
}

.map-layer-toggle-premium button[data-layer="hybrid"].active{
  background:#2563eb;
  color:#fff;
}

.map-quality-pill{
  position:absolute;
  left:14px;
  bottom:52px;
  z-index:920;
  background:rgba(0,0,0,.74);
  color:#fff;
  border:1px solid rgba(255,255,255,.18);
  border-radius:999px;
  padding:7px 10px;
  font-size:11px;
  font-weight:950;
  pointer-events:none;
  backdrop-filter:blur(8px);
  box-shadow:0 10px 28px rgba(0,0,0,.25);
}

.map.map-layer-premium .leaflet-tile-pane{
  filter:contrast(1.03) saturate(1.05);
}

.map.map-layer-light .leaflet-tile-pane{
  filter:contrast(1.06) brightness(1.03);
}

.map.map-layer-satellite .leaflet-tile-pane,
.map.map-layer-hybrid .leaflet-tile-pane{
  filter:brightness(1.09) contrast(1.15) saturate(1.15);
}

.map.map-layer-hybrid .hybrid-labels{
  mix-blend-mode:screen;
  filter:contrast(1.5) brightness(1.18) grayscale(.12);
}

.map.map-layer-light .status-marker,
.map.map-layer-premium .status-marker,
.map.map-layer-streets .status-marker{
  box-shadow:0 10px 26px rgba(0,0,0,.32);
}

.premium-marker{
  border:4px solid #fff;
  box-shadow:
    0 0 0 3px rgba(0,0,0,.18),
    0 14px 30px rgba(0,0,0,.45);
}

.premium-marker.next-stop{
  border:5px solid #fff;
  box-shadow:
    0 0 0 4px rgba(0,0,0,.22),
    0 0 0 13px rgba(37,99,235,.24),
    0 18px 42px rgba(0,0,0,.55);
}

.route-halo-line{
  stroke:#fff;
  stroke-opacity:.96;
  filter:drop-shadow(0 2px 5px rgba(0,0,0,.45));
}

.route-main-line{
  filter:drop-shadow(0 2px 5px rgba(0,0,0,.38));
}

.leaflet-control-scale{
  margin-left:12px!important;
  margin-bottom:12px!important;
}

.leaflet-control-scale-line{
  border-radius:8px;
  background:rgba(255,255,255,.86)!important;
  border:1px solid rgba(0,0,0,.22)!important;
  color:#000!important;
  font-weight:900;
}

.map.map-layer-satellite::after,
.map.map-layer-hybrid::after,
.map.map-layer-premium::after,
.map.map-layer-light::after{
  position:absolute;
  left:12px;
  bottom:12px;
  z-index:650;
  background:rgba(0,0,0,.68);
  color:#fff;
  border:1px solid rgba(255,255,255,.18);
  border-radius:999px;
  padding:6px 9px;
  font-size:10px;
  font-weight:900;
  pointer-events:none;
  backdrop-filter:blur(8px);
}

.map.map-layer-premium::after{
  content:'Mapa Premium';
}

.map.map-layer-light::after{
  content:'Mapa claro operacional';
}

.map.map-layer-satellite::after{
  content:'Satélite Premium';
}

.map.map-layer-hybrid::after{
  content:'Híbrido: satélite + ruas';
}

.driver-floating-btn.layer-toggle{
  min-width:62px;
  background:#2563eb!important;
  color:#fff!important;
  border:1px solid rgba(255,255,255,.24)!important;
}

@media (max-width:860px){
  .map-layer-toggle-premium{
    left:8px;
    right:8px;
    top:58px;
    max-width:calc(100vw - 16px);
  }

  .map-layer-toggle-premium button{
    font-size:10px;
    padding:8px 9px;
  }

  .map-quality-pill{
    left:8px;
    bottom:42px;
    font-size:9px;
  }

  .map.map-layer-satellite::after,
  .map.map-layer-hybrid::after,
  .map.map-layer-premium::after,
  .map.map-layer-light::after{
    left:8px;
    bottom:8px;
    font-size:9px;
  }
}

body.driver-mode .map-quality-pill{
  display:none;
}


/* ===============================
   V3.5 — SATÉLITE AVANÇADO + RASTREAMENTO REAL
   =============================== */

.live-track-btn.active-live{
  background:#16a34a!important;
  color:#fff!important;
  border:1px solid rgba(255,255,255,.35);
}

.driver-realtime-pill{
  position:absolute;
  right:14px;
  bottom:52px;
  z-index:921;
  background:rgba(22,163,74,.88);
  color:#fff;
  border:1px solid rgba(255,255,255,.2);
  border-radius:999px;
  padding:7px 10px;
  font-size:11px;
  font-weight:950;
  pointer-events:none;
  backdrop-filter:blur(8px);
  box-shadow:0 10px 28px rgba(0,0,0,.25);
}

.driver-realtime-pill.stale{
  background:rgba(217,48,37,.88);
}

.admin-driver-marker{
  width:42px;
  height:42px;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:#16a34a;
  color:#fff;
  border:4px solid #fff;
  box-shadow:
    0 0 0 4px rgba(0,0,0,.2),
    0 0 0 13px rgba(22,163,74,.22),
    0 14px 36px rgba(0,0,0,.45);
  animation:adminDriverPulse 1.35s infinite;
}

.admin-driver-marker span{
  font-size:19px;
  transform:translateY(1px);
}

@keyframes adminDriverPulse{
  0%{box-shadow:0 0 0 4px rgba(0,0,0,.2),0 0 0 4px rgba(22,163,74,.28),0 14px 36px rgba(0,0,0,.45)}
  70%{box-shadow:0 0 0 4px rgba(0,0,0,.2),0 0 0 18px rgba(22,163,74,0),0 14px 36px rgba(0,0,0,.45)}
  100%{box-shadow:0 0 0 4px rgba(0,0,0,.2),0 0 0 4px rgba(22,163,74,0),0 14px 36px rgba(0,0,0,.45)}
}

.driver-realtime-trail{
  filter:drop-shadow(0 2px 4px rgba(0,0,0,.35));
}

/* Satélite avançado: quando usar MapTiler com chave, o zoom pode ir até 22.
   Sem chave, Esri continua como fallback e será ampliado com maxNativeZoom. */
.map.map-layer-satellite.maptiler-active .leaflet-tile-pane,
.map.map-layer-hybrid.maptiler-active .leaflet-tile-pane{
  filter:brightness(1.1) contrast(1.16) saturate(1.18);
}

.map.map-layer-satellite:not(.maptiler-active)::after{
  content:'Satélite fallback • insira chave MapTiler para zoom melhor';
}

.map.map-layer-hybrid:not(.maptiler-active)::after{
  content:'Híbrido fallback • MapTiler melhora o zoom';
}

@media (max-width:860px){
  .driver-realtime-pill{
    right:8px;
    bottom:72px;
    max-width:calc(100vw - 16px);
    font-size:9px;
  }

  .map-quality-pill{
    bottom:96px;
  }
}

body.driver-mode .driver-realtime-pill,
body.driver-mode .map-quality-pill{
  display:none;
}


/* ===============================
   V3.6 — PRÓXIMAS ROTAS VISÍVEIS EMBAIXO
   =============================== */

/* A lista das próximas entregas agora aparece embaixo do card atual,
   em formato compacto, antes da gaveta da lista completa. */

.driver-next-routes-preview{
  margin-top:10px;
  background:#0f0f0f;
  color:#fff;
  border:1px solid rgba(255,255,255,.14);
  border-radius:20px;
  padding:10px;
}

.next-routes-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}

.next-routes-head strong{
  font-size:13px;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.next-routes-head span{
  min-width:28px;
  height:24px;
  border-radius:999px;
  display:grid;
  place-items:center;
  background:#fff;
  color:#000;
  font-size:12px;
  font-weight:950;
}

.next-routes-list{
  display:flex;
  flex-direction:column;
  gap:7px;
  max-height:190px;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.next-route-mini{
  width:100%;
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:center;
  gap:9px;
  min-height:52px;
  border:0;
  border-left:6px solid #777;
  border-radius:15px;
  background:#fff;
  color:#000;
  padding:8px 9px;
  text-align:left;
}

.next-route-mini.status-waiting{ border-left-color:#f97316; }
.next-route-mini.status-in_route{ border-left-color:#2563eb; }
.next-route-mini.status-done{ border-left-color:#16a34a; }
.next-route-mini.status-problem,
.next-route-mini.status-cancelled{ border-left-color:#dc2626; }

.next-route-order{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border-radius:13px;
  background:#000;
  color:#fff;
  font-size:13px;
  font-weight:950;
}

.next-route-info{
  min-width:0;
}

.next-route-info strong{
  display:block;
  font-size:13px;
  line-height:1.15;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.next-route-info small{
  display:block;
  margin-top:3px;
  color:#555;
  font-size:11px;
  line-height:1.18;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.next-route-status{
  border-radius:999px;
  padding:5px 7px;
  font-size:9px;
  font-weight:950;
  background:#efefef;
  color:#111;
}

.next-route-empty{
  color:#d1d1d1;
  font-size:12px;
  padding:8px 4px;
}

/* Garante que a parte de baixo possa aparecer sem ficar presa atrás da barra do navegador */
.view-driver .driver-bottom-sheet{
  max-height:72vh!important;
  overflow-y:auto!important;
  padding-bottom:calc(18px + env(safe-area-inset-bottom))!important;
}

/* Foto menor para liberar espaço para as próximas rotas */
.driver-photo-preview img{
  height:76px!important;
}

/* Em telas pequenas, mostra próximas rotas de forma mais compacta */
body[data-size="phone-sm"] .driver-next-routes-preview,
body[data-size="phone-xs"] .driver-next-routes-preview,
body.is-short-screen .driver-next-routes-preview{
  margin-top:8px;
  padding:8px;
  border-radius:17px;
}

body[data-size="phone-sm"] .next-routes-list,
body[data-size="phone-xs"] .next-routes-list,
body.is-short-screen .next-routes-list{
  max-height:124px;
  gap:6px;
}

body[data-size="phone-sm"] .next-route-mini,
body[data-size="phone-xs"] .next-route-mini,
body.is-short-screen .next-route-mini{
  min-height:46px;
  grid-template-columns:auto 1fr;
}

body[data-size="phone-sm"] .next-route-status,
body[data-size="phone-xs"] .next-route-status,
body.is-short-screen .next-route-status{
  display:none;
}

body[data-size="phone-sm"] .next-route-order,
body[data-size="phone-xs"] .next-route-order,
body.is-short-screen .next-route-order{
  width:34px;
  height:34px;
  border-radius:12px;
  font-size:12px;
}

body[data-size="phone-sm"] .next-route-info strong,
body[data-size="phone-xs"] .next-route-info strong,
body.is-short-screen .next-route-info strong{
  font-size:12px;
}

body[data-size="phone-sm"] .next-route-info small,
body[data-size="phone-xs"] .next-route-info small,
body.is-short-screen .next-route-info small{
  font-size:10px;
}

/* Em entrega ativa, botões continuam visíveis antes da lista */
.driver-bottom-sheet.active-delivery .driver-actions{
  position:relative;
  z-index:2;
}

.driver-bottom-sheet.no-delivery .driver-next-routes-preview{
  display:none;
}

/* A lista completa continua como gaveta, abaixo da prévia */
.view-driver .drawer-handle{
  margin-top:9px;
}

.view-driver .driver-list.open{
  max-height:26vh;
}

/* Para a tela do print, evita que o botão inferior fique cortado */
@media (max-width:430px){
  .view-driver .driver-bottom-sheet{
    max-height:74vh!important;
  }

  .view-driver .driver-card{
    padding:12px!important;
  }

  .view-driver .driver-ref{
    margin-bottom:6px!important;
  }
}


/* ===============================
   V3.7 — JUSTIFICATIVAS DE PROBLEMAS/CANCELADAS
   =============================== */

.delivery-reason-summary{
  margin:10px 0;
  padding:10px;
  border-radius:14px;
  background:#fff7ed;
  color:#111;
  border-left:6px solid #f97316;
}

.delivery-reason-summary.status-cancelled{
  background:#fef2f2;
  border-left-color:#dc2626;
}

.reason-summary-title{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
  margin-bottom:6px;
}

.reason-summary-title strong{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.reason-summary-title span{
  color:#555;
  font-size:11px;
  font-weight:900;
  white-space:nowrap;
}

.delivery-reason-summary p{
  margin:4px 0;
  font-size:12px;
  line-height:1.35;
  color:#222;
}

.reason-viewer-dialog{
  border:0;
  padding:0;
  width:min(94vw,520px);
  border-radius:24px;
  background:#fff;
  color:#000;
  box-shadow:0 22px 70px rgba(0,0,0,.42);
}

.reason-viewer-dialog::backdrop{
  background:rgba(0,0,0,.72);
}

.reason-viewer-dialog form{
  margin:0;
}

.reason-viewer-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  background:#000;
  color:#fff;
  padding:16px;
}

.reason-viewer-head strong{
  display:block;
  font-size:16px;
  line-height:1.2;
}

.reason-viewer-head span{
  display:block;
  color:#ddd;
  font-size:12px;
  margin-top:4px;
}

.reason-close-btn{
  border:0;
  border-radius:999px;
  background:#fff;
  color:#000;
  padding:8px 12px;
  font-weight:950;
}

.reason-viewer-body{
  padding:16px;
}

.reason-viewer-row{
  border:1px solid #e5e5e5;
  border-radius:16px;
  padding:12px;
  margin-bottom:10px;
  background:#fafafa;
}

.reason-viewer-row span{
  display:block;
  color:#777;
  font-size:11px;
  font-weight:950;
  text-transform:uppercase;
  letter-spacing:.1em;
  margin-bottom:5px;
}

.reason-viewer-row strong,
.reason-viewer-row p{
  margin:0;
  color:#111;
  font-size:15px;
  line-height:1.35;
}

.popup-reason-mini{
  margin:7px 0;
  padding:7px;
  border-radius:10px;
  background:#fff7ed;
  color:#111;
  font-size:11px;
  line-height:1.35;
  border-left:4px solid #f97316;
}

.delivery-column:nth-child(4) .delivery-card{
  border-left-width:7px;
}

/* Destaca o botão Ver justificativa no painel de problemas */
.delivery-card.status-problem [data-action="viewReason"],
.delivery-card.status-cancelled [data-action="viewReason"]{
  background:#111!important;
  color:#fff!important;
}

@media (max-width:860px){
  .reason-viewer-dialog{
    width:94vw;
    border-radius:20px;
  }

  .reason-viewer-head{
    padding:14px;
  }

  .reason-viewer-body{
    padding:12px;
  }
}
