:root{
  --bg:#f5f6f8;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --border: rgba(0,0,0,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.08);

  --primary:#cc0000;
  --primary-dark:#990000;

  --green:#1f7a2e;
  --green-dark:#166023;

  --neutral:#374151;

  --sidebar-a:#0f172a;
  --sidebar-b:#111827;
}

body.dark{
  --bg:#0b1220;
  --card:#0f172a;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --border: rgba(255,255,255,.10);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* ======================================================
   RESET + BASE
====================================================== */
*{box-sizing:border-box}

html, body{
  height:100%;
  margin:0;
  padding:0;
}

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

img,
iframe,
video,
canvas{
  max-width:100%;
  display:block;
}

.hidden{display:none !important}

/* ======================================================
   TOPBAR
====================================================== */
.topbar{
  min-height:64px;
  background:var(--card);
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
  position:sticky;
  top:0;
  z-index:50;
  gap:12px;
}

.topbar-left{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.topbar-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.icon-btn{
  border:0;
  background:transparent;
  cursor:pointer;
  width:40px;
  height:40px;
  border-radius:10px;
  color:var(--text);
  font-size:18px;
}

.icon-btn:hover{background:rgba(0,0,0,.05)}
body.dark .icon-btn:hover{background:rgba(255,255,255,.06)}

.brand-logo{
  width:40px;
  height:40px;
  object-fit:contain;
  border-radius:10px;
}

.brand-text{
  display:flex;
  flex-direction:column;
  line-height:1.05;
  min-width:0;
}

.brand-text strong,
.brand-text span{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.brand-text span{
  font-size:12px;
  color:var(--muted);
}

.pill{
  border:1px solid var(--border);
  background:var(--card);
  padding:8px 12px;
  border-radius:999px;
  cursor:pointer;
  color:var(--text);
}

.user-menu{position:relative}

.user-btn{
  border:1px solid var(--border);
  background:var(--card);
  padding:8px 12px;
  border-radius:10px;
  cursor:pointer;
  color:var(--text);
}

.user-dropdown{
  position:absolute;
  right:0;
  top:44px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
  box-shadow:var(--shadow);
  display:none;
  min-width:180px;
  z-index:60;
}

.user-dropdown.open{display:block}

.user-dropdown button{
  width:100%;
  border:0;
  background:transparent;
  padding:10px 12px;
  text-align:left;
  cursor:pointer;
  color:var(--text);
}

.user-dropdown button:hover{background:rgba(0,0,0,.06)}
body.dark .user-dropdown button:hover{background:rgba(255,255,255,.06)}

/* botão home/topo */
#btnHomeTop,
.top-action-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  height:40px;
  padding:0 14px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  font-size:14px;
  font-weight:700;
  cursor:pointer;
  transition:.2s ease;
  white-space:nowrap;
}

#btnHomeTop:hover,
.top-action-btn:hover{
  background:rgba(0,0,0,.05);
}

body.dark #btnHomeTop:hover,
body.dark .top-action-btn:hover{
  background:rgba(255,255,255,.06);
}

#btnHomeTop i,
.top-action-btn i{
  font-size:14px;
}

/* ======================================================
   APP + SIDEBAR
====================================================== */
.app{
  display:flex;
  min-height:calc(100vh - 64px);
}

.sidebar{
  width:86px;
  min-width:86px;
  background:linear-gradient(180deg, var(--sidebar-b), var(--sidebar-a));
  color:#fff;
  padding:12px 10px;
  display:flex;
  flex-direction:column;
  gap:10px;
  transition:.2s;
  position:relative;
  overflow:hidden;
}

.sidebar::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  width:6px;
  height:100%;
  background:var(--primary);
}

.sidebar.expanded{
  width:240px;
  min-width:240px;
}

.sidebar-top{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:6px 0 10px;
}

.sidebar-logo{
  width:44px;
  height:44px;
  border-radius:14px;
  object-fit:contain;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.2);
}

.sidebar-nav{
  display:flex;
  flex-direction:column;
  gap:10px;
  flex:1;
}

.sidebar-bottom{
  padding-top:8px;
  border-top:1px solid rgba(255,255,255,.06);
}

.nav-item{
  width:56px;
  height:56px;
  border-radius:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  transition:all .18s ease;
  margin:0 auto;
  flex-shrink:0;
}

