/*
 * Redesign — Cartões (5a pagina do rollout, mesmo padrao de
 * Despesas: mes vai pro header global, categoria fica atras do
 * botao "Filtrar" no conteudo).
 */

body:not([data-page="cartoes"]) .cart-topbar-info,
body:not([data-page="cartoes"]) .cart-topbar-filter {
  display: none !important;
}
body[data-page="cartoes"] .cart-topbar-info,
body[data-page="cartoes"] .cart-topbar-filter {
  display: none;
}
@media (min-width: 901px) {
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-topbar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-right: auto;
    min-width: 0;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-topbar-info h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ds-foreground);
    white-space: nowrap;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-topbar-info p {
    margin: 0;
    font-size: 11px;
    color: var(--ds-muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-topbar-filter {
    display: inline-flex;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-topbar-filter .dashboard-mes-clear {
    border-radius: var(--ds-radius-lg) !important;
    background: transparent !important;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .app-topbar {
    gap: 12px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .header-tools {
    margin-left: 0 !important;
  }

  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-secondary);
    color: var(--ds-muted-foreground);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-trigger:hover {
    border-color: color-mix(in srgb, var(--ds-accent) 30%, transparent);
    color: var(--ds-foreground);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-trigger svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-picker {
    position: relative;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-trigger-chevron {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    margin-left: -2px;
    transition: transform .15s ease;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-trigger[aria-expanded="true"] {
    border-color: color-mix(in srgb, var(--ds-accent) 40%, transparent);
    color: var(--ds-foreground);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-trigger[aria-expanded="true"] .dm-month-trigger-chevron {
    transform: rotate(180deg);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 300;
    width: 220px;
    background: var(--ds-popover);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    padding: 12px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 10px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-panel-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--ds-muted-foreground);
    white-space: nowrap;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-year-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--ds-muted-foreground);
    border-radius: var(--ds-radius-sm);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    flex-shrink: 0;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-year-nav:hover {
    background: var(--ds-secondary);
    color: var(--ds-foreground);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    border: none;
    border-radius: var(--ds-radius-md);
    background: transparent;
    color: var(--ds-foreground);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-cell:hover:not(.is-disabled) {
    background: var(--ds-secondary);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-cell.is-selected {
    background: var(--ds-accent);
    color: var(--ds-accent-foreground);
    font-weight: 600;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-cell-check {
    font-size: 10px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .dm-month-cell.is-disabled {
    color: color-mix(in srgb, var(--ds-muted-foreground) 55%, transparent);
    cursor: default;
  }

  body[data-page="cartoes"][data-theme-preset="dark"] .container.app-content {
    padding: 20px !important;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .app-page.card {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
  }

  body[data-page="cartoes"][data-theme-preset="dark"] .despesa-page-head > div:first-child {
    display: none;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .despesa-page-head {
    justify-content: flex-end;
    margin-bottom: 20px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-page-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  body[data-page="cartoes"][data-theme-preset="dark"] .cart-filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: transparent;
    color: var(--ds-muted-foreground);
    font-size: 13px;
    font-weight: 500;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-filter-toggle-btn:hover {
    color: var(--ds-foreground);
    border-color: color-mix(in srgb, var(--ds-foreground) 25%, var(--ds-border));
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-filter-toggle-btn[aria-expanded="true"] {
    color: var(--ds-accent);
    border-color: color-mix(in srgb, var(--ds-accent) 45%, transparent);
    background: color-mix(in srgb, var(--ds-accent) 8%, transparent);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cart-filter-toggle-btn svg {
    flex-shrink: 0;
  }

  /* Filtro secundario (categoria/Buscar/Limpar): recolhido por
     padrao. Campo de mes fica sempre escondido (visual, nao
     display:none, pra continuar submetendo). */
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form {
    position: relative;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form .field:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form .field:not(:first-child) {
    display: none;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .field:not(:first-child) {
    display: flex;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open {
    margin-bottom: 20px !important;
    background: var(--ds-secondary) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-lg) !important;
    padding: 16px !important;
    box-shadow: none !important;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .field label {
    color: var(--ds-muted-foreground) !important;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .field input,
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .field select {
    background: var(--ds-card) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-md) !important;
    color: var(--ds-foreground) !important;
    height: 36px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .inst-filter-redef-btn,
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .cartoes-filter-buscar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 14px !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-md) !important;
    background: transparent !important;
    color: var(--ds-muted-foreground) !important;
    font-weight: 500;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .inst-filter-redef-btn:hover,
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form.is-open .cartoes-filter-buscar-btn:hover {
    background: var(--ds-card) !important;
    color: var(--ds-foreground) !important;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartoes-list-filter-form:not(.is-open) {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    min-height: 0 !important;
  }

  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-periodo-resumo {
    display: none;
  }

  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles {
    display: grid;
    gap: 12px;
    border: none;
    overflow: visible;
    background: transparent;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile {
    position: relative;
    display: block;
    padding: 16px;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-xl) !important;
    background: var(--ds-card) !important;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 24px;
    height: 24px;
    border-radius: var(--ds-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-icon svg {
    width: 12px;
    height: 12px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 30px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .05em;
    color: var(--ds-muted-foreground);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-value {
    font-family: var(--ds-font-mono);
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-delta {
    font-size: 10px;
    color: var(--ds-muted-foreground);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-icon--blue { background: color-mix(in srgb, #3B82F6 15%, transparent); color: #3B82F6; }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-icon--red { background: color-mix(in srgb, #EF4444 15%, transparent); color: #EF4444; }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-icon--teal { background: color-mix(in srgb, #10B981 15%, transparent); color: #10B981; }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-dash-tiles .dash-completo-tile-icon--orange { background: color-mix(in srgb, #F59E0B 15%, transparent); color: #F59E0B; }

  body[data-page="cartoes"][data-theme-preset="dark"] #cartao-new-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 16px;
    border: 1px solid color-mix(in srgb, var(--ds-accent) 45%, transparent);
    border-radius: var(--ds-radius-lg);
    background: transparent;
    color: var(--ds-accent);
    font-size: 13px;
    font-weight: 500;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartao-new-btn:hover {
    background: color-mix(in srgb, var(--ds-accent) 10%, transparent);
    border-color: var(--ds-accent);
  }
  body[data-page="cartoes"][data-theme-preset="dark"] #cartao-new-btn svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
  }

  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-table-scroll .btn-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  body[data-page="cartoes"][data-theme-preset="dark"] .cartoes-table-scroll .btn-mini svg {
    flex-shrink: 0;
  }
}
