/* ==========================================================================
   EXTRATO DO CAIXA
   - Visão mensal de movimentos realizados
   - Receita automática consolidada com detalhe sob demanda
   - Tabela desktop e cartões compactos no mobile
   ========================================================================== */

.extrato-caixa-page {
  --extrato-teal-950: #00383f;
  --extrato-teal-800: #075b58;
  --extrato-teal-100: #dff3f0;
  --extrato-ink: #0f172a;
  --extrato-muted: #526174;
  --extrato-line: rgba(148, 163, 184, 0.28);
  --extrato-positive: #137a42;
  --extrato-negative: #b4232b;
}

.extrato-shell {
  width: min(calc(100% - 2rem), 1380px);
  margin: 0 auto 3rem;
}

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

.extrato-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.15rem;
}

.extrato-kicker {
  margin: 0 0 0.28rem;
  color: var(--extrato-teal-800);
  font-size: 0.75rem;
  font-weight: 850;
}

.extrato-heading h1 {
  margin: 0;
  color: var(--extrato-ink);
  font-size: clamp(1.75rem, 3vw, 2.55rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.extrato-heading p:last-child {
  max-width: 68ch;
  margin: 0.48rem 0 0;
  color: var(--extrato-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.extrato-primary-action,
.extrato-filter-submit,
.extrato-export,
.extrato-empty a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  min-height: 42px;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease-out, background-color 160ms ease-out, box-shadow 160ms ease-out;
}

.extrato-primary-action,
.extrato-filter-submit {
  border: 0;
  padding: 0.68rem 1.05rem;
  color: #fff;
  background: var(--extrato-teal-950);
  box-shadow: 0 9px 22px rgba(0, 56, 63, 0.18);
}

.extrato-primary-action:hover,
.extrato-filter-submit:hover {
  color: #fff;
  background: #00545d;
  transform: translateY(-1px);
}

.extrato-primary-action:focus-visible,
.extrato-filter-submit:focus-visible,
.extrato-export:focus-visible,
.extrato-value-detail:focus-visible,
.extrato-period-nav a:focus-visible,
.extrato-detail-header button:focus-visible,
.extrato-filter-form :is(input, select):focus-visible {
  outline: 3px solid rgba(38, 166, 154, 0.32);
  outline-offset: 2px;
}

.extrato-error {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(180, 35, 43, 0.24);
  border-radius: 14px;
  color: #8e1b23;
  background: #fff5f5;
}

.extrato-error div {
  display: grid;
  gap: 0.18rem;
}

.extrato-error span {
  color: #70242a;
  font-size: 0.9rem;
}

.extrato-summary {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding: 1.18rem;
  border-radius: var(--vm-radius-xl);
}

.extrato-summary-main {
  display: grid;
  gap: 0.18rem;
}

.extrato-summary-main span {
  color: var(--extrato-teal-800);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.extrato-summary-main strong {
  width: fit-content;
  margin-top: 0.08rem;
  color: #0c4f48;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.extrato-summary-main strong.is-negative,
.extrato-summary-main strong.is-unavailable {
  color: var(--extrato-negative);
}

.extrato-summary-main small {
  max-width: 520px;
  color: var(--extrato-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.extrato-summary-period {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.78rem;
}

.extrato-summary-card {
  display: grid;
  align-content: center;
  gap: 0.28rem;
  min-width: 0;
  min-height: 112px;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(203, 213, 225, 0.74);
  border-radius: var(--vm-radius-lg);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.055);
}

.extrato-summary-card span {
  color: #0c4f48;
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  line-height: 1.1;
  text-transform: uppercase;
}

.extrato-summary-card strong {
  color: var(--extrato-ink);
  font-size: clamp(1.35rem, 1.9vw, 1.86rem);
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  letter-spacing: -0.035em;
  line-height: 1;
  white-space: nowrap;
}

.extrato-summary-card.is-credit {
  border-color: rgba(22, 163, 74, 0.18);
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.extrato-summary-card.is-debit {
  border-color: rgba(220, 38, 38, 0.18);
  background: linear-gradient(180deg, #ffffff 0%, #fff1f2 100%);
}

.extrato-summary-card.is-result {
  border-color: rgba(0, 75, 68, 0.16);
  background: linear-gradient(180deg, #ffffff 0%, #eafaf7 100%);
}

.extrato-summary-card.is-credit span,
.extrato-summary-period .is-positive {
  color: var(--extrato-positive);
}

.extrato-summary-card.is-debit span,
.extrato-summary-period .is-negative {
  color: var(--extrato-negative);
}

.extrato-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.9rem;
  margin-bottom: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--extrato-line);
  border-radius: 14px;
  background: #fff;
}

.extrato-period-nav {
  display: grid;
  grid-template-columns: 38px minmax(132px, 1fr) 38px;
  align-items: center;
  min-height: 42px;
  overflow: hidden;
  border: 1px solid var(--extrato-line);
  border-radius: 999px;
}

.extrato-period-nav a {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--extrato-teal-950);
}

.extrato-period-nav a:hover {
  background: var(--extrato-teal-100);
}

.extrato-period-nav strong {
  color: var(--extrato-ink);
  font-size: 0.88rem;
  text-align: center;
  white-space: nowrap;
}

.extrato-period-nav strong span {
  color: var(--extrato-muted);
  font-weight: 650;
}

.extrato-filter-form {
  display: grid;
  grid-template-columns: minmax(126px, 0.8fr) 92px minmax(128px, 0.8fr) minmax(190px, 1.4fr) auto;
  align-items: end;
  gap: 0.65rem;
}

.extrato-filter-form label {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.extrato-filter-form label > span {
  color: var(--extrato-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.extrato-filter-form :is(input, select) {
  width: 100%;
  height: 42px;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.46);
  border-radius: 10px;
  padding: 0 0.72rem;
  color: var(--extrato-ink);
  background: #fff;
  font-size: 0.88rem;
}

.extrato-filter-form :is(input, select):focus {
  border-color: var(--extrato-teal-800);
}

.extrato-export {
  min-height: 42px;
  padding: 0.58rem 0.9rem;
  border: 1px solid rgba(0, 75, 68, 0.28);
  color: var(--extrato-teal-950);
  background: #f6fbfa;
  white-space: nowrap;
}

.extrato-export:hover {
  color: var(--extrato-teal-950);
  background: var(--extrato-teal-100);
}

.extrato-ledger {
  overflow: hidden;
  border: 1px solid var(--extrato-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.065);
}

.extrato-ledger-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--extrato-line);
}

.extrato-ledger-heading h2 {
  margin: 0;
  color: var(--extrato-ink);
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  font-weight: 880;
  letter-spacing: -0.02em;
}

.extrato-ledger-heading p {
  margin: 0.2rem 0 0;
  color: var(--extrato-muted);
  font-size: 0.82rem;
}

.extrato-legend {
  display: flex;
  gap: 0.85rem;
  color: var(--extrato-muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.extrato-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.extrato-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.extrato-legend .is-credit {
  background: var(--extrato-positive);
}

.extrato-legend .is-debit {
  background: var(--extrato-negative);
}

.extrato-table-wrap {
  width: 100%;
}

.extrato-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.extrato-table th {
  padding: 0.72rem 0.85rem;
  color: #425166;
  background: #f5f8fa;
  font-size: 0.71rem;
  font-weight: 850;
  text-align: left;
}

.extrato-table th:nth-child(1) { width: 13%; }
.extrato-table th:nth-child(2) { width: 38%; }
.extrato-table th:nth-child(3) { width: 21%; }
.extrato-table th:nth-child(4),
.extrato-table th:nth-child(5) { width: 14%; }

.extrato-table th:nth-child(3),
.extrato-table th.is-money {
  text-align: center;
}

@media (min-width: 801px) {
  .extrato-table :is(th, td):first-child {
    padding-left: 1.5rem;
  }

  .extrato-table :is(th, td):last-child {
    padding-right: 1.5rem;
  }
}

.extrato-table td {
  padding: 0.82rem 0.85rem;
  border-top: 1px solid rgba(226, 232, 240, 0.85);
  color: var(--extrato-ink);
  font-size: 0.86rem;
  vertical-align: middle;
}

.extrato-table tbody tr:first-child td {
  border-top: 0;
}

.extrato-table tbody tr:hover {
  background: #f9fcfc;
}

.extrato-table time {
  color: #46566b;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.extrato-description strong,
.extrato-description span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.extrato-description strong {
  color: var(--extrato-ink);
  font-weight: 800;
  white-space: nowrap;
}
.extrato-description-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(0, 93, 92, 0.32);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
  border-radius: 4px;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.extrato-description-link:hover {
  color: var(--extrato-teal-800);
  text-decoration-color: currentColor;
}

.extrato-description-link:focus-visible {
  color: var(--extrato-teal-800);
  outline: 3px solid rgba(13, 148, 136, 0.24);
  outline-offset: 3px;
  text-decoration-color: currentColor;
}


.extrato-description span {
  margin-top: 0.16rem;
  color: var(--extrato-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.extrato-origin,
.extrato-partial {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.extrato-origin {
  padding: 0.28rem 0.5rem;
  color: #334155;
  background: #eef2f6;
}

.extrato-origin-automatico {
  color: #075b58;
  background: var(--extrato-teal-100);
}

.extrato-origin-conferencia {
  color: #684513;
  background: #fff1c7;
}

.extrato-partial {
  margin-left: 0.28rem;
  padding: 0.23rem 0.42rem;
  color: #075b58;
  border: 1px solid rgba(7, 91, 88, 0.25);
  background: #fff;
}

.extrato-money {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.extrato-money.is-credit {
  color: var(--extrato-positive);
}

.extrato-money.is-debit {
  color: var(--extrato-negative);
}

.extrato-origin-cell {
  text-align: center;
  white-space: normal;
}

.extrato-value-detail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0.25rem 0.42rem;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: 900;
  line-height: 1;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: background-color 160ms ease-out;
}

.extrato-value-detail:hover {
  background: rgba(19, 122, 66, 0.09);
}

.extrato-row-conferencia {
  background: #fffcf3;
}

.extrato-empty {
  display: grid;
  justify-items: center;
  max-width: 620px;
  margin: 0 auto;
  padding: 3rem 1.2rem;
  text-align: center;
}

.extrato-empty > i {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 0.85rem;
  border-radius: 16px;
  place-items: center;
  color: var(--extrato-teal-950);
  background: var(--extrato-teal-100);
  font-size: 1.45rem;
}

.extrato-empty h3 {
  margin: 0;
  color: var(--extrato-ink);
  font-size: 1.08rem;
  font-weight: 850;
}

.extrato-empty p {
  max-width: 55ch;
  margin: 0.5rem 0 1rem;
  color: var(--extrato-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.extrato-empty a {
  min-height: 38px;
  padding: 0.5rem 0.82rem;
  color: #fff;
  background: var(--extrato-teal-950);
}

.extrato-detail-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(460px, 92vw);
  max-width: none;
  border: 0;
  color: #f8fafc;
  background: #171c26;
  box-shadow: -24px 0 70px rgba(15, 23, 42, 0.32);
}

.extrato-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.24);
}

.extrato-detail-header span {
  color: #94a3b8;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.extrato-detail-header h2 {
  margin: 0.1rem 0 0;
  color: #f8fafc;
  font-size: clamp(1.25rem, 2vw, 1.45rem);
  font-weight: 900;
}

.extrato-detail-header button {
  border: 0;
  padding: 0.25rem 0.4rem;
  color: #94a3b8;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
}

.extrato-detail-header button:hover {
  color: #f8fafc;
}

.extrato-detail-content {
  overflow-y: auto;
}

.extrato-detail-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.24);
  color: #e5e7eb;
}

.extrato-detail-item:hover {
  color: #fff;
  background: rgba(148, 163, 184, 0.1);
}

.extrato-detail-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.18);
  font-size: 1rem;
}

.extrato-detail-copy {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.extrato-detail-copy strong {
  overflow-wrap: anywhere;
  color: #f8fafc;
  font-size: 0.98rem;
  line-height: 1.35;
}

.extrato-detail-copy small {
  color: #b6bdca;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.extrato-detail-value {
  color: #bbf7d0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.extrato-detail-empty {
  display: grid;
  place-items: center;
  gap: 0.55rem;
  padding: 3rem 1.5rem;
  color: #b6bdca;
  text-align: center;
}

.extrato-detail-empty i {
  color: #22c55e;
  font-size: 2rem;
}

.extrato-detail-empty strong {
  color: #f8fafc;
  font-size: 1rem;
}

.extrato-detail-empty span {
  color: #b6bdca;
  font-size: 0.85rem;
}

.extrato-detail-footer {
  padding: 1rem 1.35rem;
  border-top: 1px solid rgba(148, 163, 184, 0.24);
  text-align: center;
}

.extrato-detail-footer span {
  color: #b8ddd6;
  font-size: 0.85rem;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .extrato-controls {
    grid-template-columns: 1fr auto;
  }

  .extrato-period-nav {
    width: fit-content;
  }

  .extrato-filter-form {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 800px) {
  .extrato-summary {
    padding: 1rem;
  }

  .extrato-summary-period {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .extrato-filter-form {
    grid-template-columns: 1fr 0.7fr 1fr;
  }

  .extrato-search-field {
    grid-column: 1 / 3;
  }

  .extrato-filter-submit {
    grid-column: 3;
  }

  .extrato-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .extrato-table,
  .extrato-table tbody,
  .extrato-table tr,
  .extrato-table td {
    display: block;
    width: 100%;
  }

  .extrato-table tbody {
    display: grid;
    gap: 0.65rem;
    padding: 0.75rem;
  }

  .extrato-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--extrato-line);
    border-radius: 14px;
    background: #fff;
  }

  .extrato-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    min-width: 0;
    padding: 0.62rem 0.72rem;
    border-top: 1px solid rgba(226, 232, 240, 0.82);
  }

  .extrato-table td::before {
    content: attr(data-label);
    color: var(--extrato-muted);
    font-size: 0.68rem;
    font-weight: 800;
  }

  .extrato-table .extrato-description {
    grid-column: 1 / -1;
    grid-row: 1;
    display: block;
    border-top: 0;
    padding-top: 0.78rem;
  }

  .extrato-table .extrato-description::before {
    display: none;
  }

  .extrato-description strong,
  .extrato-description span {
    white-space: normal;
  }

  .extrato-table td[data-label='Data'],
  .extrato-table td[data-label='Origem'] {
    grid-column: span 1;
  }

  .extrato-table .extrato-money {
    grid-column: 1 / -1;
    font-size: 1rem;
  }

}

@media (max-width: 575.98px) {
  .extrato-shell {
    width: min(calc(100% - 1rem), 1380px);
  }

  .extrato-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 0.85rem;
  }

  .extrato-primary-action {
    align-self: flex-start;
  }

  .extrato-summary-period {
    grid-template-columns: 1fr;
  }

  .extrato-summary-card {
    min-height: 88px;
    padding: 0.82rem 1rem;
  }

  .extrato-controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .extrato-period-nav {
    width: 100%;
  }

  .extrato-export {
    grid-row: 3;
    width: 100%;
  }

  .extrato-filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .extrato-filter-form label,
  .extrato-search-field,
  .extrato-filter-submit {
    grid-column: auto;
  }

  .extrato-search-field,
  .extrato-filter-submit {
    grid-column: 1 / -1;
  }

  .extrato-ledger-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .extrato-table tr {
    grid-template-columns: 1fr;
  }

  .extrato-table td[data-label='Data'],
  .extrato-table td[data-label='Origem'],
  .extrato-table .extrato-money {
    grid-column: 1;
  }

}

@media (prefers-reduced-motion: reduce) {
  .extrato-primary-action,
  .extrato-filter-submit,
  .extrato-export,
  .extrato-empty a,
  .extrato-value-detail {
    transition: none;
  }
}
