:root {
  color-scheme: light;

  /* ---------------------------------------------------------------------
     CAMADA DE TOKENS — fonte única de verdade do sistema visual.
     Os tokens de marca são substituídos em tempo de execução pelo Tenant
     Branding; todos os restantes são estruturais e não dependem do cliente.
     --------------------------------------------------------------------- */

  /* Superfícies */
  --bg-app: #f4f7fc;
  --bg-sidebar: #061638;
  --bg-surface: #ffffff;
  --bg-surface-secondary: #f7faff;
  --bg-overlay: rgb(4 17 48 / 62%);

  /* Texto */
  --text-primary: #0c1d3a;
  --text-secondary: #40516d;
  --text-muted: #66758d;
  --text-on-sidebar: #eff7ff;
  --text-on-sidebar-muted: #9fb7da;
  /* Acento legível sobre a barra lateral escura: o verde semântico (--success)
     não tem contraste suficiente contra #102848. */
  --accent-on-dark: #20d7ff;

  /* Fronteiras */
  --border: #dce5f2;
  --border-strong: #c5d2e5;

  /* Semântica de estado */
  --success: #087a5b;
  --success-soft: #dcf7ed;
  --warning: #8b5d05;
  --warning-soft: #fff2ce;
  --danger: #a82943;
  --danger-soft: #fce8ec;
  --info: #075fd8;
  --info-soft: #e7f2ff;

  /* Raios */
  --radius-sm: 9px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgb(6 22 56 / 5%), 0 5px 16px rgb(6 22 56 / 5%);
  --shadow-md: 0 14px 38px rgb(6 22 56 / 10%);
  --shadow-lg: 0 28px 72px rgb(6 22 56 / 20%);

  /* Escala de espaçamento */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Tipografia */
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-md: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;
  --font-size-2xl: 30px;
  --line-tight: 1.2;
  --line-normal: 1.5;

  /* Layout */
  --sidebar-width: 246px;
  --topbar-height: 68px;
  --content-max: 1280px;

  /* Aliases herdados: o design system anterior continua a funcionar sem alterações. */
  --ink: var(--text-primary);
  --muted: var(--text-muted);
  --line: var(--border);
  --page: var(--bg-app);
  --surface: var(--bg-surface);
  --surface-soft: var(--bg-surface-secondary);
  /* Tokens de marca. Os valores por omissão são a identidade CVLogistica; a marca da
     organização substitui-os em tempo de execução via custom properties, sem CSS por
     empresa. Os componentes consomem estes tokens, nunca hexadecimais fixos. */
  --brand-primary: #0a66ff;
  --brand-secondary: #082454;
  --brand-accent: #00bfe8;
  --brand-on-primary: #ffffff;
  --brand-on-secondary: #ffffff;
  --brand-on-accent: #ffffff;
  --brand-on-surface: #075fd8;
  --brand-focus: #075fd8;
  /* Aliases mantidos para não reescrever o design system existente. */
  --brand: var(--brand-primary);
  --brand-dark: var(--brand-secondary);
  --green: var(--success);
  --green-soft: var(--success-soft);
  --gold: var(--warning);
  --gold-soft: var(--warning-soft);
  --violet: var(--info);
  --shadow: var(--shadow-md);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
[hidden] { display: none !important; }

/* O anel de foco tem contraste próprio contra a superfície em que assenta
   (WCAG 2.1 §1.4.11): azul sobre fundos claros, âmbar sobre a barra lateral e
   outros fundos escuros. Não usa a cor da marca: o tenant não pode degradar a
   visibilidade do foco. */
:focus-visible {
  outline: 3px solid #0759dc;
  outline-offset: 3px;
}
.shell-sidebar :focus-visible,
.sidebar :focus-visible,
.bottom-nav :focus-visible,
.on-dark :focus-visible {
  outline-color: #ffd166;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--brand-dark);
  box-shadow: var(--shadow);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.offline-banner {
  position: sticky;
  z-index: 20;
  top: 0;
  padding: 10px 18px;
  background: #fff1c7;
  color: #614100;
  border-bottom: 1px solid #e2c66d;
  text-align: center;
  font-size: 13px;
  font-weight: 750;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px 22px;
  background: var(--bg-sidebar);
  color: var(--text-on-sidebar);
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 34px;
  color: #ffffff;
  text-decoration: none;
  font-size: 16px;
  font-weight: 850;
  letter-spacing: .01em;
}
.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-on-dark);
  color: #062b38;
  font-size: 12px;
  font-weight: 900;
}
.sidebar nav { display: grid; gap: 7px; }
.nav-link {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-radius: 9px;
  color: var(--text-on-sidebar);
  text-decoration: none;
  font-size: 14px;
}
.nav-link.active { background: rgb(255 255 255 / 14%); color: #ffffff; font-weight: 750; box-shadow: inset 3px 0 0 var(--accent-on-dark); }
.nav-link span:last-child { color: var(--text-on-sidebar-muted); font-size: 10px; }
.sidebar-footer {
  margin-top: auto;
  padding: 15px 11px 0;
  border-top: 1px solid rgb(255 255 255 / 16%);
  color: var(--text-on-sidebar-muted);
  font-size: 12px;
}
.online-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--accent-on-dark); }

