/* R2 · tabelas responsivas. O desktop continua usando as tabelas originais. */
.annual-mobile,
.monthly-mobile,
.mobile-sort-control,
.table-mode-switch {
  display: none;
}

.table-pagination {
  display: contents;
}

@media (max-width: 900px) {
  .table-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    width: min(100%, 360px);
    margin: 0 0 14px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #eef1f7;
  }

  .table-mode-switch button {
    min-width: 0;
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
  }

  .table-mode-switch button.active,
  .table-mode-switch button[aria-pressed="true"] {
    background: #fff;
    color: var(--p);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
  }

  #view-tabelas[data-active-table-mode="anual"] .table-section--monthly,
  #view-tabelas[data-active-table-mode="mensal"] .table-section--annual {
    display: none;
  }

  #view-tabelas[data-active-table-mode="anual"] .monthly-filter,
  #view-tabelas[data-active-table-mode="anual"] .table-pagination {
    display: none;
  }

  #view-tabelas[data-active-table-mode="anual"] .table-toolbar > label:not(.monthly-filter) {
    grid-column: 1 / -1;
  }

  .annual-desktop,
  .monthly-desktop {
    display: none !important;
  }

  .annual-mobile,
  .monthly-mobile,
  .mobile-sort-control {
    display: block;
  }

  .table-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 12px;
  }

  .table-toolbar > label,
  .table-toolbar .mobile-sort-control {
    width: 100%;
    min-width: 0;
  }

  .table-toolbar select,
  .table-toolbar input[type="number"] {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  .table-toolbar label:has(#filter-extra) {
    grid-column: 1 / -1;
    order: initial;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
  }

  .table-toolbar #filter-extra {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
  }

  .table-pagination {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    gap: 8px;
  }

  .table-pagination button {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 12px;
    font-size: 22px;
  }

  .table-pagination span {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }

  .app .table-wrap.annual-mobile,
  .app .table-wrap.monthly-mobile {
    overflow: hidden;
    max-height: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .annual-card-list,
  .monthly-card-list {
    display: grid;
    gap: 10px;
    min-width: 0;
    align-items: start;
  }

  .annual-card,
  .monthly-card,
  .annual-paid-row {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card, #fff);
    box-shadow: var(--shadow);
  }

  .annual-card.has-extra,
  .monthly-card.has-extra {
    border-color: color-mix(in srgb, var(--g) 24%, var(--line));
  }

  .annual-card > header {
    display: flex;
    align-items: center;
    min-height: 48px;
    border-bottom: 1px solid #edf0f5;
  }

  .annual-card > header > .badge {
    margin-right: 14px;
    flex: 0 0 auto;
  }

  .annual-card .year-toggle {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 12px;
    border: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
  }

  .annual-card .year-toggle span,
  .monthly-card header span,
  .annual-paid-row > span:first-child {
    min-width: 0;
  }

  .annual-card .year-toggle b,
  .monthly-card header b,
  .annual-paid-row b {
    display: block;
    font-size: 15px;
    line-height: 1.25;
  }

  .annual-card .year-toggle small,
  .monthly-card header small,
  .annual-paid-row small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
  }

  .annual-card .year-toggle i {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 9px;
    background: #f0eefc;
    color: var(--p);
    font-size: 18px;
    font-style: normal;
    font-weight: 700;
  }

  .annual-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 14px;
    padding: 7px 12px 11px;
  }

  .annual-facts > span {
    min-width: 0;
    padding: 4px 0;
  }

  .annual-facts > span:nth-child(odd) {
    padding-right: 0;
  }

  .annual-facts > span:nth-child(even) {
    padding-left: 0;
    border-left: 0;
    text-align: right;
  }

  .annual-facts small,
  .monthly-facts small,
  .annual-month-card small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  .annual-facts b,
  .monthly-facts b,
  .annual-month-card b {
    display: block;
    overflow-wrap: anywhere;
    margin-top: 2px;
    font-size: 15px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
  }

  .annual-facts .saving b,
  .monthly-facts .saving b {
    color: var(--g);
  }

  .annual-month-list {
    display: grid;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid #e5e9f0;
    background: #f6f7fa;
    animation: r2-year-reveal 180ms ease-out;
  }

  .annual-month-card {
    display: grid;
    grid-template-columns: .65fr repeat(4, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 10px;
    border: 1px solid #e3e7ef;
    border-radius: 10px;
    background: #fff;
  }

  .annual-month-card.has-extra {
    border-color: #bfe3ce;
    background: #f1faf5;
  }

  .annual-month-card footer {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .monthly-card {
    padding: 0 12px 8px;
  }

  .monthly-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 34px;
    border-bottom: 1px solid #edf0f5;
  }

  .monthly-card header span {
    display: flex;
    align-items: baseline;
    gap: 0;
    white-space: nowrap;
  }

  .monthly-card header span b,
  .monthly-card header span small {
    display: inline;
    margin: 0;
  }

  .monthly-card header span b {
    font-size: 13px;
  }

  .monthly-card header span small {
    font-size: 10px;
  }

  .monthly-card header strong {
    color: var(--b);
    font-size: 15px;
    line-height: 1.2;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .monthly-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 10px;
    padding-top: 7px;
  }

  .monthly-facts > span {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    min-width: 0;
    padding: 0;
    border: 0;
    white-space: nowrap;
  }

  .monthly-facts small,
  .monthly-facts b {
    display: inline;
    margin: 0;
    line-height: 1.25;
  }

  .monthly-facts small {
    font-size: 9px;
    letter-spacing: .02em;
    text-transform: none;
  }

  .monthly-facts b {
    font-size: 11px;
  }

  .monthly-card footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 25px;
    padding-top: 5px;
  }

  .money-chip {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 5px;
    border-radius: 999px;
    background: #e8f7ee;
    color: #0b6b3d;
    font-size: 9px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .monthly-economy,
  .remaining-term {
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  .monthly-economy {
    color: var(--g);
    flex-basis: 100%;
  }

  .remaining-term {
    margin-left: auto;
  }

  .annual-paid-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 10px;
    padding: 13px 14px;
    background: #f2faf5;
    border-color: #c9e7d5;
  }

  .annual-paid-row > strong {
    grid-column: 1 / -1;
    color: var(--g);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .annual-card-list,
  .monthly-card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .annual-paid-row {
    min-height: 92px;
  }
}

@media (max-width: 480px) {
  .table-toolbar {
    gap: 10px;
    padding: 12px;
  }

  .annual-month-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .annual-month-card > span:first-child {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
  }

  .monthly-card header {
    gap: 7px;
  }

  .monthly-card header strong {
    font-size: 14px;
  }


}

@media (prefers-reduced-motion: reduce) {
  .annual-month-list {
    animation: none;
  }

  .table-mode-switch button {
    transition: none;
  }
}

@keyframes r2-year-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
