:root {
  --bg: #0f172a;
  --panel: #111827;
  --card: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
  --border: #374151;
  --line: #374151;
  --brand: #3b82f6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.sidebar h2 {
  margin-top: 0;
  margin-bottom: 20px;
}

.tab-btn {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.menu-btn-content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.tab-btn .menu-btn-content {
  width: 100%;
}

.menu-btn-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* Ícone do menu: Agenciamento em vermelho */
.tab-btn[data-tab="agenciamentos"] .menu-btn-icon {
  color: #dc2626;
}
.tab-btn.subtle-tab .menu-btn-icon {
  width: 15px;
  height: 15px;
  flex-basis: 15px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
}

.sidebar-spacer {
  flex: 1 1 auto;
  min-height: 8px;
}

.sidebar-more {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed #334155;
}


.logout-btn .menu-btn-content {
  justify-content: center;
  width: 100%;
}

.sidebar-dots-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px dashed #475569;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sidebar-dots-btn .menu-btn-icon {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
}

.sidebar-dots-btn:hover,
.sidebar-dots-btn:focus-visible,
.sidebar-dots-btn[aria-expanded="true"] {
  border-style: solid;
  border-color: #64748b;
  color: #e2e8f0;
  background: rgba(51, 65, 85, 0.35);
}

.sidebar-more-menu {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 170px;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: none;
  z-index: 70;
}

.sidebar-more-menu.show {
  display: block;
}

.sidebar-more-menu .tab-btn {
  margin-bottom: 6px;
}

.sidebar-more-menu .tab-btn:last-child {
  margin-bottom: 0;
}

.tab-btn.subtle-tab {
  font-size: 13px;
  padding: 8px 10px;
  opacity: 0.78;
  border-style: dashed;
}

.tab-btn.subtle-tab:hover,
.tab-btn.subtle-tab:focus-visible {
  opacity: 1;
  border-style: solid;
}

