/* Comercial module styles.
   These rules mirror the Comercial .razor.css files globally because the app shell no longer relies
   on the scoped CSS bundle. Keep selectors class-based so they work on desktop, mobile web and MAUI. */

.comercial-page,
.commercial-dashboard-page,
.portfolio-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100%;
  padding: 1.25rem;
  background: #f5f6f8;
}

.view-as-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  background: var(--color-brand-70, #0077d4);
  box-shadow: 0 2px 8px rgba(0, 119, 212, 0.35);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
}

.view-as-banner i {
  flex-shrink: 0;
  font-size: 1.15rem;
}

.view-as-banner span {
  flex: 1;
}

.view-as-banner strong {
  font-weight: 800;
}

.view-as-banner .btn {
  flex-shrink: 0;
  border-color: rgba(255, 255, 255, 0.65);
  color: #fff;
  font-weight: 700;
}

.view-as-banner .btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
  color: #fff;
}

.comercial-header,
.commercial-dashboard-header,
.portfolio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.comercial-eyebrow,
.commercial-dashboard-eyebrow,
.portfolio-eyebrow {
  display: block;
  color: #5f6673;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.comercial-header h1,
.commercial-dashboard-header h1,
.portfolio-header h1 {
  margin: 0;
  color: #111827;
  font-size: 1.65rem;
  font-weight: 750;
}

.comercial-actions,
.commercial-dashboard-actions,
.portfolio-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.comercial-action,
.commercial-dashboard-action,
.portfolio-action,
.simulation-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.commercial-dashboard-select,
.portfolio-range {
  width: 12.5rem;
}

.comercial-loading,
.commercial-dashboard-loading,
.portfolio-loading,
.details-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 10rem;
  color: #4b5563;
}

.comercial-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.comercial-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid #d9dde4;
  border-radius: 8px;
  background: #fff;
  color: #253044;
  font-weight: 700;
}

.comercial-tabs button.is-active {
  border-color: var(--color-brand-70);
  background: var(--color-brand-70);
  color: #fff;
}

.history-month-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid #d9dde4;
  border-radius: 8px;
  background: #fff;
  color: #253044;
}

.history-month-filter input {
  width: 8.5rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: #253044;
  font-size: 0.85rem;
}

.comercial-accordion-stack,
.portfolio-accordion-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.comercial-accordion {
  overflow: hidden;
  border: 1px solid #e2e6ee;
  border-radius: 8px;
  background: #fff;
}

.comercial-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.8rem 1rem;
  border: 0;
  background: #fff;
  color: #111827;
  font-weight: 750;
}

.comercial-accordion-header span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.comercial-accordion-header > .bi-chevron-down {
  transition: transform 0.15s ease;
}

.comercial-accordion-header[aria-expanded="true"] > .bi-chevron-down {
  transform: rotate(180deg);
}

.comercial-accordion-body {
  padding: 1rem;
  border-top: 1px solid #edf0f5;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.commercial-dashboard-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
}

.portfolio-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 5.25rem;
  padding: 0.85rem;
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  background: #fff;
}

.summary-card > i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2.35rem;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 8px;
  background: #eef6ff;
  color: var(--color-brand-70);
  font-size: 1.1rem;
}

.summary-card span,
.summary-card small {
  display: block;
  color: #6b7280;
  font-size: 0.78rem;
}

.summary-card strong {
  display: block;
  color: #111827;
  font-size: 1.05rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.chart-grid,
.portfolio-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(17rem, 1fr));
  gap: 0.85rem;
}

.commercial-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
}

.commercial-dashboard-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.85rem;
}

.donut-card,
.portfolio-donut-card,
.commercial-dashboard-chart-card {
  min-height: 24rem;
  padding: 1rem;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  background: #fff;
}

.commercial-dashboard-chart-card {
  min-height: 22rem;
}