.nav-ico i{
  font-size:18px;
  color:#cbd5e1;
  transition:.18s;
}

.nav-item:hover{
  background:rgba(255,255,255,.08);
}

.nav-item.active{
  background:#ffffff;
  box-shadow:0 10px 20px rgba(0,0,0,.18);
}

.nav-item.active .nav-ico i{
  color:var(--primary);
}

.nav-text{display:none}

.sidebar.expanded .nav-item{
  width:auto;
  justify-content:flex-start;
  padding:0 14px;
  gap:10px;
}

.sidebar.expanded .nav-text{
  display:inline;
  color:#fff;
  font-weight:600;
}

.sidebar.expanded .nav-item.active .nav-text{
  color:#111827;
}

/* ======================================================
   CONTENT / PANELS
====================================================== */
.content{
  flex:1;
  padding:16px;
  min-width:0;
}

.grid{
  width:100%;
  max-width:none;
  min-width:0;
}

.panel{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow);
  overflow:hidden;
  min-width:0;
}

.panel-header{
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid var(--border);
  gap:10px;
  flex-wrap:wrap;
}

.panel-header h2{
  margin:0;
  font-size:18px;
}

.panel-body{
  padding:16px;
  min-width:0;
}

/* ======================================================
   BOTÕES
====================================================== */
.btn-primary,
.btn-green,
.btn-confirm,
.btn-cancel,
.btn-secondary,
.btn-next,
.danger-ghost{
  border:0;
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  font-weight:900;
}

.btn-primary{
  background:var(--primary);
  color:#fff;
}

.btn-primary:hover{background:var(--primary-dark)}

.btn-green,
.btn-confirm{
  background:var(--green);
  color:#fff;
}

.btn-green:hover,
.btn-confirm:hover{
  background:var(--green-dark);
}

.btn-cancel{
  background:var(--neutral);
  color:#fff;
}

.btn-secondary{
  background:#111827;
  color:#fff;
}

.btn-secondary:hover{
  filter:brightness(.95);
}

.btn-next{
  background:var(--green);
  color:#fff;
}

.btn-next:disabled{
  opacity:.55;
  cursor:not-allowed;
  filter:grayscale(30%);
}

.danger-ghost{
  border:1px solid var(--border);
  background:transparent;
  color:var(--primary);
  font-weight:800;
}

.danger-ghost:hover{
  background:rgba(204,0,0,.08);
}

/* ======================================================
   FORM
====================================================== */
.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-bottom:12px;
}

.field span{
  font-size:12px;
  color:var(--muted);
}

.field input,
.field select,
.field textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:12px;
  outline:none;
  background:var(--card);
  color:var(--text);
}

.field textarea{
  min-height:90px;
  resize:vertical;
}

.two-cols{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.checkbox{
  display:flex;
  align-items:center;
  gap:8px;
  margin:8px 0 12px;
  color:var(--muted);
}

.form-card{
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  min-width:0;
}

.form-card-top{
  display:flex;
  justify-content:center;
  margin-bottom:12px;
}

.action-buttons,
.form-actions,
.next-actions,
.tg-modal-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.form-actions{
  justify-content:flex-end;
  margin-top:10px;
}

.next-actions{
  margin-top:12px;
}

.action-buttons > *,
.form-actions > *,
.next-actions > *,
.tg-modal-actions > *{
  min-width:0;
}

/* ======================================================
   RESUMO ENDEREÇO
====================================================== */
.pickup-card{
  display:flex;
  gap:12px;
  align-items:flex-start;
  background:rgba(0,0,0,.03);
  border:1px solid var(--border);
  padding:12px;
  border-radius:14px;
  margin-bottom:12px;
  position:relative;
}

body.dark .pickup-card{
  background:rgba(255,255,255,.04);
}

.pickup-ico{
  width:38px;
  height:38px;
  border-radius:12px;
  background:var(--primary);
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  flex-shrink:0;
}

.pickup-title{font-weight:900}

.pickup-sub{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}

.pickup-badge{
  position:absolute;
  right:10px;
  top:10px;
  font-size:12px;
  color:var(--primary);
  font-weight:900;
}

/* ======================================================
   LAYOUT FORM + MAPA
====================================================== */
.cliente-layout{
  display:flex;
  gap:18px;
  align-items:stretch;
  min-width:0;
}

.form-area{
  flex:0 0 520px;
  min-width:0;
}

.map-area{
  flex:1 1 auto;
  min-width:0;
}

.map-body{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:14px;
  height:calc(100vh - 140px);
  box-sizing:border-box;
  min-width:0;
}

/* métricas */
.tg-metrics{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:12px;
}

.tg-metric{
  display:flex;
  align-items:center;
  gap:12px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px 14px;
  min-width:0;
}

.tg-metric-ico{
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  border-radius:999px;
  border:2px solid var(--green);
  color:var(--green);
  background:rgba(31,122,46,.08);
  flex-shrink:0;
}

.tg-metric-txt small{
  display:block;
  font-size:12px;
  color:var(--muted);
}

.tg-metric-txt strong{
  display:block;
  font-size:15px;
  font-weight:900;
  color:var(--text);
}

/* mapa */
#map{
  flex:1;
  width:100%;
  min-width:0;
  min-height:420px;
  border-radius:14px;
  overflow:hidden;
  border:1px solid var(--border);
}