.tab-btn.subtle-tab.active {
  opacity: 1;
  background: rgba(59, 130, 246, 0.18);
  border-color: #2563eb;
  color: #dbeafe;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

label.full { grid-column: 1 / -1; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
}

textarea { resize: vertical; }

button[type="submit"] {
  margin-top: 12px;
  background: var(--primary);
  border: none;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #111827;
}

.item-left {
  flex: 1;
  min-width: 0;
  line-height: 1.45;
}

.item-right {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}

.item img {
  width: 140px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.item img.driver-avatar {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  object-fit: cover;
}

/* Mensagens */
.msg { margin-top: 8px; font-size: 14px; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--ok); }

/* Kebab (...) */
.kebab-wrap { position: relative; }

.kebab-btn {
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-weight: bold;
  min-width: 36px;
  line-height: 1;
}

.kebab-menu {
  position: absolute;
  top: 110%;
  right: 0;
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 190px;
  max-width: min(260px, calc(100vw - 24px));
  padding: 6px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.kebab-menu.hidden { display: none; }

.kebab-menu button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.kebab-menu button:hover { background: #1f2937; }

.danger-action { color: #fca5a5 !important; }

/* Modais */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}
.modal-backdrop.show { display: flex; }

.modal {
  width: 100%;
  max-width: 620px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 16px;
  color: #e5e7eb;
}
.modal h3 { margin-top: 0; }

.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.btn-secondary {
  background: transparent;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}


.btn-small {
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 10px;
  line-height: 1;
}

.freight-date-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding-left: 9px;
  padding-right: 9px;
}

.freight-date-clear .btn-icon {
  font-size: 13px;
  line-height: 1;
}
.btn-primary {
  background: #3b82f6;
  border: none;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.hint {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

/* Link de arquivos */
a {
  color: #93c5fd;
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Segurança visual: nunca estourar imagem */
img {
  max-width: 100%;
  height: auto;
}

/* Mobile */
@media (max-width: 900px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-spacer {
    display: none;
  }

  .sidebar-more {
    margin-top: 6px;
    justify-content: flex-start;
    border-top: none;
    padding-top: 2px;
  }

  .sidebar-more-menu {
    left: 0;
    transform: none;
    bottom: 50px;
  }

  .grid { grid-template-columns: 1fr; }
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.section-toolbar h3 {
  margin: 0;
}

#truck-list-focus,
#driver-list-focus {
  outline: none;
}

#truck-list-focus:focus,
#driver-list-focus:focus {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.45);
  border-radius: 8px;
  padding: 2px 6px;
}

.freight-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-create-scroll {
  max-width: 920px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.modal-create-scroll .actions button[type="submit"] {
  margin-top: 0;
}

@media (max-width: 900px) {
  .modal-create-scroll {
    max-height: calc(100vh - 24px);
  }
}


/* ===== Auth (Login) ===== */
.auth-page {
  min-height: 100vh;
  margin: 0;
  font-family: Arial, sans-serif;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #e5e7eb;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid #334155;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  padding: 24px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  color: #f9fafb;
}

.auth-sub {
  margin: 0 0 18px;
  color: #cbd5e1;
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: #e5e7eb;
}

.auth-form input {
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: #0b1220;
  color: #f9fafb;
  outline: none;
}

.auth-form input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-form button {
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  background: #2563eb;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.auth-form button:hover {
  background: #1d4ed8;
}

.auth-error {
  margin-bottom: 12px;
  border: 1px solid #7f1d1d;
  background: rgba(127, 29, 29, 0.25);
  color: #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.auth-hint {
  margin-top: 14px;
  border: 1px dashed #475569;
  border-radius: 8px;
  padding: 10px;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.4;
}



.hidden {
  display: none !important;
}

.freight-subtabs {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 8px;
}
.count-pill {
  margin-left: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.freight-subtab.active .count-pill {
  background: rgba(2, 6, 23, .35);
  border-color: rgba(255,255,255,.35);
  color: #fff;
}

.freight-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin: 2px 0 12px;
}

.freight-search-wrap input {
  width: 100%;
}

.freight-sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.freight-sort-wrap label {
  color: #94a3b8;
  font-size: 12px;
  white-space: nowrap;
}

.freight-sort-wrap select {
  min-width: 230px;
}


.freight-date-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.freight-date-wrap label {
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
}

.freight-date-wrap label {
  color: #94a3b8;
  font-size: 12px;
  white-space: nowrap;
}

.freight-date-inputs {
  display: grid;
  grid-template-columns: 150px 26px 150px auto;
  align-items: center;
  gap: 6px;
}

.freight-date-inputs input[type="date"] {
  min-width: 0;
  padding: 8px 10px;
  font-size: 13px;
}

.freight-date-inputs .date-sep {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1;
}

.freight-date-inputs input[type="date"] {
  min-width: 150px;
}

.freight-date-inputs .date-sep {
  color: #94a3b8;
  font-size: 12px;
}

@media (max-width: 900px) {
  .freight-date-wrap {
    justify-content: flex-start;
  }

  .freight-date-inputs {
    width: 100%;
    grid-template-columns: 1fr 26px 1fr auto;
  }

  .freight-date-inputs input[type="date"] {
    width: 100%;
    min-width: 0;
  }

  .freight-date-clear .btn-text {
    display: none;
  }
}

@media (max-width: 900px) {
  .freight-toolbar {
    grid-template-columns: 1fr;
  }

  .freight-sort-wrap {
    width: 100%;
  }

  .freight-sort-wrap label {
    width: 100%;
    display: block;
  }

  .freight-sort-wrap select {
    width: 100%;
    min-width: 0;
  }

  .count-pill {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
  }
}

.freight-subtab {
  border: 1px solid var(--line);
  background: #111827;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  opacity: .85;
  transition: all .15s ease;
}
.freight-subtab:hover {
  opacity: 1;
  transform: translateY(-1px);
}
.freight-subtab.active {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 0 2px rgba(59,130,246,.35);
}

.freight-card-link {
  text-decoration: none;
  color: inherit;
}

.freight-card {
  background: #0f172a;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  transition: border-color .15s ease, transform .15s ease;
}
.freight-card:hover {
  border-color: #334155;
  transform: translateY(-1px);
}

.freight-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.freight-title {
  font-weight: 800;
  letter-spacing: .1px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.freight-ref {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.freight-sub {
  margin-top: 8px;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.45;
}

.status-badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  border: 1px solid transparent;
}
.status-em-carregamento {
  background: #e5e7eb;
  color: #111827;
  border-color: #d1d5db;
}
.status-em-viagem {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}
.status-concluido {
  background: #16a34a;
  color: #fff;
  border-color: #15803d;
}

/* ===== Finanças ===== */
.finance-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.finance-toolbar-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.finance-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.finance-toolbar-actions .btn-secondary {
  white-space: nowrap;
}

.finance-toolbar label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.finance-toolbar input[type="month"],
.finance-toolbar select {
  min-width: 170px;
}

.finance-toolbar select {
  background: #0b1220;
  color: #e5e7eb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.finance-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.finance-total-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111827;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.finance-total-label {
  font-size: 12px;
  color: var(--muted);
}

.finance-total-card strong {
  font-size: 20px;
  color: #f3f4f6;
  line-height: 1.2;
}


.finance-rankings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.finance-ranking-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111827;
  padding: 12px;
}

.finance-ranking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.finance-ranking-header h3 {
  margin: 0;
  font-size: 14px;
  color: #f3f4f6;
}

.finance-ranking-count {
  font-size: 12px;
  color: #9ca3af;
  border: 1px solid #374151;
  border-radius: 999px;
  padding: 4px 8px;
}

.finance-ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finance-ranking-item {
  border: 1px solid #273449;
  border-radius: 8px;
  padding: 8px;
  background: #0f172a;
  display: grid;
  gap: 8px;
}

.finance-ranking-main {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.finance-ranking-pos {
  min-width: 34px;
  text-align: center;
  border: 1px solid #374151;
  border-radius: 999px;
  padding: 3px 6px;
  font-size: 12px;
  color: #e5e7eb;
}

.finance-ranking-meta {
  margin-top: 2px;
  font-size: 12px;
  color: #9ca3af;
}

.finance-ranking-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px;
  font-size: 12px;
  color: #cbd5e1;
}

.finance-ranking-values strong {
  color: #f3f4f6;
}

.finance-ranking-empty {
  margin: 0;
  font-size: 13px;
  color: #9ca3af;
}

.finance-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111827;
  padding: 12px;
  display: grid;
  grid-template-columns: 1.5fr minmax(230px, 1fr);
  gap: 12px;
}

.finance-item-title {
  margin: 0;
  font-size: 16px;
  color: #f3f4f6;
}

.finance-item-ref {
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.finance-item-meta {
  margin: 0;
  font-size: 13px;
  color: #d1d5db;
}

.finance-item-values {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.finance-pill {
  border: 1px solid #374151;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: #e5e7eb;
  white-space: nowrap;
}

.finance-pill.warn {
  border-color: #92400e;
  color: #fde68a;
  background: rgba(146, 64, 14, 0.2);
}

.finance-pill.ok {
  border-color: #14532d;
  color: #bbf7d0;
  background: rgba(20, 83, 45, 0.28);
}

.finance-pill.pending {
  border-color: #92400e;
  color: #fde68a;
  background: rgba(146, 64, 14, 0.2);
}

.finance-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.finance-right label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.finance-right input {
  width: 100%;
}

.finance-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.finance-actions-row button {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.finance-note {
  margin: 0;
  font-size: 12px;
  color: #9ca3af;
}

@media (max-width: 860px) {
  .finance-toolbar-actions {
    width: 100%;
  }

  .finance-rankings {
    grid-template-columns: 1fr;
  }

  .finance-ranking-values {
    grid-template-columns: 1fr;
  }

  .finance-item {
    grid-template-columns: 1fr;
  }
}

/* ===== Helpers gerais ===== */
.section-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.inline-filter select {
  min-width: 120px;
}

.btn-danger {
  border: 1px solid #7f1d1d;
  background: rgba(127, 29, 29, 0.18);
  color: #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover {
  background: rgba(127, 29, 29, 0.34);
}

/* ===== Pagamentos ===== */
.field-inline {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.payments-toolbar {
  margin-top: 4px;
}

.payments-driver-title {
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.payments-list {
  margin-top: 10px;
}

.payment-item {
  border-left: 4px solid var(--border);
  align-items: flex-start;
  gap: 14px;
}

.payment-item .item-left {
  line-height: 1.5;
}

.payment-item.is-paid {
  border-left-color: rgba(16, 185, 129, 0.5);
}

.payment-item.is-pending {
  border-left-color: rgba(245, 158, 11, 0.6);
}

.payment-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.payment-actions .btn-secondary {
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: rgba(100, 116, 139, 0.16);
  color: #d1d5db;
}

.chip.ok {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
}

.chip.pending {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
}


.chip.covered {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

.payment-subline {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.95;
}

.payment-subline strong {
  color: #f3f4f6;
}

#payments-balance-card.payments-balance-positive {
  border-color: rgba(16, 185, 129, 0.42);
  background: rgba(16, 185, 129, 0.08);
}

#payments-balance-card.payments-balance-positive strong {
  color: #34d399;
}

#payments-balance-card.payments-balance-negative {
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.08);
}

#payments-balance-card.payments-balance-negative strong {
  color: #fecaca;
}

#payments-balance-card.payments-balance-even {
  border-color: rgba(100, 116, 139, 0.5);
  background: rgba(100, 116, 139, 0.08);
}

.payments-empty {
  margin: 10px 0;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.45);
}

@media (max-width: 860px) {
  .payment-item {
    flex-direction: column;
  }

  .payment-actions {
    width: 100%;
    align-items: stretch;
  }

  .payment-actions .btn-secondary {
    width: 100%;
  }
}

/* ===== Consumo ===== */
.consumption-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 14px;
}

.consumption-toolbar-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  flex: 1;
}

.consumption-toolbar-filters label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.consumption-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.consumption-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.consumption-total-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.consumption-total-label {
  font-size: 12px;
  color: var(--muted);
}

.consumption-total-card strong {
  font-size: 18px;
  color: #f3f4f6;
}

.consumption-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.consumption-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.consumption-item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  color: #d1d5db;
  font-size: 13px;
}