.donut-card h2,
.portfolio-donut-card h2,
.commercial-dashboard-chart-card h2 {
  margin: 0 0 0.5rem;
  color: #111827;
  font-size: 1rem;
  font-weight: 760;
  text-align: center;
}

.commercial-dashboard-chart-card h2 {
  font-size: 0.95rem;
}

.donut-wrap,
.portfolio-donut-wrap,
.commercial-dashboard-donut-wrap {
  position: relative;
  width: 100%;
  height: 13.75rem;
}

.commercial-dashboard-donut-wrap {
  height: 12.5rem;
}

.donut-canvas,
.portfolio-donut-canvas {
  width: 100% !important;
  height: 13.75rem !important;
}

.commercial-dashboard-donut-canvas {
  width: 100% !important;
  height: 12.5rem !important;
}

.donut-legend,
.portfolio-legend,
.commercial-dashboard-legend {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.commercial-dashboard-legend {
  gap: 0.5rem;
}

.legend-row,
.portfolio-legend-row,
.commercial-dashboard-legend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
  color: #253044;
  font-size: 0.82rem;
}

.commercial-dashboard-legend-row {
  font-size: 0.8rem;
}

.legend-dot,
.portfolio-legend-dot,
.commercial-dashboard-legend-dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
}

.legend-label,
.portfolio-legend-row span:nth-child(2),
.commercial-dashboard-legend-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-row small,
.commercial-dashboard-legend-row small {
  color: #8a93a3;
}

.simulation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.simulation-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.simulation-grid label span {
  color: #4b5563;
  font-size: 0.78rem;
  font-weight: 700;
}

.operations-table-wrap,
.commercial-dashboard-table-wrap,
.portfolio-table-wrap,
.portfolio-drilldown-wrap,
.portfolio-titles-wrap {
  overflow-x: auto;
}

.portfolio-table-wrap {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.portfolio-nested-table-wrap {
  max-width: none;
  overflow: visible;
  scrollbar-gutter: auto;
}

.operations-table,
.commercial-dashboard-table,
.portfolio-drilldown-table,
.portfolio-titles-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.operations-table {
  min-width: 62rem;
}

.group-operations-table {
  min-width: 48rem;
}

.commercial-dashboard-table {
  min-width: 48rem;
}

.portfolio-drilldown-table {
  min-width: 68rem;
  border: 1px solid #e5e9f0;
}

.portfolio-titles-table {
  min-width: 54rem;
}

.operations-table th,
.commercial-dashboard-table th,
.portfolio-drilldown-table th {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e5e9f0;
  background: #f9fafb;
  color: #5f6673;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.portfolio-drilldown-table th {
  background: #f3f6fa;
  font-size: 0.72rem;
}

/* Colunas mais compactas via padding/fonte — SEM truncar conteúdo: valores
   monetários/datas nunca são cortados; o excedente rola nos wrappers com
   overflow-x (as tabelas mantêm min-width para isso). */
.nested-operations-table th,
.titles-table th,
.portfolio-drilldown-table th,
.portfolio-titles-table th {
  padding: 0.35rem 0.4rem;
  font-size: 0.64rem;
}

.nested-operations-table td,
.titles-table td,
.portfolio-drilldown-table td,
.portfolio-titles-table td {
  padding: 0.35rem 0.4rem;
  font-size: 0.74rem;
  white-space: nowrap;
}

.operations-table td,
.commercial-dashboard-table td,
.portfolio-drilldown-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid #eef1f5;
  color: #1f2937;
  font-size: 0.86rem;
  vertical-align: middle;
}

.operations-table td {
  padding: 0.75rem;
  font-size: 0.88rem;
}

.portfolio-drilldown-table td {
  padding: 0.65rem 0.7rem;
  font-size: 0.83rem;
}

.operations-table td strong,
.operations-table td span,
.commercial-dashboard-table td strong,
.commercial-dashboard-table td span,
.portfolio-drilldown-table td small {
  display: block;
}

