* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #1a2456; padding: 16px; }
.login-box { background: white; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); text-align: center; }
.login-box img { height: auto; max-height: 90px; max-width: 260px; width: 100%; object-fit: contain; margin-bottom: 14px; }
.login-box h2 { color: #1a2456; font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.login-box p { color: #888; font-size: 0.82rem; margin-bottom: 28px; }
.login-campo { margin-bottom: 14px; text-align: left; }
.login-campo label { display: block; font-size: 0.8rem; font-weight: bold; color: #555; margin-bottom: 4px; }
.login-campo input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem; }
.login-campo input:focus { outline: none; border-color: #1a2456; }
.btn-login { width: 100%; padding: 11px; background: #1a2456; color: white; border: none; border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer; margin-top: 8px; }
.btn-login:hover { opacity: 0.88; }
.login-erro { color: #c00; font-size: 0.8rem; margin-top: 10px; display: none; }
.btn-esqueci-pw { background: none; border: none; color: #888; font-size: 0.78rem; cursor: pointer; margin-top: 12px; text-decoration: underline; font-weight: normal; }
.btn-esqueci-pw:hover { color: #1a2456; opacity: 1; }
.login-esqueci-info { background: #f8f9ff; border: 1px solid #d0d8ff; border-radius: 8px; padding: 12px 14px; font-size: 0.8rem; color: #555; margin-top: 8px; line-height: 1.6; text-align: left; }
.app-page { display: none; }
header { background: white; padding: 10px 24px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 8px rgba(0,0,0,0.1); border-bottom: 3px solid #1a2456; }
header img { height: auto; max-height: 48px; max-width: 180px; object-fit: contain; }
header h1 { font-size: 1.15rem; font-weight: 700; color: #1a2456; border-left: 2px solid #f5c400; padding-left: 16px; flex: 1; }
.user-info { font-size: 0.78rem; color: #888; text-align: right; margin-left: auto; }
.user-info strong { display: block; color: #1a2456; }
.btn-alterar-pw { background: none; border: none; color: #aaa; font-size: 0.68rem; cursor: pointer; padding: 0; text-decoration: underline; font-weight: normal; display: block; margin-top: 2px; }
.btn-alterar-pw:hover { color: #1a2456; opacity: 1; }
.btn-logout { padding: 7px 14px; background: #f0f0f0; color: #555; border: none; border-radius: 8px; font-size: 0.82rem; font-weight: bold; cursor: pointer; }
.abas { display: flex; background: white; border-bottom: 2px solid #e0e0e0; padding: 0 24px; }
.aba { padding: 13px 22px; cursor: pointer; font-size: 0.88rem; font-weight: bold; color: #888; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.aba:hover { color: #1a2456; }
.aba.ativa { color: #1a2456; border-bottom-color: #f5c400; }
.conteudo-aba { display: none; }
.conteudo-aba.ativo { display: block; }
.container { max-width: 1300px; margin: 20px auto; padding: 0 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: 10px; padding: 16px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.stat-card .numero { font-size: 2rem; font-weight: bold; color: #1a2456; }
.stat-card .label { font-size: 0.75rem; color: #888; margin-top: 4px; text-transform: uppercase; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.88rem; background: white; }
.toolbar input { flex: 1; min-width: 200px; }
button { padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.88rem; font-weight: bold; transition: opacity 0.15s; }
button:hover { opacity: 0.88; }
.btn-primary { background: #1a2456; color: white; }
.btn-yellow { background: #f5c400; color: #1a2456; }
.btn-green { background: #10b981; color: white; }
.btn-small { padding: 4px 9px; font-size: 0.75rem; }
.btn-edit { background: #f0f0f0; color: #333; }
.btn-delete { background: #fee2e2; color: #b91c1c; }
.btn-icon { padding: 5px 7px; line-height: 0; }
.btn-icon svg { display: block; }
.btn-cancelar { background: #f0f0f0; color: #333; }
.tabela-wrap { background: white; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { background: #1a2456; color: rgba(255,255,255,0.85); padding: 11px 12px; text-align: left; font-size: 0.75rem; text-transform: uppercase; white-space: nowrap; }
td { padding: 10px 12px; font-size: 0.84rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9ff; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: bold; white-space: nowrap; }
.badge.Ativo { background: #d1fae5; color: #065f46; }
.badge.Cancelada { background: #fee2e2; color: #991b1b; }
.badge.fa-sim { background: #dbeafe; color: #1d4ed8; }
.badge.fa-nao { background: #fef9c3; color: #92400e; }
.filtros-historico { background: white; border-radius: 10px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filtro-grupo { display: flex; flex-direction: column; gap: 4px; }
.filtro-grupo label { font-size: 0.75rem; font-weight: bold; color: #666; }
.filtro-grupo input, .filtro-grupo select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.85rem; }
.resumo-historico { background: #f8f9ff; border: 1px solid #e0e6ff; border-radius: 8px; padding: 12px 16px; margin-bottom: 14px; display: flex; gap: 24px; flex-wrap: wrap; }
.resumo-item { font-size: 0.82rem; color: #555; }
.resumo-item strong { color: #1a2456; font-size: 1rem; }
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100; align-items: flex-start; justify-content: center; padding: 16px; overflow-y: auto; }
.modal-overlay.aberto { display: flex; }
.modal { background: white; border-radius: 14px; padding: 28px; width: 100%; max-width: 580px; margin: auto; }
.modal h2 { font-size: 1.1rem; margin-bottom: 20px; color: #1a2456; border-bottom: 2px solid #f5c400; padding-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
.campo { display: flex; flex-direction: column; gap: 4px; }
.campo label { font-size: 0.78rem; font-weight: bold; color: #555; }
.campo input, .campo select, .campo textarea { padding: 8px 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.88rem; width: 100%; }
.campo input:read-only { background: #f8f8f8; color: #888; cursor: not-allowed; }
.campo .erro { color: #c00; font-size: 0.73rem; display: none; }
.secao-titulo { grid-column: 1 / -1; font-size: 0.75rem; font-weight: bold; color: #1a2456; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 0 4px; border-bottom: 1px solid #eee; margin-top: 6px; }
.modal-botoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid #eee; }
.vazio { text-align: center; padding: 48px; color: #aaa; font-size: 0.9rem; }
.cards-mobile { display: none; }
.venda-card { background: white; border-radius: 10px; padding: 16px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-left: 4px solid #1a2456; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card-nome { font-weight: bold; font-size: 0.95rem; color: #1a2456; }
.card-sub { font-size: 0.75rem; color: #888; margin-top: 2px; }
.card-body { font-size: 0.82rem; color: #555; line-height: 1.8; }
.card-footer { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.hide-col-comercial th:nth-child(6),
.hide-col-comercial td:nth-child(6) { display: none; }
.col-center { text-align: center; }
td:nth-child(4), td:nth-child(5) { text-align: center; }
.row-clicavel { cursor: pointer; }
.row-clicavel:hover td { background: #eef0ff; }
.modal-detalhe { max-width: 680px; }
.detalhe-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 2px solid #f5c400; }
.detalhe-titulo { font-size: 1.1rem; font-weight: bold; color: #1a2456; margin-bottom: 6px; }
.detalhe-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.detalhe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; }
.detalhe-item { display: flex; flex-direction: column; padding: 9px 0; border-bottom: 1px solid #f5f5f5; }
.detalhe-label { font-size: 0.68rem; font-weight: bold; color: #aaa; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.detalhe-valor { font-size: 0.88rem; color: #222; }
/* === DASHBOARD === */
.dashboard-filtros { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.dash-atalhos { display: flex; gap: 6px; }
.btn-dash-periodo { background: #f0f0f0; color: #555; border: none; border-radius: 6px; padding: 7px 14px; font-size: 0.82rem; font-weight: bold; cursor: pointer; }
.btn-dash-periodo.ativo { background: #1a2456; color: white; }
.btn-dash-periodo:hover { opacity: 0.85; }
.dashboard-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi-card { background: white; border-radius: 10px; padding: 18px 14px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.kpi-valor { font-size: 2rem; font-weight: bold; color: #1a2456; }
.kpi-label { font-size: 0.72rem; color: #888; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-sub { font-size: 0.75rem; color: #aaa; margin-top: 2px; }
.dashboard-charts-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.chart-card { background: white; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.chart-card-sm { padding: 16px 14px; }
.chart-card-sm canvas { max-height: 160px; }
.chart-card-titulo { font-size: 0.78rem; font-weight: 700; color: #1a2456; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.04em; }

/* === FILTROS COM X === */
.filtro-clear-wrap { display: flex; align-items: center; gap: 4px; }
.filtro-input-wrap { flex: 1; min-width: 200px; position: relative; display: flex; align-items: center; }
.filtro-input-wrap input { width: 100%; padding-right: 28px; }
.filtro-input-wrap .btn-clear-filtro { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.btn-clear-filtro { background: none; border: none; cursor: pointer; color: #bbb; font-size: 15px; font-weight: bold; padding: 2px 5px; border-radius: 4px; line-height: 1; min-height: unset; }
.btn-clear-filtro:hover { color: #555; background: #eee; opacity: 1; }

/* === TABLET (769px – 1024px) === */
@media (min-width: 769px) and (max-width: 1024px) {
  .container { padding: 0 14px; }
  .stats { gap: 10px; }
  .modal { max-width: 600px; }
}

/* === MOBILE (≤ 768px) === */
@media (max-width: 768px) {
  /* Header */
  header { padding: 8px 14px; gap: 10px; }
  header h1 { display: none; }
  .user-info { font-size: 0.72rem; }
  .user-info strong { font-size: 0.78rem; }
  header img { max-height: 38px; max-width: 140px; }

  /* Tabs */
  .abas { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .aba { padding: 12px 16px; font-size: 0.82rem; white-space: nowrap; }

  /* Stats */
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 12px 10px; }
  .stat-card .numero { font-size: 1.8rem; }

  /* Toolbar — empilha em coluna */
  .toolbar { flex-direction: column; gap: 8px; }
  .filtro-input-wrap { min-width: 100% !important; width: 100%; }
  .filtro-clear-wrap { width: 100%; }
  .filtro-clear-wrap select { flex: 1; width: 100%; }
  .toolbar .btn-yellow { width: 100%; padding: 13px; font-size: 0.95rem; }

  /* Tabela → Cards */
  .tabela-wrap { display: none; }
  .cards-mobile { display: block; }

  /* Formulário */
  .form-grid { grid-template-columns: 1fr; }
  .filtros-historico { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; }
  .filtros-historico .filtro-grupo { width: 100%; }
  .filtro-grupo input, .filtro-grupo select { width: 100%; }
  #btn-pesquisar-historico, #btn-exportar-excel { width: 100%; padding: 13px; font-size: 0.9rem; }
  .resumo-historico { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 10px 12px; }
  .resumo-item { font-size: 0.78rem; }
  .resumo-item strong { font-size: 0.9rem; }

  /* Modais — bottom sheet */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; overflow-y: auto; padding: 24px 20px 36px; width: 100%; max-width: 100%; }
  .modal-detalhe { max-width: 100%; }
  .detalhe-grid { grid-template-columns: 1fr; }
  .detalhe-header { flex-direction: column; gap: 10px; }

  /* Resumo histórico */
  .resumo-historico { gap: 10px; }
  .resumo-item strong { font-size: 0.95rem; }

  /* Botões touch-friendly */
  button { min-height: 40px; }
  .btn-small { padding: 8px 12px; font-size: 0.8rem; }
  .btn-icon { padding: 8px 10px; }
  .btn-clear-filtro { min-height: unset; }

  /* Cards */
  .venda-card { border-radius: 12px; }
  .card-footer { gap: 10px; margin-top: 10px; }
}

  .dashboard-kpis { grid-template-columns: repeat(2, 1fr); }
  .dashboard-charts-row { grid-template-columns: repeat(2, 1fr); }

/* === MOBILE PEQUENO (≤ 480px) === */
@media (max-width: 480px) {
  .container { padding: 0 10px; }
  .stats { gap: 8px; }
  .stat-card .numero { font-size: 1.6rem; }
  .stat-card .label { font-size: 0.68rem; }
  .aba { padding: 10px 14px; font-size: 0.8rem; }
  .modal { padding: 20px 16px 32px; }
}
