@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800;900&display=swap');

:root {
  /* Clean SaaS Theme Palette */
  --bg: #f8fafc;
  --bg-gradient: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  --bg-elev: #ffffff;
  --bg-sidebar: #ffffff; /* Clean white sidebar matching premium light SaaS theme */
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --muted-light: #475569;
  
  --accent: #2563eb; /* Royal SaaS Blue */
  --accent-dim: rgba(37, 99, 235, 0.05);
  --accent-glow: rgba(37, 99, 235, 0.12);
  
  --commission: #059669; /* Rich Emerald Green */
  --commission-border: rgba(16, 185, 129, 0.25);
  --commission-dim: rgba(16, 185, 129, 0.05);
  --commission-glow: rgba(16, 185, 129, 0.15);
  
  --positive: #10b981;
  --negative: #ef4444;
  --negative-dim: rgba(239, 68, 68, 0.05);
  
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-header: 'Outfit', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.03);
}
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.25);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* --- SIDEBAR (WHITE - SaaS PREMIUM LIGHT) --- */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1rem;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: none; /* Premium clean look with borders instead of heavy dark shadows */
  transition: var(--transition);
}

.sidebar__header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.sidebar__logo-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  height: auto;
}

.sidebar__logo-img {
  max-width: 140px;
  max-height: 48px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
}

/* Status Badge with Glowing Pulse */
.sidebar__status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(5, 150, 105, 0.06);
  border: 1px solid rgba(5, 150, 105, 0.15);
  color: #059669;
  padding: 0.25rem 0.5rem;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  width: fit-content;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.online-dot {
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
  position: relative;
}

.online-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-color: #10b981;
  animation: pulse-dot 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(2.5); opacity: 0; }
  100% { transform: scale(2.5); opacity: 0; }
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

/* Navigation Section Headers */
.sidebar__section-title {
  font-family: var(--font-header);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
  padding-left: 0.75rem;
}

.sidebar__link {
  color: #475569;
  text-decoration: none;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.88rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.sidebar__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: var(--transition);
}

.sidebar__link:hover {
  color: var(--text);
  background: #f1f5f9;
}

.sidebar__link:hover .sidebar__icon {
  color: var(--text);
}

.sidebar__link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
  padding-left: calc(0.75rem - 2px);
  font-weight: 600;
  box-shadow: none;
}

.sidebar__link.active .sidebar__icon {
  color: var(--accent);
}

/* --- SIDEBAR FOOTER (USER PROFILE & LOGOUT) --- */
.sidebar__footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar__profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  background: #f8fafc;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.sidebar__profile:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-header);
  box-shadow: 0 4px 10px rgba(29, 78, 216, 0.15);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.sidebar__user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.sidebar__username {
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__user-role {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: capitalize;
}

/* Modern Logout Action Button */
.sidebar__btn-logout {
  color: #ef4444;
  text-decoration: none;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.1);
  cursor: pointer;
  width: 100%;
}

.sidebar__btn-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.2);
}

.sidebar__btn-logout .sidebar__icon {
  color: inherit;
}

/* --- MOBILE HEADER & OVERLAY --- */
.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* --- MAIN CONTENT & LAYOUT --- */
.app-main {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

.layout {
  max-width: 98%; /* Dynamically use 98% of screen width to maximize space and prevent empty margins */
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem; /* Slightly reduced horizontal padding to give more room to table columns */
}

/* --- HEADERS --- */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--commission);
  font-family: var(--font-header);
}

h1 {
  margin: 0;
  font-family: var(--font-header);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* --- BUTTONS --- */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--muted-light);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.btn:hover {
  background: #f8fafc;
  color: var(--text);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.1);
}

.btn--primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}

/* --- PANELS (CLEAN WHITE CARDS) --- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-header);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.panel__hint {
  margin: -0.35rem 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

/* --- FILTERS --- */
.filters {
  background: var(--bg-elev);
}

.filters__title {
  margin: 0 0 0.6rem;
}

.filters__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.25rem;
}

.filters__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

.filters__field input[type="date"],
.filters__field select {
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  transition: var(--transition);
}

.filters__field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2.2rem;
}

.filters__field input:focus,
.filters__field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.filters__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* --- CARDS GRID --- */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.04);
}

.card--commission {
  grid-column: span 2;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-color: rgba(16, 185, 129, 0.25);
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.04);
}

