.direction-reports, .direction-report-body {
  display: grid;
  gap: clamp(12px, 2vw, 20px);
  min-width: 0;
}

.direction-report-assistant, .direction-report-controls, .direction-report-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.direction-report-assistant {
  background: linear-gradient(120deg, var(--surface), var(--raised));
}

.direction-report-answer {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--edge);
  border-inline-start: 3px solid var(--rose);
  border-radius: 12px;
  background: var(--surface);
  overflow-wrap: anywhere;
}

.direction-report-answer > p:first-child { font-weight: 650; }
.direction-report-answer small:empty, .direction-report-answer-actions:empty { display: none; }
.direction-report-answer-actions { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.direction-report-answer-actions .button { color: var(--rose-deep); }

.direction-report-heading { display: grid; gap: 4px; }
.direction-report-heading p { font-size: .875rem; }
.direction-report-panel { scroll-margin-block: 96px; }
.direction-report-panel:focus { outline: 2px solid var(--rose); outline-offset: 4px; }
.direction-report-print-header { display: none; }

.direction-report-filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
}

.direction-report-filter-row.direction-report-request {
  grid-template-columns: minmax(0, 1fr) auto;
}

.direction-report-request-buttons, .direction-report-voice-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.direction-report-request-buttons .icon-button { flex: none; }
.direction-report-voice-feedback > #voice-status { min-width: 0; overflow-wrap: anywhere; }
.direction-report-voice-feedback > .direcao-voice-wave { max-width: 100%; }
.direction-report-voice-feedback:has(> #voice-loading[hidden]):has(> #voice-wave[hidden]):has(> #voice-status:empty) {
  display: none;
}

.direction-report-filter-row:has(input[type="date"]) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.direction-report-filter-row label { min-width: 0; }
.direction-report-filter-row input, .direction-report-filter-row select { min-width: 0; }
.direction-report-controls [role="status"]:empty { display: none; }

.direction-report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.direction-report-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: 0 16px;
  margin: 0;
}

.direction-report-metric {
  min-width: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--edge);
}

.direction-report-metric dt {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-height: 2.6em;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 650;
}

.direction-report-icon { display: flex; color: var(--rose); }
.direction-report-icon svg { width: 18px; height: 18px; }
.direction-report-metric dd { margin: 0; font-size: 1.2rem; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.direction-report-negative { color: var(--amber); }
.direction-report-note { display: grid; gap: 4px; font-size: .8125rem; }

.direction-report-profit {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px 20px;
  padding: 12px 0 0;
  border-top: 1px solid var(--edge);
}

.direction-report-profit h3 { margin-bottom: 4px; }
.direction-report-profit p { font-size: .8125rem; }
.direction-report-profit-value { display: grid; gap: 3px; white-space: nowrap; }
.direction-report-profit-value strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.direction-report-profit-value span { font-size: .8125rem; }

.direction-report-table { margin: 0; }
.direction-report-table td, .direction-report-table th { min-width: 8rem; }
.direction-report-table td { font-variant-numeric: tabular-nums; }
.direction-report-table tbody th { min-width: 10rem; color: var(--text); font-weight: 700; overflow-wrap: anywhere; }
.direction-report-product { display: grid; gap: 2px; }
.direction-report-product .product-guide-link { min-height: 32px; width: fit-content; text-align: left; }
.direction-report-empty { padding: 10px 0; }
.direction-report-mobile-caption, .direction-report-mobile-label { display: none; }

#direction-report-comparison .direction-report-table {
  border: 1px solid var(--edge);
  border-radius: 12px;
}

#direction-report-comparison :is(td, th):not(:first-child) {
  min-width: 6.25rem;
  text-align: right;
}

#direction-report-comparison thead { background: var(--raised); }
#direction-report-comparison tbody tr:last-child > :is(td, th) { border-bottom: 0; }

@media (max-width: 640px) {
  .direction-report-filter-row.direction-report-request { grid-template-columns: minmax(0, 1fr); }
  .direction-report-request-buttons > [type="submit"] { flex: 1; }
  .direction-report-actions { justify-content: flex-start; }
}

