﻿:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --line: #d8e0ea;
  --line-strong: #c7d3e2;
  --text: #10263f;
  --text-soft: #5c6f85;
  --brand: #0f766e;
  --brand-hover: #0c5f59;
  --accent: #1f5bd8;
  --accent-hover: #184ab3;
  --danger: #c0394f;
  --warning: #a46b12;
  --success: #1b8a5a;
  --radius: 12px;
  --shadow-sm: 0 4px 14px rgba(18, 38, 63, 0.06);
  --shadow-md: 0 10px 28px rgba(18, 38, 63, 0.1);
}

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  min-height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', 'Manrope', 'Segoe UI', sans-serif !important;
  background: var(--bg) !important;
  color: var(--text) !important;
}

.header {
  position: relative !important;
  top: auto !important;
  z-index: 50;
  background: linear-gradient(120deg, #143554 0%, #184569 58%, #235bb8 100%) !important;
  padding: 10px 22px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 16px rgba(12, 28, 50, 0.16) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

.header-left {
  position: static !important;
  left: auto !important;
  transform: none !important;
  min-width: auto !important;
  justify-content: flex-start !important;
  gap: 12px !important;
}

.brand-logo {
  width: auto !important;
  height: 58px !important;
  max-width: min(42vw, 190px) !important;
  object-fit: contain;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  filter: brightness(1.15) contrast(1.08) drop-shadow(0 2px 8px rgba(255, 255, 255, 0.18));
}

.login-logo {
  width: 62px !important;
  height: 62px !important;
  border-radius: 10px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.login-logo {
  width: 82px !important;
  height: 82px !important;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.header-title h1 {
  margin: 0 !important;
  font-size: clamp(1.12rem, 2.2vw, 1.5rem) !important;
  font-weight: 800 !important;
  color: #fff !important;
}

.header-title p {
  margin: 4px 0 0 !important;
  color: rgba(236, 244, 255, 0.92) !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
}

.user-info,
.logout-btn,
.btn-logout {
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.26) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  color: #eef5ff !important;
  font-weight: 700 !important;
}

.logout-btn:hover,
.btn-logout:hover {
  background: rgba(255, 255, 255, 0.18) !important;
}

.nav {
  position: relative !important;
  top: auto !important;
  z-index: 45;
  background: #fff !important;
  border-bottom: 1px solid var(--line);
  padding: 0 16px !important;
  box-shadow: 0 2px 8px rgba(17, 36, 60, 0.05);
}

.nav ul {
  display: flex !important;
  list-style: none !important;
  margin: 0 !important;
  gap: 8px !important;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 6px 0;
  scrollbar-width: thin;
}

.nav a {
  display: block !important;
  text-decoration: none !important;
  border-radius: 9px;
  border-bottom: none !important;
  border: 1px solid transparent;
  padding: 9px 13px !important;
  margin: 2px 0;
  color: var(--text-soft) !important;
  font-weight: 700 !important;
}

.nav a:hover,
.nav a.active {
  color: var(--brand) !important;
  background: #edf4ff;
  border-color: #d3e1f5;
}

.container {
  max-width: 1560px !important;
  padding: 20px !important;
}

/* Dashboard */
.dashboard-page .header-icon,
.dashboard-page .section-icon,
.dashboard-page .inline-icon,
.dashboard-page .kpi-icon,
.dashboard-page .summary-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.dashboard-page .header-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.dashboard-page .dashboard-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-page .summary-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f7faff);
  box-shadow: var(--shadow-sm);
}

.dashboard-page .summary-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #1f5bd8;
  background: #eaf1ff;
}

.dashboard-page .summary-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.dashboard-page .summary-label {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 700;
}

.dashboard-page .summary-value {
  font-size: 28px;
  color: #123254;
  font-weight: 800;
  line-height: 1.1;
}

.dashboard-page #stats-grid.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

.dashboard-page #stats-grid .stat-card {
  min-height: 156px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dashboard-page #stats-grid .kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eef4ff;
  color: #235bb8;
  margin-bottom: 10px;
}

.dashboard-page #stats-grid .kpi-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.dashboard-page #stats-grid .stat-card .label {
  font-size: 14px;
  font-weight: 700;
  color: #355272;
  margin-bottom: 8px;
}

.dashboard-page #stats-grid .stat-card .value {
  font-size: 48px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dashboard-page .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-page .section-icon {
  width: 22px;
  height: 22px;
  color: #1f5bd8;
}

.dashboard-page .section-icon svg,
.dashboard-page .inline-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.dashboard-page .inline-icon {
  margin-right: 6px;
  vertical-align: -2px;
  color: #1f5bd8;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px !important;
}

.page-header h2 {
  margin: 0 !important;
  font-size: clamp(1.32rem, 2vw, 1.75rem) !important;
  color: #122f50 !important;
  font-weight: 800 !important;
}

.page-header h2::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 28px;
  border-radius: 99px;
  margin-right: 10px;
  vertical-align: middle;
  background: linear-gradient(180deg, var(--brand), var(--accent));
}

.filters,
.table-container,
.section,
.config-section,
.logs-container,
.upload-card,
.stat-card,
.resumo-card,
.info-box,
.login-container,
.card {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
}

.section,
.config-section,
.logs-container,
.upload-card,
.resumo-card,
.info-box,
.card {
  padding: 16px !important;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px !important;
  padding: 14px !important;
}

