/**
 * Relatório Mensal (com_xd view=resumo)
 * Loaded from templates/ja_nexora/index.php (head-guaranteed, like profile.css).
 * Cards / tipografia → profile.css (.xd-resumo shared)
 * Tabelas / KPIs / expandíveis → port WP blocksy-child
 *
 * Table tokens follow T4 theme (:root / html[data-bs-theme]) — no fixed hex.
 */

.xd-resumo,
table.xd-table,
.tabela-xd-01 {
  --xd-blue: var(--color-primary);
  --xd-cyan: var(--color-secondary);
  /* Light tint of secondary on white — tracks brand + dark overrides below */
  --xd-table-head: color-mix(in srgb, var(--color-secondary) 28%, var(--color-white));
  --xd-table-border: color-mix(in srgb, var(--color-secondary) 28%, var(--color-white));
  --xd-table-soft: color-mix(in srgb, var(--color-secondary) 8%, var(--color-white));
  --xd-white: var(--color-white);
}

html[data-bs-theme="dark"] .xd-resumo,
html[data-bs-theme="dark"] table.xd-table,
html[data-bs-theme="dark"] .tabela-xd-01 {
  --xd-table-head: color-mix(in srgb, var(--color-primary) 32%, var(--color-surface, var(--color-bg-alt)));
  --xd-table-border: var(--color-border);
  --xd-table-soft: var(--color-surface-2, var(--color-bg-alt));
  --xd-white: var(--color-surface, var(--color-bg-alt));
}

/* .sec-raw herda section[class^=sec-]{padding-block:var(--sec-pad)} (~48–72).
   Com .nx-cat-header isso empilha no fundo do PageHeader — neutralizar e usar
   o mesmo ritmo de .nx-cat-body (48 / 72). */
body:has(.nx-cat-header) section.sec-raw.xd-resumo {
  padding-block: 0;
}

body:has(.nx-cat-header) section.sec-raw.xd-resumo > .container {
  padding-top: 48px;
  padding-bottom: 72px;
}

@media (max-width: 767.98px) {
  body:has(.nx-cat-header) section.sec-raw.xd-resumo > .container {
    padding-top: 0;
    padding-bottom: 32px;
  }
}

.xd-resumo .xd-resumo-block__body {
  padding: 16px 20px 20px;
}

.xd-resumo .xd-resumo-note {
  margin: 12px 0 0;
  font-size: 0.875rem;
  color: var(--color-text-dim, #6b7196);
}

/* —— Partner card —— */
.xd-resumo .xd-resumo-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 28px 32px;
  align-items: start;
}

.xd-resumo .xd-resumo-layout--no-aside {
  grid-template-columns: minmax(0, 1fr);
}

.xd-resumo .xd-resumo-aside {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.xd-resumo .xd-resumo-sidebar.profile-blocks--extra.card {
  margin-top: 0;
  margin-bottom: 0;
}

.xd-resumo .xd-resumo-sidebar__head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  border-bottom: 1px solid var(--color-border-soft);
}

.xd-resumo .xd-resumo-sidebar__head .profile-blocks-title {
  border-bottom: 0;
  padding-bottom: 8px;
}

.xd-resumo .xd-resumo-mes {
  padding: 0 20px 16px;
}