.operations-table td span,
.commercial-dashboard-table td span,
.portfolio-drilldown-table td small {
  color: #6b7280;
  font-size: 0.76rem;
}

.group-row {
  background: #fff;
}

.group-row td {
  border-bottom-color: #dfe5ee;
}

.row-expand-button,
.portfolio-expand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #111827;
  font: inherit;
  font-weight: 800;
  text-align: left;
}

.row-expand-button i,
.portfolio-expand i {
  flex-shrink: 0;
  color: var(--color-brand-70);
}

.portfolio-expand span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nested-row > td,
.titles-row > td,
.portfolio-nested-row > td,
.portfolio-titles-row > td {
  background: #fbfcfe;
}

.nested-row > td,
.titles-row > td {
  padding: 0;
}

.nested-table-wrap {
  padding: 0.75rem;
  overflow-x: auto;
}

.nested-operations-table,
.titles-table {
  width: 100%;
  min-width: 58rem;
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  background: #fff;
}

.titles-table {
  border-color: #eef1f5;
}

.daily-table {
  min-width: 30rem;
}

.titles-row > td,
.portfolio-titles-row > td {
  background: #f8fafc;
}

.titles-row .titles-table {
  margin: 0.35rem 0 0.75rem;
}

.title-overdue,
.portfolio-title-overdue {
  background: #fff0f0;
}

.title-overdue td,
.portfolio-title-overdue td {
  color: #7f1d1d;
}

.status-pill {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem !important;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-open {
  background: #dcfce7;
  color: #166534 !important;
}

.status-closed {
  background: #e5e7eb;
  color: #374151 !important;
}

.liquidity-d0 {
  background: #dcfce7;
  color: #166534 !important;
}

.liquidity-d5 {
  background: #fef9c3;
  color: #854d0e !important;
}

.liquidity-d15 {
  background: #ffedd5;
  color: #9a3412 !important;
}

.liquidity-over {
  background: #fee2e2;
  color: #991b1b !important;
}

.liquidity-none {
  background: #e5e7eb;
  color: #374151 !important;
}

.portfolio-minute-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font: inherit;
  font-weight: 700;
  color: var(--color-brand-70, #0077D4);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.portfolio-minute-link:hover:not(:disabled) {
  color: var(--color-brand-80, #0060AB);
}

.portfolio-minute-link:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  text-decoration: none;
}

.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.85rem;
  color: #4b5563;
}

.pagination-row > div {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.empty-state,
.commercial-dashboard-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 6rem;
  border: 1px dashed #cfd6e2;
  border-radius: 8px;
  background: #fbfcfe;
  color: #6b7280;
}

.commercial-dashboard-positive,
.portfolio-limit-positive {
  color: #166534 !important;
}

.commercial-dashboard-negative,
.portfolio-limit-negative {
  color: #b91c1c !important;
  font-weight: 800;
}

