/* ==========================================================================
   RELATORIOS
   ========================================================================== */

.reports-page-shell {
  width: min(100% - 2rem, 1460px);
}

.reports-page-shell .app-breadcrumb {
  margin-bottom: 1rem;
}

.reports-page-shell .list-stage {
  width: 100%;
  padding-inline: 0;
}

.reports-titlebar .page-titlebar-side {
  min-width: 330px;
}

.reports-shell {
  display: grid;
  gap: 1.25rem;
  padding-bottom: 1rem;
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1.25rem;
}

.reports-panel {
  grid-column: span 12;
}

.reports-panel-half {
  grid-column: span 6;
}

.reports-panel-third {
  grid-column: span 4;
}

.reports-period-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  background: #f0f6ff;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 14px;
}

.reports-period-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #0f3a7a;
}

.reports-period-info > i {
  font-size: 1.2rem;
}

.reports-period-kicker {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b6a99;
}

.reports-period-current {
  font-size: 1.02rem;
  color: #0f3a7a;
}

.reports-period-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
}

.reports-period-field {
  display: grid;
  gap: 0.2rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #4b6a99;
}

/* Selects usam o padrão do sistema (.form-select do Bootstrap, com caret
   SVG e bordas consistentes). Aqui só ajustamos a largura mínima. */
.reports-period-field .form-select {
  min-width: 132px;
}

.reports-period-field .form-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.reports-period-apply {
  padding: 0.5rem 0.9rem;
  border: none;
  border-radius: 9px;
  background: #1d4ed8;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 640px) {
  .reports-period-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .reports-period-form {
    justify-content: space-between;
  }
  .reports-period-field .form-select {
    min-width: 0;
    width: 100%;
  }
}

