* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { overflow-x: hidden; }

body {
  font-family: 'Segoe UI', sans-serif;
  background: #f4f6f9;
  color: #333;
  font-size: 14px;
}

/* NAV */
nav {
  background: #1a1a2e;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
nav .logo {
  color: #e94560;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}
nav .nav-links a {
  color: #ccc;
  text-decoration: none;
  margin-left: 20px;
  font-size: 14px;
}
nav .nav-links a:hover { color: #fff; }

main {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 16px;
}

/* PAGE HEADER */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-header h2 { font-size: 20px; color: #1a1a2e; }
.header-actions { display: flex; gap: 8px; }

/* RESUMO */
.resumo {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.card-resumo {
  background: #fff;
  border-radius: 8px;
  padding: 12px 20px;
  border-left: 4px solid #e94560;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}
.card-resumo .label { font-size: 12px; color: #888; }
.card-resumo .valor { font-size: 18px; font-weight: 700; color: #1a1a2e; }

/* Modal A Chegar */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  min-width: 320px;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
}
.modal-fechar {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #888;
  line-height: 1;
}
.modal-fechar:hover { color: #e94560; }
.achegar-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.achegar-table thead th { color: #888; font-weight: 600; text-align: left; padding: 4px 8px 8px 0; border-bottom: 2px solid #f0f0f0; }
.achegar-table thead th:last-child { text-align: right; }
.achegar-table tbody td { padding: 7px 8px 7px 0; border-bottom: 1px solid #f5f5f5; color: #333; }
.achegar-table tbody td:last-child { text-align: right; font-weight: 700; color: #1a1a2e; }
.achegar-table tbody tr:last-child td { border-bottom: none; }

/* FILTROS */
.filtros {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.filtros select, .filtros input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
}

/* TABLE */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
th {
  background: #1a1a2e;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
tr:hover { background: #fafafa; }
.vazio { text-align: center; color: #aaa; padding: 24px; }

/* BADGES */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-pago { background: #fef3c7; color: #92400e; }
.badge-saiu-da-china { background: #dbeafe; color: #1e40af; }
.badge-chegou-no-br { background: #e0e7ff; color: #3730a3; }
.badge-a-caminho { background: #ffedd5; color: #c2410c; }
.badge-saiu-para-entrega { background: #fce7f3; color: #9d174d; }
.badge-entregue { background: #d1fae5; color: #065f46; }

.status-select {
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  padding: 2px 8px;
  border-radius: 12px;
  text-align: center;
}
.status-select:focus { outline: 1px solid #666; }

.rastreio-vazio { color: #aaa; cursor: pointer; }
.rastreio-link { color: #e94560; font-size: 13px; text-decoration: none; line-height: 1; }
.rastreio-link:hover { opacity: 0.7; }
.rastreio-edit-btn { padding: 1px 5px; font-size: 11px; background: transparent; border: 1px solid #ddd; color: #666; }
.rastreio-edit-btn:hover { border-color: #e94560; color: #e94560; }
.rastreio-popup {
  display: flex;
  gap: 4px;
  align-items: center;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: nowrap;
  min-width: 280px;
}
.rastreio-popup .rastreio-input { width: 130px; padding: 3px 6px; font-size: 12px; border: 1px solid #ddd; border-radius: 4px; }
.rastreio-popup .transp-input { padding: 3px 4px; font-size: 12px; border: 1px solid #ddd; border-radius: 4px; }
.rastreio-cell { min-width: 140px; }
.rastreio-status { color: #555; }

/* BUTTONS */
.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #e94560; color: #fff; }
.btn-secondary { background: #1a1a2e; color: #fff; }
.btn-outline { background: transparent; color: #1a1a2e; border: 1px solid #1a1a2e; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* FORMS */
.form-pedido { background: #fff; border-radius: 8px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: #555; }
.form-group input, .form-group select {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: #e94560;
}
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

.form-inline { display: flex; gap: 8px; margin-bottom: 16px; }
.form-inline input { flex: 1; padding: 8px 10px; border: 1px solid #ddd; border-radius: 4px; }
.form-comprador { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }
.form-comprador input { padding: 8px 10px; border: 1px solid #ddd; border-radius: 4px; }

/* LOGIN */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1a1a2e;
}
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 320px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-box h1 { font-size: 24px; color: #e94560; margin-bottom: 4px; }
.login-sub { color: #888; font-size: 13px; margin-bottom: 20px; }
.login-box input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}
.login-box button {
  width: 100%;
  padding: 10px;
}

.erro { color: #dc2626; margin-bottom: 10px; font-size: 13px; }
.sucesso { color: #16a34a; margin-bottom: 10px; font-size: 13px; }
.alerta-entrega {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-weight: 700;
  color: #92400e;
  font-size: 14px;
}
.acoes { white-space: nowrap; }

/* ======= MOBILE RESPONSIVE ======= */

/* Rastreio copy */
.rastreio-copy-span {
  cursor: pointer;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.rastreio-copy-span:hover { background: #f0f4ff; }
.rastreio-copy-span.rastreio-copiado { color: #3b82f6; font-weight: 700; }

/* Pagination */
.row-hidden { display: none !important; }
.load-more-wrap { text-align: center; padding: 16px 0; margin-top: 4px; }
.load-more-count { font-size: 12px; color: #888; margin-top: 4px; }

/* Hamburger toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 4px;
}
.nav-toggle:hover { background: rgba(255,255,255,0.1); }
.nav-toggle svg { display: block; }

@media (max-width: 768px) {
  /* Nav */
  nav {
    position: relative;
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 0 14px;
  }
  .logo { flex: 1; line-height: 52px; }
  .nav-toggle { display: flex; align-items: center; height: 52px; }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    background: #1a1a2e;
    border-top: 1px solid rgba(255,255,255,0.1);
    order: 3;
    padding: 4px 0 8px;
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    margin: 0;
    padding: 12px 16px;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .nav-links a:last-child { border-bottom: none; }

  /* Main */
  main { margin: 10px auto; padding: 0 10px; }

  /* Page header */
  .page-header { flex-wrap: wrap; gap: 8px; align-items: flex-start; }
  .page-header h2 { font-size: 17px; }
  .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  /* anula o display:inline inline do form e faz ele participar do flex */
  .header-actions form {
    display: flex !important;
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
  }
  .header-actions form button {
    flex: 1;
    min-height: 44px;
    font-size: 13px;
  }
  .header-actions > .btn,
  .header-actions > button {
    flex: 1 1 calc(50% - 3px);
    min-height: 44px;
    font-size: 13px;
    text-align: center;
    justify-content: center;
    display: flex;
    align-items: center;
  }
  .header-actions .btn-primary {
    flex-basis: 100%;
    order: 99;
  }

  /* Resumo cards */
  .resumo {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
  }
  .card-resumo {
    min-width: 148px;
    flex-shrink: 0;
    scroll-snap-align: start;
    padding: 10px 14px;
  }
  .card-resumo .valor { font-size: 15px; }

  /* Filtros */
  .filtros { flex-wrap: wrap; }
  .filtros select, .filtros input {
    flex: 1 1 auto;
    min-height: 44px;
    font-size: 16px;
  }
  .filtros .btn { min-height: 44px; }

  /* Hide columns on mobile */
  .col-hide-mobile { display: none !important; }

  /* Table */
  td, th { padding: 8px 7px; }
  .status-select { font-size: 10px; padding: 3px 5px; }
  .rastreio-cell { min-width: 80px; }
  .rastreio-copy-span { padding: 5px 4px; }

  /* Touch targets */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 36px; padding: 6px 10px; }

  /* Form */
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-group input, .form-group select { min-height: 44px; font-size: 16px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1; text-align: center; justify-content: center; }

  /* Compradores form */
  .form-comprador { flex-wrap: wrap; }
  .form-comprador input { flex: 1 1 140px; min-height: 44px; font-size: 16px; }

  /* Modais */
  .modal-box { min-width: unset; width: 92vw; max-width: 480px; padding: 18px; }
}

@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
  main { padding: 0 8px; }
  td, th { padding: 7px 5px; }
  .login-box {
    width: calc(100% - 32px);
    padding: 28px 20px;
  }
}
