/* ============================================================================
   TMExpress · Design System (ds.css)
   Única fonte visual do sistema. Nenhuma tela deve usar cores hardcoded fora
   destes tokens. Suporta Light e Dark mode via [data-theme].
   ============================================================================ */

:root {
  /* ---- Marca (navy Trans Magalhaes Express) ---- */
  --brand-50:  #eef3f9;
  --brand-100: #d6e2ef;
  --brand-200: #adc3dd;
  --brand-300: #7f9dc2;
  --brand-400: #517aa4;
  --brand-500: #35608f;
  --brand-600: #2c4f78;
  --brand-700: #244063;
  --brand-800: #1d3350;
  --brand-900: #16273e;

  /* ---- Semânticos ---- */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger:  #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: var(--brand-600);
  --info-bg: var(--brand-50);

  /* ---- Superfícies (Light) ---- */
  --bg:        #f4f7fb;
  --bg-soft:   #eef2f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --overlay:   rgba(15, 23, 42, 0.45);
  --glass:     rgba(255, 255, 255, 0.72);
  --glass-brd: rgba(255, 255, 255, 0.6);

  /* ---- Texto ---- */
  --text:      #0f172a;
  --text-soft: #475569;
  --text-mut:  #94a3b8;
  --text-inv:  #ffffff;

  /* ---- Bordas ---- */
  --border:    #e2e8f0;
  --border-strong: #cbd5e1;

  /* ---- Raio / Sombra / Tipografia ---- */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  --sh-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --sh:    0 4px 14px rgba(15,23,42,.08);
  --sh-lg: 0 12px 34px rgba(15,23,42,.14);
  --sh-brand: 0 8px 24px rgba(44,79,120,.32);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.16,.84,.44,1);
}

[data-theme="dark"] {
  --bg:        #0b1220;
  --bg-soft:   #0e1729;
  --surface:   #111c31;
  --surface-2: #17233b;
  --overlay:   rgba(2, 6, 18, 0.62);
  --glass:     rgba(17, 28, 49, 0.66);
  --glass-brd: rgba(148, 163, 184, 0.16);

  --text:      #e8eefc;
  --text-soft: #a9b6cf;
  --text-mut:  #6b7a99;
  --text-inv:  #0b1220;

  --border:    #22314f;
  --border-strong: #33456b;

  --info-bg:   rgba(37,99,235,.16);
  --success-bg: rgba(22,163,74,.16);
  --danger-bg: rgba(220,38,38,.16);
  --warning-bg: rgba(217,119,6,.16);

  --sh-sm: 0 1px 2px rgba(0,0,0,.3);
  --sh:    0 6px 18px rgba(0,0,0,.4);
  --sh-lg: 0 16px 40px rgba(0,0,0,.5);
}

/* ---------------------------------------------------------------- Base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .3s var(--ease), color .3s var(--ease);
}
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--brand-200); color: var(--brand-900); }

/* Fundo ilustrativo (aurora sutil) usado em telas de auth/landing */
.ds-aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
}
.ds-aurora::before, .ds-aurora::after {
  content: ""; position: absolute; width: 46vw; height: 46vw; border-radius: 50%;
  filter: blur(90px); opacity: .5;
}
.ds-aurora::before { background: radial-gradient(circle, var(--brand-400), transparent 60%); top: -12vw; left: -8vw; }
.ds-aurora::after  { background: radial-gradient(circle, var(--brand-600), transparent 60%); bottom: -14vw; right: -8vw; opacity:.4; }

/* --------------------------------------------------------- Tipografia ---- */
.ds-h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2rem); font-weight: 800; letter-spacing: -.02em; margin: 0; color: var(--text); }
.ds-h2 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.ds-sub { color: var(--text-soft); margin: 6px 0 0; font-size: .95rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 700; color: var(--brand-600); }
.page-head { margin-bottom: 22px; }
.muted { color: var(--text-mut); }