.consumption-note {
  margin: 0;
  color: #9ca3af;
  font-size: 12px;
  border-top: 1px dashed #253048;
  padding-top: 8px;
}

.consumption-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 860px) {
  .section-toolbar-actions {
    width: 100%;
  }

  .inline-filter {
    width: 100%;
    justify-content: space-between;
  }

  .inline-filter select {
    flex: 1;
    min-width: 0;
  }

  .consumption-toolbar-actions {
    width: 100%;
  }

  .consumption-toolbar-actions button {
    width: 100%;
  }

  .consumption-item-grid {
    grid-template-columns: 1fr;
  }

  .consumption-actions {
    justify-content: stretch;
  }

  .consumption-actions button {
    flex: 1;
  }
}


/* =====================================================
   VISUAL PROFESSIONAL REFRESH v44
   ===================================================== */
:root {
  --bg: #020617;
  --panel: #0b1220;
  --card: #111a2e;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #2563eb;
  --danger: #ef4444;
  --ok: #22c55e;
  --border: #25324a;
  --line: #2a3954;
  --brand: #2563eb;
}

html, body {
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0.1px;
  background:
    radial-gradient(1200px 760px at 4% -8%, rgba(37, 99, 235, 0.18), transparent 42%),
    radial-gradient(900px 620px at 102% -10%, rgba(14, 165, 233, 0.15), transparent 38%),
    linear-gradient(180deg, #070f1f 0%, #020617 100%);
}

body {
  color: #e2e8f0;
}

.layout {
  position: relative;
}

.sidebar {
  background: linear-gradient(180deg, rgba(8, 15, 30, 0.95) 0%, rgba(9, 14, 25, 0.97) 100%);
  border-right: 1px solid rgba(71, 85, 105, 0.45);
  box-shadow: inset -1px 0 0 rgba(15, 23, 42, 0.65);
  padding: 22px 18px;
}

.sidebar h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  color: #f8fafc;
}

