:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-light: #f8fafc;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --gray: #64748b;

  --prme-navy: #0E2A4C;
  --prme-blue: #1D5DA6;
  --prme-blue-soft: #EAF1FA;
  --prme-gold: #E8A23D;
  --prme-gold-deep: #C67F1E;
  --prme-ink: #1B2233;
  --prme-muted: #667085;
  --prme-line: #E3E7EE;
  --prme-line-soft: #EEF1F5;
}

.print-only { display: none; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e293b);
}

.login-card {
  background: #fff;
  padding: 2.5rem 2.5rem;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  width: 340px;
  max-width: calc(100% - 2rem);
}

.login-card h1 {
  font-size: 1.4rem;
  margin: 0 0 1.5rem;
  text-align: center;
  color: #0f172a;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  color: #475569;
}

.login-card input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  margin-bottom: 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1rem;
}

.login-card button {
  width: 100%;
  padding: 0.7rem;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

.login-card button:hover { background: #1e293b; }

.error-msg {
  background: #fee2e2;
  color: #b91c1c;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ---------- App shell ---------- */
.topbar {
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
}

.topbar a { color: #e2e8f0; text-decoration: none; }
.topbar .brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav a { margin-left: 1.2rem; font-size: 0.9rem; }
.topbar nav a.active, .topbar nav a:hover { color: var(--accent); }
.topbar form { display: inline; margin-left: 1.2rem; }

.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown-toggle { display: inline-flex; align-items: center; gap: 0.25rem; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 1.2rem;
  margin-top: 0.5rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.4rem;
  min-width: 160px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  z-index: 20;
}
.nav-dropdown-menu a {
  display: block;
  margin-left: 0;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: rgba(255,255,255,0.08); }
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.topbar button.logout {
  background: none;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.container { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  color: #fff;
  background: #0f172a;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--accent); color: #0f172a; font-weight: 600; }
.btn-danger { background: var(--red); }
.btn-secondary { background: #64748b; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.filters input, .filters select {
  padding: 0.45rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #334155;
  padding: 0 0.2rem;
}
.checkbox-field input { padding: 0; width: auto; }

.table-wrap { overflow-x: auto; border-radius: 8px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
th, td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.88rem;
}
th { background: #f1f5f9; color: #334155; font-weight: 600; }
tr:hover { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}
.badge-entregue { background: var(--green); }
.badge-nao_entregue { background: var(--red); }
.badge-sem_entrega { background: var(--gray); }

.actions a, .actions button {
  margin-right: 0.4rem;
  font-size: 0.8rem;
}

.gap-row td {
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 8px, #f1f5f9 8px, #f1f5f9 16px);
  color: #94a3b8;
}
.gap-row td:first-child { font-weight: 600; color: #64748b; }
.gap-label { font-style: italic; font-size: 0.85rem; }

.form-card {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  max-width: 560px;
}
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; color: #475569; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}
.form-actions { display: flex; gap: 0.6rem; margin-top: 1.2rem; }

.errors {
  background: #fee2e2;
  color: #b91c1c;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.errors ul { margin: 0; padding-left: 1.2rem; }

/* ---------- Dashboard TV ---------- */
.tv-body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-family: 'Segoe UI', Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

.tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2rem 0.6rem;
  border-bottom: 2px solid var(--border);
}

.tv-header h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.5px;
}

.tv-header-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.tv-clock { font-size: 1.4rem; color: var(--accent); font-variant-numeric: tabular-nums; }

.tv-map-btn {
  background: var(--accent);
  color: #0f172a;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.tv-map-btn:hover { opacity: 0.9; }

.tv-back-btn {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}
.tv-back-btn:hover { background: rgba(255,255,255,0.16); }

.map-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.map-modal[hidden] { display: none; }

.map-modal-inner {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  height: 100%;
  max-width: 1300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.map-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.4rem;
  background: var(--bg);
  color: #fff;
  flex-shrink: 0;
}
.map-modal-header h2 { margin: 0; font-size: 1.15rem; }

.map-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}
.map-modal-close:hover { color: var(--accent); }

.map-container { flex: 1; width: 100%; }

.map-popup-list { margin-top: 0.4rem; max-height: 180px; overflow-y: auto; }
.map-popup-row { font-size: 0.8rem; padding: 0.1rem 0; }

/* ---------- Dia em foco (dashboard) ---------- */
.day-modal-inner {
  max-width: 720px;
  height: auto;
  max-height: 85vh;
  background: var(--panel);
}

.day-modal-summary {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.4rem 0;
}
.day-modal-summary .tv-stat { font-size: 0.8rem; padding: 0.25rem 0.7rem; }

.day-modal-cards {
  padding: 1rem 1.4rem 1.4rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.7rem;
}
.day-modal-cards .tv-card {
  font-size: 0.9rem;
  padding: 0.75rem 0.9rem;
  line-height: 1.5;
}
.day-modal-cards .tv-card .inv-num { font-size: 0.85rem; }
.day-modal-cards .tv-card .cidade { font-size: 0.9rem; }
.day-modal-cards .tv-card .meta { font-size: 0.78rem; }
.day-modal-cards .tv-card .valor { font-size: 0.95rem; }

.tv-subheader {
  margin-top: 0.3rem;
  font-size: 0.95rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tv-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
}
.tv-nav-btn:hover { background: var(--accent); color: #0f172a; }

.tv-nav-today {
  margin-left: 0.4rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: #0f172a;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
}
.tv-nav-today:hover { opacity: 0.9; }

.tv-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 0.6rem;
  padding: 1.2rem 1.2rem 2rem;
  flex: 1;
  min-height: 0;
}

.tv-day {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tv-day.is-today {
  border: 2px solid var(--accent);
  background: linear-gradient(180deg, rgba(56,189,248,0.10), var(--panel) 12%);
}

.tv-day.drag-over {
  border: 2px dashed var(--accent);
  background: rgba(56,189,248,0.14);
}

.tv-day-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 6px;
}
.tv-day-header:hover { background: rgba(255,255,255,0.05); }
.tv-day-name {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
}
.tv-day.is-today .tv-day-name { color: var(--accent); }

.tv-day-number {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.tv-day.is-today .tv-day-number { background: var(--accent); color: #0f172a; }

.tv-day-header .count {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  flex-shrink: 0;
}
.tv-day.is-today .tv-day-header .count { background: var(--accent); color: #0f172a; }

.tv-day-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}
.tv-stat {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  white-space: nowrap;
}
.tv-stat-nao_entregue { background: rgba(234,179,8,0.18); color: var(--yellow); }
.tv-stat-entregue { background: rgba(34,197,94,0.18); color: var(--green); }
.tv-stat-sem_entrega { background: rgba(100,116,139,0.25); color: var(--text-dim); }
.tv-stat.is-zero { opacity: 0.35; }

.tv-day-cards {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  overflow-y: auto;
}

.tv-card {
  background: #0f172a;
  border-left: 3px solid var(--gray);
  border-radius: 5px;
  padding: 0.32rem 0.45rem;
  font-size: 0.7rem;
  line-height: 1.25;
  cursor: grab;
}
.tv-card.dragging { opacity: 0.35; }
.tv-card.status-entregue { border-left-color: var(--green); }
.tv-card.status-nao_entregue { border-left-color: var(--yellow); }
.tv-card.status-sem_entrega { border-left-color: var(--gray); opacity: 0.7; }

.tv-card .inv-num { font-weight: 700; color: var(--accent); font-size: 0.7rem; }
.tv-card .cliente { font-weight: 600; margin: 0.1rem 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-card .cidade { font-weight: 800; color: #fff; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-card .meta { color: var(--text-dim); font-size: 0.64rem; }
.tv-card .valor { font-weight: 700; }

.tv-empty { color: var(--text-dim); font-size: 0.72rem; font-style: italic; }

.tv-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding-bottom: 1rem;
}

@media (max-width: 1100px) {
  .tv-calendar { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 700px) {
  .tv-calendar { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Roteiro de Entregas (PRME) ---------- */
.letterhead-rota {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 0 8px;
}
.letterhead-rota img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--prme-line), 0 4px 14px rgba(14,42,76,0.12);
}
.brand-text-rota { display: flex; flex-direction: column; gap: 2px; }
.brand-name-rota {
  font-weight: 700;
  font-size: 22px;
  color: var(--prme-navy);
  letter-spacing: 0.01em;
}
.brand-tag-rota {
  font-size: 11px;
  font-weight: 600;
  color: var(--prme-gold-deep);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.page-title-rota { margin-left: auto; text-align: right; }
.page-title-rota .eyebrow-rota {
  font-size: 11px;
  font-weight: 600;
  color: var(--prme-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.page-title-rota h1 {
  margin: 2px 0 0;
  font-size: 19px;
  color: var(--prme-ink);
}
.page-title-rota .subtitle-rota {
  font-size: 12.5px;
  color: var(--prme-muted);
  margin-top: 2px;
}

.rota-rule {
  height: 3px;
  background: linear-gradient(90deg, var(--prme-navy) 0%, var(--prme-navy) 60%, var(--prme-gold) 100%);
  margin: 0 0 20px;
}

.rota-hint {
  background: var(--prme-blue-soft);
  color: var(--prme-navy);
  border: 1px solid var(--prme-line);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.manual-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--prme-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 12px;
}

.rota-table-card { background: #fff; }

.rota-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13.5px;
}
.rota-table thead th {
  background: var(--prme-navy);
  color: #fff;
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  white-space: nowrap;
}
.rota-table th.num, .rota-table td.num { text-align: right; }
.rota-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--prme-line-soft);
  white-space: nowrap;
  color: var(--prme-ink);
}
.rota-table td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.rota-table td.rota-obs { white-space: normal; max-width: 220px; font-size: 12.5px; color: var(--prme-muted); }
.rota-table tbody tr:nth-child(even) { background: #FAFBFD; }
.rota-table tbody tr:hover { background: var(--prme-blue-soft); }
.rota-table tbody tr[draggable="true"] { cursor: grab; }
.rota-table tbody tr.dragging { opacity: 0.35; }
.rota-table tbody tr.drag-over { box-shadow: inset 0 2px 0 var(--prme-gold); }

.rota-table .order-col { width: 56px; }
.rota-table .order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--prme-navy);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.rota-table tfoot td {
  font-weight: 700;
  border-top: none;
  border-bottom: none;
  background: linear-gradient(90deg, #FCEFDA 0%, #F8E2C0 100%);
  color: var(--prme-navy);
  padding: 13px 14px;
}

.rota-empty {
  text-align: center;
  color: var(--prme-muted);
  padding: 34px 0;
}

.doc-footer {
  margin: 8px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--prme-line);
  font-size: 11.5px;
  color: var(--prme-muted);
}

@media print {
  @page { size: landscape; margin: 12mm 14mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .print-only { display: block; }
  .container { max-width: none; padding: 0; }
  .card { border: none; padding: 0; box-shadow: none; }
  .rota-table thead th, .rota-table tfoot td, .rota-table .order-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ---------- Financeiro ---------- */
.range-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #334155;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.kpi-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.kpi-label { font-size: 0.78rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: #0f172a; margin-top: 0.25rem; }

.chart-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.2rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
}
.chart-card h3 { margin: 0 0 0.8rem; font-size: 1rem; color: #334155; }
.chart-wrap { position: relative; height: 320px; }

/* ---------- Adicionar invoice rapido (tela principal) ---------- */
.quick-add { align-items: flex-end; border-left: 4px solid var(--accent); }
.qa-field { display: flex; flex-direction: column; gap: 0.2rem; }
.qa-field label, .qa-field > span { font-size: 0.7rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.04em; }
.qa-field input, .qa-field select { width: 100%; }
.qa-num strong { font-size: 1.1rem; color: #0f172a; padding: 0.35rem 0.2rem; }
.qa-sm { width: 100px; }
.qa-grow { flex: 1; min-width: 160px; }
.qa-submit { align-self: flex-end; }
.flash-ok {
  background: #dcfce7;
  color: #166534;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
}

/* ---------- Cidades / dia de entrega sugerido ---------- */
.dias-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.4rem; }
.form-row label.dia-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #334155;
  cursor: pointer;
}
.form-row label.dia-check input { width: auto; padding: 0; }
.qa-hint, .date-hint { font-size: 0.7rem; color: #0369a1; min-height: 0.9rem; }
.qa-field > span.qa-hint { text-transform: none; letter-spacing: 0; color: #0369a1; }

/* ---------- Lista de invoices compacta (uma linha por invoice) ---------- */
.tabela-compacta { min-width: 900px; }
.tabela-compacta th, .tabela-compacta td {
  padding: 0.28rem 0.6rem;
  font-size: 0.8rem;
  white-space: nowrap;
  line-height: 1.25;
}
.tabela-compacta td:nth-child(2) { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.tabela-compacta td:nth-child(3) { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.tabela-compacta .badge { padding: 0.1rem 0.55rem; font-size: 0.68rem; }
.tabela-compacta .actions a.btn { padding: 0.15rem 0.6rem; font-size: 0.75rem; margin: 0; }
.tabela-compacta .gap-label { font-size: 0.78rem; }

/* Dica de dias de entrega fora do fluxo: nao desalinha o campo de data */
.quick-add { row-gap: 1.3rem; padding-bottom: 1.5rem; }
.qa-field { position: relative; }
.qa-field > span.qa-hint {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  min-height: 0;
  white-space: nowrap;
}
.quick-add .qa-field input, .quick-add .qa-field select { height: 2.15rem; box-sizing: border-box; }

/* ---------- Nova invoice (verde) x Filtros (cinza): evitam confusao ---------- */
.quick-add {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-left: 5px solid #16a34a;
}
.quick-add .qa-field input, .quick-add .qa-field select { border-color: #bbf7d0; background: #fff; }
.quick-add .qa-field input:focus, .quick-add .qa-field select:focus { outline: 2px solid #16a34a; outline-offset: 0; }
.quick-add .qa-submit { background: #16a34a; color: #fff; font-weight: 600; }
.quick-add .qa-submit:hover { background: #15803d; opacity: 1; }
.qa-title {
  flex: 0 0 100%;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #166534;
  margin-bottom: -0.5rem;
}
.filtros-busca { background: #f1f5f9; }
.qa-title.qa-title-filtro { color: #64748b; font-weight: 600; margin-bottom: -0.3rem; }

/* ---------- Preparo de Roteiro (duas caixas, como a janela do Excel) ---------- */
.preparo-ajuda { color: #475569; font-size: 0.9rem; margin: 0 0 0.8rem; }
.preparo-msg { min-height: 1.4rem; font-size: 0.85rem; margin: -0.2rem 0 0.6rem; padding: 0 0.2rem; }
.preparo-msg.ok { color: #166534; font-weight: 600; }
.preparo-msg.erro { color: #b91c1c; font-weight: 600; }
.preparo-msg.aviso { color: #a16207; }
.preparo-msg.info { color: #475569; }

.preparo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
}
.dual-box {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.7rem 0.8rem 0.6rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.dual-box-roteiro { border-color: #38bdf8; border-width: 2px; background: #f0f9ff; }
.dual-box h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dual-count {
  background: #0f172a;
  color: #fff;
  border-radius: 999px;
  padding: 0 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0;
}
.dual-box select {
  width: 100%;
  height: 340px;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.78rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.2rem;
  background: #fff;
}
.dual-box select option { padding: 0.12rem 0.3rem; white-space: pre; }
.dual-dica { display: block; margin-top: 0.4rem; color: #64748b; font-size: 0.72rem; }
.link-btn { background: none; border: none; padding: 0; color: #0369a1; cursor: pointer; font-size: inherit; text-decoration: underline; }
.dual-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.dual-actions .btn { min-width: 108px; }

.preparo-aplicar {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  margin-top: 0.9rem;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-left: 5px solid #0ea5e9;
  border-radius: 8px;
  padding: 0.8rem 1rem;
}
.preparo-aplicar .qa-field { min-width: 240px; }
.preparo-aplicar select { height: 2.15rem; padding: 0.4rem 0.6rem; border: 1px solid #cbd5e1; border-radius: 6px; }
.preparo-aplicar .btn:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 900px) {
  .preparo-grid { grid-template-columns: 1fr; }
  .dual-actions { flex-direction: row; flex-wrap: wrap; }
}

/* ---------- Mapa por cidade (limites + cores) ---------- */
.map-container { background: #dbeafe; }
.map-subtitulo { font-weight: 400; font-size: 0.8rem; color: #94a3b8; margin-left: 0.6rem; }
.map-fora { padding: 0.45rem 1.2rem; font-size: 0.75rem; color: #64748b; background: #f8fafc; border-top: 1px solid #e2e8f0; min-height: 1.6rem; flex-shrink: 0; }
.map-legenda {
  background: rgba(255,255,255,0.95);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  font-size: 0.72rem;
  line-height: 1.5;
  color: #334155;
}
.map-legenda i { display: inline-block; width: 14px; height: 12px; margin-right: 6px; border: 1px solid #94a3b8; vertical-align: -1px; }
.map-container.leaflet-container { background: #dbeafe; }

/* ---------- Mapa: seletor de dia e lista ao passar o mouse ---------- */
.map-dias {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.map-dia {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}
.map-dia span { background: #e2e8f0; color: #334155; border-radius: 999px; padding: 0 0.4rem; margin-left: 0.2rem; font-size: 0.7rem; }
.map-dia:hover { border-color: #0284c7; }
.map-dia.hoje { border-color: #38bdf8; }
.map-dia.ativo { background: #0284c7; border-color: #0284c7; color: #fff; }
.map-dia.ativo span { background: rgba(255,255,255,0.25); color: #fff; }

.leaflet-tooltip.map-tip { white-space: normal; max-width: 340px; font-size: 0.78rem; line-height: 1.35; }
.map-popup-row { white-space: nowrap; }
.map-mais { color: #64748b; font-style: italic; }
.map-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; background: #64748b; }
.map-dot.st-entregue { background: #22c55e; }
.map-dot.st-nao_entregue { background: #eab308; }
.map-dot.st-sem_entrega { background: #64748b; }
.leaflet-tooltip.map-tip .map-popup-list { max-height: none; overflow: visible; }