/* -------------------------------------------------------------- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 22px; }
.card-hover { transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--brand-200); }

.glass {
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
}

/* ------------------------------------------------------------ Botões ---- */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: 11px 18px; border-radius: var(--r); cursor: pointer;
  border: 1px solid transparent; transition: all .18s var(--ease);
  user-select: none; white-space: nowrap; text-decoration: none; line-height: 1;
}
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--sh-brand); }
.btn-primary:hover { background: var(--brand-700); transform: translateY(-1px); text-decoration: none; }
.btn-primary:active { transform: translateY(0); }

.btn-secondary { background: var(--surface); color: var(--brand-700); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--brand-50); border-color: var(--brand-300); text-decoration: none; }
[data-theme="dark"] .btn-secondary { background: var(--surface-2); color: var(--brand-300); }
[data-theme="dark"] .btn-secondary:hover { background: #1c2b47; }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 1rem; }
button:disabled, .btn-primary[disabled], .btn-secondary[disabled] { opacity: .6; cursor: not-allowed; transform: none !important; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r); cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--text-soft);
  transition: all .18s var(--ease);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

/* Ícone dentro de botão (pintado pelo ui.js) */
.btn-primary svg, .btn-secondary svg, .btn-ghost svg, .btn-danger svg, .btn-icon svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------- Forms ---- */
.ds-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-soft); margin: 0 0 6px; }
.input, .select, textarea.input {
  width: 100%; font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 11px 13px; transition: all .18s var(--ease); outline: none;
}
.input::placeholder { color: var(--text-mut); }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--brand-500); background: var(--surface);
  box-shadow: 0 0 0 4px rgba(59,130,246,.16);
}
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(220,38,38,.14); }
.input.is-valid { border-color: var(--success); }
.field { margin-bottom: 16px; }
.field-hint { font-size: .8rem; color: var(--text-mut); margin-top: 6px; }
.field-error { font-size: .8rem; color: var(--danger); margin-top: 6px; display: none; }
.field.has-error .field-error { display: block; }

/* Input com ícone / botão embutido (ex.: mostrar senha) */
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-affix {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-mut); cursor: pointer; border-radius: var(--r-sm);
}
.input-affix:hover { color: var(--text); background: var(--surface-2); }

/* Medidor de força de senha */
.pw-meter { height: 6px; border-radius: var(--r-full); background: var(--border); overflow: hidden; margin-top: 8px; }
.pw-meter > i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .3s var(--ease), background .3s var(--ease); }
.pw-weak > i   { width: 33%; background: var(--danger); }
.pw-medium > i { width: 66%; background: var(--warning); }
.pw-strong > i { width: 100%; background: var(--success); }

/* ------------------------------------------------------------ Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-full); border: 1px solid transparent; }
.badge-neutral { background: var(--surface-2); color: var(--text-soft); border-color: var(--border); }
.badge-primary { background: var(--info-bg); color: var(--brand-700); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
[data-theme="dark"] .badge-primary { color: var(--brand-300); }

/* ------------------------------------------------------------- Tabela ---- */
.ds-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ds-table th { text-align: left; font-weight: 600; color: var(--text-mut); text-transform: uppercase;
  letter-spacing: .04em; font-size: .72rem; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.ds-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.ds-table tbody tr { transition: background .15s var(--ease); }
.ds-table tbody tr:hover { background: var(--surface-2); }

/* -------------------------------------------------------------- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60;
  animation: ds-fade .2s var(--ease); }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); width: 100%; max-width: 460px; padding: 24px; animation: ds-pop .25s var(--ease); }

/* --------------------------------------------------------- Empty / Skel -- */
.empty-state { text-align: center; padding: 44px 20px; color: var(--text-soft); }
.empty-state .ico { width: 56px; height: 56px; margin: 0 auto 14px; color: var(--brand-400);
  display: flex; align-items: center; justify-content: center; background: var(--info-bg); border-radius: var(--r-lg); }
.empty-state .ico svg { width: 28px; height: 28px; }

.skeleton { background: linear-gradient(100deg, var(--surface-2) 30%, var(--border) 50%, var(--surface-2) 70%);
  background-size: 200% 100%; animation: ds-shimmer 1.3s infinite; border-radius: var(--r-sm); }
.skel-line { height: 12px; margin: 8px 0; }
.skel-row  { height: 44px; margin: 8px 0; border-radius: var(--r); }
.skel-card { height: 120px; border-radius: var(--r-lg); }

/* --------------------------------------------------------- Navegação ----- */
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.nav-tile { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); transition: all .22s var(--ease); }
.nav-tile:hover { transform: translateY(-3px); box-shadow: var(--sh); border-color: var(--brand-200); text-decoration: none; }
.nav-tile .ico { width: 42px; height: 42px; border-radius: var(--r); background: var(--info-bg); color: var(--brand-600);
  display: flex; align-items: center; justify-content: center; }

