/* Componentes */

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transition: border-color var(--t) var(--ease), transform var(--t) var(--ease), background-color var(--t) var(--ease);
}
.card-body { padding: var(--sp-6); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) 0; }
.card-head h2, .card-head h3 { margin: 0; font-size: var(--fs-md); }
.card-head + .card-body { padding-top: var(--sp-4); }
.card.flush .card-body { padding: 0; }

.stat { position: relative; overflow: hidden; padding: var(--sp-5) var(--sp-6); }
.stat:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; }
.stat .label .chip { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.stat .label .chip svg { width: 16px; height: 16px; }
.stat .value { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }
.stat.positive .value { color: var(--success); }
.stat.negative .value { color: var(--danger); }
.stat::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, var(--accent-soft), transparent 70%); pointer-events: none; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 550; font-size: var(--fs-sm);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-hover); border-color: var(--text-faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--brand-500), var(--brand-600)); border-color: var(--brand-700); color: var(--accent-contrast); box-shadow: 0 6px 18px -8px rgba(10, 120, 210, .7); }
.btn-primary:hover { background: linear-gradient(180deg, #1585DD, var(--brand-500)); border-color: var(--brand-600); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-bg); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); border-color: var(--danger); }
.btn-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, transparent); background: var(--success-bg); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-xs); border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-block { width: 100%; }

/* Formulários */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-5); }
.col-12 { grid-column: span 12; } .col-11 { grid-column: span 11; } .col-10 { grid-column: span 10; } .col-9 { grid-column: span 9; }
.col-8 { grid-column: span 8; } .col-7 { grid-column: span 7; } .col-6 { grid-column: span 6; } .col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; } .col-1 { grid-column: span 1; }
@media (max-width: 760px) { .form-grid > [class*="col-"] { grid-column: span 12; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: var(--fs-sm); font-weight: 550; color: var(--text-muted); }
.field .req { color: var(--accent-text); margin-left: 2px; }
.input, .field input[type=text], .field input[type=password], .field input[type=email], .field input[type=number],
.field input[type=search], .field select, .field textarea, select.input {
  width: 100%; height: 40px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--input-bg); color: var(--text);
  font: inherit; font-size: var(--fs-base);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
/* Caixa alta em cadastros e pesquisas (e-mail, login, senha e chave Pix mantêm o texto original) */
.input, .field input[type=text], .field input[type=search], .field textarea { text-transform: uppercase; }
.field input[type=email], .field input[name$=email], .field input[name=username], .field input[name=payee_pix_key],
.field input[name=color], [data-keep-case], [data-keep-case] input { text-transform: none; }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { text-transform: none; }
.field textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; }
.field select, select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23999' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.field select option { background: var(--surface-solid); color: var(--text); }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--text-faint); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field input[type=color] { width: 64px; height: 40px; padding: 4px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--input-bg); cursor: pointer; }
.field input[type=file] { font: inherit; color: var(--text-muted); }
.field input[type=file]::file-selector-button { font: inherit; margin-right: 12px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; }
.field .help { font-size: var(--fs-xs); color: var(--text-faint); }
.field .error { font-size: var(--fs-xs); color: var(--danger); font-weight: 500; }
.field.has-error input, .field.has-error select, .field.has-error textarea, .is-invalid { border-color: var(--danger) !important; }
.is-valid { border-color: color-mix(in srgb, var(--success) 70%, transparent) !important; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--brand-500); }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: var(--fs-sm); pointer-events: none; }
.input-group input { padding-left: 38px !important; }
.form-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; padding-top: var(--sp-5); margin-top: var(--sp-5); border-top: 1px solid var(--border); flex-wrap: wrap; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset-title { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 600; grid-column: span 12; margin-top: var(--sp-3); padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.segmented { display: inline-flex; align-self: flex-start; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; }
.segmented label { padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 550; color: var(--text-muted); transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + span { color: var(--accent-contrast); }
.segmented label:has(input:checked) { background: var(--accent); color: var(--accent-contrast); }
.segmented label:has(input:focus-visible) { box-shadow: var(--focus); }
.net-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.net-preview strong { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; color: var(--accent-text); }

/* Filtros */
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; padding: var(--sp-4) var(--sp-5); }
.filters .field { min-width: 150px; flex: 1 1 150px; }
.filters .field.wide { flex: 2 1 240px; }
.filters .field input, .filters .field select { height: 36px; }
.filters .actions { display: flex; gap: 8px; }

/* Tabelas */
.table-wrap { overflow: auto; max-height: 68vh; border-radius: var(--radius-lg); }
.table-wrap.no-max { max-height: none; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-solid); color: var(--text-muted);
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
}
.table thead th a { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.table tbody tr:nth-child(even) td { background: var(--zebra); }
.table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.table tbody tr:hover td { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .r, .table th.r { text-align: right; }
.table .c { text-align: center; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn, .table .actions form { margin-left: 4px; }
.table .actions form { display: inline; }
.table tr.group td { background: var(--accent-soft) !important; font-weight: 600; color: var(--text); }
.table tr.subtotal td { font-weight: 600; background: var(--surface-2) !important; }
.table tr.total td { font-weight: 700; background: var(--accent-soft) !important; border-top: 2px solid var(--accent); }
.table tfoot td { font-weight: 650; background: var(--surface-solid); position: sticky; bottom: 0; }
.table .strong { font-weight: 600; color: var(--text); }
.table .sub { display: block; font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }
.cell-title { font-weight: 550; color: var(--text); }
.empty { text-align: center; padding: 48px 16px !important; color: var(--text-muted); }
.empty svg { width: 36px; height: 36px; color: var(--text-faint); display: block; margin: 0 auto 10px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--info-bg); color: var(--info); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-aberto { background: var(--info-bg); color: var(--info); }
.badge-vencido { background: var(--danger-bg); color: var(--danger); }
.badge-pago { background: var(--success-bg); color: var(--success); }
.badge-parcial { background: var(--warning-bg); color: var(--warning); }
.badge-cancelado { background: transparent; color: var(--text-faint); border: 1px dashed var(--border-strong); text-decoration: line-through; }
.badge-brand { background: var(--accent-soft); color: var(--accent-text); }
.badge-in { background: var(--success-bg); color: var(--success); }
.badge-out { background: var(--danger-bg); color: var(--danger); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 8px; box-shadow: 0 0 0 3px rgba(255,255,255,.04); }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }

/* Paginação */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.cur { min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: 8px; color: var(--text-muted); border: 1px solid transparent; }
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination span.cur { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); font-weight: 600; }

/* Detalhes (definition list) */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-4) var(--sp-6); margin: 0; }
.dl dt { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; }
.dl dd { margin: 4px 0 0; font-weight: 500; word-break: break-word; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 60;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; opacity: 0; transform: translateY(-4px) scale(.98); pointer-events: none; transform-origin: top right;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-menu a, .dropdown-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu svg { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-menu .head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-trigger { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: var(--radius-pill); background: transparent; border: 1px solid transparent; color: var(--text); cursor: pointer; font: inherit; }
.user-trigger:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: var(--fs-sm); color: var(--accent-contrast); background: linear-gradient(135deg, var(--brand-400), var(--brand-700)); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px color-mix(in srgb, var(--accent) 50%, transparent); }
.user-name { font-weight: 550; font-size: var(--fs-sm); }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-strong); color: var(--text-faint); background: var(--surface); }