.tab-btn {
  border-radius: 12px;
  border: 1px solid rgba(71, 85, 105, 0.45);
  background: rgba(15, 23, 42, 0.46);
  padding: 11px 12px;
  transition: all .18s ease;
}

.tab-btn:hover,
.tab-btn:focus-visible {
  background: rgba(30, 41, 59, 0.72);
  border-color: rgba(100, 116, 139, 0.72);
  transform: translateY(-1px);
}

.tab-btn.active {
  background: linear-gradient(140deg, #2563eb, #1d4ed8);
  border-color: rgba(147, 197, 253, 0.65);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.27);
  color: #fff;
}

.menu-btn-icon {
  color: #bfdbfe;
}

.tab-btn.active .menu-btn-icon {
  color: #ffffff;
}

.tab-btn[data-tab="freights"] .menu-btn-icon { color: #60a5fa; }
.tab-btn[data-tab="finances"] .menu-btn-icon { color: #34d399; }
.tab-btn[data-tab="consumo"] .menu-btn-icon { color: #fbbf24; }
.tab-btn[data-tab="trucks"] .menu-btn-icon { color: #38bdf8; }
.tab-btn[data-tab="drivers"] .menu-btn-icon { color: #a78bfa; }
.tab-btn[data-tab="trash"] .menu-btn-icon { color: #f87171; }
.tab-btn[data-tab="users"] .menu-btn-icon { color: #94a3b8; }

.sidebar-user {
  background: linear-gradient(165deg, rgba(2, 6, 23, .72), rgba(15, 23, 42, .85)) !important;
  border: 1px solid rgba(100, 116, 139, 0.42) !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 26px rgba(2, 6, 23, .32);
}

.sidebar-user-name {
  font-size: 14px;
  color: #f8fafc !important;
}

.sidebar-user-role {
  color: #94a3b8 !important;
}

.logout-btn {
  border-radius: 10px !important;
  border-color: rgba(100, 116, 139, 0.5) !important;
  background: rgba(15, 23, 42, 0.55) !important;
  transition: all .17s ease;
}

.logout-btn:hover {
  background: rgba(30, 41, 59, 0.72) !important;
  transform: translateY(-1px);
}

.sidebar-dots-btn {
  border-color: rgba(100, 116, 139, 0.62);
  background: rgba(15, 23, 42, .55);
}

.sidebar-more-menu {
  background: rgba(8, 15, 30, 0.96);
  border-color: rgba(100, 116, 139, 0.5);
  box-shadow: 0 16px 32px rgba(2, 6, 23, 0.5);
}

.content {
  padding: 28px;
}

.tab-panel h1 {
  margin: 2px 0 14px;
  font-size: clamp(1.35rem, 1.05rem + 1vw, 1.8rem);
  letter-spacing: .2px;
  color: #f8fafc;
}

.card {
  border-radius: 16px;
  border: 1px solid rgba(71, 85, 105, 0.45);
  background: linear-gradient(165deg, rgba(11, 18, 32, 0.86), rgba(15, 23, 42, 0.72));
  box-shadow: 0 14px 32px rgba(2, 6, 23, 0.34);
  padding: 18px;
}

.section-toolbar h3 {
  font-size: 16px;
  color: #f1f5f9;
}

.hint {
  color: #93a5bf !important;
}

label {
  font-size: 13px;
  color: #9fb0c7;
  font-weight: 600;
}

input, textarea, select {
  border-radius: 10px;
  border: 1px solid rgba(71, 85, 105, 0.65);
  background: rgba(3, 10, 24, 0.72);
  color: #e2e8f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

input::placeholder,
textarea::placeholder {
  color: #7f91ad;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.95);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
  background: rgba(7, 15, 30, 0.92);
}

.btn-primary,
button[type="submit"] {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  border: 1px solid rgba(147, 197, 253, 0.4) !important;
  color: #fff !important;
  border-radius: 10px !important;
  font-weight: 700;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.24);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

.btn-primary:hover,
button[type="submit"]:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.28);
}

.btn-secondary {
  border-radius: 10px !important;
  border: 1px solid rgba(100, 116, 139, 0.62) !important;
  color: #dbe7fb !important;
  background: rgba(15, 23, 42, 0.55) !important;
  transition: all .16s ease;
}

.btn-secondary:hover {
  background: rgba(30, 41, 59, 0.78) !important;
  border-color: rgba(148, 163, 184, 0.74) !important;
  transform: translateY(-1px);
}

.btn-danger {
  border-radius: 10px;
}

.item,
.finance-item,
.consumption-item,
.trash-item,
.freight-card,
.finance-total-card,
.finance-ranking-card,
.consumption-total-card {
  border-radius: 14px !important;
  border: 1px solid rgba(71, 85, 105, 0.42) !important;
  background: linear-gradient(165deg, rgba(8, 15, 30, .78), rgba(15, 23, 42, .66)) !important;
  box-shadow: 0 8px 20px rgba(2, 6, 23, .22);
}

.item,
.finance-item,
.consumption-item,
.trash-item,
.freight-card {
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.item:hover,
.finance-item:hover,
.consumption-item:hover,
.trash-item:hover,
.freight-card:hover {
  border-color: rgba(96, 165, 250, 0.55) !important;
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(2, 6, 23, .3);
}

.finance-total-card strong,
.consumption-total-card strong {
  color: #f8fafc;
  letter-spacing: .2px;
}

.finance-total-label,
.consumption-total-label,
.finance-ranking-count,
.finance-note,
.consumption-note,
.freight-ref,
.trash-ref {
  color: #90a3be !important;
}

.freight-subtab {
  border-radius: 999px;
  background: rgba(15, 23, 42, .7);
  border-color: rgba(71, 85, 105, .55);
}

.freight-subtab.active {
  box-shadow: 0 8px 16px rgba(37, 99, 235, .22);
}

.count-pill {
  border-color: rgba(100, 116, 139, .6);
  background: rgba(2, 6, 23, .52);
}

.kebab-btn {
  border-radius: 10px;
  border-color: rgba(71, 85, 105, 0.62);
  background: rgba(2, 6, 23, 0.62);
}

.kebab-menu {
  background: rgba(8, 15, 30, 0.98);
  border-color: rgba(100, 116, 139, 0.5);
  box-shadow: 0 14px 28px rgba(2, 6, 23, .46);
}

.kebab-menu button:hover {
  background: rgba(30, 41, 59, .65);
}

.modal {
  border-radius: 16px !important;
  border: 1px solid rgba(100, 116, 139, .45) !important;
  background: linear-gradient(175deg, rgba(8, 15, 30, .98), rgba(15, 23, 42, .95)) !important;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .58);
}

.modal-backdrop {
  backdrop-filter: blur(3px);
}

.chip {
  border-radius: 999px;
  letter-spacing: .2px;
}

/* Scrollbar */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.7);
}

*::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.8);
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.8);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.95);
}