.xd-resumo .xd-resumo-mes .form-control {
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  border-color: var(--color-border, #e2e6f0);
}

.xd-resumo .xd-resumo-month-card .xd-resumo-sidebar__head {
  border-bottom: 0;
}

.xd-resumo .xd-resumo-sidebar__body {
  padding: 4px 0 12px;
}

.xd-resumo .xd-resumo-sidebar .info-rows--stacked {
  display: block;
  margin: 0;
  padding: 0 20px 8px;
}

.xd-resumo .xd-resumo-sidebar .info-rows--stacked .info-row {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border-soft, #eceef5);
}

.xd-resumo .xd-resumo-sidebar .info-rows--stacked .info-row:last-child {
  border-bottom: 0;
}

.xd-resumo .xd-resumo-sidebar .info-rows--stacked .info-row dt {
  display: block;
  margin: 0 0 4px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-dim, #6b7196);
}

.xd-resumo .xd-resumo-sidebar .info-rows--stacked .info-row dd {
  display: block;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-heading, #0b0d1a);
  word-break: break-word;
}

.xd-resumo .xd-resumo-sidebar .info-rows--stacked .info-row dd a {
  color: var(--xd-blue);
  text-decoration: none;
}

.xd-resumo .xd-resumo-sidebar .info-rows--stacked .info-row dd a:hover {
  text-decoration: underline;
}

.xd-resumo .xd-resumo-sidebar .profile-xd-section-title {
  margin: 12px 20px 0;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-soft, #eceef5);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--xd-blue);
}

.xd-resumo .xd-resumo-sidebar__sep {
  margin: 4px 20px;
  border: 0;
  border-top: 1px dashed var(--color-border-soft, #eceef5);
}

/* —— Downloads card + block spacing —— */
.xd-resumo .xd-resumo-main > .profile-blocks--extra.card:first-child,
.xd-resumo .xd-resumo-aside > .profile-blocks--extra.card:first-child {
  margin-top: 0;
}

.xd-resumo .xd-resumo-dl-card .xd-resumo-block__body {
  padding-top: 16px;
  padding-bottom: 16px;
}

.xd-resumo .xd-resumo-hero {
  margin: 0 0 28px;
}

.xd-resumo .xd-resumo-hero__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.xd-resumo .xd-resumo-hero__row--actions-only {
  justify-content: flex-end;
}

.xd-resumo .xd-resumo-hero__title {
  margin: 0;
  font-family: var(--font-heading, inherit);
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  font-weight: 700;
  color: var(--color-heading, #0b0d1a);
  letter-spacing: -0.02em;
  flex: 1 1 240px;
}

.xd-resumo .xd-resumo-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.xd-resumo .xd-resumo-dl {
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
}

.xd-resumo .xd-resumo-dl.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.xd-resumo .xd-resumo-charts {
  margin-top: 24px;
  margin-bottom: 24px;
}

.xd-resumo .xd-resumo-charts .xd-resumo-block {
  margin-top: 0;
  margin-bottom: 0;
}

/* —— KPI tiles (WP .licencas_em_modelo…) —— */
.xd-resumo .xd-kpi {
  border: 1px solid var(--xd-table-border) !important;
  border-radius: 12px;
  padding: 6px 6px 6px 12px;
  background: var(--xd-white) !important;
  height: 100%;
  transition: background 0.12s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}

.xd-resumo .xd-kpi:hover {
  background: var(--xd-table-head) !important;
}

.xd-resumo .xd-kpi__value {
  margin-top: 6px;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--xd-blue);
}

.xd-resumo .xd-kpi span {
  color: var(--color-text-dim, #6b7196);
  font-size: 0.875rem;
}

/* —— Tables (WP .tabela-xd-01) — !important beats Nexora th,td ——
   Scope: .xd-resumo (relatório) + standalone .xd-table / .tabela-xd-01 (ex. condições comerciais) */
.xd-resumo .tabela-scroll {
  max-height: 800px;
  overflow: auto;
  position: relative;
}

.xd-resumo table.tabela-xd-01,
.xd-resumo .tabela-xd-01,
table.xd-table.tabela-xd-01,
table.tabela-xd-01 {
  width: 100% !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  font-size: 15px !important;
  font-variant-numeric: tabular-nums;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.xd-resumo .tabela-xd-01 thead th,
.xd-resumo table.tabela-xd-01 thead th,
table.xd-table.tabela-xd-01 thead th,
table.tabela-xd-01 thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  border: 1px solid var(--xd-white) !important;
  border-bottom: 1px solid var(--xd-white) !important;
  background-color: var(--xd-table-head) !important;
  background: var(--xd-table-head) !important;
  padding: 8px !important;
  font-weight: 500 !important;
  color: var(--xd-blue) !important;
  text-align: left !important;
  white-space: nowrap;
}

.xd-resumo .tabela-xd-01 td,
.xd-resumo table.tabela-xd-01 td,
table.xd-table.tabela-xd-01 td,
table.tabela-xd-01 td {
  border: 1px solid var(--xd-table-border) !important;
  border-bottom: 1px solid var(--xd-table-border) !important;
  padding: 8px !important;
  background: var(--xd-white) !important;
  color: inherit;
  vertical-align: middle;
}

.xd-resumo .tabela-xd-01 tbody tr:nth-child(even) td,
.xd-resumo table.tabela-xd-01 tbody tr:nth-child(even) td,
table.xd-table.tabela-xd-01 tbody tr:nth-child(even) td,
table.tabela-xd-01 tbody tr:nth-child(even) td {
  background: var(--xd-table-soft) !important;
}

.xd-resumo .tabela-xd-01 .text-end,
.xd-resumo .tabela-xd-01 td.right,
.xd-resumo .tabela-xd-01 tr.text-end > td,
table.xd-table.tabela-xd-01 .text-end,
table.xd-table.tabela-xd-01 td.right,
table.tabela-xd-01 .text-end {
  text-align: right !important;
  white-space: nowrap;
}

.xd-resumo .tabela-xd-01 .text-start,
table.xd-table.tabela-xd-01 .text-start,
table.tabela-xd-01 .text-start {
  text-align: left !important;
}

.xd-resumo .totais_resumos {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--xd-blue);
  white-space: nowrap;
}

/* —— Row expand (WP .btn-expandir) —— */
.xd-resumo .xd-col-expand {
  width: 2.5rem;
}

.xd-resumo button.btn-expandir {
  cursor: pointer;
  background-color: var(--xd-white);
  padding: 0 8px;
  border: 1px solid var(--xd-table-border);
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--xd-blue);
}

.xd-resumo button.btn-expandir:hover {
  background-color: var(--xd-cyan);
  color: var(--xd-white);
  border-color: var(--xd-cyan);
}

.xd-resumo tr.linha-detalhes > td {
  background: var(--xd-white) !important;
  padding: 12px 8px !important;
}

.xd-resumo .xd-modulos-pills {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
}

.xd-resumo .xd-modulos-pills li {
  padding: 4px 8px;
  border: 1px solid var(--xd-table-border);
  border-radius: 3px;
  font-size: 13px;
  letter-spacing: 0.05em;
  font-weight: 500;
  color: var(--xd-blue);
  background: var(--xd-table-soft);
}

.xd-resumo tr.xd-agent-group > td {
  background: #f0f0f0 !important;
  font-weight: 600;
}

.xd-resumo .xd-agent-group__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.xd-resumo table.tabela-xd-02 {
  width: 100%;
  border-collapse: collapse;
  border-style: none;
  margin: 0;
}

.xd-resumo table.tabela-xd-02 th {
  border-bottom: 1px solid var(--xd-table-border) !important;
  background-color: var(--xd-white) !important;
  padding: 8px !important;
  font-weight: 600 !important;
  color: var(--xd-blue) !important;
  text-align: left !important;
}

.xd-resumo table.tabela-xd-02 td {
  border: 0 !important;
  padding: 8px !important;
  background: transparent !important;
}

/* —— Expandable blocks (WP .btn-expandir-resumo) —— */
.xd-resumo details.bloco-expandivel {
  margin-block-end: 0;
}

.xd-resumo summary.btn-expandir-resumo {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-soft);
}

