: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;
  }
}
