:root {
  /* Cores institucionais */
  --cor-cabecalho: #1a1a1a;
  --cor-rodape: #1a1a1a;

  /* Botões */
  --cor-fundo-botao-cabecalho: #ffffff;
  --cor-botao-cabecalho-quando-passa-o-mouse: var(--portal-yellow);
  --cor-botao-sucesso: #28a745;
  --cor-botao-excluir: #dc3545;

  /* Ícones */
  --cor-icone-card: var(--portal-blue);
  --cor-icone-card-quando-passa-o-mouse: var(--portal-yellow);

  /* Status */
  --cor-status-aberto: #ffc107;
  --cor-status-encerrado: #28a745;

  /* Base */
  --cor-texto-padrao: #333;
  --cor-fundo-pagina: #f5f5f5;
  --cor-fundo-card: #ffffff;
}

/* Reset e base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  line-height: 1.5;
  background-color: var(--cor-fundo-pagina);
  color: var(--cor-texto-padrao);
  padding-bottom: 80px;
}

/* Cabeçalho */
header.despesas-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background-color: #ffffff;
  color: #111827;
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.despesas-topbar-home .header-buttons {
  margin-left: auto;
}

.despesas-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 92px;
  height: 48px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.topbar-title span {
  font-size: 0.78rem;
  color: #6b7280;
}

.topbar-title strong {
  font-size: 1.05rem;
  color: #111827;
}

.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d6a11e;
  border-radius: 6px;
  background: var(--portal-yellow);
  color: #111827;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, transform 0.18s ease;
}

.topbar-back:hover {
  background: #f1bd3e;
  transform: translateY(-1px);
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-button {
  min-width: 38px;
  min-height: 36px;
  background-color: #f3f4f6;
  color: #111827;
  border: 1px solid #e5e7eb;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.header-button.icon-only {
  align-items: center;
  background: #ffffff;
  display: inline-flex;
  font-size: 1.05rem;
  justify-content: center;
  padding: 0;
  width: 38px;
}

.settings-button {
  border-color: #d6a11e;
  color: var(--portal-blue);
}

.header-button:hover {
  background-color: #e5e7eb;
}

/* Conteúdo principal */
.main-content {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.main-content h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--cor-texto-padrao);
}

/* Filtros */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
}

.filter-bar input,
.filter-bar select {
  padding: 0.5rem;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-width: 200px;
}

/* Botão Nova Viagem */
.btn-nova-viagem {
  background-color: var(--cor-botao-sucesso);
  color: var(--cor-fundo-botao-cabecalho);
  padding: 10px 20px;
  font-size: 1rem;
  border-radius: 8px;
  margin: 0 auto 1.5rem auto;
  display: block;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-nova-viagem:hover {
  background-color: #218838;
}

/* Cards */
.viagens-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.viagem-card {
  background-color: var(--cor-fundo-card);
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 1rem;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s;
}

.viagem-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.viagem-card.closed {
  opacity: 0.6;
}

.card-header h4 {
  margin: 0 0 0.25rem 0;
  font-size: 1.2rem;
  font-weight: bold;
}

.viagem-cadastrante {
  color: #444;
  font-weight: bold;
  font-size: 0.95rem;
}

.card-body p {
  margin: 0.3rem 0;
  font-size: 0.95rem;
}

.status-aberto {
  background-color: var(--cor-status-aberto);
  color: black;
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: bold;
}

.status-encerrado {
  background-color: var(--cor-status-encerrado);
  color: var(--cor-fundo-botao-cabecalho);
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: bold;
}

.card-footer {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 10px;
}

.icon-button {
  background: var(--portal-blue-soft);
  border: 1px solid #dbe4ff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--cor-icone-card);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.icon-button:hover {
  background: #fff7df;
  border-color: var(--portal-yellow);
  color: var(--cor-icone-card-quando-passa-o-mouse);
}

.icon-button.danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: var(--cor-botao-excluir);
}

.icon-button.danger:hover {
  background: #ffe4e6;
  border-color: var(--cor-botao-excluir);
}

.ai-status {
  color: #4b5563;
  font-size: 0.86rem;
  line-height: 1.35;
  min-height: 1.2rem;
  margin-top: 0.45rem;
}

.ai-status.loading {
  color: var(--portal-blue);
}

.ai-status.ok {
  color: #166534;
}

.ai-status.warn {
  color: #854d0e;
}

.receipt-day-summary {
  background: #fff7df !important;
  border-color: #f1d894 !important;
  padding: 0.85rem 1rem;
}

.receipt-day-summary-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.receipt-day-summary h4 {
  color: #113560;
  margin: 0;
}

.receipt-day-summary-total {
  color: #113560;
  white-space: nowrap;
}

body.despesas-mobile-form-page {
  overflow-x: hidden;
  padding-bottom: 24px;
}

body.despesas-mobile-form-page .portal-generated-page-heading {
  display: none !important;
}

body.despesas-mobile-form-page .form-page,
body.despesas-mobile-form-page .mobile-form-shell {
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
  max-width: none;
  width: 100%;
}