/* Login com acabamento premium */
.auth-page {
  background:
    radial-gradient(1000px 620px at 12% -5%, rgba(37,99,235,.22), transparent 45%),
    radial-gradient(900px 560px at 95% -10%, rgba(14,165,233,.14), transparent 42%),
    linear-gradient(180deg, #0b1220 0%, #020617 100%);
}

.auth-card {
  border: 1px solid rgba(100, 116, 139, .44);
  background: linear-gradient(165deg, rgba(11, 18, 32, .94), rgba(15, 23, 42, .88));
  box-shadow: 0 22px 48px rgba(2, 6, 23, .52);
}

@media (max-width: 980px) {
  .content {
    padding: 16px;
  }

  .card {
    border-radius: 14px;
    padding: 14px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(71, 85, 105, .5);
    padding: 14px;
  }

  .tab-btn {
    margin-bottom: 8px;
  }
}



/* =====================================================
   MOBILE UX UPGRADE v45 (menu hamburger + espaço otimizado)
   ===================================================== */
.mobile-topbar,
.mobile-menu-backdrop {
  display: none;
}

body.mobile-menu-lock {
  overflow: hidden;
}

@media (max-width: 900px) {
  .layout {
    display: block;
    min-height: 100vh;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 1300;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.5);
    background: linear-gradient(180deg, rgba(8, 15, 30, .97), rgba(9, 14, 25, .94));
    backdrop-filter: blur(6px);
  }

  .mobile-menu-btn {
    border: 1px solid rgba(100, 116, 139, .68);
    background: rgba(15, 23, 42, .72);
    color: #e2e8f0;
    border-radius: 10px;
    height: 40px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-menu-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 18px;
  }

  .mobile-menu-btn:active {
    transform: translateY(1px);
  }

  .mobile-topbar-title {
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(2, 6, 23, .58);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .layout.menu-open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: var(--mobile-topbar-h, 0px);
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    max-width: 320px;
    z-index: 1250;
    transform: translateX(-104%);
    transition: transform .24s ease;
    border-right: 1px solid rgba(71, 85, 105, 0.6);
    border-bottom: none;
    padding: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    box-shadow: 24px 0 40px rgba(2, 6, 23, .38);
  }

  .layout.menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar h2 {
    margin-bottom: 10px;
    font-size: 18px;
  }

  .tab-btn {
    min-height: 44px;
    margin-bottom: 8px;
    border-radius: 10px;
    padding: 10px 11px;
  }

  .sidebar-user {
    margin-bottom: 12px;
  }

  .sidebar-more {
    margin-top: 10px;
    justify-content: center;
  }

  .sidebar-more-menu {
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
  }

  .content {
    padding: 12px;
    padding-bottom: 18px;
  }

  .tab-panel h1 {
    margin-top: 2px;
    margin-bottom: 10px;
    font-size: 1.35rem;
  }

  .card {
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 12px;
  }

  .section-toolbar {
    align-items: stretch;
    gap: 8px;
  }

  .section-toolbar-actions {
    width: 100%;
    gap: 8px;
  }

  .section-toolbar-actions > * {
    flex: 1 1 100%;
    min-width: 0;
  }

  .item,
  .trash-item {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }

  .item-right,
  .trash-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .item img {
    width: 100%;
    max-width: 100%;
    height: auto;
  }

  .finance-toolbar,
  .consumption-toolbar {
    gap: 10px;
  }

  .finance-toolbar-filters,
  .consumption-toolbar-filters {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .finance-toolbar-actions,
  .consumption-toolbar-actions,
  .finance-actions-row,
  .consumption-actions {
    width: 100%;
  }

  .finance-toolbar-actions > button,
  .consumption-toolbar-actions > button,
  .finance-actions-row > button,
  .consumption-actions > button,
  .actions > button {
    width: 100%;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    max-width: 100%;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    border-radius: 12px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }
}

/* Bloco discreto para itens ocultados */
.hidden-entities-box {
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.45);
}