.card--commission:hover {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.08);
}

.card--commission .card__label {
  color: #065f46;
}

.card--commission .card__value {
  color: var(--commission);
  font-size: 1.85rem;
  font-weight: 700;
}

.card--commission .card__hint {
  color: #047857;
}

.card__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.card__value {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card__hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

/* --- TABLES (STABLE & NO CUT-OFFS) --- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.table-wrap--scroll {
  max-height: none !important; /* APPARECE DIRETO NA TELA (NO SCROLL VERTICAL) */
  overflow-y: visible !important;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table th,
.table td {
  padding: 0.75rem 0.85rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

.table th {
  position: sticky;
  top: 0;
  background: #f1f5f9; /* Soft light gray table header */
  font-weight: 700;
  color: var(--muted-light);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  z-index: 5;
  border-bottom: 1px solid #cbd5e1;
}

.table tbody tr {
  transition: background 0.1s ease;
}

.table tbody tr:hover td {
  background: #f8fafc;
}

/* Table Emphasis Styles */
.table th.th-emphasis {
  border-left: 2px solid var(--commission);
  background: #ecfdf5;
  color: #065f46;
}

.table td.td-emphasis {
  border-left: 2px solid var(--commission);
  font-weight: 700;
  color: #047857;
  background: #f0fdf4;
}

.table tbody tr:hover td.td-emphasis {
  background: #ecfdf5;
}

/* Stable Column Widths (Preventing Chopped Text & Auto-Resizing to Fill Screen) */
#tblViagens th:nth-child(1), #tblViagens td:nth-child(1) { width: 7.5rem; min-width: 7.5rem; }   /* Data */
#tblViagens th:nth-child(2), #tblViagens td:nth-child(2) { min-width: 8.5rem; width: auto; }    /* Placa (Dynamic & Spacious) */
#tblViagens th:nth-child(3), #tblViagens td:nth-child(3) { width: 8.5rem; min-width: 8.5rem; }   /* Ticket/NFE */
#tblViagens th:nth-child(4), #tblViagens td:nth-child(4) { width: 6rem; min-width: 6rem; }       /* Peso */
#tblViagens th:nth-child(5), #tblViagens td:nth-child(5) { min-width: 18rem; width: auto; }     /* Rota (Dynamic & Spacious) */
#tblViagens th:nth-child(6), #tblViagens td:nth-child(6) { min-width: 13rem; width: auto; }     /* Material (Dynamic & Spacious) */
#tblViagens th:nth-child(7), #tblViagens td:nth-child(7) { width: 7rem; min-width: 7rem; }       /* Frete */
#tblViagens th:nth-child(8), #tblViagens td:nth-child(8) { width: 8.5rem; min-width: 8.5rem; }   /* Frete total */
#tblViagens th:nth-child(9), #tblViagens td:nth-child(9) { width: 7rem; min-width: 7rem; }       /* Comissão */
#tblViagens th:nth-child(10), #tblViagens td:nth-child(10) { width: 9.5rem; min-width: 9.5rem; } /* Comissão total */
#tblViagens th:nth-child(11), #tblViagens td:nth-child(11) { min-width: 13rem; width: auto; }   /* Proprietário (Dynamic & Spacious) */
#tblViagens th:nth-child(12), #tblViagens td:nth-child(12) { width: 5rem; min-width: 5rem; }     /* Check comissão */
#tblViagens th:nth-child(13), #tblViagens td:nth-child(13) { width: 5rem; min-width: 5rem; }     /* Check terceiro */

#tblResumoProp th:nth-child(1), #tblResumoProp td:nth-child(1) { min-width: 13rem; }
#tblResumoRota th:nth-child(1), #tblResumoRota td:nth-child(1) { min-width: 18rem; }

/* Table Input Fields */
.cell-input-wrap {
  padding-top: 0.25rem !important;
  padding-bottom: 0.25rem !important;
}

.cell-edit-input,
.comissao-input,
.ticket-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: center;
  transition: var(--transition);
}

.cell-edit-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  padding-right: 1.1rem !important;
  cursor: pointer;
  text-align: center;
  text-align-last: center;
}

.cell-edit-input:hover,
.comissao-input:hover,
.ticket-input:hover {
  background: rgba(15, 23, 42, 0.03);
  border-color: var(--border);
}