/* -------------------------------------------------- Loading global (net) - */
#ds-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 90;
  background: linear-gradient(90deg, var(--brand-400), var(--brand-700)); box-shadow: 0 0 10px var(--brand-500);
  transition: width .2s var(--ease), opacity .3s var(--ease); opacity: 0; }
.ds-loading-overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center;
  justify-content: center; z-index: 80; backdrop-filter: blur(2px); }
.spinner { width: 42px; height: 42px; border: 3px solid var(--border); border-top-color: var(--brand-600);
  border-radius: 50%; animation: ds-spin .8s linear infinite; }
.btn-spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
  border-radius: 50%; animation: ds-spin .7s linear infinite; }

/* --------------------------------------------------------------- Toast --- */
#ds-toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px;
  max-width: min(92vw, 380px); }
.ds-toast { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-lg); color: var(--text);
  animation: ds-slidein .28s var(--ease); border-left: 4px solid var(--brand-500); }
.ds-toast.success { border-left-color: var(--success); }
.ds-toast.error   { border-left-color: var(--danger); }
.ds-toast.warning { border-left-color: var(--warning); }
.ds-toast .t-ico { flex: 0 0 auto; margin-top: 1px; }
.ds-toast .t-body { font-size: .9rem; }
.ds-toast.hide { animation: ds-slideout .25s var(--ease) forwards; }

/* --------------------------------------------------------- Navbar/App ---- */
.app-header { position: sticky; top: 0; z-index: 50; background: var(--glass);
  backdrop-filter: blur(12px) saturate(160%); -webkit-backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid var(--border); }
.app-header .inner { max-width: 1200px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand-500), var(--brand-800));
  display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: var(--sh-brand); }
.brand .logo svg { width: 20px; height: 20px; }
#nav-menu { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: var(--r);
  color: var(--text-soft); font-weight: 500; font-size: .92rem; transition: all .16s var(--ease); }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--info-bg); color: var(--brand-700); }
[data-theme="dark"] .nav-link.active { color: var(--brand-300); }
.nav-link svg { width: 17px; height: 17px; }

.app-footer { border-top: 1px solid var(--border); color: var(--text-mut); font-size: .85rem;
  padding: 22px 20px; text-align: center; margin-top: 40px; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }

/* --------------------------------------------------------- Utilitários --- */
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-mut); font-size: .82rem; margin: 8px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }

/* ------------------------------------------------------------- Animações - */
@keyframes ds-spin { to { transform: rotate(360deg); } }
@keyframes ds-shimmer { to { background-position: -200% 0; } }
@keyframes ds-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ds-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ds-slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes ds-slideout { to { opacity: 0; transform: translateX(20px); } }
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* --------------------------------------------------------- Responsivo ---- */
@media (max-width: 640px) {
  .app-header .inner { padding: 10px 14px; }
  .nav-link span.label { display: none; }
  .container { padding: 18px 14px; }
  #ds-toasts { left: 12px; right: 12px; max-width: none; }
}

/* ============================================================================
   Utilitários (substituem o Tailwind — bloqueado pela CSP de produção)
   ============================================================================ */