.reports-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.reports-kpi {
  display: grid;
  align-content: start;
  min-height: 142px;
  padding: 1.15rem;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.reports-kpi span {
  display: block;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1.15;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.reports-kpi strong {
  display: block;
  margin-top: 0.45rem;
  color: #0f172a;
  font-size: clamp(1.7rem, 2vw, 2.2rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.reports-kpi small {
  display: block;
  margin-top: 0.7rem;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
}

.reports-bar-chart {
  display: grid;
  gap: 0.95rem;
}

.reports-bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
}

.reports-bar-label,
.reports-bar-value {
  color: #0f172a;
  font-weight: 800;
  line-height: 1.2;
}

.reports-bar-label {
  overflow-wrap: anywhere;
}

.reports-bar-value {
  text-align: right;
  white-space: nowrap;
}

.reports-bar-track {
  overflow: hidden;
  height: 14px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
}

.reports-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #22c55e);
}

.reports-bar-fill-revenue {
  background: linear-gradient(90deg, #0f766e, #22c55e);
}

.reports-bar-value-sm {
  font-size: 0.72rem;
}

.reports-rank-cell {
  font-size: 0.72rem;
  color: var(--vm-color-text-subtle, #6c757d);
  font-weight: 700;
  width: 28px;
}

.reports-revenue-value {
  font-weight: 700;
}

.reports-revenue-table a {
  color: inherit;
  text-decoration: none;
}

.reports-revenue-table a:hover {
  text-decoration: underline;
}

.reports-bar-fill-alert {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.stock-badge-good {
  background: #dcfce7;
  color: #166534;
}

.stock-badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.stock-badge-critical {
  background: #fee2e2;
  color: #991b1b;
}

.reports-list {
  display: grid;
  gap: 0.85rem;
}

.reports-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background:
    radial-gradient(
      circle at 10% 8%,
      rgba(37, 99, 235, 0.035),
      transparent 34%
    ),
    rgba(248, 250, 252, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.reports-list-item strong,
.reports-list-item span,
.reports-list-item small {
  display: block;
}

.reports-list-item strong {
  color: #0f172a;
  font-size: 0.96rem;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.reports-list-item small {
  margin-top: 0.2rem;
  color: #64748b;
  font-size: 0.88rem;
  line-height: 1.35;
}

.reports-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  max-width: 100%;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.reports-empty {
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.88);
  color: #64748b;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

@media (max-width: 1199.98px) {
  .reports-titlebar .page-titlebar-side {
    min-width: 280px;
  }

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

  .reports-panel-half,
  .reports-panel-third {
    grid-column: span 6;
  }
}

@media (max-width: 991.98px) {
  .reports-titlebar .page-titlebar-side {
    min-width: 0;
  }

  .reports-panel-half,
  .reports-panel-third {
    grid-column: span 12;
  }
}

@media (max-width: 767.98px) {
  .reports-page-shell {
    width: min(100% - 0.78rem, 560px);
  }

  .reports-page-shell .list-stage {
    padding-inline: 0 !important;
  }

  .reports-titlebar {
    padding: 0.88rem;
    border-radius: 20px;
  }

  .reports-titlebar .page-titlebar-content {
    gap: 0.42rem;
  }

  .reports-titlebar .page-titlebar-content h1 {
    font-size: 1.62rem;
    line-height: 1.08;
    letter-spacing: -0.035em;
  }

  .reports-titlebar .page-titlebar-content p {
    margin-top: 0.2rem;
    font-size: 1.02rem;
    line-height: 1.34;
  }

  .reports-titlebar .list-kicker {
    min-height: 26px;
    padding: 0.34rem 0.58rem;
    font-size: 0.7rem;
  }

  .reports-titlebar .page-titlebar-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.72rem;
  }

  .reports-titlebar .list-stat {
    min-height: 70px;
    padding: 0.62rem 0.68rem;
    border-radius: 15px;
  }

  .reports-titlebar .list-stat strong {
    font-size: 0.64rem;
    line-height: 1.1;
  }

  .reports-titlebar .list-stat span {
    font-size: 0.9rem;
    line-height: 1.15;
  }

  .reports-shell {
    gap: 0.86rem;
    padding-bottom: 6.75rem;
  }

  .reports-grid {
    gap: 0.86rem;
  }

  .reports-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.68rem;
  }

  .reports-kpi {
    min-height: 126px;
    padding: 0.88rem;
    border-radius: 18px;
  }

  .reports-kpi span {
    font-size: 0.72rem;
    line-height: 1.12;
  }

  .reports-kpi strong {
    margin-top: 0.38rem;
    font-size: 1.55rem;
    line-height: 1.04;
  }

  .reports-kpi small {
    margin-top: 0.54rem;
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .reports-kpi-financial strong {
    font-size: 1.36rem;
  }

  .reports-panel {
    padding: 1rem !important;
    border-radius: 22px;
  }

  .reports-panel .dashboard-panel-header {
    gap: 0.58rem;
    margin-bottom: 0.95rem;
  }

  .reports-panel .dashboard-panel-header h2 {
    font-size: 1.2rem;
    line-height: 1.12;
    letter-spacing: -0.03em;
  }

  .reports-panel .dashboard-panel-header p {
    margin-top: 0.3rem;
    font-size: 1.02rem;
    line-height: 1.36;
  }

  .reports-panel .dashboard-section-tag {
    min-height: 24px;
    padding: 0.28rem 0.58rem;
    font-size: 0.7rem;
  }

  .reports-bar-chart {
    gap: 0.74rem;
  }

  .reports-bar-row {
    grid-template-columns: 1fr;
    gap: 0.34rem;
  }

  .reports-bar-label {
    font-size: 0.88rem;
    line-height: 1.2;
  }

  .reports-bar-track {
    height: 13px;
  }

  .reports-bar-value {
    font-size: 0.9rem;
    text-align: left;
  }

  .reports-list {
    gap: 0.72rem;
  }

  .reports-list-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.9rem;
    border-radius: 16px;
  }

  .reports-list-item strong {
    font-size: 0.9rem;
    line-height: 1.22;
  }

  .reports-list-item small {
    font-size: 0.82rem;
    line-height: 1.34;
  }

  .reports-badge {
    min-width: 0;
    padding: 0.38rem 0.68rem;
    font-size: 0.86rem;
    white-space: normal;
  }

  .reports-empty {
    padding: 0.88rem;
    border-radius: 16px;
    font-size: 0.84rem;
  }
}

@media (max-width: 479.98px) {
  .reports-titlebar {
    padding: 0.82rem;
  }

  .reports-titlebar .page-titlebar-content h1 {
    font-size: 1.54rem;
  }

  .reports-titlebar .page-titlebar-content p {
    font-size: 1.02rem;
  }

  .reports-titlebar .page-titlebar-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reports-titlebar .list-stat {
    min-height: 66px;
    padding: 0.56rem 0.58rem;
  }

  .reports-titlebar .list-stat span {
    font-size: 0.84rem;
  }

  .reports-shell {
    gap: 0.78rem;
  }

  .reports-grid {
    gap: 0.78rem;
  }

  .reports-kpi-grid {
    gap: 0.6rem;
  }

  .reports-kpi {
    min-height: 118px;
    padding: 0.78rem;
    border-radius: 17px;
  }

  .reports-kpi span {
    font-size: 0.68rem;
  }

  .reports-kpi strong {
    font-size: 1.42rem;
  }

  .reports-kpi small {
    font-size: 0.74rem;
  }

  .reports-kpi-financial strong {
    font-size: 1.22rem;
  }

  .reports-panel {
    padding: 0.9rem !important;
    border-radius: 20px;
  }

  .reports-panel .dashboard-panel-header h2 {
    font-size: 1.12rem;
  }

  .reports-panel .dashboard-panel-header p {
    font-size: 1.02rem;
  }

  .reports-bar-chart {
    gap: 0.68rem;
  }

  .reports-bar-label {
    font-size: 0.84rem;
  }

  .reports-bar-track {
    height: 12px;
  }

  .reports-bar-value {
    font-size: 0.84rem;
  }

  .reports-list-item {
    padding: 0.82rem;
  }

  .reports-list-item strong {
    font-size: 0.86rem;
  }

  .reports-list-item small {
    font-size: 0.78rem;
  }

  .reports-badge {
    font-size: 0.82rem;
  }
}

/* ==========================================================================
   MOBILE TYPE NORMALIZATION
   ========================================================================== */

@media (max-width: 767.98px) {
  .reports-page-shell :is(p, li, td, .form-control, .form-select),
  .reports-shell :is(p, li, td, .form-control, .form-select),
  .reports-shell :is(.reports-kpi, .reports-panel, .reports-list-item) :is(p, span, small) {
    font-size: var(--vm-mobile-system-text) !important;
    line-height: var(--vm-mobile-system-line) !important;
  }

  .reports-page-shell :is(label, small, .report-chip, .report-pill, .table-badge),
  .reports-shell :is(label, small, .report-chip, .report-pill, .table-badge, .reports-badge) {
    font-size: var(--vm-mobile-system-small) !important;
    line-height: var(--vm-mobile-system-line-compact) !important;
  }

  .reports-page-shell :is(.report-kicker, .list-kicker, td::before),
  .reports-shell :is(.report-kicker, .list-kicker, td::before) {
    font-size: var(--vm-mobile-system-micro) !important;
    line-height: var(--vm-mobile-system-line-compact) !important;
  }
}

/* ==========================================================================
   TOP POR RECEITA — cards no mobile
   ========================================================================== */

@media (max-width: 767.98px) {
  /* Rótulo dimensiona ao conteúdo para "ESTABELECIMENTO" não quebrar linha */
  body.list-page-body .modern-table.reports-revenue-table tbody td {
    grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  }

  body.list-page-body .modern-table.reports-revenue-table tbody td::before {
    white-space: nowrap;
  }

  /* Posição (#1, #2...) junta e alinhada à direita, sem rótulo "#" separado */
  body.list-page-body .modern-table.reports-revenue-table tbody td.reports-rank-cell {
    display: block;
    width: auto;
    text-align: right;
    font-weight: 900;
    color: #0f172a;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody td.reports-rank-cell::before {
    content: '#';
    margin: 0;
    color: inherit;
    font-size: inherit !important;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
  }
}

@media (max-width: 767.98px) {
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.68rem;
    row-gap: 0.18rem;
    align-items: center;
    min-height: 74px;
    padding: 0.78rem 3rem 0.78rem 0.9rem !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td {
    display: none !important;
    border-bottom: 0 !important;
    padding: 0 !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td.reports-rank-cell,
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td:nth-child(2),
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td.reports-revenue-value {
    display: block !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td.reports-rank-cell {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    min-width: 2rem;
    text-align: left;
    font-size: 1rem;
    line-height: 1.2;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    text-align: left;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td:nth-child(2)::before,
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td.reports-revenue-value::before {
    content: none !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td:nth-child(2) a {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: #0f172a;
    font-size: 0.96rem;
    font-weight: 900;
    line-height: 1.18;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td.reports-revenue-value {
    grid-column: 2;
    grid-row: 2;
    color: #16a34a;
    font-size: 0.86rem;
    font-weight: 900;
    line-height: 1.2;
    text-align: left !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-table-card:not(.is-mobile-card-open) td.reports-revenue-value::after {
    content: " em receita";
    color: #64748b;
    font-weight: 800;
  }
}

/* ==========================================================================
   TOP POR RECEITA — card ABERTO no mobile
   ========================================================================== */

@media (max-width: 767.98px) {
  /* Card aberto com a MESMA anatomia do card fechado:
     selo de posição (#N) à esquerda, nome ao lado e os detalhes abaixo. */
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.72rem;
    align-items: start;
    padding: 0.82rem 0.95rem 0.9rem !important;
  }

  /* Selo de posição idêntico ao card fechado (#N sobre o chip "v"). */
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td.reports-rank-cell {
    grid-column: 1;
    grid-row: 1;
    display: block !important;
    width: auto;
    min-width: 2rem;
    min-height: 0 !important;
    padding: 0.06rem 0 0 !important;
    border-bottom: 0 !important;
    text-align: left !important;
    font-size: 1rem;
    line-height: 1.2;
  }

  /* Nome do estabelecimento como título, ao lado do selo, sem rótulo. */
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    display: block !important;
    min-height: 0 !important;
    padding: 0.16rem 0 0 !important;
    border-bottom: 0 !important;
    text-align: left !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td:nth-child(2)::before {
    content: none !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td:nth-child(2) a {
    display: block;
    color: #0f172a;
    font-size: 1.02rem;
    font-weight: 900;
    line-height: 1.22;
    text-decoration: none;
  }

  /* Linhas de detalhe ocupam a largura toda, logo abaixo do cabeçalho. */
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td[data-label="Bairro"],
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td[data-label="Score"],
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td.reports-revenue-value {
    grid-column: 1 / -1;
    min-height: 0 !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }

  /* Primeira linha de detalhe ganha respiro e divisória do cabeçalho. */
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td[data-label="Bairro"] {
    margin-top: 0.62rem;
    border-top: 1px solid rgba(226, 232, 240, 0.82);
    padding-top: 0.62rem !important;
  }

  /* Badge de score com o tamanho do conteúdo, encostado à direita. */
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td[data-label="Score"] .score-badge {
    display: inline-flex !important;
    justify-self: end;
    width: auto;
    min-width: 30px;
    padding: 3px 12px;
  }

  /* Receita total é a métrica principal: destaque em verde, sem divisória. */
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td.reports-revenue-value {
    border-bottom: 0 !important;
  }

  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td.reports-revenue-value,
  body.list-page-body .modern-table.reports-revenue-table tbody tr.is-mobile-card-open td.reports-revenue-value span {
    color: #16a34a;
    font-size: 1.04rem;
    font-weight: 900;
  }
}