.cell-edit-input:focus,
.comissao-input:focus,
.ticket-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.comissao-input:focus {
  border-color: var(--commission);
  box-shadow: 0 0 0 2px var(--commission-glow);
}

.is-blocked-edit {
  cursor: default !important;
}

.is-blocked-edit:disabled {
  opacity: 1 !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  background: transparent !important;
  border-color: transparent !important;
}

/* Custom Checkboxes */
input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --- MODALS & DIALOGS --- */
.modal {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
  max-width: 500px;
  width: 90%;
  overflow: hidden;
  transform: scale(0.97);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal--form {
  max-width: min(520px, 94vw);
  max-height: min(92vh, 820px);
  display: flex;
  flex-direction: column;
}

.modal--form .modal__content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: min(92vh, 820px);
  padding: 0;
  overflow: hidden;
}

.modal--form .modal__header {
  flex-shrink: 0;
  margin-bottom: 0;
  padding: 1.25rem 1.75rem 0.75rem;
}

.modal--form .modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.75rem;
  -webkit-overflow-scrolling: touch;
}

.modal--form .modal__footer {
  flex-shrink: 0;
  margin-top: 0;
  padding: 1rem 1.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #ffffff;
  position: sticky;
  bottom: 0;
  z-index: 1;
}

.modal[open] {
  transform: scale(1);
  opacity: 1;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal__content {
  padding: 1.75rem;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.modal__title {
  margin: 0;
  font-family: var(--font-header);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.btn-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-close:hover {
  color: var(--text);
  transform: scale(1.08);
}

/* --- FORMS --- */
.form-cadastro {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-group input,
.form-group select {
  font-family: var(--font);
  font-size: 0.92rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.form-group input[readonly] {
  opacity: 0.65;
  background: #f1f5f9;
  cursor: not-allowed;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* --- PROPOSTA CUSTOM STYLES --- */
.proposta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.item-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: var(--transition);
}

.item-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}

.item-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.item-card__header h3 {
  margin: 0;
  font-family: var(--font-header);
  font-size: 1rem;
  font-weight: 700;
}

.item-card__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.btn-remove {
  background: var(--negative-dim);
  color: var(--negative);
  border: 1px solid rgba(239, 68, 68, 0.1);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.78rem;
  transition: var(--transition);
}

.btn-remove:hover {
  background: var(--negative);
  color: #ffffff;
}

#loadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- FOOTER & MISC --- */
.footer {
  margin-top: 2rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.alerts {
  margin-bottom: 1.25rem;
}

.alert {
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: var(--accent);
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.positive {
  color: var(--positive) !important;
}

.negative {
  color: var(--negative) !important;
}

/* --- FECHAMENTO LAYOUT --- */
.fechamento-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* --- AUTH / LOGIN OVERHAUL (CLEAN PREMIUM) --- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: #f8fafc;
  background-image: radial-gradient(at 0% 0%, rgba(243, 244, 246, 0.5) 0, transparent 50%), 
                    radial-gradient(at 50% 0%, rgba(219, 234, 254, 0.3) 0, transparent 50%);
}

.auth-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.04), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  transition: var(--transition);
}

.auth-box:hover {
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.06);
}

.auth-box h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-align: center;
  font-family: var(--font-header);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.auth-box .alert {
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.auth-box--wide {
  max-width: 640px;
}

.company-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.company-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.75rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.company-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}

.company-card--loja:hover {
  border-color: #db2777;
  box-shadow: 0 8px 24px rgba(219, 39, 119, 0.12);
}

.company-card__icon {
  margin-bottom: 1rem;
  color: var(--accent);
}

.company-card--loja .company-card__icon {
  color: #db2777;
}

.company-card__logo {
  max-width: 140px;
  max-height: 72px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sidebar__logo-img--loja {
  max-width: 160px;
  max-height: 64px;
}

.mobile-header__logo--loja {
  max-height: 40px;
  width: auto;
  object-fit: contain;
}

.loja-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.loja-brand__logo {
  max-height: 52px;
  width: auto;
  object-fit: contain;
}

.loja-brand__eyebrow {
  margin: 0;
}

.loja-panel-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.loja-panel-brand img {
  max-height: 28px;
  width: auto;
  object-fit: contain;
}

.company-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.company-card__desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.sidebar--loja {
  --accent: #db2777;
  --accent-dim: rgba(219, 39, 119, 0.05);
  --accent-glow: rgba(219, 39, 119, 0.12);
}

.sidebar__company-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.sidebar__company-badge.sidebar__brand--loja {
  background: rgba(219, 39, 119, 0.08);
  color: #db2777;
}

.sidebar__btn-switch {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.sidebar__btn-switch:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.loja-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.loja-kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.loja-kpi__label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.loja-kpi__value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-header);
  color: var(--text);
}

.loja-kpi--pink .loja-kpi__value {
  color: #db2777;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge--success {
  background: var(--commission-dim);
  color: var(--commission);
}

.badge--warning {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.badge--danger {
  background: var(--negative-dim);
  color: var(--negative);
}

.produto-foto-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: var(--bg);
}

.produto-foto-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.produto-foto-placeholder {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  padding: 0.5rem;
}

.produto-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.produto-thumb--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.65rem;
  color: var(--muted);
}

.btn--sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.alert--success {
  background: var(--commission);
  color: white;
  border-color: transparent;
}

.sacoleira-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sacoleira-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
}