.hidden-entities-box summary {
  cursor: pointer;
  color: #9ca3af;
  font-size: 12px;
  user-select: none;
  list-style: none;
}

.hidden-entities-box summary::-webkit-details-marker {
  display: none;
}

.hidden-entities-box summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.hidden-entities-box[open] summary::before {
  transform: rotate(90deg);
}

.hidden-entities-list {
  margin-top: 8px;
  gap: 8px;
}

.hidden-entities-list .item {
  background: rgba(17, 24, 39, 0.65);
  border-style: dashed;
}

.hidden-item .item-right {
  align-items: center;
}

.hidden-entities-box.hidden {
  display: none;
}



/* =========================
   Agenciamento
========================= */
.agenciamento-item {
  align-items: flex-start;
  gap: 14px;
}
.agenciamento-item .item-left {
  width: 100%;
}
.agenciamento-subline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  margin-bottom: 10px;
}
.agenciamento-date {
  font-size: 12px;
  color: var(--muted);
}
.agenciamento-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(210px, 1fr));
  gap: 8px 12px;
  margin-bottom: 10px;
}
.agenciamento-notes {
  margin-bottom: 10px;
  font-size: 14px;
}
.agenciamento-values {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 14px;
}
.agenciamento-values strong {
  font-size: 15px;
}
.agenciamento-profit {
  color: var(--success-strong, #0f766e);
}
.link-inline {
  color: var(--primary-600, #2563eb);
  text-decoration: none;
}
.link-inline:hover {
  text-decoration: underline;
}
.agenciamento-remove-doc-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.agenciamento-remove-doc-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Tags do agenciamento */
.status-badge.ag-status-sem_motorista_encontrado {
  background: #f3f4f6;
  color: #374151;
  border-color: #e5e7eb;
}
.status-badge.ag-status-acordado_motorista {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.status-badge.ag-status-em_carregamento {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}
.status-badge.ag-status-em_viagem {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.status-badge.ag-status-aguardando_pagamento {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.status-badge.ag-status-pago_motorista {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}
.status-badge.ag-status-finalizado {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

@media (max-width: 900px) {
  .agenciamento-grid {
    grid-template-columns: 1fr;
  }
  .agenciamento-values {
    gap: 8px 12px;
  }
}

/* =========================
   Agenciamento - filtros, resumo e agrupamento mensal
   ========================= */
.agenciamento-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.agenciamento-toolbar-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
  flex: 1;
  min-width: min(100%, 780px);
}

.agenciamento-toolbar-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.agenciamento-toolbar-filters input,
.agenciamento-toolbar-filters select {
  width: 100%;
}

.agenciamento-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-left: auto;
}

.agenciamento-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin: 8px 0 12px;
}

.agenciamento-summary-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f172a;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.agenciamento-summary-card span {
  color: var(--muted);
  font-size: 12px;
}

.agenciamento-summary-card strong {
  font-size: 1.02rem;
}

.agenciamento-summary-card.success {
  border-color: rgba(16, 185, 129, .35);
  background: rgba(16, 185, 129, .08);
}

.agenciamento-summary-card.warning {
  border-color: rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .08);
}

.agenciamento-monthly-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #0b1220;
  margin-bottom: 10px;
}

.agenciamento-monthly-box > summary {
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 8px;
}

.agenciamento-monthly-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.agenciamento-month-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111827;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agenciamento-month-card strong {
  font-size: .95rem;
}

.agenciamento-month-card span {
  font-size: .84rem;
  color: var(--muted);
}

.agenciamento-month-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b1220;
  padding: 10px;
  margin-bottom: 12px;
}