/* Modais */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; visibility: hidden; opacity: 0; transition: opacity var(--t) var(--ease), visibility var(--t); }
.modal.open { visibility: visible; opacity: 1; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 16, .62); backdrop-filter: blur(4px); }
.modal-dialog { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.98); transition: transform var(--t-slow) var(--ease); }
.modal.open .modal-dialog { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-head h2 { font-size: var(--fs-md); margin: 0; }
.modal-body { padding: 18px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 14px 14px 14px 16px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); border-left: 3px solid var(--info); animation: toast-in var(--t-slow) var(--ease); }
.toast.leaving { animation: toast-out var(--t) var(--ease) forwards; }
.toast svg { width: 18px; height: 18px; margin-top: 1px; }
.toast .msg { flex: 1; font-size: var(--fs-sm); }
.toast button { background: none; border: 0; color: var(--text-faint); cursor: pointer; padding: 2px; border-radius: 6px; }
.toast-success { border-left-color: var(--success); } .toast-success svg { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error svg { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); } .toast-warning svg { color: var(--warning); }
.toast-info svg { color: var(--accent-text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* Skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 10px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent); animation: shimmer 1.4s infinite; }
:root[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .8), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.chart-box { position: relative; height: 300px; }
.chart-box .skeleton { position: absolute; inset: 0; }
.chart-box.small { height: 260px; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px var(--sp-6); border-top: 1px solid var(--border); transition: background-color var(--t-fast) var(--ease); }
.list li:hover { background: var(--surface-hover); }
.list .meta { flex: 1; min-width: 0; }
.list .meta .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; color: var(--text); }
.list .meta .s { font-size: var(--fs-xs); color: var(--text-faint); }
.list .when { text-align: right; font-size: var(--fs-xs); color: var(--text-muted); }
.list .amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--warning-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
.callout svg { color: var(--warning); width: 18px; height: 18px; margin-top: 2px; }
.callout.danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.callout.danger svg { color: var(--danger); }

.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-600), var(--brand-400)); border-radius: inherit; transition: width var(--t-slow) var(--ease); }

.report-card { display: flex; flex-direction: column; gap: 10px; padding: var(--sp-5) var(--sp-6); color: var(--text); }
.report-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); transform: translateY(-2px); text-decoration: none; }
.report-card .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.report-card p { color: var(--text-muted); margin: 0; font-size: var(--fs-sm); }

.tabs-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.color-swatch { width: 22px; height: 22px; border-radius: 7px; display: inline-block; vertical-align: middle; border: 1px solid var(--border-strong); }
.perm-yes { color: var(--success); font-weight: 700; }
.perm-no { color: var(--text-faint); }

/* ---------------------------------------------------------------- calendário (campos de data) */
input[data-mask="date"] {
  cursor: pointer;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238A94A8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.datepicker {
  position: fixed; z-index: 150; width: 288px; padding: 12px;
  background: var(--surface-solid); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); user-select: none;
}
.datepicker button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 8px; }
.datepicker button:hover { background: var(--surface-2); }
.datepicker button:focus-visible { outline: none; box-shadow: var(--focus); }
.dp-header { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 8px; }
.dp-title { display: flex; gap: 2px; }
.dp-head { padding: 6px 10px; font-weight: 600; font-size: var(--fs-base); }
.dp-range { padding: 6px 10px; font-weight: 600; font-size: var(--fs-base); }
.dp-nav { width: 32px; height: 32px; font-size: 1.25rem; line-height: 1; color: var(--text-muted); }
.dp-grid { display: grid; gap: 2px; }
.dp-days { grid-template-columns: repeat(7, 1fr); }
.dp-months { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-wd { text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint); padding: 4px 0; }
.dp-days .dp-cell { height: 34px; }
.dp-months .dp-cell { height: 44px; }
.dp-cell.is-today { box-shadow: inset 0 0 0 1px var(--accent); }
.datepicker .dp-cell.is-selected { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.dp-footer { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.dp-link { padding: 6px 10px; color: var(--accent-text); font-weight: 600; }