.leaflet-container{
  border-radius:14px;
}

/* ======================================================
   MODAL SUCESSO
====================================================== */
.tg-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:999;
  visibility:hidden;
  opacity:0;
  transition:.2s;
}

.tg-modal.active{
  visibility:visible;
  opacity:1;
}

.tg-modal-box{
  background:var(--card);
  padding:30px;
  border-radius:18px;
  width:420px;
  max-width:90%;
  text-align:center;
  box-shadow:var(--shadow);
  min-width:0;
}

.tg-check{
  width:90px;
  height:90px;
  margin:0 auto 15px;
  border-radius:50%;
  border:4px solid var(--green);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:36px;
  color:var(--green);
}

.tg-modal-info{
  margin:15px 0 20px;
  text-align:left;
}

.tg-modal-info p{
  margin:6px 0;
  font-size:14px;
}

/* ======================================================
   RESPONSIVO
====================================================== */
@media (max-width: 1100px){
  .cliente-layout{
    flex-direction:column;
  }

  .form-area,
  .map-area{
    width:100%;
    flex:1 1 auto;
  }

  .map-body{
    height:auto;
  }

  #map{
    height:420px;
    min-height:420px;
    flex:none;
  }

  .tg-metrics{
    grid-template-columns:1fr;
  }
}

@media (max-width: 768px){
  html,
  body{
    overflow-x:hidden;
  }

  .topbar{
    height:auto;
    padding:10px 12px;
    flex-wrap:wrap;
  }

  .topbar-left,
  .topbar-right{
    width:100%;
  }

  .topbar-left{
    justify-content:flex-start;
  }

  .topbar-right{
    justify-content:flex-end;
  }

  .brand-logo{
    width:36px;
    height:36px;
  }

  .brand-text strong{
    font-size:15px;
  }

  .brand-text span{
    font-size:11px;
  }

  .app{
    flex-direction:column;
    min-height:calc(100vh - 64px);
  }

  .sidebar{
    width:100%;
    min-width:100%;
    height:auto;
    flex-direction:row;
    align-items:center;
    justify-content:space-between;
    overflow-x:auto;
    padding:10px 8px;
    gap:8px;
  }

  .sidebar::before{
    width:100%;
    height:4px;
    top:auto;
    bottom:0;
  }

  .sidebar.expanded{
    width:100%;
    min-width:100%;
  }

  .sidebar-top{
    display:none;
  }

  .sidebar-nav{
    flex-direction:row;
    align-items:center;
    gap:8px;
    flex:1;
  }

  .sidebar-bottom{
    border-top:0;
    padding-top:0;
  }

  .nav-item{
    width:52px;
    height:52px;
    min-width:52px;
    margin:0;
    border-radius:14px;
  }

  .sidebar.expanded .nav-item{
    width:52px;
    padding:0;
    justify-content:center;
  }

  .nav-text,
  .sidebar.expanded .nav-text{
    display:none !important;
  }

  .content{
    padding:12px;
  }

  .panel-header{
    padding:12px;
  }

  .panel-body{
    padding:12px;
  }

  .panel-header h2{
    font-size:16px;
  }

  .two-cols{
    grid-template-columns:1fr;
    gap:10px;
  }

  .field input,
  .field select,
  .field textarea{
    font-size:16px;
  }

  .action-buttons,
  .form-actions,
  .next-actions,
  .tg-modal-actions{
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
  }

  .btn-primary,
  .btn-green,
  .btn-confirm,
  .btn-cancel,
  .btn-secondary,
  .btn-next,
  .danger-ghost,
  #btnHomeTop,
  .top-action-btn,
  .pill,
  .user-btn{
    width:100%;
    justify-content:center;
  }

  .pickup-card{
    padding:12px;
  }

  .pickup-badge{
    position:static;
    margin-left:auto;
  }

  .tg-metric{
    padding:12px;
  }

  .tg-metric-txt strong{
    font-size:14px;
  }

  #map{
    height:320px;
    min-height:320px;
    border-radius:12px;
  }

  .tg-modal-box{
    width:calc(100% - 24px);
    padding:20px;
    border-radius:16px;
  }

  .tg-check{
    width:74px;
    height:74px;
    font-size:28px;
  }

  .tg-modal-info{
    margin:12px 0 16px;
  }
}