.details-header {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.details-header > div {
  padding: 0.75rem;
  border: 1px solid #e5e9f0;
  border-radius: 8px;
}

.details-header span {
  display: block;
  color: #6b7280;
  font-size: 0.75rem;
}

.details-header strong {
  display: block;
  color: #111827;
  overflow-wrap: anywhere;
}

.portfolio-table {
  --portfolio-name-width: 17rem;
  --portfolio-agent-width: 12rem;
  --portfolio-overdue-width: 9rem;
  --portfolio-month-width: 8.5rem;
  --portfolio-total-width: 10rem;
  --portfolio-approved-width: 10rem;
  --portfolio-available-width: 11rem;
  --portfolio-rate-width: 8rem;
  --portfolio-action-width: 7rem;
  width: 100%;
  min-width: 74rem;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.portfolio-table th {
  padding: 0.65rem 0.75rem;
  background: var(--color-brand-70);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.portfolio-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e5e9f0;
  color: #1f2937;
  font-size: 0.86rem;
  vertical-align: middle;
  white-space: nowrap;
}

.portfolio-table .portfolio-month-col {
  min-width: var(--portfolio-month-width);
  width: var(--portfolio-month-width);
}

.portfolio-table .portfolio-sticky-left,
.portfolio-table .portfolio-sticky-right {
  position: sticky;
  z-index: 2;
  background: #fff;
}

.portfolio-table th.portfolio-sticky-left,
.portfolio-table th.portfolio-sticky-right {
  z-index: 4;
  background: var(--color-brand-70);
}

.portfolio-table .portfolio-name-col {
  left: 0;
  min-width: var(--portfolio-name-width);
  width: var(--portfolio-name-width);
  max-width: var(--portfolio-name-width);
  overflow: hidden;
  text-overflow: ellipsis;
}

.portfolio-table .portfolio-agent-col {
  left: var(--portfolio-name-width);
  min-width: var(--portfolio-agent-width);
  width: var(--portfolio-agent-width);
  max-width: var(--portfolio-agent-width);
  overflow: hidden;
  text-overflow: ellipsis;
}

.portfolio-table .portfolio-overdue-col {
  left: var(--portfolio-name-width);
  min-width: var(--portfolio-overdue-width);
  width: var(--portfolio-overdue-width);
  box-shadow: 6px 0 8px -7px rgba(15, 23, 42, 0.75);
}

.portfolio-table .portfolio-overdue-after-agent {
  left: calc(var(--portfolio-name-width) + var(--portfolio-agent-width));
}

.portfolio-table .portfolio-action-col {
  right: 0;
  min-width: var(--portfolio-action-width);
  width: var(--portfolio-action-width);
}

.portfolio-table .portfolio-rate-col {
  right: var(--portfolio-action-width);
  min-width: var(--portfolio-rate-width);
  width: var(--portfolio-rate-width);
}

.portfolio-table .portfolio-available-col {
  right: calc(var(--portfolio-action-width) + var(--portfolio-rate-width));
  min-width: var(--portfolio-available-width);
  width: var(--portfolio-available-width);
}

.portfolio-table .portfolio-approved-col {
  right: calc(var(--portfolio-action-width) + var(--portfolio-rate-width) + var(--portfolio-available-width));
  min-width: var(--portfolio-approved-width);
  width: var(--portfolio-approved-width);
}

.portfolio-table .portfolio-total-col {
  right: calc(var(--portfolio-action-width) + var(--portfolio-rate-width) + var(--portfolio-available-width) + var(--portfolio-approved-width));
  min-width: var(--portfolio-total-width);
  width: var(--portfolio-total-width);
  box-shadow: -6px 0 8px -7px rgba(15, 23, 42, 0.75);
}

.portfolio-agent-row {
  background: #e8f2ff;
}

.portfolio-agent-row td {
  font-weight: 750;
}

.portfolio-agent-row td.portfolio-sticky-left,
.portfolio-agent-row td.portfolio-sticky-right {
  background: #e8f2ff;
}

.portfolio-table .portfolio-name-col .portfolio-expand,
.portfolio-table .portfolio-agent-col .portfolio-expand {
  width: 100%;
}

@media (max-width: 1400px) {
  .commercial-dashboard-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .summary-grid,
  .portfolio-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid,
  .portfolio-chart-grid,
  .simulation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .commercial-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .details-header {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .comercial-page,
  .commercial-dashboard-page,
  .portfolio-page {
    padding: 0.85rem;
  }

  .comercial-header,
  .commercial-dashboard-header,
  .portfolio-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .comercial-actions,
  .commercial-dashboard-actions,
  .portfolio-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .commercial-dashboard-select,
  .portfolio-range {
    width: 100%;
  }

  .summary-grid,
  .commercial-dashboard-summary,
  .portfolio-summary-grid,
  .chart-grid,
  .portfolio-chart-grid,
  .simulation-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .details-header {
    grid-template-columns: 1fr;
  }
}