.sacoleira-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--accent-dim);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.sidebar--loja .sacoleira-card__header {
  background: rgba(219, 39, 119, 0.05);
}

.sacoleira-card__nome {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.sacoleira-card__meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.sacoleira-card__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sacoleira-card .table-wrap {
  padding: 0 0.5rem 0.5rem;
}

@media (max-width: 520px) {
  .company-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1023px) {
  .fechamento-layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  /* Mobile Header Activation */
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: #ffffff; /* Premium clean white header */
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 150;
    width: 100%;
  }

  .mobile-header__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
  }

  .mobile-header__logo {
    height: 28px;
    width: auto;
  }

  .mobile-header__title {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--text);
  }

  .hamburger-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
  }

  .hamburger-btn:hover {
    opacity: 0.8;
  }

  /* Transform Sidebar to Mobile Drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px !important;
    transform: translateX(-100%);
    z-index: 200;
    background: #ffffff;
    box-shadow: 15px 0 40px rgba(15, 23, 42, 0.08);
  }

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

  .app-container {
    flex-direction: column;
  }

  .layout {
    padding: 1.25rem 1rem 3rem;
  }

  .header {
    margin-bottom: 1.5rem;
  }

  .grid-cards {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .card--commission {
    grid-column: span 2;
  }

  .panel {
    padding: 1.25rem 1rem;
    margin-bottom: 1rem;
  }
}

@media (max-width: 768px) {
  /* Hide unnecessary columns on mobile */
  #tblViagens th:nth-child(3), #tblViagens td:nth-child(3),
  #tblViagens th:nth-child(6), #tblViagens td:nth-child(6),
  #tblViagens th:nth-child(7), #tblViagens td:nth-child(7),
  #tblViagens th:nth-child(8), #tblViagens td:nth-child(8),
  #tblViagens th:nth-child(11), #tblViagens td:nth-child(11) {
    display: none !important;
  }

  #tblResumoProp th:nth-child(5), #tblResumoProp td:nth-child(5),
  #tblResumoRota th:nth-child(5), #tblResumoRota td:nth-child(5) {
    display: none !important;
  }

  #tblTransportador th:nth-child(3), #tblTransportador td:nth-child(3),
  #tblTransportador th:nth-child(5), #tblTransportador td:nth-child(5),
  #tblTransportador th:nth-child(6), #tblTransportador td:nth-child(6),
  #tblTransportador th:nth-child(7), #tblTransportador td:nth-child(7) {
    display: none !important;
  }
  
  .cell-edit-input, .comissao-input, .ticket-input {
    min-width: unset !important;
    width: 100% !important;
  }
  
  .modal {
    width: 95%;
  }
  
  .modal__content {
    padding: 1.25rem;
  }
  
  .modal__header {
    margin-bottom: 1rem;
  }
  
  .modal__footer {
    margin-top: 1.25rem;
  }

  .proposta-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .grid-cards {
    grid-template-columns: 1fr;
  }
  
  .card--commission {
    grid-column: span 1;
  }
  
  .filters__buttons {
    width: 100%;
  }
  
  .filters__buttons .btn {
    flex: 1;
  }
  
  .header__actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  
  .header__actions .btn {
    width: 100%;
  }
}