@media (max-width: 480px){
  .topbar{
    padding:8px 10px;
  }

  .brand-text strong{
    font-size:14px;
  }

  .brand-text span{
    font-size:10px;
  }

  .content{
    padding:10px;
  }

  .panel,
  .form-card{
    border-radius:12px;
  }

  .panel-header,
  .panel-body{
    padding-left:10px;
    padding-right:10px;
  }

  .nav-item{
    width:48px;
    height:48px;
    min-width:48px;
  }

  #map{
    height:280px;
    min-height:280px;
  }
}
/* ===== PATCH APENAS VISUAL LOGIN/CADASTRO ===== */

.auth-page,
.auth-body {
  background: #f3f4f6;
}

.auth-shell,
.auth-wrap {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.auth-box,
.auth-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.10);
}

.auth-top,
.auth-brand {
  display: flex;
  justify-content: center;
  padding: 20px 16px 10px;
}

.auth-logo,
.auth-brand img {
  width: 90px;
  max-width: 90px;
  height: auto;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f7f7f7;
  border-bottom: 1px solid #e5e7eb;
}

.auth-tab {
  flex: 1;
  padding: 14px;
  border: 0;
  cursor: pointer;
  background: #fff;
  color: #111;
  font-weight: 700;
}

.auth-tab.active,
.auth-tab.is-active {
  background: #c40000;
  color: #fff;
}

.auth-tabview,
.auth-pane {
  display: none;
  padding: 20px;
}

.auth-tabview.active,
.auth-pane.is-active {
  display: block;
}

.auth-title {
  text-align: center;
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-sub {
  text-align: center;
  margin: 0 0 16px;
  color: #666;
  font-size: 14px;
}

.auth-form label {
  display: block;
  font-size: 13px;
  margin: 10px 0 6px;
  color: #333;
  font-weight: 600;
}

.auth-form input,
.auth-form textarea,
.auth-form select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  outline: 0;
  font-size: 14px;
}

.auth-form input:focus,
.auth-form textarea:focus,
.auth-form select:focus {
  border-color: #c40000;
  box-shadow: 0 0 0 3px rgba(196,0,0,.10);
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.auth-actions .btn,
.auth-actions button,
.auth-form .btn,
.auth-form button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.tg-primary {
  background: #c40000;
  color: #fff;
}

.tg-secondary {
  background: #4f81ff;
  color: #fff;
}

.tg-success {
  background: #2eaf4a;
  color: #fff;
}

.auth-hint {
  margin-top: 10px;
  text-align: center;
  color: #c40000;
  font-weight: 600;
}

.auth-footer {
  text-align: center;
  margin-top: 12px;
}

.step {
  display: none;
}

.step.active {
  display: block;
}

.auth-radios {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 10px 0 12px;
  font-size: 14px;
  flex-wrap: wrap;
}

.auth-radios label {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 520px) {
  .auth-box,
  .auth-card {
    max-width: 100%;
    border-radius: 10px;
  }

  .auth-actions {
    flex-direction: column;
  }

  .auth-tabview,
  .auth-pane {
    padding: 16px;
  }

  .auth-logo,
  .auth-brand img {
    width: 76px;
    max-width: 76px;
  }

  .auth-title {
    font-size: 18px;
  }
}