body.despesas-mobile-form-page .form-container,
body.despesas-mobile-form-page .mobile-form-panel,
body.despesas-mobile-form-page .mobile-form-panel > form {
  box-sizing: border-box;
  min-width: 0;
}

body.despesas-mobile-form-page .form-container,
body.despesas-mobile-form-page .mobile-form-panel > form {
  width: min(100%, 430px);
}

html[data-portal-theme="dark"] .receipt-day-summary {
  background: #1f2025 !important;
  border-color: rgba(226, 167, 33, 0.85) !important;
  box-shadow: inset 4px 0 0 var(--portal-yellow), var(--portal-shadow) !important;
}

html[data-portal-theme="dark"] .receipt-day-summary h4 {
  color: #f8fafc !important;
}

html[data-portal-theme="dark"] .receipt-day-summary-total {
  color: #f8d36b !important;
}

@media (max-width: 760px) {
  body.despesas-mobile-form-page .portal-appbar {
    gap: 12px !important;
    min-height: 64px !important;
    padding: 10px 16px !important;
  }

  body.despesas-mobile-form-page .portal-appbar-title strong {
    font-size: 1.05rem !important;
  }

  body.despesas-mobile-form-page.portal-has-global-appbar .form-page,
  body.despesas-mobile-form-page.portal-has-global-appbar .mobile-form-shell,
  body.despesas-mobile-form-page .form-page,
  body.despesas-mobile-form-page .mobile-form-shell {
    display: block !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: none !important;
    min-height: calc(100dvh - 64px) !important;
    padding: 10px 10px calc(92px + env(safe-area-inset-bottom)) !important;
    width: 100% !important;
  }

  body.despesas-mobile-form-page .mobile-form-panel {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  body.despesas-mobile-form-page .form-container,
  body.despesas-mobile-form-page .mobile-form-panel > form {
    border-radius: 12px !important;
    max-width: none !important;
    padding: 18px !important;
    width: 100% !important;
  }

  body.despesas-mobile-form-page h2 {
    font-size: 1.55rem;
    line-height: 1.15;
    margin: 0 0 1rem;
  }

  body.despesas-mobile-form-page label {
    font-size: 0.96rem;
    line-height: 1.25;
    margin-top: 0.75rem;
  }

  body.despesas-mobile-form-page input,
  body.despesas-mobile-form-page select,
  body.despesas-mobile-form-page textarea {
    font-size: 16px;
    max-width: 100%;
    min-height: 52px;
    min-width: 0;
    padding: 0.78rem;
  }

  body.despesas-mobile-form-page input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    display: block;
    inline-size: 100%;
    max-inline-size: 100%;
    max-width: 100% !important;
    min-inline-size: 0;
    min-width: 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100% !important;
  }

  body.despesas-mobile-form-page .receipt-upload-panel {
    margin-bottom: 0.85rem;
    padding: 0.75rem;
  }

  body.despesas-mobile-form-page .receipt-upload-button {
    font-size: 1rem;
    min-height: 50px;
    padding: 0.75rem 1rem;
  }

  body.despesas-mobile-form-page .receipt-preview {
    max-height: 160px;
  }

  html body.despesas-mobile-form-page.portal-unified-header-shell.portal-has-global-appbar main.form-page,
  html body.despesas-mobile-form-page.portal-unified-header-shell.portal-has-global-appbar main.mobile-form-shell {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }

  body.despesas-mobile-form-page .btn-salvar,
  body.despesas-mobile-form-page .btn-cancelar,
  body.despesas-mobile-form-page button[type="submit"] {
    min-height: 50px;
  }

  .receipt-day-summary-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .receipt-day-summary-total {
    white-space: normal;
  }
}

@media (max-width: 380px) {
  body.despesas-mobile-form-page .portal-appbar {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  body.despesas-mobile-form-page .portal-appbar-title strong {
    font-size: 1rem !important;
  }

  body.despesas-mobile-form-page .form-container,
  body.despesas-mobile-form-page .mobile-form-panel > form {
    padding: 16px !important;
  }

  body.despesas-mobile-form-page .receipt-preview {
    max-height: 140px;
  }
}

/* Rodapé */
footer {
  background-color: var(--cor-rodape);
  color: var(--cor-fundo-botao-cabecalho);
  text-align: center;
  padding: 10px;
  position: relative;
}

@media (max-width: 720px) {
  header.despesas-topbar {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }

  .despesas-topbar-left {
    flex: 1 1 auto;
    flex-wrap: nowrap;
  }

  .header-buttons {
    flex: 0 0 auto;
    justify-content: flex-end;
    margin-left: auto;
  }

  .brand-logo {
    width: 64px;
    height: 34px;
  }

  .topbar-back {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.9rem;
  }

  .topbar-title span {
    font-size: 0.72rem;
  }

  .topbar-title strong {
    font-size: 0.95rem;
  }
}

/* Responsividade */
@media (max-width: 768px) {
  .filter-bar {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }

  .filter-bar input,
  .filter-bar select {
    width: 90%;
    max-width: 400px;
    font-size: 1rem;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
  }

  .btn-nova-viagem {
    width: 90%;
    max-width: 400px;
  }

  .viagem-card {
    padding: 1rem;
    width: 95%;
    margin: 0 auto;
  }
}