main { min-width: 0; max-width: 1700px; width: 100%; margin-inline: auto; padding: 32px clamp(22px, 3.4vw, 58px) 52px; }
.mobile-nav { display: none; }
.topbar, .top-actions, .panel-heading, .panel-actions, .dialog-heading, .dialog-actions, .row-actions, .alert-actions {
  display: flex;
  align-items: center;
}
.topbar { justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.top-actions, .panel-actions, .row-actions, .alert-actions { gap: 9px; }
.eyebrow { margin: 0 0 5px; color: var(--brand); font-size: 11px; font-weight: 850; letter-spacing: .11em; }
h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.15; letter-spacing: -.03em; }
h1 { font-size: clamp(27px, 3vw, 38px); }
h2 { font-size: clamp(20px, 2vw, 24px); }
h3 { font-size: 17px; }
.muted-copy, .form-hint { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.primary-button, .secondary-button, .progress-button, .text-button, .icon-button {
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 750;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.primary-button { padding: 10px 16px; background: var(--brand); color: #ffffff; box-shadow: 0 7px 17px rgb(7 89 220 / 18%); }
.primary-button:hover { background: #004bc0; transform: translateY(-1px); }
.secondary-button { padding: 9px 13px; border-color: #cbd6e2; background: #ffffff; color: #324860; }
.secondary-button:hover { border-color: #9fb2c7; background: #f4f7fa; }
.progress-button { min-height: 35px; padding: 7px 10px; background: #e8f1ff; color: #084cae; }
.progress-button:hover { background: #d8e8ff; }
.text-button { min-height: 35px; padding: 6px 8px; background: transparent; color: #15519f; }
.text-button:hover { background: #edf3fb; }
.danger-text { color: var(--danger); }
.icon-button { display: grid; place-items: center; width: 40px; padding: 0; background: #eef2f6; color: #526278; font-size: 24px; line-height: 1; }

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid #c8d6e3;
  border-radius: 999px;
  background: #ffffff;
  color: #455a71;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.connection-icon { width: 8px; height: 8px; border-radius: 50%; background: #78889b; }
.connection-state.live { color: #086649; border-color: #a6dccb; background: #e9f8f2; }
.connection-state.live .connection-icon { background: #15946d; box-shadow: 0 0 0 4px rgb(21 148 109 / 13%); }
.connection-state.reconnecting, .connection-state.polling { color: #704a00; border-color: #ead191; background: #fff8e4; }
.connection-state.reconnecting .connection-icon, .connection-state.polling .connection-icon { background: #d08c09; }
.connection-state.offline { color: #8c263c; border-color: #e8b7c1; background: #fff1f3; }
.connection-state.offline .connection-icon { background: #bb3852; }

.message { min-height: 0; margin: 0 0 18px; color: var(--green); font-size: 13px; font-weight: 700; }
.message.info { color: #315e93; }
.message.error { color: var(--danger); }
.message:not(:empty) { padding: 11px 13px; border: 1px solid currentColor; border-radius: 9px; background: #ffffff; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(135px, 1fr)); gap: 13px; margin-bottom: 24px; }
.metric-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-top: 3px solid #66758a;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 15px rgb(20 35 58 / 5%);
}
.metric-card.accent-blue { border-top-color: var(--brand); }
.metric-card.accent-green { border-top-color: var(--green); }
.metric-card.accent-gold { border-top-color: #c28308; }
.metric-card.accent-violet { border-top-color: var(--violet); }
.metric-card.accent-danger { border-top-color: var(--danger); }
.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 11px; line-height: 1.35; }
.metric-card strong { display: block; margin: 9px 0 5px; font-size: clamp(25px, 2.4vw, 32px); letter-spacing: -.05em; }

.map-panel, .operations-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.map-panel, .queue-panel { margin-bottom: 22px; }
.alerts-panel { margin-bottom: 20px; }
.panel-heading { justify-content: space-between; gap: 20px; padding: 21px 23px 17px; }
.map-content { display: grid; grid-template-columns: minmax(0, 1fr) 220px; border-top: 1px solid var(--line); }
.map-canvas {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  background-color: #eef3fa;
  background-image: linear-gradient(#dbe6f3 1px, transparent 1px), linear-gradient(90deg, #dbe6f3 1px, transparent 1px);
  background-size: 26px 26px;
}
.map-canvas::before {
  content: '';
  position: absolute;
  top: -21%;
  left: 13%;
  width: 70%;
  height: 130%;
  border-radius: 48% 38% 44% 52%;
  background: #d7e5ca;
  opacity: .92;
  transform: rotate(-11deg);
}
.map-watermark { position: absolute; z-index: 1; left: 17px; bottom: 13px; color: var(--text-secondary); font-size: 9px; font-weight: 850; letter-spacing: .09em; }
.map-empty { position: relative; z-index: 1; padding: 100px 20px; color: var(--muted); text-align: center; }
.map-marker { position: absolute; z-index: 2; transform: translate(-50%, -50%); }
/* A cor vem do estado operacional, calculado em operations.js — a folha de
   estilos não tem tabela de cores própria para não haver duas verdades sobre
   o que é «ocupado». O valor de recurso só se usa se o estado não chegar. */
.map-marker.driver { display: grid; place-items: center; width: 29px; height: 29px; border: 3px solid #ffffff; border-radius: 50%; background: var(--estado-cor, var(--brand)); box-shadow: 0 2px 8px rgb(16 40 72 / 38%); color: #ffffff; font-size: 0; }
.map-marker.driver::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #ffffff; }
/* Posição antiga acrescenta-se ao estado em vez de o substituir: o contorno
   passa a tracejado e a cor do estado mantém-se. */
.map-marker.driver[data-posicao-antiga='sim'] { border-style: dashed; }
.map-marker.pickup, .map-marker.dropoff { width: 16px; height: 16px; border: 3px solid #ffffff; box-shadow: 0 1px 6px rgb(16 40 72 / 38%); }
.map-marker.pickup { border-radius: 50%; background: #14966e; }
.map-marker.dropoff { border-radius: 3px; background: #d33d58; transform: translate(-50%, -50%) rotate(45deg); }
.map-summary { display: grid; align-content: center; gap: 15px; padding: 20px 18px; }
.map-summary div { display: grid; gap: 1px; }
.map-summary strong { font-size: 25px; letter-spacing: -.04em; }
.map-summary span, .map-summary p { margin: 0; color: var(--muted); font-size: 11px; }
.legend { display: inline-block; width: 8px; height: 8px; margin: 0 3px 0 8px; border-radius: 50%; }
.legend:first-child { margin-left: 0; }
.driver-dot { background: var(--brand); }
.pickup-dot { background: #14966e; }
.dropoff-dot { background: #d33d58; }
.map-list { display: grid; gap: 0; margin: 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.map-list li { display: flex; justify-content: space-between; gap: 20px; padding: 12px 22px; border-bottom: 1px solid var(--line); font-size: 12px; }
.map-list span { color: var(--muted); white-space: nowrap; }

.filter-bar {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) repeat(3, minmax(130px, .75fr)) auto;
  gap: 12px;
  padding: 0 23px 20px;
}
.filter-bar label, .form-grid label, .inline-form label { display: grid; gap: 6px; color: #40516a; font-size: 12px; font-weight: 750; }
.filter-bar input, .filter-bar select, .form-grid input, .form-grid select, .form-grid textarea, .inline-form input, .inline-form select, .inline-form textarea {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid #c8d3df;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}
.filter-bar input:hover, .filter-bar select:hover, .form-grid input:hover, .form-grid select:hover, .form-grid textarea:hover, .inline-form input:hover, .inline-form select:hover, .inline-form textarea:hover { border-color: #98acc1; }
.filter-reset { align-self: end; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 870px; border-collapse: collapse; }
th, td { padding: 15px 18px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f9fbfd; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
td { font-size: 13px; }
td strong { display: block; font-size: 13px; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.route { max-width: 250px; color: #40516a; }
.clamp { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unassigned { color: var(--gold); font-weight: 750; }
.status { display: inline-block; padding: 6px 8px; border-radius: 999px; font-size: 10px; font-weight: 850; white-space: nowrap; }
.status-ready-for-dispatch, .status-assigned { color: #6e4b03; background: var(--gold-soft); }
.status-accepted, .status-arrived-at-pickup, .status-picked-up { color: #0752ae; background: #e4efff; }
.status-in-transit, .status-arrived-at-dropoff { color: #663592; background: #f1e9f8; }
.status-delivered { color: #086149; background: var(--green-soft); }
.status-cancelled, .status-delivery-failed { color: #97263d; background: var(--danger-soft); }
.queue-cards { display: none; }
.queue-footer { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 10px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }
.loading-state::before { content: ''; display: inline-block; width: 13px; height: 13px; margin-right: 8px; border: 2px solid #b9c8d7; border-top-color: var(--brand); border-radius: 50%; vertical-align: -2px; animation: spin .8s linear infinite; }
.error-state { color: var(--danger); }

.count-badge { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px; background: #edf2f7; color: #43566d; font-size: 12px; font-weight: 850; }
.alert-list { display: grid; }
.alert-item { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 22px; border-top: 1px solid var(--line); border-left: 4px solid #7890aa; }
.alert-item.severity-critical { border-left-color: var(--danger); }
.alert-item.severity-warning { border-left-color: #bd7a00; }
.alert-item strong, .alert-item small { display: block; }
.alert-item strong { margin: 4px 0; font-size: 13px; }
.alert-item small, .alert-meta { color: var(--muted); font-size: 11px; }

dialog { width: min(610px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto; border: 0; border-radius: 15px; background: #ffffff; color: var(--ink); box-shadow: 0 26px 70px rgb(16 40 72 / 38%); }
dialog::backdrop { background: rgb(9 27 52 / 66%); backdrop-filter: blur(2px); }
.dialog-heading { position: sticky; z-index: 2; top: 0; justify-content: space-between; gap: 20px; padding: 21px 23px 18px; border-bottom: 1px solid var(--line); background: #ffffff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 22px 23px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid textarea, .inline-form textarea { resize: vertical; }
.dialog-actions { justify-content: flex-end; gap: 10px; margin: 6px -23px -22px; padding: 17px 23px; border-top: 1px solid var(--line); background: #f9fbfd; }
.selection-summary, .confirmation-copy, .courier-summary { margin: 0; padding: 11px 13px; border-radius: 8px; background: #f4f7fa; color: #40516a; font-size: 12px; line-height: 1.5; }
.confirmation-copy { border-left: 3px solid var(--brand); }

.drawer { width: min(760px, calc(100vw - 16px)); max-width: none; height: calc(100vh - 16px); max-height: none; margin: 8px 8px 8px auto; border-radius: 15px 0 0 15px; }
.drawer-shell { min-height: 100%; }
.drawer-content { padding: 23px; }
.detail-grid { display: grid; gap: 25px; }
.detail-grid > section { padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.detail-grid > section:last-child { padding-bottom: 0; border-bottom: 0; }
.detail-summary dl { display: grid; grid-template-columns: minmax(100px, .6fr) 1.6fr; gap: 9px 18px; margin: 17px 0; }
.detail-summary dt { color: var(--muted); font-size: 12px; font-weight: 750; }
.detail-summary dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 13px; }
.detail-actions { margin-top: 14px; }
.timeline { position: relative; display: grid; gap: 0; margin: 16px 0 0; padding: 0 0 0 24px; list-style: none; }
.timeline::before { content: ''; position: absolute; top: 7px; bottom: 7px; left: 6px; width: 2px; background: #dce5ee; }
.timeline li { position: relative; display: grid; gap: 3px; padding: 0 0 17px; }
.timeline li::before { content: ''; position: absolute; top: 4px; left: -22px; width: 10px; height: 10px; border: 2px solid #ffffff; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px #bfd1e5; }
.timeline span, .timeline small { color: var(--muted); font-size: 11px; }
.notes-list { display: grid; gap: 9px; margin-top: 15px; }
.notes-list article { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.notes-list p { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.notes-list small { color: var(--muted); }
.inline-form { display: grid; gap: 12px; margin-top: 16px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1220px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-reset { justify-self: start; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  main { padding: 0 23px 42px; }
  .mobile-nav { display: flex; align-items: center; gap: 18px; margin: 0 -23px 26px; padding: 12px 23px; border-bottom: 1px solid var(--line); background: #102848; }
  .mobile-nav .brand { margin-right: auto; padding: 0; }
  .mobile-nav a:not(.brand) { color: #dce8f9; text-decoration: none; font-size: 13px; }
  .topbar { margin-top: 0; }
  .map-content { grid-template-columns: minmax(0, 1fr); }
  .map-summary { grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
  .map-summary p { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  main { padding-right: 14px; padding-left: 14px; }
  .mobile-nav { gap: 13px; margin-right: -14px; margin-left: -14px; padding-right: 14px; padding-left: 14px; }
  .mobile-nav .brand span:last-child { display: none; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 15px; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .top-actions .connection-state { margin-right: auto; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric-card { padding: 14px; }
  .panel-heading { align-items: flex-start; padding: 18px 16px 14px; }
  .panel-heading:not(.queue-heading) { flex-wrap: wrap; }
  .queue-heading { align-items: center; }
  .filter-bar { grid-template-columns: minmax(0, 1fr); padding: 0 16px 17px; }
  .filter-reset { width: 100%; }
  .table-wrap { display: none; }
  .queue-cards:not([hidden]) { display: grid; }
  .queue-card { display: grid; gap: 13px; padding: 16px; border-top: 1px solid var(--line); }
  .queue-card header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .queue-card dl { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 7px 12px; margin: 0; }
  .queue-card dt { color: var(--muted); font-size: 11px; font-weight: 750; }
  .queue-card dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 12px; }
  .queue-card .row-actions { justify-content: flex-end; }
  .map-canvas { min-height: 240px; }
  .map-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 16px; }
  .map-list li { align-items: flex-start; flex-direction: column; gap: 4px; padding: 12px 16px; }
  .map-list span { white-space: normal; }
  .alert-item { align-items: flex-start; flex-direction: column; gap: 12px; padding: 15px 16px; }
  .alert-actions { width: 100%; justify-content: flex-end; }
  .form-grid { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .form-grid .wide { grid-column: auto; }
  .dialog-actions { margin: 6px -18px -18px; padding: 15px 18px; }
  .drawer { width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
  .drawer-content { padding: 18px; }
  .detail-summary dl { grid-template-columns: minmax(85px, .7fr) minmax(0, 1.4fr); }
}

@media (max-width: 390px) {
  .mobile-nav { gap: 10px; }
  .mobile-nav a:not(.brand) { font-size: 12px; }
  .top-actions .connection-state { flex-basis: 100%; width: fit-content; }
  .metric-grid { grid-template-columns: minmax(0, 1fr); }
  .metric-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 12px; }
  .metric-card strong { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
  .metric-card small { grid-column: 1; }
  .queue-heading { align-items: flex-start; flex-direction: column; }
  .panel-actions, .panel-actions .secondary-button { width: 100%; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .status, .connection-state, .metric-card, .alert-item { border: 1px solid CanvasText; }
  .connection-icon, .legend, .timeline li::before { forced-color-adjust: none; }
}

/* Acompanhamento público do destinatário (tracking.html).
   Reutiliza os tokens do design system; não introduz paleta nova. */
.tracking-body { background: var(--page); }
.tracking-page { max-width: 720px; margin: 0 auto; padding: 28px 18px 48px; display: flex; flex-direction: column; gap: 16px; }
.tracking-header h1 { margin: 4px 0 6px; font-size: 26px; letter-spacing: -.4px; }
.tracking-subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.tracking-main { display: flex; flex-direction: column; gap: 16px; }
.tracking-main:focus-visible { outline-offset: 6px; }

.tracking-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.tracking-card h2 { margin: 0 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.tracking-card p { margin: 0 0 6px; }
.tracking-card--muted { background: var(--surface-soft); box-shadow: none; }
/* O erro é comunicado por título, texto e ícone textual, não apenas por cor. */
.tracking-card--error { border-color: #e7b3bf; background: var(--danger-soft); }
.tracking-card--error h2 { color: var(--danger); }
.tracking-card--error h2::before { content: "! "; font-weight: 800; }

.tracking-loading-text { color: var(--muted); }
.tracking-reference { font-size: 13px; color: var(--muted); letter-spacing: .4px; }
.tracking-status { font-size: 24px; font-weight: 760; line-height: 1.25; margin: 2px 0 4px; color: var(--brand-dark); }
.tracking-status-code { font-size: 12px; color: var(--muted); }
.tracking-eta { margin: 14px 0 8px; padding: 12px 14px; border-radius: 10px; background: var(--green-soft); }
.tracking-eta dt { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--green); font-weight: 700; }
.tracking-eta dd { margin: 4px 0 0; font-size: 17px; font-weight: 700; color: var(--ink); }
.tracking-updated { font-size: 12px; color: var(--muted); margin: 0; }
.tracking-note { font-size: 12px; color: var(--muted); }
.tracking-coords { font-size: 13px; font-variant-numeric: tabular-nums; }

.tracking-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tracking-timeline-item { position: relative; padding: 8px 0 12px 20px; border-left: 2px solid var(--line); }
.tracking-timeline-item:last-child { border-left-color: transparent; }
.tracking-timeline-item::before {
  content: ""; position: absolute; left: -6px; top: 12px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand);
}
.tracking-timeline-item:first-child::before { background: var(--brand); }
.tracking-timeline-label { font-weight: 650; margin: 0; }
.tracking-timeline-time { font-size: 12px; color: var(--muted); margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.tracking-timeline-reason { font-size: 12px; color: var(--danger); margin: 4px 0 0; }

.tracking-footer p { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }

@media (max-width: 560px) {
  .tracking-page { padding: 18px 12px 36px; gap: 12px; }
  .tracking-card { padding: 16px; border-radius: 12px; }
  .tracking-status { font-size: 21px; }
  .tracking-header h1 { font-size: 22px; }
}

/* Componentes de marca partilhados por todas as interfaces. */
.brand-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-identity img { display: block; max-height: 34px; max-width: 132px; object-fit: contain; }
.brand-identity-text { display: flex; flex-direction: column; min-width: 0; }
.brand-identity-name { font-weight: 760; letter-spacing: -.2px; line-height: 1.15; overflow-wrap: anywhere; }
.brand-identity-slogan { font-size: 12px; color: var(--muted); line-height: 1.25; }
.brand-powered-by { font-size: 11px; color: var(--muted); letter-spacing: .2px; }
.brand-powered-by[hidden] { display: none !important; }

/* Pré-visualização da marca no portal da empresa. */
.brand-preview { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.brand-preview-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--brand-primary); color: var(--brand-on-primary); }
.brand-preview-sidebar { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 10px; background: var(--brand-secondary); color: var(--brand-on-secondary); }
.brand-preview-button { display: inline-block; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--brand-primary); color: var(--brand-on-primary); font-weight: 700; }
.brand-preview-accent { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--brand-accent); color: var(--brand-on-accent); font-size: 12px; font-weight: 700; }
.brand-preview-card { padding: 14px; border: 1px solid var(--line); border-left: 4px solid var(--brand-primary); border-radius: 10px; background: var(--surface-soft); }
.brand-preview-link { color: var(--brand-on-surface); font-weight: 650; }
/* Na pré-visualização, a barra lateral simulada é escura: o slogan herda a cor
   "on-secondary" da marca em vez do cinzento de superfície clara, que só chegaria
   a 2.36:1. */
.brand-preview-sidebar .brand-identity-slogan,
.brand-preview-header .brand-identity-slogan { color: inherit; }
.brand-warnings { margin: 0; padding-left: 18px; font-size: 13px; color: var(--gold); }

@media (max-width: 560px) {
  .brand-identity img { max-height: 28px; max-width: 104px; }
  .brand-preview { padding: 12px; }
}

/* =====================================================================
   COMPONENTES DO SISTEMA VISUAL
   Um único sistema partilhado pelas seis páginas. Nenhum estilo é
   específico de uma empresa: a identidade entra pelos tokens de marca.
   ===================================================================== */

/* --- Classes que o HTML usava sem definição -------------------------- */
.search-field { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.search-field input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
}
.wide-field { grid-column: 1 / -1; }
.map-live { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--font-size-xs); font-weight: 700; color: var(--success); }
.map-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

/* --- Aparência aplicacional partilhada ------------------------------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); background: var(--bg-app); }
.identity-entry { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: var(--space-5); padding: var(--space-5); background: var(--bg-app); }
.identity-brand { display: grid; justify-items: center; gap: 2px; color: var(--text-primary); }
.identity-brand strong { font-size: var(--font-size-2xl); letter-spacing: -.5px; }
.identity-brand span { color: var(--text-muted); font-size: var(--font-size-sm); }
.identity-card { width: min(100%, 440px); }
.identity-card h1 { margin-top: 0; }
.shell-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-4);
  background: var(--bg-sidebar);
  color: var(--text-on-sidebar);
}
.shell-main { min-width: 0; display: flex; flex-direction: column; }
.shell-content { flex: 1; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); max-width: var(--content-max); width: 100%; }

.shell-nav { display: flex; flex-direction: column; gap: var(--space-1); }
.shell-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-on-sidebar);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 650;
}
.shell-nav a:hover { background: rgb(255 255 255 / 8%); }
/* O item ativo é marcado por barra e peso, nunca apenas por cor. */
.shell-nav a[aria-current="page"] { background: rgb(255 255 255 / 14%); box-shadow: inset 3px 0 0 var(--accent-on-dark); }
.shell-nav-group { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: .8px; color: var(--text-on-sidebar-muted); padding: var(--space-3) 12px var(--space-1); }
/* Dentro da barra lateral escura o texto secundário usa o tom próprio: o cinzento
   de superfície clara (--text-muted) só chega a 2.98:1 sobre #102848. */
.shell-sidebar .brand-identity-slogan,
.shell-sidebar .brand-powered-by,
.sidebar .brand-identity-slogan,
.sidebar .brand-powered-by { color: var(--text-on-sidebar-muted); }
.shell-sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); color: var(--text-on-sidebar-muted); font-size: var(--font-size-xs); }

.shell-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.shell-topbar h1 { margin: 0; font-size: var(--font-size-xl); line-height: var(--line-tight); letter-spacing: -.4px; }
.breadcrumb { display: flex; gap: var(--space-2); margin: 0 0 2px; padding: 0; list-style: none; font-size: var(--font-size-xs); color: var(--text-muted); }
.breadcrumb li + li::before { content: "/"; margin-right: var(--space-2); color: var(--border-strong); }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.shell-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--font-size-xs); }

/* --- Cartões e secções ----------------------------------------------- */
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: var(--space-5); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.card-title { margin: 0; font-size: var(--font-size-lg); letter-spacing: -.2px; }
.card-subtitle { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: var(--font-size-sm); }
.card-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.stat-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.stat-label { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); font-weight: 700; }
.stat-value { font-size: var(--font-size-2xl); font-weight: 760; line-height: var(--line-tight); font-variant-numeric: tabular-nums; }
.stat-hint { font-size: var(--font-size-xs); color: var(--text-muted); }
.stat--accent { border-left: 4px solid var(--brand-primary); }

/* --- Status pills: cor, texto e forma; nunca só cor ------------------ */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); border: 1px solid transparent; font-size: var(--font-size-xs); font-weight: 750; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill--neutral { background: var(--bg-surface-secondary); color: var(--text-secondary); border-color: var(--border); }
.pill--info { background: var(--info-soft); color: var(--info); }
.pill--progress { background: var(--warning-soft); color: var(--warning); }
.pill--success { background: var(--success-soft); color: var(--success); }
.pill--danger { background: var(--danger-soft); color: var(--danger); }
/* Marca de forma distinta, para o estado ser percetível sem cor. */
.pill--danger::before { border-radius: 2px; }
.pill--progress::before { border-radius: 2px; transform: rotate(45deg); }

/* --- Tabela que se converte em cartões ------------------------------- */
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; }
/* `table-layout: fixed` obriga as colunas a partilhar a largura do cartão:
   moradas longas quebram em vez de empurrarem a página para o lado. */
.data-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; font-size: var(--font-size-sm); }
.data-table th, .data-table td { overflow-wrap: anywhere; }
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: var(--space-3);
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
}
.data-table tbody td { padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg-surface-secondary); }
.data-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  /* Em ecrã estreito a tabela vira lista de cartões: nenhuma operação
     essencial passa a exigir scroll horizontal. */
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .data-table tbody tr { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface); }
  .data-table tbody td { display: flex; justify-content: space-between; gap: var(--space-3); padding: 0; border: 0; }
  .data-table tbody td::before { content: attr(data-label); font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; }
  .data-table .numeric { text-align: left; }
  .data-table { table-layout: auto; }
  .table-scroll { overflow-x: visible; }
}

/* --- Estados de interface -------------------------------------------- */
.state { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-4); text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface-secondary); color: var(--text-secondary); }
.state-title { margin: 0; font-size: var(--font-size-md); font-weight: 700; color: var(--text-primary); }
.state-detail { margin: 0; font-size: var(--font-size-sm); color: var(--text-muted); max-width: 46ch; }
.state--error { border-style: solid; border-color: var(--danger); background: var(--danger-soft); }
.state--error .state-title::before { content: "! "; color: var(--danger); font-weight: 800; }

.skeleton { display: grid; gap: var(--space-3); }
.skeleton-line { height: 14px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--bg-surface-secondary) 25%, #eef2f7 37%, var(--bg-surface-secondary) 63%); background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite; }
.skeleton-line:nth-child(2) { width: 82%; }
.skeleton-line:nth-child(3) { width: 64%; }
@keyframes skeleton-shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* --- Toasts ----------------------------------------------------------- */
.toast-region { position: fixed; z-index: 60; right: var(--space-4); bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); width: min(360px, calc(100vw - var(--space-6))); }
.toast { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); border-left-width: 4px; background: var(--bg-surface); box-shadow: var(--shadow-lg); font-size: var(--font-size-sm); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { border: 0; background: transparent; color: var(--text-muted); font-size: var(--font-size-lg); line-height: 1; padding: 0 var(--space-1); }
/* Prefixo textual: o tipo é percetível sem depender de cor. */
.toast::before { font-weight: 800; }
.toast--success { border-left-color: var(--success); }
.toast--success::before { content: "OK"; color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--error::before { content: "!"; color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast--warning::before { content: "!"; color: var(--warning); }
.toast--info { border-left-color: var(--info); }
.toast--info::before { content: "i"; color: var(--info); }

/* --- Modal de confirmação -------------------------------------------- */
.modal { border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: min(480px, calc(100vw - var(--space-6))); }
.modal::backdrop { background: var(--bg-overlay); }
.modal-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.modal-title { margin: 0; font-size: var(--font-size-lg); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); flex-wrap: wrap; }

/* --- Formulários ------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: var(--font-size-sm); font-weight: 650; color: var(--text-secondary); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--font-size-md);
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--bg-surface-secondary); color: var(--text-muted); }
.field-help { font-size: var(--font-size-xs); color: var(--text-muted); }
.field-error { font-size: var(--font-size-xs); color: var(--danger); font-weight: 650; }
.field-error::before { content: "! "; font-weight: 800; }
.field[data-invalid="true"] input, .field[data-invalid="true"] select, .field[data-invalid="true"] textarea { border-color: var(--danger); }
.field-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.detail-stack { display: grid; gap: var(--space-4); max-width: 1120px; }
.detail-section { display: grid; gap: var(--space-4); padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface-secondary); }
.detail-section > h3 { margin: 0; }
.stacked-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.stacked-form > .form-field { display: grid; gap: var(--space-2); min-width: 0; color: var(--text-muted); font-size: var(--font-size-sm); font-weight: 700; }
.stacked-form > .form-field input, .stacked-form > .form-field select { width: 100%; min-width: 0; }
.stacked-form > .form-hint, .stacked-form > .form-actions { grid-column: 1 / -1; }
.fleet-list { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.fleet-item { display: grid; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface); }
.fleet-item-summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.fleet-item-summary > :first-child { margin-right: auto; font-weight: 700; }
.fleet-editor { border-top: 1px solid var(--border); padding-top: var(--space-3); }
.fleet-editor summary { cursor: pointer; color: var(--brand-primary); font-weight: 700; }
.fleet-edit-form { margin-top: var(--space-3); }
.report-filters { margin-bottom: var(--space-5); }
.location-picker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

/* --- Stepper do assistente ------------------------------------------- */
.stepper { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-5); padding: 0; list-style: none; }
.stepper li { flex: 1 1 140px; display: flex; flex-direction: column; gap: 4px; padding-top: var(--space-2); border-top: 3px solid var(--border); color: var(--text-muted); font-size: var(--font-size-xs); font-weight: 700; }
.stepper li[aria-current="step"] { border-top-color: var(--brand-primary); color: var(--brand-on-surface); }
.stepper li[data-complete="true"] { border-top-color: var(--success); color: var(--success); }

/* --- Timeline vertical ------------------------------------------------ */
.vtimeline { list-style: none; margin: 0; padding: 0; }
.vtimeline li { position: relative; padding: 0 0 var(--space-4) var(--space-5); border-left: 2px solid var(--border); }
.vtimeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.vtimeline li::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg-surface); border: 2px solid var(--brand-primary); }
.vtimeline li[data-current="true"]::before { background: var(--brand-primary); }
.vtimeline-label { font-weight: 650; }
.vtimeline-time { font-size: var(--font-size-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- Navegação inferior da PWA --------------------------------------- */
.bottom-nav { position: sticky; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-1); padding: var(--space-2); background: var(--bg-surface); border-top: 1px solid var(--border); }
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  /* Alvo táctil confortável para uso com uma só mão. */
  min-height: 52px;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
}
.bottom-nav button[aria-current="page"] { background: var(--bg-surface-secondary); color: var(--brand-on-surface); box-shadow: inset 0 -3px 0 var(--brand-primary); }

/* --- Ações grandes do estafeta --------------------------------------- */
.action-stack { display: grid; gap: var(--space-3); }
.action-button { min-height: 60px; padding: var(--space-4); border: 0; border-radius: var(--radius-md); background: var(--brand-primary); color: var(--brand-on-primary); font-size: var(--font-size-lg); font-weight: 760; }
.action-button--secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-strong); }
.action-button--danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }

/* --- Responsividade da aparência aplicacional ------------------------- */
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .shell-sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: var(--space-4); overflow-x: auto; padding: var(--space-3) var(--space-4); }
  .shell-nav { flex-direction: row; gap: var(--space-2); }
  .shell-nav-group, .shell-sidebar-footer { display: none; }
  .shell-content { padding: var(--space-4); }
}

@media (max-width: 560px) {
  .shell-topbar { flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
  .shell-topbar h1 { font-size: var(--font-size-lg); }
  .shell-content { padding: var(--space-3); gap: var(--space-4); }
  .card { padding: var(--space-4); }
  .toast-region { right: var(--space-2); left: var(--space-2); width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line { animation: none; }
}

@media (forced-colors: active) {
  .pill, .card, .stat, .toast, .state { border: 1px solid CanvasText; }
  .shell-nav a[aria-current="page"] { outline: 2px solid CanvasText; }
}

/* Progresso público da entrega. O estado é dado por posição, texto e cor —
   nunca só por cor (WCAG 2.1 §1.4.1). */
.tracking-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.tracking-progress li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  text-align: center;
}
.tracking-progress li::before {
  position: absolute;
  z-index: 0;
  top: 7px;
  left: -50%;
  width: 100%;
  height: 3px;
  background: var(--border-strong);
  content: "";
}
.tracking-progress li:first-child::before { display: none; }
.tracking-progress li > span {
  z-index: 1;
  width: 17px;
  height: 17px;
  border: 3px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-surface);
}
.tracking-progress li[data-state="done"] { color: var(--text-secondary); }
.tracking-progress li[data-state="done"]::before,
.tracking-progress li[data-state="current"]::before { background: var(--success); }
.tracking-progress li[data-state="done"] > span { border-color: var(--success); background: var(--success); }
.tracking-progress li[data-state="current"] {
  color: var(--text-primary);
  font-weight: 720;
}
.tracking-progress li[data-state="current"] > span {
  border-color: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

@media (max-width: 430px) {
  .tracking-progress li small { font-size: 10px; }
}

@media (forced-colors: active) {
  .tracking-progress li > span { forced-color-adjust: none; border-color: CanvasText; }
  .tracking-progress li[data-state="done"] > span { background: CanvasText; }
}

/* =====================================================================
   CVLogistica product polish · identidade comercial 2026
   Camada estritamente visual: os tokens de tenant continuam soberanos.
   ===================================================================== */

body { font-synthesis: none; -webkit-font-smoothing: antialiased; }
a, button, input, select, textarea, .card, .stat, .metric-card, .toast, dialog {
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 160ms ease;
}

.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(105deg, var(--brand-primary), var(--brand-accent));
  box-shadow: 0 9px 24px color-mix(in srgb, var(--brand-primary) 24%, transparent);
  font-weight: 750;
}
.primary-button:hover { background: linear-gradient(105deg, color-mix(in srgb, var(--brand-primary) 88%, #001b43), var(--brand-accent)); box-shadow: 0 12px 28px color-mix(in srgb, var(--brand-primary) 30%, transparent); }
.secondary-button { min-height: 42px; border-color: var(--border-strong); border-radius: 10px; background: var(--bg-surface); color: var(--text-primary); font-weight: 680; }
.secondary-button:hover { border-color: color-mix(in srgb, var(--brand-primary) 36%, var(--border)); background: var(--info-soft); color: var(--brand-on-surface); }
.text-button { color: var(--brand-on-surface); font-weight: 720; }

.card, .operations-panel, .map-panel, .tracking-card {
  border-color: color-mix(in srgb, var(--border) 84%, white);
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: color-mix(in srgb, var(--brand-primary) 16%, var(--border)); box-shadow: 0 8px 28px rgb(6 22 56 / 7%); }
.card-header { margin-bottom: var(--space-5); }
.card-title { letter-spacing: -.25px; }
.card-subtitle { line-height: 1.55; }

.field > span:first-child { color: var(--text-secondary); font-weight: 700; }
.field input, .field select, .field textarea {
  min-height: 46px;
  border-color: var(--border);
  border-radius: 10px;
  background: #fbfdff;
  box-shadow: inset 0 1px 2px rgb(6 22 56 / 3%);
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-primary) 12%, transparent); }

.pill, .status, .connection-state { border: 1px solid currentColor; border-color: color-mix(in srgb, currentColor 18%, transparent); font-weight: 750; letter-spacing: .01em; }
.pill--success, .status-delivered { background: var(--success-soft); color: var(--success); }
.pill--progress, .status-in-transit, .status-assigned { background: var(--info-soft); color: var(--info); }
.pill--danger, .status-delivery-failed, .status-cancelled { background: var(--danger-soft); color: var(--danger); }

/* Entrada única -------------------------------------------------------- */
.identity-entry {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(400px, 42%) minmax(0, 58%);
  align-content: stretch;
  justify-items: stretch;
  gap: 0;
  padding: 0;
  background: #ffffff;
}
.identity-login-panel { display: grid; align-items: center; padding: clamp(32px, 6vw, 88px); background: #fff; }
.identity-login-inner { width: min(100%, 460px); margin: 0 auto; }
.identity-logo { display: block; width: min(100%, 310px); height: 112px; margin: 0 0 clamp(32px, 5vh, 58px); object-fit: cover; object-position: center; }
.identity-intro { margin-bottom: 28px; }
.identity-intro .eyebrow { margin-bottom: 10px; color: var(--brand-on-surface); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.identity-intro h1 { margin: 0 0 10px; color: var(--text-primary); font-size: clamp(30px, 3vw, 42px); letter-spacing: -.045em; line-height: 1.08; }
.identity-intro p:last-child { max-width: 42ch; margin: 0; color: var(--text-muted); line-height: 1.6; }
.identity-form { gap: 18px; }
.identity-submit { width: 100%; min-height: 50px; justify-content: center; font-size: 15px; }
.identity-submit span { margin-left: auto; font-size: 20px; }
.identity-recovery-trigger { display: block; margin: 18px auto 0; }
.identity-flow { margin-top: 22px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface-secondary); }
.identity-flow-title { margin: 0 0 14px; font-weight: 780; }
.identity-assurance { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 28px 0 0; color: var(--text-muted); font-size: 12px; }
.identity-assurance span { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); font-weight: 900; }
.identity-hero { position: relative; min-height: 100svh; overflow: hidden; background: #061638; color: white; }
.identity-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 62% center; }
.identity-hero-overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgb(3 14 41 / 84%) 0%, rgb(3 14 41 / 40%) 48%, rgb(3 14 41 / 20%) 100%), linear-gradient(0deg, rgb(3 14 41 / 72%) 0%, transparent 58%); }

/* Faixa de capacidades no hero do login.
   Mantém-se dentro da identidade CVLogistica e não depende da marca do tenant. */
.identity-feature-rail {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 112px;
  margin: 0;
  padding: 15px clamp(14px, 2vw, 26px);
  list-style: none;
  border-bottom: 1px solid rgb(97 229 255 / 18%);
  background:
    linear-gradient(90deg, rgb(4 22 58 / 96%), rgb(5 37 91 / 91%)),
    radial-gradient(circle at 14% 0%, rgb(44 220 255 / 16%), transparent 36%);
  box-shadow: 0 8px 32px rgb(1 11 32 / 20%);
  backdrop-filter: blur(12px);
}
.identity-feature-rail li {
  min-width: 0;
  display: grid;
  grid-template-rows: 29px auto auto;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 3px 12px;
  text-align: center;
}
.identity-feature-rail li + li { border-left: 1px solid rgb(173 215 255 / 18%); }
.identity-feature-icon { width: 27px; height: 27px; color: #2cdcff; }
.identity-feature-rail strong {
  display: block;
  color: #ffffff;
  font-size: 12px;
  font-weight: 780;
  line-height: 1.2;
  letter-spacing: -.01em;
}
.identity-feature-rail span {
  display: block;
  max-width: 150px;
  color: rgb(239 247 255 / 68%);
  font-size: 10px;
  line-height: 1.35;
}
.identity-hero--with-features .identity-hero-content {
  /* Mantém a mensagem principal livre da faixa superior em ecrãs menos altos. */
  max-height: calc(100svh - 150px);
}
.identity-hero-content { position: absolute; z-index: 1; right: clamp(30px, 7vw, 96px); bottom: clamp(40px, 8vh, 98px); left: clamp(30px, 7vw, 96px); max-width: 720px; }
.hero-kicker { margin: 0 0 18px; color: #61e5ff; font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.identity-hero h2 { max-width: 720px; margin: 0; color: #fff; font-size: clamp(40px, 5vw, 74px); letter-spacing: -.055em; line-height: .98; text-wrap: balance; }
.identity-hero h2 span { color: #2cdcff; }
.identity-hero-content > p:not(.hero-kicker, .platform-status) { max-width: 54ch; margin: 24px 0; color: rgb(239 247 255 / 82%); font-size: clamp(15px, 1.4vw, 18px); line-height: 1.65; }
.identity-benefits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 30px 0; padding: 0; list-style: none; }
.identity-benefits li { padding: 16px; border: 1px solid rgb(120 210 255 / 22%); border-radius: 14px; background: rgb(4 23 58 / 52%); backdrop-filter: blur(12px); }
.identity-benefits strong, .identity-benefits span { display: block; }
.identity-benefits strong { margin-bottom: 4px; color: white; font-size: 13px; }
.identity-benefits span { color: rgb(239 247 255 / 68%); font-size: 11px; line-height: 1.4; }
.platform-status { display: inline-flex; align-items: center; gap: 9px; margin: 0; padding: 9px 13px; border: 1px solid rgb(41 214 156 / 25%); border-radius: var(--radius-pill); background: rgb(4 28 46 / 64%); color: #aaf4d8; font-size: 12px; font-weight: 720; }
.platform-status span { width: 8px; height: 8px; border-radius: 50%; background: #20dc9a; box-shadow: 0 0 0 5px rgb(32 220 154 / 14%); }

/* Shell autenticada --------------------------------------------------- */
.shell { background: linear-gradient(135deg, #f7faff 0%, var(--bg-app) 55%, #eef5ff 100%); }
.shell-sidebar, .sidebar { background: radial-gradient(circle at 20% 0%, #0d3270 0, var(--bg-sidebar) 38%, #04112d 100%); }
.shell-sidebar { padding: 24px 18px; border-right: 1px solid rgb(85 173 255 / 12%); }
.shell-sidebar .brand-identity { min-height: 70px; margin-bottom: 16px; }
.brand-base-logo { display: block; width: 100%; max-width: 202px; height: 68px; object-fit: cover; object-position: center; border-radius: 10px; }
.shell-sidebar .brand-identity > img[data-branding="logo"] { max-width: 190px; max-height: 64px; object-fit: contain; }
.shell-nav { gap: 5px; }
.shell-nav a { min-height: 44px; border: 1px solid transparent; border-radius: 10px; }
.shell-nav a:hover { border-color: rgb(80 196 255 / 14%); background: rgb(33 151 255 / 10%); color: #fff; transform: translateX(2px); }
.shell-nav a[aria-current="page"] { background: linear-gradient(90deg, rgb(10 102 255 / 32%), rgb(0 191 232 / 10%)); box-shadow: inset 3px 0 0 #27d8ff; color: #fff; }
.shell-topbar { min-height: 82px; padding: 15px 28px; background: rgb(255 255 255 / 88%); box-shadow: 0 1px 0 var(--border); backdrop-filter: blur(16px); }
.shell-topbar h1 { font-size: 22px; letter-spacing: -.55px; }
.shell-content { max-width: 1480px; padding: 28px; gap: 24px; }
.shell-footer { background: rgb(255 255 255 / 48%); }
.stat-grid { gap: 14px; }
.stat { position: relative; overflow: hidden; min-height: 120px; padding: 20px; }
.stat::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(var(--brand-primary), var(--brand-accent)); content: ""; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-value { color: var(--text-primary); font-size: clamp(26px, 2.4vw, 36px); letter-spacing: -.05em; }
.stat-hint { margin-top: auto; }

/* Torre de controlo --------------------------------------------------- */
.operations-page .app-shell { background: linear-gradient(135deg, #f7faff, #eef5ff); }
.operations-page .sidebar { padding: 22px 18px; }
.brand-logo-link img { display: block; width: 205px; height: 76px; object-fit: contain; border-radius: 10px; }
.mobile-nav .brand img { width: 34px; height: 34px; border-radius: 9px; }
.operations-page main { max-width: 1680px; }
.operations-page .topbar { padding-top: 8px; }
.metric-grid { gap: 12px; }
.metric-card { min-height: 116px; border-top-width: 0; border-radius: 14px; box-shadow: var(--shadow-sm); }
.metric-card::before { display: block; width: 30px; height: 4px; margin-bottom: 10px; border-radius: 4px; background: var(--brand-primary); content: ""; }
.metric-card.accent-green::before { background: var(--success); }
.metric-card.accent-gold::before { background: var(--warning); }
.metric-card.accent-violet::before { background: var(--info); }
.metric-card.accent-danger::before { background: var(--danger); }
.operations-page .map-panel { padding: 22px; border-radius: 18px; box-shadow: var(--shadow-md); }
.operations-page .map-canvas { min-height: clamp(390px, 47vh, 640px); border: 1px solid #bcd4ee; border-radius: 16px; background: radial-gradient(circle at 75% 28%, rgb(0 191 232 / 18%), transparent 30%), linear-gradient(145deg, #dcecff, #f5faff 50%, #e7f2ff); }
.operations-page .map-canvas::after { position: absolute; inset: 12% 10%; border: 1px dashed rgb(10 102 255 / 28%); border-radius: 45% 55% 38% 62%; content: ""; transform: rotate(-4deg); }
.queue-panel { border-radius: 18px; }
.drawer { box-shadow: -24px 0 70px rgb(4 17 45 / 20%); transform-origin: right center; }

/* Portal e wizard ----------------------------------------------------- */
#view-dashboard { grid-template-columns: 1fr; }
#view-dashboard > .stat-grid { grid-column: 1 / -1; }
#view-wizard { max-width: 980px; margin: 0 auto; padding: clamp(22px, 4vw, 42px); }
.stepper { counter-reset: product-step; gap: 0; }
.stepper li { position: relative; padding: 40px 10px 0; border-top: 2px solid var(--border); text-align: center; }
.stepper li::before { position: absolute; top: -16px; left: 50%; display: grid; width: 32px; height: 32px; place-items: center; border: 2px solid var(--border); border-radius: 50%; background: white; content: counter(product-step); counter-increment: product-step; transform: translateX(-50%); }
.stepper li[aria-current="step"]::before { border-color: var(--brand-primary); background: var(--brand-primary); color: white; box-shadow: 0 0 0 5px var(--info-soft); }
.stepper li[data-complete="true"]::before { border-color: var(--success); background: var(--success); color: white; }
#wizard-form fieldset { min-height: 320px; padding: 26px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-surface-secondary); }
#wizard-form legend { padding: 0 8px; color: var(--text-primary); font-size: 14px; font-weight: 760; }

/* Tracking público ---------------------------------------------------- */
.tracking-body { background: radial-gradient(circle at 50% 0%, #0f438b 0, #061638 28%, #eef5ff 28.2%); }
.tracking-page { max-width: 880px; padding-top: 42px; }
.tracking-header { padding: 8px 10px 24px; color: #fff; text-align: center; }
.tracking-header .brand-identity { justify-content: center; }
.tracking-header .brand-base-logo { width: min(100%, 300px); height: 92px; margin: 0 auto 14px; }
.tracking-header h1 { margin-top: 12px; color: white; font-size: clamp(28px, 5vw, 42px); letter-spacing: -.04em; }
.tracking-subtitle { color: rgb(239 247 255 / 72%); }
.tracking-main { gap: 18px; }
.tracking-card { padding: clamp(20px, 4vw, 32px); border-radius: 18px; box-shadow: 0 16px 46px rgb(6 22 56 / 10%); }
.tracking-hero { position: relative; overflow: hidden; border-top: 4px solid var(--brand-primary); }
.tracking-hero::after { position: absolute; top: -80px; right: -70px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--brand-accent) 16%, transparent), transparent 70%); content: ""; pointer-events: none; }
.tracking-status { color: var(--brand-on-surface); font-size: clamp(28px, 5vw, 40px); letter-spacing: -.035em; }
.tracking-eta { padding: 18px; border: 1px solid color-mix(in srgb, var(--success) 18%, transparent); border-radius: 14px; }
.tracking-eta dd { font-size: 22px; }
#tracking-courier-card { min-height: 180px; background: radial-gradient(circle at 82% 20%, color-mix(in srgb, var(--brand-accent) 18%, transparent), transparent 26%), linear-gradient(135deg, #f8fbff, #eaf3ff); }
.tracking-timeline-item { padding: 10px 0 18px 26px; border-left-width: 3px; }
.tracking-timeline-item::before { left: -7px; width: 12px; height: 12px; box-shadow: 0 0 0 4px #fff; }

@media (max-width: 1024px) {
  .identity-entry { grid-template-columns: minmax(360px, 48%) minmax(0, 52%); }
  .identity-feature-rail { grid-template-columns: repeat(3, minmax(0, 1fr)); min-height: 166px; padding-block: 11px; }
  .identity-feature-rail li:nth-child(4) { border-left: 0; }
  .identity-feature-rail li:nth-child(n+4) { border-top: 1px solid rgb(173 215 255 / 14%); }
  .identity-login-panel { padding: 36px; }
  .identity-hero-content { right: 34px; bottom: 46px; left: 34px; }
  .identity-benefits { grid-template-columns: 1fr; max-width: 340px; }
  .identity-benefits li:nth-child(n+3) { display: none; }
  .brand-base-logo { max-width: 180px; }
}

@media (max-width: 768px) {
  .stacked-form { grid-template-columns: minmax(0, 1fr); }
  .stacked-form > .form-hint, .stacked-form > .form-actions { grid-column: auto; }
  .detail-section { padding: var(--space-4); }
  .identity-entry { grid-template-columns: 1fr; }
  .identity-login-panel { min-height: 100svh; padding: 34px 22px; }
  .identity-logo { width: 250px; height: 92px; margin-bottom: 34px; }
  .identity-hero { display: none; }
  .shell-topbar { padding-inline: 20px; }
  .shell-content { padding: 20px; }
  .operations-page .map-canvas { min-height: 340px; }
  #wizard-form fieldset { min-height: 0; padding: 20px; }
}

@media (max-width: 430px) {
  .identity-login-panel { padding: 26px 18px; }
  .identity-logo { width: 220px; height: 80px; margin-bottom: 26px; }
  .identity-intro h1 { font-size: 30px; }
  .identity-assurance { align-items: flex-start; text-align: left; }
  .shell-content { padding: 14px; }
  .stat { min-height: 104px; }
  .tracking-page { padding-top: 24px; }
  .tracking-header .brand-base-logo { width: 230px; height: 72px; }
  .stepper li { min-width: 72px; padding-inline: 4px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Estado comercial da subscrição. Âmbar para restrição (reversível, o cliente
   pode agir) e vermelho para revogação (encerramento). Nunca aparece por
   indisponibilidade da plataforma comercial. */
.limit-warning {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #e2c66d;
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  color: #5a3d02;
  font-size: var(--font-size-sm);
}
.limit-warning[data-state="OVER_LIMIT"],
.limit-warning[data-state="LIMIT_REACHED"] {
  border-color: #e7b3bf;
  background: var(--danger-soft);
  color: #6e1a2c;
}

/* --- Capacidades e credenciais ----------------------------------------
   Uma capacidade bloqueada continua visível: esconder deixaria o cliente sem
   saber que existe, e sem saber que plano a dá. */
.plan-capabilities { display: grid; gap: var(--space-3); margin-bottom: var(--space-5); }
.plan-capability { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); }
.plan-capability[data-available="false"] { background: var(--bg-muted, #f4f7fb); color: var(--text-muted); }
.plan-capability-name { font-weight: 730; }
.plan-capability-hint { font-size: var(--font-size-sm); }
.api-clients { margin-top: var(--space-4); }
.webhook-form { display: grid; gap: var(--space-3); margin: var(--space-4) 0; }
.webhook-form .secondary-button { justify-self: start; }
.api-secret { padding: var(--space-3) var(--space-4); border: 1px solid #8fd6bb; border-radius: var(--radius-md); background: var(--success-soft); color: #14513b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--font-size-sm); word-break: break-all; }

/* --- Plano e utilização ----------------------------------------------
   Cartões de comparação. O plano atual é distinguido por texto e moldura,
   nunca só por cor. */
.plan-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.plan-status { margin: 0 0 var(--space-4); font-size: var(--font-size-sm); color: var(--text-secondary); }
.plan-status[data-restricted="true"] { padding: var(--space-3) var(--space-4); border: 1px solid #e7b3bf; border-radius: var(--radius-md); background: var(--danger-soft); color: #6e1a2c; }
.plan-entitlements { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.plan-entitlement { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-pill); font-size: var(--font-size-xs); font-weight: 700; }
.plan-entitlement[data-granted="true"] { border-color: #8fd6bb; background: var(--success-soft); color: #14513b; }
.plan-entitlement[data-granted="false"] { color: var(--text-muted); }
.plan-compare-title { margin: var(--space-6) 0 var(--space-3); font-size: var(--font-size-base); }
.plan-catalogue { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.plan-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface); }
.plan-card[data-current="true"] { border-color: var(--brand-primary); border-width: 2px; box-shadow: var(--shadow-sm); }
.plan-card-name { font-weight: 780; }
.plan-card-badge { align-self: flex-start; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--brand-primary); color: #fff; font-size: var(--font-size-xs); font-weight: 750; }
.plan-card-price { font-size: var(--font-size-sm); color: var(--text-secondary); }
.plan-card-limits { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: var(--font-size-xs); color: var(--text-secondary); }

@media (max-width: 560px) {
  .plan-actions { width: 100%; }
  .plan-actions > * { flex: 1 1 auto; }
}

/* --- Consumo do plano ------------------------------------------------
   Barras informativas. O estado é sempre dito por texto além da cor: uma
   barra vermelha sozinha não comunica nada a quem não distingue cores. */
.usage-bars { display: grid; gap: var(--space-4); }
.usage-metric { display: grid; gap: 6px; }
.usage-metric-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.usage-metric-label { font-weight: 720; font-size: var(--font-size-sm); }
.usage-metric-value { font-variant-numeric: tabular-nums; font-weight: 760; color: var(--text-secondary); }
.usage-metric-definition { font-size: var(--font-size-xs); color: var(--text-muted); }
.usage-track { height: 10px; border-radius: var(--radius-pill); background: var(--bg-muted, #eef2f9); overflow: hidden; }
.usage-fill { height: 100%; border-radius: var(--radius-pill); background: var(--brand-primary); transition: width .3s ease; }
.usage-metric[data-status="WARNING"] .usage-fill { background: #c98a05; }
.usage-metric[data-status="LIMIT_REACHED"] .usage-fill,
.usage-metric[data-status="OVER_LIMIT"] .usage-fill { background: #b3243c; }
.usage-metric[data-status="UNKNOWN"] .usage-track { background: repeating-linear-gradient(135deg, #eef2f9, #eef2f9 6px, #e3e9f3 6px, #e3e9f3 12px); }
.usage-freshness { margin: var(--space-4) 0 0; font-size: var(--font-size-xs); color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  .usage-fill { transition: none; }
}

/* Unified Dashboard / App Shell -------------------------------------- */
.shell-nav-link { position: relative; }
.shell-nav-icon { display: grid; width: 24px; height: 24px; flex: 0 0 24px; place-items: center; border-radius: 7px; background: rgb(255 255 255 / 7%); font-size: 15px; }
.shell-menu-button { display: none; }
.shell-drawer-overlay { position: fixed; z-index: 39; inset: 0; display: none; border: 0; background: rgb(3 13 34 / 58%); }
.shell-user-menu { display: inline-flex; align-items: center; gap: 8px; color: var(--text-primary); text-decoration: none; font-size: var(--font-size-sm); font-weight: 700; }
.shell-user-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent)); color: white; font-size: 11px; letter-spacing: .04em; }
.shell-logout { font-size: 18px; }
.dashboard-primary-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(430px, 1fr); gap: 18px; margin-top: 18px; }
.dashboard-support-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.dashboard-activity-card { margin-top: 18px; }
.map-dashboard-card { position: relative; min-height: 430px; }
.unified-map-canvas { position: relative; min-height: 330px; overflow: hidden; border: 1px solid #bdd4eb; border-radius: 14px; background: radial-gradient(circle at 75% 25%, rgb(0 191 232 / 17%), transparent 25%), linear-gradient(145deg, #deecfc, #f8fbff 55%, #e7f3ff); }
.unified-map-canvas::before { position: absolute; inset: 12% 8%; border: 1px dashed rgb(10 102 255 / 24%); border-radius: 40% 60% 54% 46%; content: ""; transform: rotate(-5deg); }
.unified-map-marker { position: absolute; z-index: 2; width: 14px; height: 14px; border: 3px solid white; border-radius: 50%; background: var(--brand-primary); box-shadow: 0 3px 10px rgb(6 22 56 / 28%); transform: translate(-50%, -50%); }
/* Verde fixo pintava de «disponível» quem estava ocupado, offline ou com um
   problema. A cor passa a vir do estado, calculado em courier-state.js. */
.unified-map-marker--driver { width: 18px; height: 18px; background: var(--estado-cor, var(--success)); }
.unified-map-marker--dropoff { border-radius: 3px; background: var(--danger); transform: translate(-50%, -50%) rotate(45deg); }
.unified-map-grid-label { position: absolute; right: 12px; bottom: 10px; color: var(--text-muted); font-size: 10px; }
.compact-plan-alert { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; padding: 10px 14px; border: 1px solid #e2c66d; border-radius: 10px; background: var(--warning-soft); color: #5a3d02; font-size: var(--font-size-sm); }
.compact-plan-alert[hidden] { display: none; }
.stat--primary::before { background: var(--brand-primary); }
.stat--success::before { background: var(--success); }
.dashboard-alert { display: flex; align-items: center; gap: 10px; padding-block: 8px; border-bottom: 1px solid var(--border); }

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .shell-sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(290px, 88vw); height: 100vh; align-items: stretch; flex-direction: column; overflow-y: auto; transform: translateX(-105%); transition: transform .2s ease; }
  .shell-nav { flex-direction: column; }
  .shell-nav-group, .shell-sidebar-footer { display: block; }
  .shell-nav-open .shell-sidebar { transform: translateX(0); }
  .shell-nav-open .shell-drawer-overlay { display: block; }
  .shell-menu-button { display: inline-grid; place-items: center; flex: 0 0 auto; }
  .dashboard-primary-grid { grid-template-columns: 1fr; }
  .operations-page .mobile-nav { display: none; }
}

@media (max-width: 768px) {
  .shell-topbar { flex-direction: row; align-items: center; }
  .topbar-actions { margin-left: auto; }
  .operations-page .shell-topbar { align-items: flex-start; flex-direction: column; }
  .operations-page .topbar-actions { width: 100%; margin-left: 0; }
  .topbar-actions > .pill, .shell-user-name, .shell-primary-action { display: none; }
  .dashboard-support-grid { grid-template-columns: 1fr; }
  .map-dashboard-card { min-height: 350px; }
  .unified-map-canvas { min-height: 260px; }
}

.entitlement-banner {
  position: sticky;
  z-index: 19;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--warning-soft);
  color: #5a3d02;
  border-bottom: 1px solid #e2c66d;
  font-size: var(--font-size-sm);
}
.entitlement-banner[data-mode="REVOKED"] {
  background: var(--danger-soft);
  color: #6e1a2c;
  border-bottom-color: #e7b3bf;
}
.entitlement-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entitlement-banner-text strong { font-weight: 780; }
.entitlement-banner .secondary-button { flex: 0 0 auto; }

@media (max-width: 560px) {
  .entitlement-banner { padding: var(--space-3) var(--space-4); }
  .entitlement-banner .secondary-button { width: 100%; }
}

/* --- Páginas públicas: perfil e convite (Fase 8F) -------------------------- */
/*
   Servem quem ainda não tem conta. A marca da empresa entra como cor de
   destaque; a identidade da página continua a ser da CVLogistica — sem isso,
   uma página forjada seria indistinguível.
*/
:root { --public-accent: #6048c0; }
.public-page { display: flex; flex-direction: column; min-height: 100vh; align-items: center; justify-content: center; gap: 1.5rem; padding: 2rem 1rem; }
.public-card { width: min(34rem, 100%); background: var(--surface, #fff); border: 1px solid var(--border, #e3e3ec); border-radius: 1rem; padding: 2rem; box-shadow: 0 1px 3px rgb(0 0 0 / 8%); border-top: 4px solid var(--public-accent); }
.public-platform { margin: 0 0 .75rem; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--public-accent); font-weight: 600; }
.public-card h1 { margin: 0 0 .5rem; font-size: 1.5rem; line-height: 1.25; }
.public-type { margin: 0 0 1rem; color: var(--muted, #666); font-size: .9rem; }
.public-facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 1.25rem 0 0; font-size: .9rem; }
.public-facts dt { color: var(--muted, #666); }
.public-facts dd { margin: 0; font-weight: 500; }
.public-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; align-items: center; }
.public-actions .primary-action { background: var(--public-accent); color: #fff; padding: .7rem 1.15rem; border-radius: .5rem; text-decoration: none; font-weight: 600; }
.public-state { margin: 1.25rem 0 0; font-size: .85rem; color: var(--muted, #666); }
.public-footer { width: min(34rem, 100%); font-size: .8rem; color: var(--muted, #666); text-align: center; }

/* --- Seletor e comutador de organização (Fase 8F) -------------------------- */
.org-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgb(20 18 32 / 55%); padding: 1.5rem; }
.org-picker { width: min(30rem, 100%); background: var(--surface, #fff); border-radius: 1rem; padding: 1.75rem; box-shadow: 0 10px 30px rgb(0 0 0 / 20%); }
.org-picker h2 { margin: 0 0 .35rem; font-size: 1.25rem; }
.org-picker p { margin: 0 0 1.25rem; color: var(--muted, #666); font-size: .9rem; }
.org-card-list { display: grid; gap: .6rem; }
.org-card { display: flex; align-items: center; gap: .85rem; width: 100%; text-align: left; padding: .85rem 1rem; border: 1px solid var(--border, #e3e3ec); border-radius: .7rem; background: transparent; cursor: pointer; }
.org-card:hover, .org-card:focus-visible { border-color: var(--public-accent, #6048c0); }
.org-card[disabled] { opacity: .5; cursor: progress; }
.org-card-avatar { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .55rem; background: var(--public-accent, #6048c0); color: #fff; font-weight: 700; font-size: .8rem; }
.org-card-copy { display: flex; flex-direction: column; }
.org-card-copy small { color: var(--muted, #666); }
.org-switcher-select { border: 1px solid var(--border, #e3e3ec); border-radius: .5rem; padding: .4rem .6rem; background: var(--surface, #fff); font: inherit; max-width: 16rem; }
.qr-block { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; margin-top: 1rem; padding: 1rem; border: 1px dashed var(--border, #e3e3ec); border-radius: .7rem; }
.qr-block code { word-break: break-all; font-size: .85rem; }

/* Ha quanto tempo uma entrega espera por uma decisao humana. Discreto, mas
   sempre visivel: e o que ordena a fila de despacho. */
.waiting-since { display: block; color: var(--warning, #8B5D05); font-size: 0.75rem; margin-top: 0.15rem; }

/* Mapa real da Torre. Mesma altura do esquemático, para a troca entre os dois
   não empurrar o resto do painel. */
.google-map { width: 100%; height: 320px; border-radius: 14px; overflow: hidden; }

/* --- Navegação interna da Torre -------------------------------------------
 *
 * Os quatro módulos da Torre. Estavam com a classe do Portal Empresa, cujo CSS
 * esta página não carrega: saíam como texto solto, sem forma nem estado.
 *
 * Barra própria, construída sobre os tokens existentes. Largura repartida em
 * partes iguais, com um teto — em ecrãs largos os botões param de crescer em
 * vez de se esticarem de margem a margem. O foco herda o contorno global.
 */
.ops-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
  padding: 0 0 var(--space-4);
  border-bottom: 1px solid var(--border);
}

.ops-tabs a {
  flex: 1 1 0;
  min-width: 148px;
  max-width: 232px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.ops-tabs a:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

/* O módulo selecionado é o único preenchido: distingue-se sem depender de cor
 * sozinha — muda o fundo, o contraste e a sombra ao mesmo tempo. */
.ops-tabs a[aria-current="page"] {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  box-shadow: var(--shadow-sm);
}

.ops-tabs a[aria-current="page"]:hover {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
}

/* Em ecrãs estreitos passam a duas colunas, e nunca a uma linha que transborde. */
@media (max-width: 720px) {
  .ops-tabs a {
    flex: 1 1 calc(50% - var(--space-2));
    min-width: 0;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ops-tabs a { transition: none; }
}

/* --- Listas de cartões da Torre --------------------------------------------
 *
 * A equipa usava `.business-list`, que vive em `business.css` — ficheiro que a
 * Torre não carrega. Os cartões saíam sem moldura e com o nome colado ao email.
 * Foi o mesmo engano dos separadores: emprestar uma classe de outra página.
 */
.ops-list { display: grid; gap: var(--space-3); }

.ops-list article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.ops-list article > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ops-list article strong { color: var(--text-primary); }
.ops-list article small { color: var(--text-muted); }

.ops-subheading { margin: var(--space-5) 0 var(--space-3); }

@media (max-width: 720px) {
  .ops-list article { align-items: flex-start; }
}

/* Filtros de painel da Torre: pesquisa e estado lado a lado, e em coluna quando
 * não cabem. Reutiliza `.field`, que já existe. */
.ops-filters { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-4); }
.ops-filters .field { flex: 1 1 220px; min-width: 0; margin: 0; }

/* Ações do mapa operacional: enquadrar e seguir, ao lado da alternativa em lista. */
.map-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.map-actions .secondary-button[aria-pressed="true"] {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
}
.map-actions .secondary-button[disabled] { opacity: .55; cursor: not-allowed; }
.google-map { width: 100%; min-height: 380px; border-radius: var(--radius-sm); }
.map-info { font-size: var(--font-size-sm); line-height: 1.5; color: #202124; }
/* A idade da posição e o problema ativo distinguem-se do resto da ficha sem
   competir com a cor do pino — a cor do estado decide-se em courier-state.js e
   não se repete aqui. */
.map-info-stale { color: var(--text-muted); }
.map-info-problema { color: var(--danger); font-weight: 600; }

/* Legenda do mapa: a cor diz o estado, o desenho diz o veículo, e o texto diz
 * ambos — para quem não distingue as cores. */
.map-legend { display: grid; gap: var(--space-2); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.map-legend li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
}
.map-legend strong { color: var(--text-primary); font-weight: 700; }
.map-legend small { grid-column: 2 / -1; color: var(--text-muted); }
.map-legend .legend-count { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-primary); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.legend-disponivel { background: #0f9d58; }
.legend-ocupado { background: #db4437; }
.legend-problema { background: #e8710a; }
.legend-offline { background: #8492a6; }
.map-legend-note { margin: var(--space-2) 0 0; font-size: var(--font-size-xs); color: var(--text-muted); }

/* Ficha do veículo — painéis internos dentro do módulo Veículos. */
.fleet-detail { margin-top: var(--space-4); padding: var(--space-4); border: 1px solid var(--border-subtle, #e2e8f0); border-radius: var(--radius-md, 10px); background: var(--surface-raised, #fff); }
.fleet-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0; }
.fleet-tabs button { padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle, #e2e8f0); border-radius: 999px; background: transparent; cursor: pointer; font-size: var(--font-size-sm); }
.fleet-tabs button[aria-current='true'] { background: var(--brand); color: #fff; border-color: var(--brand); }
.fleet-detail-list { display: grid; gap: var(--space-2); margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.fleet-detail-list li { display: grid; gap: 2px; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle, #eef2f7); }
.fleet-detail-list li span { color: var(--text-muted); font-size: var(--font-size-sm); }
.fleet-total { margin-top: var(--space-3); font-weight: 700; }
.fleet-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-3); margin: var(--space-3) 0; }
.fleet-summary div { display: grid; gap: 2px; }
.fleet-summary strong { font-size: var(--font-size-lg); }
.fleet-summary span { color: var(--text-muted); font-size: var(--font-size-sm); }
.ops-filters { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; margin: var(--space-3) 0; }
.fleet-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: end; margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px dashed var(--border-subtle, #e2e8f0); }
.fleet-actions .field { min-width: 140px; }
.fleet-actions .form-error { flex-basis: 100%; }

/* Remuneração — mesma linguagem nas duas superfícies, estafetas e equipa. */
.compensation-panel { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border-subtle, #eef2f7); }
.compensation-panel h4 { margin: 0 0 var(--space-2); font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.compensation-summary { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--space-3); margin: 0; }
.compensation-summary dt { color: var(--text-muted); font-size: var(--font-size-sm); }
.compensation-summary dd { margin: 0; font-weight: 600; }
.compensation-history { margin-top: var(--space-3); }
.compensation-history h5 { margin: 0 0 var(--space-2); font-size: var(--font-size-sm); color: var(--text-muted); }
.compensation-history ul { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.compensation-history li { display: grid; gap: 2px; padding-left: var(--space-3); border-left: 2px solid var(--border-subtle, #e2e8f0); }
.compensation-history li span { color: var(--text-muted); font-size: var(--font-size-sm); }
.compensation-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: end; margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px dashed var(--border-subtle, #e2e8f0); }
.compensation-form .field { min-width: 150px; }
.compensation-form .form-error { flex-basis: 100%; }

/* --- Resultado operacional -------------------------------------------------
 *
 * Uma tabela de dinheiro lê-se pela coluna, não pela linha: os olhos descem os
 * montantes à procura do que destoa. Por isso os números alinham à direita e em
 * tabular-nums, para que as casas fiquem umas por cima das outras.
 */
.finance-result { display: grid; gap: var(--space-5); margin-bottom: var(--space-6); }
.finance-result .section-title { margin: 0; font-size: var(--font-size-lg); color: var(--text-primary); }

.finance-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.finance-table .muted { color: var(--text-muted); font-weight: 400; }
.finance-table tbody th { text-align: left; font-weight: 600; padding: var(--space-3); border-bottom: 1px solid var(--border); }

/* A decomposição da remuneração é recuada e mais discreta: são as duas
 * naturezas da linha acima, não parcelas irmãs. Quem as somasse ao total
 * contaria a remuneração duas vezes, e o recuo é o que evita esse erro de
 * leitura. */
.finance-table .sub-row th { padding-left: var(--space-6); font-weight: 400; color: var(--text-secondary); }
.finance-table .sub-row td { color: var(--text-secondary); }
.finance-table .sub-row { background: var(--bg-surface-secondary); }

.finance-table .total-row th, .finance-table .total-row td {
  border-top: 2px solid var(--border-strong);
  border-bottom: none;
  font-weight: 700;
  color: var(--text-primary);
}

/* O que falta apurar diz-se em texto e à vista, não num rodapé: o resultado
 * ainda não é final e quem o lê tem de o saber antes de decidir. */
.finance-caveat {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--border-strong);
  background: var(--bg-surface-secondary);
  border-radius: 0 var(--radius-sm, 6px) var(--radius-sm, 6px) 0;
}


/* Gestao canonica: lista, selecao, barra global, detalhe. */
.mgmt-row { cursor: pointer; }
.mgmt-row.is-selected { outline: 2px solid var(--accent, #c9a227); background: color-mix(in srgb, var(--accent, #c9a227) 12%, transparent); }
.mgmt-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.mgmt-detail { margin-top: 1rem; padding: 1rem; border: 1px solid var(--border, #d8d2c4); border-radius: 8px; }
.mgmt-filters { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.75rem 0; }
tr.is-selected, .queue-card.is-selected { outline: 2px solid var(--accent, #c9a227); }

/* Gestao: tabela compacta com selecao e barra global. */
.mgmt-table { width: 100%; min-width: 0; }
.mgmt-table .mgmt-select-cell { width: 2.25rem; text-align: center; }
.mgmt-table tbody tr { cursor: pointer; }
.mgmt-table tbody tr.is-selected { background: #eef5ff; }
.mgmt-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 0.75rem; min-height: 2.25rem; }
.mgmt-bar button:disabled { opacity: 0.45; cursor: not-allowed; }