.agenciamento-month-group-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.agenciamento-month-group-head h3 {
  margin: 0;
  font-size: 1rem;
}

.agenciamento-month-group-head p {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.agenciamento-month-group-head strong {
  color: #34d399;
  font-size: .92rem;
}

.agenciamento-month-group-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Correção do menu (...) no mobile para caminhões e motoristas */
@media (max-width: 900px) {
  #tab-trucks .item-right,
  #tab-drivers .item-right {
    justify-content: flex-end;
    width: 100%;
  }

  #tab-trucks .item-right .kebab-menu,
  #tab-drivers .item-right .kebab-menu {
    right: 0;
    left: auto;
    max-width: min(230px, calc(100vw - 40px));
  }

  .agenciamento-toolbar-filters {
    grid-template-columns: 1fr 1fr;
  }

  .agenciamento-toolbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .agenciamento-summary-cards {
    grid-template-columns: 1fr 1fr;
  }

  .agenciamento-month-group-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .agenciamento-toolbar-filters {
    grid-template-columns: 1fr;
  }

  .agenciamento-summary-cards {
    grid-template-columns: 1fr;
  }

  .agenciamento-monthly-list {
    grid-template-columns: 1fr;
  }
}


/* ===== Fix: rolagem do modal de edição de agenciamento (mobile) ===== */
.modal-edit-scroll {
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .modal-backdrop {
    overflow-y: auto;
    align-items: flex-start;
  }

  .modal-edit-scroll,
  .modal-create-scroll {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}


/* =========================
   Agenciamento - documentos
   ========================= */
.agenciamento-actions{
  display:flex;
  gap:8px;
  align-items:flex-start;
}

.doc-btn{
  position: relative;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 40px;
  line-height: 1;
  display:flex;
  align-items:center;
  justify-content:center;
}

.doc-btn:hover{
  border-color: #4b5563;
}

.doc-icon{
  font-size: 16px;
}

.doc-badge{
  position:absolute;
  top:-7px;
  right:-7px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #0b1220;
}

/* Modal de documentos */
.modal-docs{
  max-width: 720px;
}

.modal-docs-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-docs-body{
  display:flex;
  flex-direction: column;
  gap: 12px;
}

.modal-close{
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

.docs-list{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.doc-row{
  display:flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b1220;
}

.doc-main{
  display:flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.doc-meta{
  display:flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}

.doc-actions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-sm{
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.docs-actions{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap: wrap;
}

.docs-actions input[type="file"]{
  max-width: 340px;
}



/* ===== Permissões por aba (Admin > Usuários) ===== */
.perm-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.35);
}

.perm-title {
  font-weight: 800;
  margin: 0;
  color: #f8fafc;
}

.perm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.perm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.perm-mini-btn {
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.1;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px 10px;
}

.perm-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
}

.perm-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.hint.small {
  font-size: 12px;
  margin-top: 8px;
}

/* Painel quando o usuário não tem nenhuma permissão */
.no-access-card {
  border: 1px dashed #475569;
  background: rgba(2, 6, 23, 0.28);
}
.no-access-card h3 {
  margin: 0 0 6px 0;
}
.no-access-card p {
  margin: 0;
  color: #cbd5e1;
}

/* ===== Sidebar bottom bar (usuário + menu "...") ===== */
.sidebar-bottom-bar{
  border-top: 1px dashed #334155;
  padding-top: 10px;
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.sidebar-bottom-bar .sidebar-user{
  margin: 0;
  flex: 1 1 auto;
}

.sidebar-bottom-bar .sidebar-more{
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  justify-content: flex-end;
}

.sidebar-bottom-bar .sidebar-dots-btn{
  margin-top: 4px;
}

/* Em telas muito estreitas, empilha para não estourar */
@media (max-width: 420px){
  .sidebar-bottom-bar{
    flex-direction: column;
    align-items: stretch;
  }
  .sidebar-bottom-bar .sidebar-more{
    justify-content: flex-start;
  }
}


/* ===== Mobile: menu lateral rolagem + fechamento fora + ajustes de popups ===== */
@media (max-width: 900px) {
  /* Mantém o rodapé (usuário + "...") sempre visível durante a rolagem do menu */
  .sidebar-bottom-bar{
    position: sticky;
    bottom: 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(
      180deg,
      rgba(17, 24, 39, 0) 0%,
      rgba(17, 24, 39, 0.86) 35%,
      rgba(17, 24, 39, 0.98) 100%
    );
    backdrop-filter: blur(6px);
  }

  /* Menus (...) não podem estourar horizontalmente */
  .kebab-menu{
    max-width: calc(100vw - 24px);
  }
}


.upper-input { text-transform: uppercase; }

/* ===== Pagamentos: Vales do motorista ===== */
.payments-pending-breakdown{
  margin-top: 8px;
}

.payments-debt-hint{
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: #fca5a5;
  opacity: 0.92;
}

.payments-vales{
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}

.payments-vales-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 8px;
}

.payments-vales-head h3{
  margin:0;
  font-size: 14px;
  font-weight: 700;
}

.payments-vales-list .item{
  align-items:flex-start;
}

.vale-item .item-left{
  line-height: 1.35;
}

.vale-item .item-right{
  display:flex;
  gap: 8px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap: wrap;
}


/* Badges (usado em Despesas) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.badge.subtle {
  background: rgba(255,255,255,0.03);
}

.badge.success {
  border-color: rgba(34, 197, 94, 0.45);
}



/* Botões compactos (usado em Despesas) */
.btn-xs{
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1;
  border-radius: 10px;
}

.expense-inline-actions{
  display:flex;
  gap: 8px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap: wrap;
}

@media (max-width: 520px){
  .expense-inline-actions{
    justify-content:flex-start;
  }
}

/* Despesas: anexo */
.expense-attachment-link{
  color: inherit;
  text-decoration: underline dotted;
  opacity: .88;
  max-width: 240px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.expense-attachment-link:hover{ opacity: 1; }

/* Despesas: lista de anexos (modal) */
.expense-attachment-files{
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.expense-attachment-item{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.expense-attachment-item .left{
  display:flex;
  align-items:center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.expense-attachment-item .right{
  display:flex;
  align-items:center;
  gap: 8px;
}

.expense-attachment-item .expense-attachment-link{
  max-width: 380px;
}

@media (max-width: 520px){
  .expense-attachment-item{
    flex-direction: column;
    align-items: stretch;
  }
  .expense-attachment-item .right{
    justify-content: flex-end;
  }
  .expense-attachment-item .expense-attachment-link{
    max-width: 100%;
  }
}



/* Despesas: seção de pagas (discreta e recolhível) */
.expenses-paid-details {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.expenses-paid-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.expenses-paid-details summary::-webkit-details-marker { display: none; }

.expenses-paid-details[open] summary {
  margin-bottom: 10px;
}

.expenses-paid-details .payments-list {
  margin-top: 8px;
}



/* ===== Despesas (A + C) ===== */
.finance-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  margin-bottom: 14px;
}

.finance-filters label {
  display: block;
  margin-bottom: 0;
  font-size: 13px;
  color: var(--muted);
}

.finance-filters input[type="month"],
.finance-filters input[type="text"],
.finance-filters select {
  min-width: 170px;
}

.field-inline.field-grow {
  flex: 1 1 260px;
  min-width: 240px;
}

.finance-filters select {
  background: #0b1220;
  color: #e5e7eb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.payment-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111827;
  padding: 12px;
  margin-bottom: 10px;
}

.payment-row.is-paid {
  border-left: 4px solid rgba(16, 185, 129, 0.55);
}

.payment-row.is-pending {
  border-left: 4px solid rgba(245, 158, 11, 0.6);
}

.payment-main {
  flex: 1 1 auto;
  min-width: 0;
}

.payment-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.3;
}

.payment-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.payment-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.payment-amount {
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
}

.expense-inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.expenses-section {
  margin-top: 10px;
}

.expenses-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 10px;
}

.expenses-section-header .left,
.expenses-section-header .right {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.expenses-section.overdue .expenses-section-header {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.10);
}

.expenses-section.pending .expenses-section-header {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.expenses-debt-details summary {
  cursor: pointer;
}

.expenses-timeline {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.expenses-timeline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #111827;
}

.expenses-timeline-row:first-child {
  border-top: none;
}

.expenses-timeline-row.is-zero {
  opacity: 0.65;
}

@media (max-width: 720px) {
  .payment-row {
    flex-direction: column;
    align-items: stretch;
  }
  .payment-right {
    align-items: flex-start;
  }
  .payment-amount {
    font-size: 18px;
  }
}
/* ===========================
   Ajustes de cores dos ícones do menu
   - Comissões (payments): cor exclusiva
   - Agenciamentos: sempre vermelho (ativo e inativo)
   =========================== */

.tab-btn[data-tab="payments"] .menu-btn-icon { color: #f97316; } /* laranja (exclusiva) */

.tab-btn[data-tab="agenciamentos"] .menu-btn-icon { color: #dc2626; }
.tab-btn.active[data-tab="agenciamentos"] .menu-btn-icon { color: #dc2626; }


/* =========================
   Aba Lucro
   ========================= */
.profit-breakdown {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.profit-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.profit-result-card.positive {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.08);
}
.profit-result-card.negative {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.08);
}
.profit-result-card.zero {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.06);
}

.profit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.profit-item .profit-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.profit-item .profit-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.profit-item .profit-badge {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}
.profit-item.positive {
  border-color: rgba(34, 197, 94, 0.40);
}
.profit-item.positive .profit-badge,
.profit-item.positive .profit-value {
  color: var(--ok);
}
.profit-item.negative {
  border-color: rgba(239, 68, 68, 0.40);
}
.profit-item.negative .profit-badge,
.profit-item.negative .profit-value {
  color: var(--danger);
}



/* Expenses edit scope */
.expense-edit-scope {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.expense-edit-scope-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.expense-edit-scope-options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.radio-inline input {
  transform: translateY(1px);
}

.phone-whatsapp-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  opacity: 0.92;
}

.phone-whatsapp-link:hover {
  opacity: 1;
}