.xd-resumo summary.btn-expandir-resumo::-webkit-details-marker,
.xd-resumo summary.btn-expandir-resumo::marker {
  display: none;
  content: "";
}

.xd-resumo summary.btn-expandir-resumo::before {
  content: "+";
  display: inline-block;
  margin-right: 8px;
  padding: 0 8px;
  background-color: var(--xd-white);
  border: 1px solid var(--xd-table-border);
  font-size: 16px;
  line-height: 1.5;
  color: var(--xd-blue);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.xd-resumo details[open] > summary.btn-expandir-resumo::before {
  content: "–";
}

.xd-resumo summary.btn-expandir-resumo:hover::before {
  background-color: var(--xd-cyan);
  color: var(--xd-white);
  border-color: var(--xd-cyan);
}

.xd-resumo .btn-expandir-resumo-2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 16px;
}

.xd-resumo .btn-expandir-resumo-2 > div {
  font-family: var(--font-heading, inherit);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading, #0b0d1a);
  line-height: 1.35;
  margin-bottom: 0;
}

.xd-resumo .btn-expandir-resumo-2 small {
  font-weight: 400;
  color: var(--color-text-dim, #6b7196);
}

.xd-resumo details[open] > summary.btn-expandir-resumo {
  border-bottom-color: var(--xd-table-border);
}

.xd-resumo canvas {
  max-width: 100%;
}

@media (max-width: 991px) {
  .xd-resumo .xd-resumo-layout {
    grid-template-columns: 1fr;
  }

  .xd-resumo .xd-resumo-aside {
    position: static;
  }
}

@media (max-width: 560px) {
  .xd-resumo .xd-resumo-sidebar__head {
    flex-direction: column;
    align-items: stretch;
  }

  .xd-resumo .xd-resumo-mes {
    padding: 0 20px 16px;
  }

  .xd-resumo .xd-resumo-mes .form-control {
    width: 100%;
  }
}