.filters > div,
.filters .filtro-item {
  min-width: 165px;
  flex: 1 1 165px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filters label,
.form-group label,
label {
  color: #304a66 !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
}

input,
select,
textarea,
.filters input,
.filters select,
.form-group input,
.form-group select,
.form-group textarea,
.upload-form select,
.upload-form input[type='file'] {
  min-height: 40px;
  border: 1px solid var(--line-strong) !important;
  border-radius: 10px !important;
  background: var(--surface-muted) !important;
  color: var(--text) !important;
}

textarea {
  min-height: 90px;
}

input:focus,
select:focus,
textarea:focus,
.filters input:focus,
.filters select:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.upload-form select:focus,
.upload-form input[type='file']:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(31, 91, 216, 0.14) !important;
  background: #fff !important;
}

.btn,
.btn-novo,
.btn-exportar,
.btn-imprimir,
.btn-upload,
.btn-refresh,
.btn-save,
.btn-login,
.btn-cancelar,
.btn-salvar,
.btn-action,
.btn-primary,
.btn-secondary,
.btn-excluir,
.campo-editavel,
.obs-editar {
  border-radius: 10px !important;
  border: 1px solid transparent !important;
  font-weight: 700 !important;
  letter-spacing: 0.1px;
  transition: all 0.16s ease;
}

.btn,
.btn-novo,
.btn-imprimir,
.btn-upload,
.btn-refresh,
.btn-save,
.btn-login,
.btn-salvar,
.btn-action,
.btn-primary,
.campo-editavel,
.obs-editar {
  background: var(--brand) !important;
  color: #fff !important;
}

.btn:hover,
.btn-novo:hover,
.btn-imprimir:hover,
.btn-upload:hover,
.btn-refresh:hover,
.btn-save:hover,
.btn-login:hover,
.btn-salvar:hover,
.btn-action:hover,
.btn-primary:hover,
.campo-editavel:hover,
.obs-editar:hover {
  background: var(--brand-hover) !important;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-exportar,
.btn-secondary {
  background: var(--accent) !important;
  color: #fff !important;
}

.btn-exportar:hover,
.btn-secondary:hover {
  background: var(--accent-hover) !important;
}

.btn-cancelar {
  background: #6a7888 !important;
  color: #fff !important;
}

.btn-excluir,
.danger {
  background: var(--danger) !important;
  color: #fff !important;
}

.table-top-scroll {
  display: none;
  height: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f2f5fa;
}

.table-top-scroll__inner {
  height: 1px;
}

.table-container {
  position: relative;
  overflow: auto;
  max-height: calc(100dvh - 300px);
  overscroll-behavior: contain;
}

.table-container table {
  min-width: max-content;
}

/* Sem rolagem horizontal nas grades principais */
#tabelaClientes,
#tabelaBoletos,
#tabelaEnvios {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}

#tabelaClientes th,
#tabelaClientes td,
#tabelaBoletos th,
#tabelaBoletos td,
#tabelaEnvios th,
#tabelaEnvios td {
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Nessas grades, o header nao deve ficar sticky */
#tabelaClientes thead th,
#tabelaBoletos thead th,
#tabelaEnvios thead th {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

table {
  border-collapse: separate !important;
  border-spacing: 0;
}

.table-container thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

th {
  background: #eef3fa !important;
  color: #2e4865 !important;
  font-weight: 800 !important;
  border-bottom: 1px solid var(--line) !important;
}

td {
  color: #17324f;
  border-bottom: 1px solid #e8eef6 !important;
}

.table {
  width: 100%;
  border-collapse: collapse !important;
  table-layout: fixed;
}

.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
}

tbody tr:nth-child(odd) {
  background: #fbfcfe;
}

tbody tr:hover {
  background: #f3f8ff !important;
}

.badge,
.pill,
[class*='badge-'] {
  border-radius: 999px !important;
  font-weight: 700 !important;
}

.stat-card {
  border: 1px solid #dbe5f1 !important;
  background: #fff !important;
}

.stat-card .value {
  font-weight: 800 !important;
}

.stat-card.primary .value {
  color: var(--brand) !important;
}

.stat-card.success .value {
  color: var(--success) !important;
}

.stat-card.warning .value {
  color: var(--warning) !important;
}

.stat-card.danger .value {
  color: var(--danger) !important;
}

.obs-wrapper {
  gap: 8px !important;
}

.obs-texto {
  white-space: pre-line;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: 180px;
  overflow: auto;
}

.info-box {
  border-left: 4px solid var(--accent) !important;
}

.modal {
  backdrop-filter: blur(2px);
}

.modal-content {
  border: 1px solid var(--line) !important;
  border-radius: 16px !important;
  box-shadow: var(--shadow-md) !important;
}

.alert {
  border: 1px solid #efccd4 !important;
  background: #fff4f7 !important;
  color: #8d2037 !important;
  border-radius: 10px !important;
}

.alert::before {
  content: 'Atenção';
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  color: var(--danger);
}

.footer,
.logo p,
.card p,
.page-header p {
  color: var(--text-soft) !important;
}

.logo h1,
.card h1,
.login-container h1 {
  color: #122f50 !important;
  font-weight: 800 !important;
}

.ui-fade {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ui-fade.ui-ready {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1024px) {
  .header {
    padding: 12px 14px !important;
  }

  .brand-logo {
    height: 52px !important;
    max-width: min(58vw, 170px) !important;
  }

  .nav {
    top: auto;
    padding: 0 8px !important;
  }

  .container {
    padding: 12px !important;
  }

  .table-container {
    max-height: none;
  }

  .dashboard-page .dashboard-summary {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-page #stats-grid.stats-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 900px) {
  .header-right .user-info {
    display: none !important;
  }

  .header {
    justify-content: space-between !important;
  }

  .header-left {
    left: auto !important;
    transform: none !important;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-page .dashboard-summary,
  .dashboard-page #stats-grid.stats-grid {
    grid-template-columns: 1fr;
  }

  .filters button,
  .filters .btn-imprimir {
    width: 100%;
    align-self: stretch;
  }
}

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