.flex { display: flex; } .inline-flex { display: inline-flex; }
.grid { display: grid; }
.flex-col { flex-direction: column; } .flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .items-start { align-items: flex-start; } .items-end { align-items: flex-end; }
.justify-center { justify-content: center; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.gap-1{gap:4px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}.gap-6{gap:24px}
.flex-1 { flex: 1; } .w-full { width: 100%; } .h-full { height: 100%; }
.text-left{text-align:left}.text-right{text-align:right}
.text-sm{font-size:.85rem}.text-xs{font-size:.75rem}.text-lg{font-size:1.125rem}.text-xl{font-size:1.35rem}
.font-semibold{font-weight:600}.font-bold{font-weight:700}
.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-6{margin-top:24px}
.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mb-6{margin-bottom:24px}
.p-2{padding:8px}.p-3{padding:12px}.p-4{padding:16px}
.rounded { border-radius: var(--r); } .rounded-lg { border-radius: var(--r-lg); } .rounded-full { border-radius: var(--r-full); }

/* Grades responsivas de métricas/dashboards */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.metric { padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-sm); }
.metric .m-label { font-size: .78rem; color: var(--text-mut); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.metric .m-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; color: var(--text); }
.metric .m-sub { font-size: .82rem; color: var(--text-soft); margin-top: 2px; }
.metric .m-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--info-bg); color: var(--brand-600); display: flex; align-items: center; justify-content: center; }

/* Área de upload (drag & drop) */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 26px; text-align: center;
  color: var(--text-soft); transition: all .2s var(--ease); cursor: pointer; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand-500); background: var(--info-bg); color: var(--brand-700); }
.dropzone .dz-ico { width: 46px; height: 46px; margin: 0 auto 10px; color: var(--brand-500); }

/* Segmented control (ex.: KM vazio x pago) */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 4px; gap: 4px; }
.segmented button { border: none; background: transparent; color: var(--text-soft); font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 16px; border-radius: calc(var(--r) - 3px); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all .16s var(--ease); }
.segmented button.active { background: var(--brand-600); color: #fff; box-shadow: var(--sh-sm); }

/* Timeline (histórico) */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline .tl-item { position: relative; padding-bottom: 20px; }
.timeline .tl-dot { position: absolute; left: -21px; top: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--brand-500); }
.timeline .tl-item.pago .tl-dot { border-color: var(--success); }
.timeline .tl-item.vazio .tl-dot { border-color: var(--brand-400); }

/* Chip de filtro / paginação */
.chip { display:inline-flex; align-items:center; gap:6px; padding:6px 12px; border-radius:var(--r-full);
  border:1px solid var(--border); background:var(--surface); font-size:.82rem; cursor:pointer; color:var(--text-soft); }
.chip.active { background: var(--info-bg); color: var(--brand-700); border-color: var(--brand-200); }
.pager { display:flex; align-items:center; justify-content:center; gap:8px; margin-top:18px; }

/* Bell de notificações */
.bell { position: relative; }
.bell .dot { position:absolute; top:6px; right:6px; min-width:16px; height:16px; padding:0 4px; border-radius:999px;
  background:var(--danger); color:#fff; font-size:.66rem; font-weight:700; display:flex; align-items:center; justify-content:center; }

/* ============================================================================
   Mobile First — navbar com menu hamburguer, graficos e tabelas responsivas
   ============================================================================ */
.app-header .inner { position: relative; }
.nav-wrap { display: flex; align-items: center; gap: 6px; margin-left: auto; }
#nav-actions { display: flex; align-items: center; gap: 4px; }

/* Marca / logo */
.brand .logo { background: linear-gradient(135deg, var(--brand-500), var(--brand-800)); }
.brand .logo svg { width: 22px; height: 22px; color: #fff; }
.brand .wordmark { font-weight: 800; letter-spacing: .01em; line-height: 1; }
.brand .wordmark small { display: block; font-size: .58rem; font-weight: 600; letter-spacing: .28em;
  color: var(--brand-500); text-transform: uppercase; margin-top: 2px; }

/* Botao hamburguer (visivel só no mobile) */
.nav-toggle { display: inline-flex; }

/* Menu de links: dropdown no mobile, inline no desktop */
#nav-menu {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  flex-direction: column; gap: 2px; padding: 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--sh-lg); animation: ds-fade .16s var(--ease);
}
#nav-menu.open { display: flex; }
#nav-menu .nav-link { width: 100%; padding: 11px 12px; }
#nav-menu .nav-link .label { display: inline !important; }

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  #nav-menu {
    display: flex; position: static; flex-direction: row; gap: 4px; padding: 0;
    background: none; border: none; box-shadow: none; animation: none;
  }
}

