* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Roboto, sans-serif; }
html, body { height: 100%; width: 100%; overflow: hidden; }
[hidden] { display: none !important; }

/* Tela de código de acesso */
#login {
  position: fixed;
  inset: 0;
  background: #1a202c;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 16px;
}
.login-card {
  background: #fff;
  border-radius: 10px;
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.login-card h1 { font-size: 1.1rem; color: #1a202c; margin-bottom: 4px; }
.login-card p { font-size: 0.8rem; color: #64748b; margin-bottom: 16px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1.2rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  letter-spacing: 0.25em;
  text-align: center;
}
.login-card button {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: #2563eb;
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:disabled { opacity: 0.6; cursor: wait; }
#login-err { color: #dc2626; font-size: 0.8rem; min-height: 1.2em; margin-top: 8px; text-align: center; }

#app { display: flex; height: 100vh; width: 100vw; }

#sidebar {
  width: 400px;
  height: 100%;
  background: #ffffff;
  box-shadow: 2px 0 10px rgba(0,0,0,0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px;
  background: #1a202c;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.sidebar-header h1 { font-size: 1.15rem; margin-bottom: 4px; }
.sidebar-header p { font-size: 0.8rem; color: #cbd5e0; }
#btn-sair {
  background: transparent;
  color: #cbd5e0;
  border: 1px solid #4a5568;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
#btn-sair:hover { background: #2d3748; }

.fase-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 6px;
  background: #111827;
}
.fase-btn {
  padding: 7px 8px;
  border: 1px solid #374151;
  background: transparent;
  color: #9ca3af;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.fase-btn:hover { background: #1f2937; color: #e5e7eb; }
.fase-btn[aria-pressed="true"] {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  cursor: default;
}
.fase-btn[disabled] { opacity: 0.55; cursor: wait; }

.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #2d3748;
  color: #fff;
  padding: 10px 6px;
  font-size: 0.72rem;
  gap: 4px;
}
.summary-item { text-align: center; }
.summary-item strong { display: block; font-size: 1.05rem; color: #63b3ed; font-variant-numeric: tabular-nums; }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.78rem;
  color: #475569;
  flex-wrap: wrap;
}
.controls input { width: 52px; padding: 3px 5px; border: 1px solid #cbd5e0; border-radius: 4px; font-size: 0.8rem; }
.controls button, .btn {
  padding: 4px 8px;
  border: 1px solid #cbd5e0;
  background: #fff;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  color: #334155;
  text-decoration: none;
  display: inline-block;
}
.controls button:hover, .btn:hover { background: #e2e8f0; }

.loc-list { flex: 1; overflow-y: auto; padding: 12px; }

.region-card {
  margin-bottom: 12px;
  border-radius: 8px;
  border-left: 5px solid;
  background: #f7fafc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
}

.region-card-title {
  padding: 8px 12px 4px;
  font-weight: bold;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #edf2f7;
  cursor: pointer;
}
.region-stats {
  padding: 2px 12px 8px;
  background: #edf2f7;
  font-size: 0.78rem;
  color: #334155;
  font-variant-numeric: tabular-nums;
}
.region-stats b { color: #0f172a; }
.progress { height: 5px; background: #cbd5e0; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.progress > div { height: 100%; background: #16a34a; transition: width 0.3s; }
.region-nav { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

.place-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 12px;
  border-top: 1px solid #e2e8f0;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.place-item:hover { background: #e2e8f0; }
.place-item .chk { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; cursor: pointer; accent-color: #16a34a; }
.place-body { flex: 1; min-width: 0; }
.place-item.done { background: #f0fdf4; }
.place-item .chk { accent-color: #16a34a; }
.place-item.done .place-name { text-decoration: line-through; color: #64748b; }
.done-info { color: #15803d; font-size: 0.72rem; font-weight: 600; margin-top: 3px; }

/* escola comecada mas nao terminada (so na fase Montagem) */
.place-item.partial { background: #fffbeb; }
.place-item.partial .chk { accent-color: #f59e0b; }
.done-info.partial { color: #a16207; }

.place-name { font-weight: 600; color: #2d3748; }
.place-addr { color: #718096; font-size: 0.75rem; margin-top: 2px; }
.leg { color: #475569; font-size: 0.72rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.prec { font-size: 0.65rem; padding: 0 4px; border-radius: 3px; margin-left: 4px; font-weight: 600; text-decoration: none; display: inline-block; }
.prec-escola { background: #dcfce7; color: #166534; }
.prec-rua { background: #fef9c3; color: #854d0e; }
.prec-aprox { background: #fee2e2; color: #991b1b; }
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: bold;
  color: #fff;
  float: right;
}

#map { flex: 1; height: 100%; }

.custom-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
  font-size: 11px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
.btn-entrega {
  margin-top: 8px;
  width: 100%;
  padding: 6px;
  border: 0;
  border-radius: 4px;
  background: #16a34a;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.btn-entrega.undo { background: #e2e8f0; color: #334155; }

/* contador de telas montadas dentro do pino */
.mont-prog {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 4px;
}
.mont-prog > span { flex: 1; color: #78350f; }
.mont-prog .step {
  width: 34px;
  height: 30px;
  border: 1px solid #d97706;
  border-radius: 4px;
  background: #fff;
  color: #b45309;
  font-size: 17px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
}
.mont-prog .step:hover:not(:disabled) { background: #fef3c7; }
.mont-prog .step:disabled { opacity: 0.35; cursor: default; }
/* sem origem: o Google Maps usa a localização atual de quem clicou */
.btn-maps {
  display: block;
  margin-top: 8px;
  padding: 6px;
  border-radius: 4px;
  background: #2563eb;
  color: #fff !important;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.btn-maps:hover { background: #1d4ed8; }
.legend {
  background: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.3);
  font-size: 0.72rem;
  line-height: 1.6;
  color: #334155;
}
#status { font-size: 0.72rem; color: #64748b; padding: 4px 12px; }
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  z-index: 4000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-width: calc(100vw - 32px);
}
#toast.err { background: #dc2626; }

/* Janela de informações (botão Info) */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4500;
  padding: 16px;
}
.modal-card {
  position: relative;
  background: #fff;
  border-radius: 10px;
  max-width: 520px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 22px 22px 18px;
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.modal-card h2 { font-size: 1.05rem; color: #0f172a; margin-bottom: 8px; padding-right: 28px; }
.modal-card h3 { font-size: 0.85rem; color: #0f172a; margin: 16px 0 6px; }
.modal-card ul { padding-left: 18px; margin: 4px 0; }
.modal-card li { margin: 3px 0; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}
.formula {
  background: #f1f5f9;
  border-left: 3px solid #2563eb;
  padding: 8px 10px;
  margin: 10px 0;
  font-weight: 600;
  color: #0f172a;
}
.conta { width: 100%; border-collapse: collapse; margin-top: 4px; font-variant-numeric: tabular-nums; }
.conta td { padding: 4px 0; border-bottom: 1px solid #e2e8f0; }
.conta td:last-child { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 12px; }
.conta tr.tot td { border-bottom: 0; border-top: 2px solid #0f172a; font-weight: 700; color: #0f172a; }
.legend-list { list-style: none; padding-left: 0 !important; }
.legend-list li { display: flex; align-items: center; gap: 8px; }
.mini-pin { width: 20px; height: 20px; font-size: 10px; flex-shrink: 0; }

/* Celular: mapa em cima, lista embaixo — a tela inteira rola */
@media (max-width: 760px) {
  html, body { height: auto; overflow-x: hidden; overflow-y: auto; }
  #app { flex-direction: column; height: auto; min-height: 100vh; }
  #map { order: 1; flex: none; height: 45vh; }
  #sidebar { order: 2; width: 100%; height: auto; box-shadow: 0 -2px 10px rgba(0,0,0,0.15); }
  .loc-list { flex: none; overflow: visible; }
  .sidebar-header { padding: 10px 12px; }
  .sidebar-header p { display: none; }
  .legend { display: none; }
}
