@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap");

/* ============================================
   LOGÍSTICA DA VIDA — SaaS Theme Layer
   Loaded AFTER styles.css. Same selectors, premium skin.
   ============================================ */

:root {
  --bg: #f4f5f7;
  --bg-gradient: none;
  --bg-elev: #ffffff;
  --bg-sidebar: #0b1220;
  --surface-2: #f8fafc;
  --border: #e6e8ec;
  --border-hover: #d0d5dd;
  --text: #0f172a;
  --muted: #667085;
  --muted-light: #475467;

  --accent: #0b57d0;
  --accent-dim: rgba(11, 87, 208, 0.08);
  --accent-glow: rgba(11, 87, 208, 0.14);

  --commission: #067647;
  --commission-border: rgba(6, 118, 71, 0.2);
  --commission-dim: rgba(6, 118, 71, 0.06);
  --commission-glow: rgba(6, 118, 71, 0.12);

  --positive: #067647;
  --negative: #d92d20;
  --negative-dim: rgba(217, 45, 32, 0.06);

  --status-ok: #067647;
  --status-warn: #b54708;
  --status-danger: #d92d20;
  --status-info: #0b57d0;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-header: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
  --transition: 160ms cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Precisa vencer o top layer de <dialog> — por isso o valor máximo de z-index. */
  --z-toast: 2147483646;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: none;
  color: var(--text);
}

/* ---------- Sidebar (dark, Linear-like) ---------- */
.sidebar {
  width: 248px;
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 1.25rem 0.85rem;
  box-shadow: none;
}

.sidebar__header {
  margin-bottom: 1.25rem;
}

.sidebar__footer {
  margin-top: 1rem;
  padding-top: 1rem;
}

