/* =========================================================
   fastEntregas · Mega Tintas — design system
   Vermelho (ação/marca) · branco (fundo) · cinzas (estrutura)
   Verde = concluído · Âmbar = pendência/compra
   ========================================================= */
:root {
  --red: #d7261e;
  --red-700: #b31d17;
  --red-50: #fef2f1;
  --red-100: #fde0de;

  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --text-2: #4b5160;
  --muted: #7a8190;
  --border: #e6e8ec;
  --border-strong: #d4d7de;

  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --indigo: #4338ca;
  --indigo-bg: #e0e7ff;
  --gray-bg: #eef0f3;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --sidebar: 232px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.boot { height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.2s ease-in-out infinite; }

/* ---------- Formulários ---------- */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
label.field .hint { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; min-height: 38px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--red-100); outline-offset: 0; border-color: var(--red);
}
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: 13.5px; white-space: nowrap;
  min-height: 38px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none !important; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--red-700); border-color: var(--red-700); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-soft); }
.btn.danger { color: var(--red); border-color: var(--red-100); }
.btn.danger:hover { background: var(--red-50); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.btn.lg { min-height: 48px; padding: 12px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 34px; min-height: 34px; }
.btn.loading { pointer-events: none; opacity: .7; }
.btn.loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand img { width: 34px; height: 34px; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.brand-name b { color: var(--red); font-weight: 800; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .02em; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; text-decoration: none;
}
.nav a:hover { background: var(--bg-soft); color: var(--text); }
.nav a.active { background: var(--red-50); color: var(--red); }
.nav a svg.i { width: 18px; height: 18px; }
.user-menu { margin-top: auto; border-top: 1px solid var(--border); padding: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gray-bg); color: var(--text-2); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex: none; }
.user-menu .who { min-width: 0; flex: 1; }
.user-menu .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu .who small { font-size: 11.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.page { padding: 22px 26px 40px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.backlink { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 550; margin-bottom: 8px; }

/* ---------- Cartões/estatísticas ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-body { padding: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.stat .label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; }
.stat .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.stat.red .dot { background: var(--red); }
.stat.amber .dot { background: #f59e0b; }
.stat.green .dot { background: #22c55e; }
.stat.indigo .dot { background: #6366f1; }
.stat.amber.has .value { color: var(--amber); }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--gray-bg); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.PENDING { background: var(--gray-bg); color: #4b5563; }
.badge.AWAITING_PURCHASE { background: var(--amber-bg); color: var(--amber); }
.badge.READY { background: var(--blue-bg); color: var(--blue); }
.badge.IN_ROUTE { background: var(--indigo-bg); color: var(--indigo); }
.badge.IN_DELIVERY { background: var(--red-50); color: var(--red); }
.badge.COMPLETED { background: var(--green-bg); color: var(--green); }
.badge.CANCELED { background: var(--gray-bg); color: var(--muted); text-decoration: line-through; }
.badge.plain::before { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px;
  font: inherit; font-size: 12px; font-weight: 650; border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.chip.IN_STOCK { background: var(--green-bg); color: var(--green); }
.chip.NEEDS_PURCHASE { background: var(--red-50); color: var(--red); border-color: var(--red-100); }
.chip[disabled] { cursor: default; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Kanban ---------- */
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav .label { font-weight: 650; min-width: 150px; text-align: center; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(176px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kcol { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 220px; }
.kcol.today { border-color: var(--red-100); box-shadow: inset 0 3px 0 var(--red); }
.kcol-head { padding: 12px 12px 8px; display: flex; align-items: baseline; gap: 8px; }
.kcol-head .day { font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.kcol-head .date { font-size: 12px; color: var(--muted); }
.kcol-head .count { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.kcol.today .day { color: var(--red); }
.kcol-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; }
.kcol-empty { font-size: 12.5px; color: var(--muted); text-align: center; padding: 18px 8px; }
.kcol-add { margin: 0 8px 10px; border: 1px dashed var(--border-strong); background: transparent; color: var(--text-2); }
.kcol-add:hover { border-color: var(--red); color: var(--red); background: var(--red-50); }
.kcol-route { margin: 0 8px 8px; }

.dcard {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 11px; cursor: pointer; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 5px; text-align: left; font: inherit; color: inherit; width: 100%;
}
.dcard:hover { border-color: var(--border-strong); }
.dcard.AWAITING_PURCHASE { border-left-color: #f59e0b; }
.dcard.READY { border-left-color: #3b82f6; }
.dcard.IN_ROUTE { border-left-color: #6366f1; }
.dcard.IN_DELIVERY { border-left-color: var(--red); }
.dcard.COMPLETED { border-left-color: #22c55e; background: #fbfefc; }
.dcard.CANCELED { opacity: .6; }
.dcard .top { display: flex; align-items: center; justify-content: space-between; gap: 4px 6px; flex-wrap: wrap; }
.dcard .num { font-size: 11px; font-weight: 800; letter-spacing: .05em; color: var(--muted); }
.dcard .client { font-weight: 650; font-size: 14px; line-height: 1.3; }
.dcard .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-2); }
.dcard .meta span { display: inline-flex; align-items: center; gap: 4px; }
.dcard .meta svg.i { width: 13px; height: 13px; color: var(--muted); }
.dcard .warn { font-size: 12px; font-weight: 650; color: var(--amber); display: flex; align-items: center; gap: 5px; }
.dcard .warn svg.i { width: 13px; height: 13px; }
.dcard .done { font-size: 12px; font-weight: 700; color: var(--green); }
.dcard .actions { margin-top: 4px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-soft); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fafbfc; }
.table .actions { text-align: right; white-space: nowrap; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty svg.i { width: 28px; height: 28px; color: var(--border-strong); display: block; margin: 0 auto 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters label.field { min-width: 140px; flex: 1 1 140px; max-width: 220px; }
.search { position: relative; flex: 1; max-width: 340px; }
.search svg.i { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.search input { padding-left: 34px; }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 14px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface);
}
dialog.modal.wide { width: min(820px, calc(100vw - 24px)); }
dialog.modal.narrow { width: min(460px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(17, 20, 28, .45); }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .14s ease-out; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head .sub { color: var(--muted); font-size: 12.5px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg-soft); border-radius: 0 0 14px 14px; }

.section-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 18px; }
.kv .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kv .v { font-weight: 550; margin-top: 2px; word-break: break-word; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.date-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--red-50); color: var(--red); font-weight: 650; }

/* ---------- Seletor de cliente ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto;
}
.combo-item { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; padding: 9px 12px; cursor: pointer; color: inherit; }
.combo-item:hover, .combo-item.active { background: var(--bg-soft); }
.combo-item small { display: block; }
.combo-item.new { color: var(--red); font-weight: 650; border-top: 1px solid var(--border); }
.selected-client { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.selected-client .avatar { background: var(--red-50); color: var(--red); }

/* ---------- Materiais ---------- */
.mat-input { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; }
.mat-list { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 10px; }
.mat-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 12px; border-bottom: 1px solid var(--border); }
.mat-item:last-child { border-bottom: 0; }
.mat-item .qty { font-weight: 750; min-width: 38px; }
.mat-item .desc { flex: 1; min-width: 0; font-weight: 550; overflow-wrap: anywhere; }
.mat-item.check { cursor: pointer; }
.mat-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Rota ---------- */
.route-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.route-map { height: calc(100vh - 170px); min-height: 360px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; background: var(--bg-soft); position: sticky; top: 16px; }
.route-map .map-fallback { height: 100%; display: grid; place-items: center; color: var(--muted); padding: 20px; text-align: center; }
.pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--red); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); display: grid; place-items: center; }
.pin span { transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 12px; }
.pin.done { background: #22c55e; }
.pin.next { background: #111827; }
.rlist { display: flex; flex-direction: column; }
.rstop { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.rstop:last-child { border-bottom: 0; }
.rstop.dragging { box-shadow: var(--shadow-lg); position: relative; z-index: 5; border-radius: var(--radius-sm); }
.rstop .pos { width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 800; font-size: 12.5px; display: grid; place-items: center; flex: none; }
.rstop.COMPLETED .pos { background: #22c55e; }
.rstop.CANCELED .pos { background: var(--border-strong); }
.rstop .info { flex: 1; min-width: 0; cursor: pointer; }
.rstop .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rstop .info small { display: block; }
.handle { cursor: grab; touch-action: none; color: var(--muted); padding: 8px 4px; border: 0; background: none; display: grid; place-items: center; }
.handle:active { cursor: grabbing; }
.next-card { border: 1px solid var(--red-100); background: var(--red-50); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.next-card .label { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--red); text-transform: uppercase; }
.next-card .name { font-size: 18px; font-weight: 750; margin: 6px 0 2px; }
.progress { height: 6px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: #22c55e; }

/* ---------- Execução / finalização (mobile-first) ---------- */
.run { max-width: 680px; }
.run-client { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.contact-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.contact-actions .btn { flex-direction: column; gap: 4px; min-height: 64px; font-size: 12.5px; }
.contact-actions .btn svg.i { width: 20px; height: 20px; }
.step { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; background: var(--surface); }
.step-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--gray-bg); color: var(--text-2); font-weight: 800; font-size: 12px; display: grid; place-items: center; flex: none; }
.step.ok .step-num { background: var(--green); color: #fff; }
.step-body { padding: 14px; }
.term { font-size: 13.5px; color: var(--text-2); }
.sigpad { position: relative; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; touch-action: none; }
.sigpad canvas { display: block; width: 100%; height: 200px; cursor: crosshair; }
.sigpad .line { position: absolute; left: 20px; right: 20px; bottom: 42px; border-bottom: 1px solid var(--border-strong); pointer-events: none; }
.sigpad .ph { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }
.sigpad.locked { border-style: solid; border-color: #86efac; background: #fbfefc; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--bg-soft); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: grid; place-items: center; }
.sig-view { max-width: 320px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.sig-view img { display: block; width: 100%; }
.sticky-foot { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 14px 0 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 6px 0; font-size: 12.5px; }
.timeline li .when { color: var(--muted); min-width: 118px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg-soft); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; }
.auth-card .brand { padding: 0 0 20px; }
.auth-card .brand img { width: 42px; height: 42px; }
.auth-card .brand-name { font-size: 22px; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; background: var(--red-50); color: var(--red-700); }
.alert.info { background: var(--blue-bg); color: var(--blue); }
.alert.warn { background: var(--amber-bg); color: var(--amber); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; }
#toasts[popover] { inset: auto 16px 16px auto; margin: 0; border: 0; padding: 0; background: transparent; overflow: visible; color: inherit; }
#toasts[popover]:not(:popover-open):empty { display: none; }
.toast { pointer-events: none; display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: #16181d; color: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-weight: 550; max-width: 360px; animation: slideup .18s ease-out; }
.toast svg.i { color: #4ade80; }
.toast.error svg.i { color: #f87171; }

/* ---------- Skeleton ---------- */
.sk { background: #eceef1; border-radius: var(--radius-sm); animation: pulse 1.4s ease-in-out infinite; }
.sk.card { height: 92px; }
.sk.line { height: 12px; margin: 8px 0; }

/* ---------- Switch ---------- */
.switch-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--red); }
.switch input:checked + span::after { transform: translateX(18px); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
@keyframes slideup { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Mapas ---------- */
.mini-map { height: 180px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-soft); margin-bottom: 14px; }
.mini-map .map-fallback { height: 100%; display: grid; place-items: center; color: var(--muted); }
.picker { display: flex; flex-direction: column; gap: 8px; }
.picker-map { height: 260px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-soft); }
.picker-map .map-fallback { height: 100%; }
.picker-foot small svg.i { width: 14px; height: 14px; }
.pin.client { background: var(--red); }
.pin.delivered { background: #22c55e; }
.pin.s-PENDING { background: #9ca3af; }
.pin.s-AWAITING_PURCHASE { background: #f59e0b; }
.pin.s-READY { background: #3b82f6; }
.pin.s-IN_ROUTE { background: #6366f1; }
.pin.s-IN_DELIVERY { background: var(--red); }
.pin.s-COMPLETED { background: #22c55e; }
.pin span { font-size: 11px; }
.truck-pin {
  position: absolute; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 5px; white-space: nowrap;
  background: #16181d; color: #fff; padding: 4px 9px 4px 6px; border-radius: 999px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.truck-pin::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: #16181d; }
.truck-pin span { font-size: 14px; }
.truck-pin small { color: #cbd0d8; }
.day-map { margin-bottom: 18px; }
.day-map .panel-head { flex-wrap: wrap; }
.daymap { height: 380px; background: var(--bg-soft); }
.daymap .map-fallback { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-day { font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip-day.active { background: var(--red); border-color: var(--red); color: #fff; }
.chip-day b { margin-left: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend .dot.s-READY { background: #3b82f6; } .legend .dot.s-AWAITING_PURCHASE { background: #f59e0b; }
.legend .dot.s-IN_ROUTE { background: #6366f1; } .legend .dot.s-IN_DELIVERY { background: var(--red); } .legend .dot.s-COMPLETED { background: #22c55e; }
.leaflet-popup-content { font: 13px/1.4 var(--font); }
.btn.waze { background: #33ccff; border-color: #33ccff; color: #05203a; }
.btn.waze:hover { background: #1fbdf2; }
.contact-actions { grid-template-columns: repeat(4, 1fr); }
.track-badge {
  position: fixed; left: 12px; bottom: 12px; z-index: 900; display: inline-flex; align-items: center; gap: 6px; pointer-events: none;
  background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 650;
}
@media (max-width: 640px) {
  .daymap { height: 300px; }
  .picker-map { height: 220px; }
  .track-badge { bottom: auto; top: 58px; left: auto; right: 12px; }
}
@media (max-width: 380px) { .contact-actions { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .route-layout { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 100; left: 0; top: 0; transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { position: fixed; inset: 0; background: rgba(17,20,28,.4); z-index: 90; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 50; }
  .topbar .brand { padding: 0; }
  .topbar .brand img { width: 28px; height: 28px; }
  .page { padding: 16px 16px 32px; }
  .route-layout { grid-template-columns: 1fr; }
  .route-map { position: relative; top: 0; height: 42vh; min-height: 260px; }
  .kanban { grid-auto-columns: 84%; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 8px; scroll-padding: 0 16px; }
  .kcol { scroll-snap-align: start; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 22px; }
  .stats .stat:last-child { grid-column: span 2; }
  .grid-2 { grid-template-columns: 1fr; }
  .mat-input { grid-template-columns: 1fr 74px; }
  .mat-input .btn { grid-column: span 2; }
  dialog.modal, dialog.modal.wide, dialog.modal.narrow { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .modal-foot { border-radius: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 18px; }
  .filters label.field { max-width: none; }
  /* Tabelas viram cartões */
  .table.cards thead { display: none; }
  .table.cards tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table.cards td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 14px; }
  .table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  .table.cards td.actions { justify-content: flex-end; }
  .table.cards td.actions::before { content: none; }
  #toasts, #toasts[popover] { left: 12px; right: 12px; bottom: auto; top: 64px; inset: 64px 12px auto 12px; }
  .toast { max-width: none; }
}