@media (max-width: 390px) {
  .direction-report-filter-row, .direction-report-filter-row:has(input[type="date"]) { grid-template-columns: minmax(0, 1fr); }
  .direction-report-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 640px) {
  #direction-report-comparison tr > th:first-child {
    position: sticky;
    inset-inline-start: 0;
    z-index: 1;
    min-width: 8rem;
    background: var(--surface);
    box-shadow: 1px 0 var(--edge);
  }
  #direction-report-comparison thead tr > th:first-child { background: var(--raised); }

  .direction-report-table-stacked { overflow: visible; }
  .direction-report-mobile-caption { display: block; font-weight: 700; }
  .direction-report-event-context + .direction-report-table .direction-report-mobile-caption { display: none; }
  .direction-report-table-stacked :is(table, tbody) { display: block; }
  .direction-report-table-stacked thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .direction-report-table-stacked tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding-block: 12px;
    border-block-end: 1px solid var(--edge);
  }

  .direction-report-table-stacked tbody th { grid-column: 1 / -1; }
  .direction-report-table-stacked tbody :is(th, td) {
    min-width: 0;
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .direction-report-mobile-label {
    display: block;
    color: var(--muted);
    font-size: .75rem;
  }
}

@page direction-report {
  size: A4 portrait;
  margin: 13mm 12mm;
}

@media print {
  html:has(#direction-reports),
  body:has(#direction-reports) {
    min-height: 0;
    background: #fff;
  }

  body:has(#direction-reports) {
    --text: #211b20;
    --muted: #50444c;
    --edge: #bfaeb8;
    --rose: #702847;
    --amber: #713d26;
    color: var(--text);
  }

  body:has(#direction-reports) > :not(main),
  body:has(#direction-reports) main > :not(.content),
  body:has(#direction-reports) .content > :not(#page),
  body:has(#direction-reports) #page > :not(#direction-reports),
  #direction-reports > :not(.direction-report-print-header, .direction-report-body) {
    display: none;
  }

  body:has(#direction-reports) main { page: direction-report; }

  body:has(#direction-reports) :is(main, .content) {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  #direction-reports,
  #direction-reports .direction-report-body {
    display: block;
  }

  #direction-reports .direction-report-print-header {
    display: block;
    margin-bottom: 5mm;
    padding-bottom: 3mm;
    border-bottom: 1pt solid var(--rose);
    break-inside: avoid;
    break-after: avoid;
  }

  .direction-report-print-header :is(h1, h2) {
    margin: 0 0 1.5mm;
    color: var(--rose);
    font-size: 22pt;
    line-height: 1.1;
  }

  .direction-report-print-header :is(p, small) { font-size: 9pt; }

  #direction-reports .direction-report-panel {
    display: block;
    margin: 0 0 5mm;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    outline: none;
  }

  #direction-reports .direction-report-heading {
    display: block;
    margin-bottom: 2mm;
    break-inside: avoid;
    break-after: avoid;
  }

  .direction-report-heading h2 { font-size: 13pt; }
  .direction-report-heading p,
  .direction-report-note,
  .direction-report-profit :is(p, span),
  .direction-report-empty {
    font-size: 8.5pt;
  }

  .direction-report-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 4mm;
  }

  .direction-report-metric {
    padding: 2mm 0;
    break-inside: avoid;
  }

  .direction-report-metric dt { min-height: 0; font-size: 8pt; }
  .direction-report-metric dd { font-size: 11pt; }
  .direction-report-icon { display: none; }
  .direction-report-note { margin-block: 2mm; }
  .direction-report-profit { padding-top: 2mm; break-inside: avoid; }
  .direction-report-profit h3,
  .direction-report-profit-value strong { font-size: 10pt; }

  #direction-reports .direction-report-table {
    overflow: visible;
    max-width: none;
    border: 0;
    border-radius: 0;
  }

  .direction-report-table table { table-layout: fixed; font-size: 8.5pt; line-height: 1.3; }
  .direction-report-table thead { display: table-header-group; }
  .direction-report-table tr { break-inside: avoid; }

  #direction-reports .direction-report-table :is(td, th) {
    min-width: 0;
    padding: 1.5mm 1mm;
    overflow-wrap: anywhere;
    white-space: normal;
    vertical-align: top;
  }

  #direction-report-events .direction-report-event-context { break-inside: avoid-page; break-after: avoid-page; }
  #direction-report-events .direction-report-table table { table-layout: auto; }
  #direction-report-events .direction-report-table thead th { overflow-wrap: normal; }
  #direction-report-events .direction-report-table tbody td { white-space: nowrap; }

  #direction-reports .direction-report-table thead th { border-bottom: 1pt solid var(--text); }
  #direction-report-consultants thead th:first-child,
  #direction-report-events thead th:first-child { width: 17%; }
  #direction-report-comparison thead { background: none; }

  .direction-report-product { display: block; }
  #direction-reports .direction-report-product .product-guide-link {
    display: inline;
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    font: inherit;
    color: inherit;
  }
  .direction-report-product .product-guide-link + small { display: block; }
}
