* {
  box-sizing: border-box;
}

:root {
  --bg: #0b1220;
  --panel: #111a2b;
  --panel-2: #162238;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e7edf7;
  --muted: #9fb0c8;
  --accent: #3ea6ff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #0b1220 0%, #0f1729 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.app {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.1;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.filters,
.mini-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filters {
  background: rgba(17, 26, 43, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.filters-secondary {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.filter-heading {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 220px;
}

.filter-heading-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-heading-text {
  font-size: 14px;
  color: var(--text);
}

.vendedor-trigger {
  min-width: 320px;
}

select,
button {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #172235;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

select {
  min-width: 150px;
}

button {
  cursor: pointer;
  transition: 0.2s ease;
  font-weight: 600;
}

button:hover {
  transform: translateY(-1px);
}

button.secondary,
.mini-action {
  background: #132034;
}

.multi-filter {
  position: relative;
}

.multi-filter-trigger {
  min-width: 220px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.multi-filter-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.multi-filter-value {
  font-size: 14px;
  color: var(--text);
}

.multi-filter-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 250px;
  max-height: 320px;
  overflow: auto;
  background: #101a2c;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.multi-filter-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.mini-action {
  padding: 7px 10px;
  font-size: 12px;
}

.multi-filter-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.multi-option {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.multi-option input {
  accent-color: var(--accent);
}

.cards {
  display: grid;
  gap: 14px;
}

.cards-block {
  margin-bottom: 18px;
}

.cards-main {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.cards-main .card {
  min-height: 112px;
}

.cards-special {
  grid-template-columns: minmax(260px, 320px);
  justify-content: start;
}

.cards-audit {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 16px 0 20px;
}

.card {
  background: rgba(17, 26, 43, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.card span {
  color: var(--muted);
  font-size: 13px;
}

.card strong {
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.card-qty {
  color: var(--muted);
  font-size: 12px;
}

.clickable-card {
  cursor: pointer;
  transition: 0.18s ease;
}

.clickable-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.16);
}

.clickable-card.active {
  outline: 2px solid rgba(62, 166, 255, 0.45);
  border-color: rgba(62, 166, 255, 0.55);
}

.card-gold {
  background: linear-gradient(180deg, rgba(62, 44, 0, 0.45) 0%, rgba(17, 26, 43, 0.96) 100%);
}

.card-blue {
  background: linear-gradient(180deg, rgba(7, 51, 87, 0.45) 0%, rgba(17, 26, 43, 0.96) 100%);
}

.card-purple {
  background: linear-gradient(180deg, rgba(57, 23, 95, 0.45) 0%, rgba(17, 26, 43, 0.96) 100%);
}

.card-green {
  background: linear-gradient(180deg, rgba(15, 79, 42, 0.45) 0%, rgba(17, 26, 43, 0.96) 100%);
}

.card-red {
  background: linear-gradient(180deg, rgba(104, 22, 22, 0.45) 0%, rgba(17, 26, 43, 0.96) 100%);
}

.small-card strong {
  font-size: 22px;
}

.card-special {
  min-height: 108px;
}

.panel {
  background: rgba(17, 26, 43, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-inner {
  margin-top: 12px;
  margin-bottom: 18px;
}

.chart-panel {
  margin-bottom: 18px;
}

.detail-header,
.meta-header,
.export-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.detail-header h2,
.meta-header h2,
.export-header h2 {
  margin: 0;
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
}

.sellers-panel {
  margin-bottom: 18px;
}

.seller-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.seller-list-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.seller-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(7, 12, 22, 0.45);
}

.seller-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.seller-rank {
  color: var(--muted);
  font-size: 12px;
}

.seller-name {
  font-weight: 700;
  font-size: 14px;
}

.seller-value {
  font-weight: 700;
  font-size: 14px;
}

.seller-meta {
  color: var(--muted);
  font-size: 12px;
}

.seller-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 2px;
}

.seller-row-clickable {
  cursor: pointer;
}

.seller-row-clickable:hover td {
  background: rgba(255, 255, 255, 0.05);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 360px;
}

.chart-wrap.large {
  height: 420px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
  align-items: start;
}

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 12, 22, 0.45);
}

.detail-scroll {
  max-height: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

thead th {
  position: sticky;
  top: 0;
  background: #111a2b;
  z-index: 1;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

tfoot td {
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.status-ok {
  color: #4ade80;
  font-weight: 700;
}

.status-bad {
  color: #f87171;
  font-weight: 700;
}

.status-neutral {
  color: #fbbf24;
  font-weight: 700;
}

.percent-good {
  color: #4ade80;
  font-weight: 700;
}

.percent-mid {
  color: #fbbf24;
  font-weight: 700;
}

.percent-bad {
  color: #f87171;
  font-weight: 700;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 18, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(3px);
}

.loading-box {
  background: #101a2c;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.chart-stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.chart-panel .mini-filters {
  align-items: center;
}

.chart-panel-legacy {
  padding: 22px 26px;
}

.chart-legacy-header {
  align-items: center;
  margin-bottom: 18px;
}

.chart-legacy-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.chart-wrap-legacy {
  height: 620px;
}

.meta-grid > .panel {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.meta-grid > .panel .table-wrap {
  flex: 1;
}

.meta-grid > .panel .detail-header,
.meta-grid > .panel .meta-header {
  min-height: 54px;
  align-items: center;
}

.meta-grid table {
  min-width: 100%;
}

.panel-meta-equal .meta-placeholder {
  min-width: 244px;
  min-height: 44px;
}

@media (max-width: 1400px) {
  .seller-list-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .cards-main,
  .cards-audit {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .seller-list-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 1600px);
  }

  .cards-main,
  .cards-audit {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cards-special {
    grid-template-columns: 1fr;
  }

  .filters,
  .mini-filters,
  .detail-header,
  .meta-header,
  .export-header,
  .filters-secondary {
    align-items: stretch;
  }

  .multi-filter-trigger,
  .vendedor-trigger,
  select,
  button {
    width: 100%;
    min-width: 100%;
  }

  .chart-wrap,
  .chart-wrap.large {
    height: 320px;
  }

  .chart-wrap-legacy {
    height: 380px;
  }

  .panel-meta-equal .meta-placeholder {
    display: none;
  }
}


/* Ajustes opção 1 refinada */
.filters-primary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filters-primary .multi-filter {
  flex: 0 0 auto;
}

.filters-primary #vendedorMultiFilter .multi-filter-trigger {
  min-width: 280px;
}

.sellers-panel.compact-panel {
  padding-top: 16px;
}

.sellers-compact-scroll {
  max-height: 470px;
}

.sellers-table {
  min-width: 100%;
}

.sellers-table thead th {
  position: sticky;
  top: 0;
  background: #111a2b;
  z-index: 1;
}

.sellers-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.seller-empty {
  margin-bottom: 10px;
}

@media (max-width: 1200px) {
  .filters-primary #vendedorMultiFilter .multi-filter-trigger {
    min-width: 220px;
  }
}

@media (max-width: 760px) {
  .filters-primary {
    align-items: stretch;
  }

  .filters-primary .multi-filter,
  .filters-primary .multi-filter-trigger,
  .filters-primary button {
    width: 100%;
  }
}


.app-footer {
  margin-top: 22px;
  padding: 16px 6px 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  opacity: 0.9;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-footer strong {
  color: #dfe8f5;
  font-style: normal;
  font-weight: 600;
}




.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 18, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.login-card {
  width: min(100%, 420px);
  background: rgba(17, 26, 43, 0.98);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-message {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.login-message.error {
  color: #fca5a5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #172235;
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

.login-field input:focus {
  border-color: rgba(62, 166, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(62, 166, 255, 0.14);
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.login-actions button {
  min-width: 130px;
}

@media (max-width: 760px) {
  .login-card {
    padding: 20px;
    border-radius: 18px;
  }

  .login-actions button {
    width: 100%;
  }
}


.login-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

.login-remember input {
  accent-color: var(--accent);
}


.date-range-filter {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #172235;
  padding: 9px 12px;
  min-width: 330px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.date-range-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.date-range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.date-range-inputs label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}

.date-range-inputs input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #101a2c;
  color: var(--text);
  padding: 8px 9px;
  font-size: 13px;
  outline: none;
}

.date-range-filter small {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 760px) {
  .date-range-filter {
    min-width: 100%;
  }
}

/* Ajuste v5 - card único de período */
.period-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(23, 34, 53, 0.95);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 560px;
  flex: 1 1 560px;
}

.period-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.period-card-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.period-card-header small {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.period-card-controls {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(145px, 0.8fr) minmax(260px, 1.3fr);
  gap: 8px;
  align-items: stretch;
}

.period-card .multi-filter,
.period-card .date-range-filter {
  min-width: 0;
  width: 100%;
}

.period-card .multi-filter-trigger.compact-trigger {
  min-width: 0;
  width: 100%;
  height: 100%;
}

.period-card .date-range-filter {
  padding: 8px 10px;
  background: #101a2c;
}

.period-card .date-range-inputs input {
  padding: 7px 8px;
}

.period-card .multi-filter-dropdown {
  min-width: 230px;
}

@media (max-width: 1180px) {
  .period-card {
    min-width: 100%;
    flex-basis: 100%;
  }
}

@media (max-width: 760px) {
  .period-card,
  .period-card-controls,
  .period-card .multi-filter,
  .period-card .multi-filter-trigger,
  .period-card .date-range-filter {
    width: 100%;
    min-width: 100%;
  }

  .period-card-controls {
    grid-template-columns: 1fr;
  }

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

  .period-card-header small {
    text-align: left;
  }
}


/* v5 - filtro compacto de período no cabeçalho */
.periodo-filter {
  position: relative;
}

.periodo-trigger {
  min-width: 245px;
  max-width: 280px;
}

.periodo-dropdown {
  width: min(720px, calc(100vw - 48px));
  max-height: 78vh;
  overflow: auto;
  padding: 14px;
}

.periodo-dropdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 12px;
  align-items: start;
}

.periodo-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(7, 12, 22, 0.32);
  padding: 12px;
  min-width: 0;
}

.periodo-section-full {
  grid-column: 1 / -1;
}

.periodo-section-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  margin-bottom: 10px;
}

.periodo-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.periodo-quick-grid .mini-action {
  width: 100%;
  text-align: center;
}

.periodo-options {
  max-height: 210px;
  overflow: auto;
  padding-right: 4px;
}

.periodo-custom-section .date-range-inputs {
  grid-template-columns: 1fr;
}

.periodo-custom-section small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.periodo-dropdown-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .periodo-dropdown-grid {
    grid-template-columns: 1fr;
  }

  .periodo-quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .periodo-trigger {
    min-width: 220px;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .periodo-trigger,
  .periodo-filter {
    width: 100%;
    min-width: 100%;
  }

  .periodo-dropdown {
    width: calc(100vw - 32px);
  }
}