.sidebar__logo-img {
  max-width: 132px;
  max-height: 40px;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.sidebar--loja .sidebar__logo-img,
.sidebar__logo-img--loja {
  filter: none;
  opacity: 1;
}

.sidebar__company-badge {
  color: #e4e7ec;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
}

.sidebar__status-badge {
  background: rgba(6, 118, 71, 0.15);
  border-color: rgba(6, 118, 71, 0.25);
  color: #75e0a7;
  font-size: 0.62rem;
}

.sidebar__section-title {
  color: #667085;
  margin-top: 1.1rem;
  letter-spacing: 0.08em;
}

.sidebar__link {
  color: #c2c9d6; /* WCAG AA on #0b1220 */
  border-radius: 8px;
  padding: 0.62rem 0.7rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.sidebar__link:hover {
  color: #f9fafb;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar__link:hover .sidebar__icon {
  color: #f9fafb;
}

.sidebar__link.active {
  color: #ffffff;
  background: rgba(11, 87, 208, 0.28);
  border-left: none;
  padding-left: 0.7rem;
  box-shadow: inset 0 0 0 1px rgba(11, 87, 208, 0.35);
}

.sidebar__link.active .sidebar__icon {
  color: #84adff;
}

.sidebar__icon {
  color: #667085;
}

.sidebar__footer {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.sidebar__profile {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar__profile:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar__username {
  color: #f9fafb;
}

.sidebar__user-role {
  color: #98a2b3;
}

.sidebar__avatar {
  background: linear-gradient(135deg, var(--accent), #053991);
  box-shadow: none;
}

.sidebar__btn-logout {
  background: rgba(217, 45, 32, 0.08);
  border-color: rgba(217, 45, 32, 0.18);
  color: #f97066;
}

.sidebar__btn-logout:hover {
  background: rgba(217, 45, 32, 0.16);
  color: #fda29b;
}

.sidebar__btn-switch {
  color: #98a2b3;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-weight: 500;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  cursor: pointer;
}

.sidebar__btn-switch:hover {
  color: #f9fafb;
  background: rgba(255, 255, 255, 0.05);
}

/* Loja keeps warmer accent on dark shell */
.sidebar--loja .sidebar__link.active {
  background: rgba(190, 24, 93, 0.22);
  box-shadow: inset 0 0 0 1px rgba(190, 24, 93, 0.35);
}

.sidebar--loja .sidebar__link.active .sidebar__icon {
  color: #fda4d0;
}

/* Scrollbar visible on the dark sidebar shell — the default global
   scrollbar (dark thumb) is invisible on #0b1220, hiding the fact that
   lower nav items (Proposta, Cadastros, Configurações…) need a scroll. */
.sidebar,
.sidebar__nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
}

.sidebar::-webkit-scrollbar-thumb:hover,
.sidebar__nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
}

.sidebar::-webkit-scrollbar-track,
.sidebar__nav::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Main shell ---------- */
.app-main {
  background: var(--bg);
}

.layout {
  max-width: 1280px;
  padding: 1.25rem 1.25rem 2.5rem;
}

.header {
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0;
  border-bottom: none;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.35rem;
}

.header h1 {
  font-family: var(--font-header);
  font-size: clamp(1.45rem, 2.5vw, 1.85rem);
  font-weight: 750;
  letter-spacing: -0.035em;
  margin: 0;
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.35rem 0 0;
  max-width: 42rem;
}

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

/* ---------- Buttons ---------- */
.btn {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
  min-height: 40px;
  padding: 0.55rem 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.btn:hover {
  background: var(--surface-2, #f9fafb);
  border-color: var(--border-hover);
  transform: translateY(-0.5px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(11, 87, 208, 0.25), 0 4px 12px rgba(11, 87, 208, 0.18);
}

.btn--primary:hover {
  background: #0948b0;
  border-color: #0948b0;
  color: #fff;
}

.btn--sm {
  min-height: 32px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

/* ---------- Panels / filters ---------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem;
}

.panel h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

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

.filters {
  margin-bottom: 1rem;
}

.filters__title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.65rem;
}

.filters__row {
  gap: 0.65rem;
}

.filters__field span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.filters__field input,
.filters__field select,
.form-group input,
.form-group select,
.form-group textarea,
.panel__search input[type="search"] {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  min-height: 40px;
  font-family: var(--font);
  font-size: 1rem;
}

.filters__field input:focus,
.form-group input:focus,
.form-group select:focus,
.panel__search input[type="search"]:focus {
  outline: none;
  border-color: rgba(11, 87, 208, 0.5);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filters__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-light);
  cursor: pointer;
}

.chip-filter:has(input:checked) {
  background: var(--accent-dim);
  border-color: rgba(11, 87, 208, 0.3);
  color: var(--accent);
}

/* ---------- KPI strip (not chubby cards) ---------- */
.smart-grid,
.grid-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-bottom: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.smart-card,
.card {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.smart-card:last-child,
.card:last-child {
  border-bottom: none;
}

.smart-card:hover,
.card:hover {
  transform: none;
  box-shadow: none;
  background: #fafbfc;
  border-color: transparent;
}

.smart-card--hero,
.card--commission {
  background: transparent;
  border-color: transparent;
  border-bottom: 1px solid var(--border);
}

.smart-card--hero:hover,
.card--commission:hover {
  background: #fafbfc;
}

.smart-card__label,
.card__label {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.smart-card__value,
.card__value {
  font-family: var(--font-header);
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-top: 0.25rem;
}

.smart-card__value--md {
  font-size: 1.4rem;
}

.card--commission .card__value,
.smart-card--hero .smart-card__value {
  color: var(--commission);
}

.smart-card__hint,
.card__hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.smart-card__stats {
  margin-top: 0.55rem;
  gap: 0.35rem;
}

.smart-card__stats li {
  font-size: 0.8rem;
}

.badge {
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 650;
  padding: 0.15rem 0.4rem;
}

.badge--ok,
.badge--success {
  color: var(--status-ok);
  background: rgba(6, 118, 71, 0.08);
  border-color: rgba(6, 118, 71, 0.14);
}

.badge--warn,
.badge--warning {
  color: var(--status-warn);
  background: rgba(181, 71, 8, 0.08);
  border-color: rgba(181, 71, 8, 0.16);
}

.badge--info {
  color: var(--status-info);
  background: rgba(11, 87, 208, 0.08);
  border-color: rgba(11, 87, 208, 0.14);
}

.badge--danger {
  color: var(--status-danger);
  background: rgba(217, 45, 32, 0.08);
  border-color: rgba(217, 45, 32, 0.14);
}

.badge--neutral {
  color: var(--muted);
  background: #f2f4f7;
  border-color: var(--border);
}

/* ---------- Table ---------- */
.panel--table .panel__toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.table {
  font-size: 0.84rem;
}

.table thead th {
  background: #f9fafb;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.75rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #eef0f3;
  vertical-align: middle;
}

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

.table .num,
.table .td-emphasis {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.78rem;
}

/* ---------- Modal ---------- */
.modal__content {
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.18);
}

.modal__header {
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ---------- Auth ---------- */
.auth-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(11, 87, 208, 0.16), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(6, 118, 71, 0.1), transparent 50%),
    #f4f5f7;
}

.auth-box {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.08);
}

.auth-box--wide {
  width: min(720px, 100%);
}

.auth-box h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  text-align: center;
}

.auth-box .subtitle {
  text-align: center;
  margin-bottom: 1.25rem;
}

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

.company-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.company-card:hover {
  border-color: rgba(11, 87, 208, 0.35);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
  transform: translateY(-1px);
}

.company-card__title {
  margin: 0.55rem 0 0.2rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.company-card__desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.tabs .btn {
  box-shadow: none;
  border-color: transparent;
  background: transparent;
  min-height: 36px;
}

.tabs .btn--primary {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: transparent;
  box-shadow: none;
}

.tabs .btn--primary:hover {
  background: var(--accent-dim);
  color: var(--accent);
}
.footer {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 1rem;
}

.alerts .alert,
.alert {
  border-radius: 10px;
}

/* ---------- Mobile ---------- */
.mobile-header {
  background: #0b1220;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mobile-header__title {
  color: #f9fafb;
}

.hamburger-btn {
  color: #f9fafb;
}

@media (min-width: 720px) {
  .smart-grid,
  .grid-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .smart-card,
  .card {
    border-bottom: none;
    border-right: 1px solid var(--border);
  }

  .smart-card:nth-child(2n),
  .card:nth-child(2n) {
    border-right: none;
  }

  .smart-card:nth-child(-n + 2),
  .card:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .panel--table .panel__toolbar {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }

  .panel__search {
    min-width: 280px;
  }

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

@media (min-width: 1100px) {
  .layout {
    padding: 1.5rem 1.75rem 3rem;
  }

  .smart-grid,
  .grid-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .smart-card,
  .card {
    border-bottom: none !important;
    border-right: 1px solid var(--border);
  }

  .smart-card:last-child,
  .card:last-child {
    border-right: none;
  }
}

@media (max-width: 1023px) {
  .sidebar {
    background: var(--bg-sidebar);
  }
}

/* ---------- Trip list (no horizontal scroll) ---------- */
.trip-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.trip-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-2, #fafbfc);
}

.trip-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
}

.trip-card__top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.trip-card__placa {
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.trip-card__meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.trip-card__money {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.trip-card__frete {
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
}

.trip-card__comissao {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--commission);
  font-weight: 600;
}

.trip-card__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.75rem;
}

.trip-card__grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.trip-card__grid span {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.trip-card__grid strong {
  font-size: 0.86rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.trip-card__flags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.trip-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.trip-card__actions .btn {
  width: 100%;
  min-height: 44px;
}

.btn--danger {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.25);
  background: rgba(217, 45, 32, 0.06);
}

.btn--danger:hover {
  background: rgba(217, 45, 32, 0.12);
  color: #912018;
}

.table-wrap,
.table-wrap--scroll {
  overflow-x: auto;
  max-height: none !important;
}

@media (min-width: 900px) {
  .trip-card {
    flex-direction: row;
    align-items: stretch;
  }

  .trip-card__main {
    flex: 1;
    min-width: 0;
  }

  .trip-card__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trip-card__actions {
    width: 148px;
    grid-template-columns: 1fr;
    align-content: center;
  }
}

@media (min-width: 1100px) {
  .trip-card__grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Modal viagem: corpo com scroll + footer fixo */
.modal.modal--form {
  max-width: min(520px, 94vw);
  max-height: min(90vh, 860px);
  width: 94vw;
  padding: 0;
  overflow: hidden;
}

.modal.modal--form[open] {
  display: flex;
  flex-direction: column;
}

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

.modal.modal--form .modal__header {
  flex-shrink: 0;
  margin: 0;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.modal.modal--form .modal-form-scroll {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  margin: 0;
}

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

.modal.modal--form .modal__footer {
  flex-shrink: 0;
  margin: 0;
  padding: 0.9rem 1.15rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.modal {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border);
}

.modal__footer--stack .modal__footer-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.modal__footer--stack .modal__footer-actions .btn {
  min-height: 44px;
}

/* ===== Premium UI extensions ===== */

/* Dark theme — contraste legível em painéis, modal e formulários */
[data-theme="dark"] {
  --bg: #0c0f16;
  --bg-elev: #151a24;
  --bg-sidebar: #0a0d14;
  --surface-2: #1c2230;
  --text: #eef2f8;
  --muted: #9aa6bc;
  --muted-light: #c2cad8;
  --border: #2a3345;
  --border-hover: #3d4a63;
  --accent: #5b9bff;
  --accent-dim: rgba(91, 155, 255, 0.14);
  --accent-glow: rgba(91, 155, 255, 0.22);
  --commission: #3dd68c;
  --positive: #3dd68c;
  --negative: #f97171;
  --negative-dim: rgba(249, 113, 113, 0.12);
  --status-ok: #3dd68c;
  --status-warn: #f0b429;
  --status-danger: #f97171;
  --status-info: #5b9bff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

[data-theme="dark"] body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(59, 130, 246, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 90% 110%, rgba(16, 185, 129, 0.09) 0%, transparent 55%);
  color: var(--text);
}

[data-theme="dark"] .btn {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .btn:hover {
  background: #242b3b;
  color: #fff;
}

[data-theme="dark"] .btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #061018;
}

[data-theme="dark"] .btn--primary:hover {
  background: #7aafff;
  border-color: #7aafff;
  color: #061018;
}

[data-theme="dark"] .btn--danger {
  background: var(--negative);
  border-color: var(--negative);
  color: #fff;
}

[data-theme="dark"] .panel,
[data-theme="dark"] .smart-card,
[data-theme="dark"] .filters,
[data-theme="dark"] .loja-kpi,
[data-theme="dark"] .auth-box,
[data-theme="dark"] .venda-card,
[data-theme="dark"] .trip-card,
[data-theme="dark"] .company-card,
[data-theme="dark"] .item-card {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .modal,
[data-theme="dark"] .modal__content,
[data-theme="dark"] .modal.modal--form .modal__footer {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .modal::backdrop {
  background: rgba(4, 8, 16, 0.72);
}

[data-theme="dark"] .filters__field input,
[data-theme="dark"] .filters__field select,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .panel__search input[type="search"],
[data-theme="dark"] .table-toolkit__search,
[data-theme="dark"] .sidebar__search input {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .filters__field input::placeholder,
[data-theme="dark"] .form-group input::placeholder,
[data-theme="dark"] .form-group textarea::placeholder {
  color: #7f8aa0;
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus,
[data-theme="dark"] .filters__field input:focus,
[data-theme="dark"] .filters__field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

[data-theme="dark"] .table th {
  background: #111722;
  color: var(--muted-light);
}

[data-theme="dark"] .table td {
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .chip-filter {
  background: var(--surface-2);
  color: var(--muted-light);
  border-color: var(--border);
}

[data-theme="dark"] .mobile-header {
  background: var(--bg-sidebar);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .mobile-header__title,
[data-theme="dark"] .hamburger-btn,
[data-theme="dark"] .icon-btn {
  color: var(--text);
}

[data-theme="dark"] .venda-preview,
[data-theme="dark"] .trip-empty,
[data-theme="dark"] .empty-state {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--muted-light);
}

[data-theme="dark"] .venda-preview__title {
  color: var(--accent);
}

[data-theme="dark"] .alert {
  border-color: var(--border);
}

[data-theme="dark"] .alert--error {
  background: rgba(249, 113, 113, 0.12);
  color: #fecaca;
}

[data-theme="dark"] .alert--success {
  background: rgba(61, 214, 140, 0.12);
  color: #a7f3d0;
}

[data-theme="dark"] .positive { color: var(--positive); }
[data-theme="dark"] .negative { color: var(--negative); }

[data-theme="dark"] code {
  background: var(--surface-2);
  color: #d7e3ff;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
}

/* Soft gradient atmosphere on body — no purple clichés */
body {
  background-image: radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99, 155, 255, 0.07) 0%, transparent 60%),
                    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(52, 211, 153, 0.05) 0%, transparent 60%);
  background-attachment: fixed;
}

/* ===== Toast ===== */
.toast-host {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 2rem));
}

/* Toast dentro de <dialog> (top layer) — permanece visível sobre o modal */
dialog .toast-host {
  position: fixed;
  z-index: var(--z-toast);
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  background: #1e2130;
  color: #e8eaf0;
  font-size: 0.9rem;
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  pointer-events: all;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition: opacity 0.18s ease, transform 0.18s ease;
  border-left: 3px solid #4a90d9;
}

.toast--in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast--out {
  opacity: 0;
  transform: translateY(-4px) scale(0.97);
}

.toast--success { border-left-color: #34d399; }
.toast--error   { border-left-color: #f87171; }
.toast--warn    { border-left-color: #fbbf24; }
.toast--info    { border-left-color: #60a5fa; }

.toast__msg { flex: 1; }

.toast__close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.15rem;
  min-height: unset;
  border-radius: 4px;
}

.toast__close:hover { opacity: 1; }

/* ===== Sidebar enhancements ===== */
.sidebar--collapsed {
  width: 72px;
  overflow: hidden;
}

.sidebar--collapsed .sidebar__text,
.sidebar--collapsed .sidebar__section-title,
.sidebar--collapsed .sidebar__search input,
.sidebar--collapsed .sidebar__shortcut,
.sidebar--collapsed .sidebar__badge {
  display: none;
}

.sidebar__search {
  padding: 0.5rem 0.75rem;
}

.sidebar__search input {
  width: 100%;
  background: var(--bg-elev, rgba(255,255,255,0.06));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
}

.sidebar__tools {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.5rem;
}

.sidebar__tool {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: #c2c9d6;
  font-size: 0.875rem;
  transition: background 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar__tool:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.sidebar__shortcut {
  margin-left: auto;
  font-size: 0.72rem;
  opacity: 0.45;
}

.sidebar__badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent, #3b82f6);
  color: #fff;
  padding: 0.1em 0.45em;
  border-radius: 999px;
}

.sidebar__company-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
  display: inline-block;
}

/* Collapsed tooltip via data-tooltip */
.sidebar--collapsed [data-tooltip] {
  position: relative;
}

.sidebar--collapsed [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1a1d27;
  color: #e8eaf0;
  font-size: 0.8rem;
  white-space: nowrap;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
}

.sidebar--collapsed [data-tooltip]:hover::after {
  opacity: 1;
}

/* Sidebar inactive link color — WCAG AA compliant */
.sidebar__nav-link,
.sidebar__link {
  color: #c2c9d6;
}

/* Body when sidebar is collapsed — adjust main margin */
.sidebar-collapsed .app-main {
  margin-left: 72px;
}

/* ===== Utility classes ===== */
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

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

@media (max-width: 640px) {
  .grid-2col,
  .grid-3col {
    grid-template-columns: 1fr;
  }
}

/* Modal size variants */
.modal--sm .modal__content  { max-width: 360px; }
.modal--md .modal__content  { max-width: 520px; }
.modal--lg .modal__content  { max-width: 720px; }
.modal--xl .modal__content  { max-width: 960px; }

/* Button variants */
.btn--danger {
  background: var(--negative, #dc2626);
  color: #fff;
  border-color: var(--negative, #dc2626);
}

.btn--danger:hover {
  filter: brightness(1.1);
}

.btn--sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  min-height: 30px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  min-height: unset;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.07);
  color: var(--text, #1e293b);
}

/* Table toolkit */
.table-toolkit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0;
  margin-bottom: 0.5rem;
}

.table-toolkit__left,
.table-toolkit__right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.table-toolkit__search {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.875rem;
  background: var(--bg-elev, #fff);
  color: var(--text);
  min-width: 180px;
}

.table-toolkit__search:focus {
  outline: none;
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.table-toolkit__page-size {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.table-toolkit__page-size select {
  font: inherit;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.25rem 0.5rem;
  background: var(--bg-elev, #fff);
  color: var(--text);
}

.table-toolkit__meta {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.table-toolkit__pager {
  display: flex;
  gap: 0.25rem;
}

/* Sortable column headers */
.table-sortable {
  cursor: pointer;
  user-select: none;
}

.table-sortable::after {
  content: ' ↕';
  opacity: 0.35;
  font-size: 0.75em;
}

.table-sortable[aria-sort="ascending"]::after  { content: ' ↑'; opacity: 0.75; }
.table-sortable[aria-sort="descending"]::after { content: ' ↓'; opacity: 0.75; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}

.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state__title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.empty-state__body {
  font-size: 0.9rem;
}

/* Focus-visible rings */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}

/* Mobile header actions row */
@media (max-width: 480px) {
  .header__actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  .header__actions .btn {
    flex: 1;
    min-width: 0;
    font-size: 0.82rem;
    padding: 0.4rem 0.55rem;
  }
}

/* Clickable card */
.card--clickable {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card--clickable:hover,
.card--clickable:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

/* Skeleton loading */
.skeleton {
  position: relative;
  overflow: hidden;
  background: #e8ebf0;
  border-radius: 8px;
  min-height: 1rem;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

[data-theme="dark"] .skeleton {
  background: #2a2d3a;
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.is-invalid {
  border-color: var(--negative) !important;
  box-shadow: 0 0 0 3px var(--negative-dim, rgba(217, 45, 32, 0.12)) !important;
}

.table-toolkit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.table-toolkit__left,
.table-toolkit__right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.table-toolkit__search {
  min-width: min(280px, 100%);
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  font: inherit;
}

.table-toolkit__meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.table-sortable {
  cursor: pointer;
  user-select: none;
}

.table-sortable:hover {
  color: var(--accent);
}

.modal--ui .modal__content {
  max-width: min(440px, 94vw);
}

.modal__body-text {
  margin: 0 0 1rem;
  color: var(--muted-light, var(--muted));
  line-height: 1.45;
}

.btn--danger {
  background: var(--negative);
  border-color: var(--negative);
  color: #fff;
}

.btn--danger:hover {
  filter: brightness(0.95);
  color: #fff;
}

/* Prevent accidental horizontal scroll on app shell */
.app-container,
.app-main,
.layout {
  max-width: 100%;
  overflow-x: clip;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
  font-size: 0.95rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.85rem;
  max-width: 28rem;
}

/* Motion: subtle page entrance */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-main .layout > .header,
.app-main .layout > .smart-grid,
.app-main .layout > .loja-kpi-grid,
.app-main .layout > .panel,
.app-main .layout > .filters {
  animation: fade-up 0.35s ease both;
}

.app-main .layout > .smart-grid { animation-delay: 0.04s; }
.app-main .layout > .loja-kpi-grid { animation-delay: 0.04s; }
.app-main .layout > .filters { animation-delay: 0.06s; }
.app-main .layout > .panel { animation-delay: 0.08s; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