/* Graficos: wrapper com altura fixa (evita canvas crescendo/colapsando) */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box canvas { position: absolute; inset: 0; }
@media (max-width: 640px) { .chart-box { height: 210px; } }

/* Tabelas: rolagem horizontal no mobile */
@media (max-width: 700px) {
  .ds-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}

/* Cartao de destaque financeiro (positivo/negativo) */
.fin-pos { color: var(--success); }
.fin-neg { color: var(--danger); }
.fin-card { border-left: 4px solid var(--border); }
.fin-card.pos { border-left-color: var(--success); }
.fin-card.neg { border-left-color: var(--danger); }

/* Segmented control quebra no mobile */
@media (max-width: 520px) { .segmented { width: 100%; } .segmented button { flex: 1; justify-content: center; } }

/* Ajuste de container e headings no mobile (mobile-first refinements) */
@media (max-width: 640px) {
  .ds-h1 { font-size: 1.4rem; }
  .container { padding: 16px 12px; }
  .modal-card { padding: 18px; }
  .metric .m-value { font-size: 1.45rem; }
}

/* ---- Editor de recorte (Cropper.js) — conter no mobile ---- */
.cropper-container { max-width: 100% !important; }
#crop-img { max-width: 100%; display: block; }
.modal-card img { max-width: 100%; height: auto; }
.dropzone img { max-width: 100%; height: auto; }

/* [PT] Campo de KM bloqueado durante a leitura automatica do odometro */
.input.is-locked{background:var(--surface-2,#f1f4f8);color:var(--muted,#6b7a90);cursor:not-allowed;opacity:.85}
.input.is-locked::placeholder{color:var(--muted,#6b7a90)}

/* ============================================================================
   VARREDURA DE RESPONSIVIDADE — rede de seguranca (aplica a todas as telas)
   Garante que nada estoure horizontalmente em nenhum tamanho de tela.
   ============================================================================ */
body { overflow-x: clip; }                       /* nada vaza na horizontal (nao quebra o header sticky) */
img, svg, video { max-width: 100%; height: auto; }
input, select, textarea, .input, .select { max-width: 100%; }
.card, .metric .m-value, .ds-sub, p { overflow-wrap: anywhere; }
.modal-card { max-height: 90vh; overflow-y: auto; }   /* modais altos rolam em telas curtas */
.page-head, .between { min-width: 0; }                /* permite encolher em vez de empurrar */

/* Celular (<= 640px): filtros/acoes quebram e controles ocupam a largura toda */
@media (max-width: 640px) {
  .row, .between { flex-wrap: wrap; }
  .input[style*="max-width"], .select[style*="max-width"] { max-width: 100% !important; width: 100%; }
  .modal-overlay { padding: 12px; }
  .segmented { width: 100%; }
  .nav-grid { grid-template-columns: 1fr; }
}

/* Telas bem estreitas (<= 380px): reduz respiros e fontes grandes */
@media (max-width: 380px) {
  .ds-h1 { font-size: 1.2rem; }
  .btn-lg { padding: 12px 16px; font-size: .95rem; }
  .container { padding: 14px 10px; }
  .glass { padding: 22px !important; }
  .metric { padding: 14px; }
}
