.card {
  background: linear-gradient(180deg, rgba(19,34,53,.92), rgba(12,24,38,.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card__title { margin: 0; font-size: 15px; }
.card__body { padding: 16px 18px 18px; }
.card--compact .card__body { padding-top: 10px; }

.kpi-card { position: relative; overflow: hidden; padding: 18px; min-height: 126px; }
.kpi-card::after { content: ""; position: absolute; inset: auto -20% -60% 40%; height: 90px; border-radius: 50%; filter: blur(30px); opacity: .18; background: var(--accent, var(--yellow)); }
.kpi-card__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kpi-card__label { color: var(--soft); font-weight: 700; font-size: 14px; }
.kpi-card__icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: color-mix(in srgb, var(--accent, var(--yellow)) 16%, transparent); color: var(--accent, var(--yellow)); border: 1px solid color-mix(in srgb, var(--accent, var(--yellow)) 30%, transparent); }
.kpi-card__value { margin: 14px 0 8px; font-size: clamp(22px, 2.3vw, 31px); font-weight: 800; letter-spacing: -.04em; }
.kpi-card__meta { color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; border: 1px solid transparent; padding: 12px 16px;
  color: var(--text); background: var(--panel); transition: .18s ease; text-decoration: none;
  min-height: 42px;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn--primary { color: #101010; background: linear-gradient(180deg, #ffd26a, #f0a91b); font-weight: 800; }
.btn--success { background: linear-gradient(180deg, #1e8f52, #156a3e); font-weight: 800; }
.btn--danger { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.btn--ghost { border-color: var(--line-strong); background: rgba(255,255,255,.04); }
.btn--small { min-height: 34px; padding: 8px 11px; font-size: 13px; }
.btn--wide { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--soft); }

.status-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px; padding: 6px 10px; font-weight: 800; font-size: 11px; border: 1px solid currentColor;
  width: max-content; max-width: 100%; line-height: 1.15;
}
.status-pill--success, .status-accounted { color: #86efac; background: rgba(34,197,94,.14); }
.status-pending_accounting { color: #fde68a; background: rgba(250,204,21,.14); }
.status-conflict { color: #fdba74; background: rgba(249,115,22,.15); }
.status-excluded { color: #fca5a5; background: rgba(239,68,68,.14); }
.status-pending_bank { color: #93c5fd; background: rgba(59,130,246,.14); }
.status-review { color: #d8b4fe; background: rgba(168,85,247,.12); }
.status-cash { color: #d8b4fe; background: rgba(168,85,247,.15); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-btn { border: 1px solid var(--line); background: rgba(255,255,255,.035); color: var(--muted); border-radius: 999px; padding: 9px 12px; }
.tab-btn.is-active { color: #111827; background: var(--yellow); border-color: var(--yellow); font-weight: 800; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.input, .select, .textarea {
  width: 100%; color: var(--text); background: rgba(255,255,255,.045); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 12px 13px; outline: none; min-height: 44px;
}
.input:focus, .select:focus, .textarea:focus { border-color: rgba(245,185,66,.6); box-shadow: 0 0 0 3px rgba(245,185,66,.12); }
.textarea { min-height: 92px; resize: vertical; }
.field { display: grid; gap: 7px; }
.field label { color: var(--soft); font-size: 13px; font-weight: 700; }
.field small { color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 9px; color: var(--soft); }
.switch input { width: 17px; height: 17px; accent-color: var(--yellow); }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: grid; gap: 10px; }
.toast { max-width: 420px; background: #101c2b; border: 1px solid var(--line-strong); border-left: 4px solid var(--yellow); border-radius: 14px; padding: 13px 14px; box-shadow: var(--shadow); color: var(--text); }
.toast--success { border-left-color: var(--green); }
.toast--danger { border-left-color: var(--red); }
.toast--info { border-left-color: var(--blue); }

.empty-state { padding: 34px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 18px; }
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-list { display: grid; gap: 8px; }
.quick-list__item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.quick-list__item:last-child { border-bottom: 0; }
.quick-list__label { color: var(--muted); }
.quick-list__value { font-weight: 800; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, rgba(245,185,66,.12), transparent 32%), rgba(3,10,19,.88);
  backdrop-filter: blur(12px);
  padding: 24px;
}
.auth-gate.is-hidden { display: none; }
.auth-gate__card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(19,34,53,.96), rgba(10,21,34,.98));
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 30px;
  display: grid;
  gap: 16px;
  text-align: center;
}
.auth-gate__logo { width: 64px; height: 64px; margin: 0 auto 4px; }
.auth-gate__eyebrow { color: var(--yellow); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; margin: 0; }
.auth-gate h1 { margin: 0; font-size: 30px; }
.auth-gate p { margin: 0; color: var(--soft); line-height: 1.5; }
.auth-gate small { color: var(--muted); line-height: 1.45; }
.auth-warning { color: var(--yellow); font-weight: 800; }

.alert-inline {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.alert-inline--danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.10);
  color: #fecaca;
}

/* V9 — selects/dropdowns integrados en tema oscuro */
.input, .select, .textarea, .period-control select {
  color-scheme: dark;
  background-color: #101c2b;
}
.select option, .period-control select option {
  background: #101c2b;
  color: #eef5ff;
}
.select option:checked, .period-control select option:checked {
  background: #1f6feb;
  color: #ffffff;
}
.select option:disabled, .period-control select option:disabled {
  color: #64748b;
  background: #0d1826;
}
.section-eyebrow {
  display: inline-block;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .09em;
  margin-bottom: 6px;
}
.movement-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.movement-kpi h2 {
  margin: 6px 0 2px;
  font-size: clamp(22px, 2vw, 30px);
  letter-spacing: -.04em;
}
.movement-kpi small { color: var(--muted); }
.movements-header { align-items: center; }
.movements-card__head { align-items: flex-start; }
.movements-card__subtitle { margin: 6px 0 0; }
.search-input { width: min(360px, 100%); }
.type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid currentColor;
  line-height: 1;
}
.type-pill--income { color: #86efac; background: rgba(34,197,94,.13); }
.type-pill--expense { color: #fca5a5; background: rgba(239,68,68,.13); }

/* V10 — resumen contextual y controles sin desplegable nativo */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.choice-grid--four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.choice-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.045);
  color: var(--soft);
  font-weight: 800;
  cursor: pointer;
  transition: .16s ease;
}
.choice-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.choice-pill:hover {
  border-color: rgba(245,185,66,.48);
  background: rgba(245,185,66,.08);
}
.choice-pill:has(input:checked) {
  color: #111827;
  background: var(--yellow);
  border-color: var(--yellow);
}
@media (max-width: 720px) {
  .choice-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* V12 — panel de configuración de categorías */
.category-admin-card .card__body { padding-top: 0; }
.category-admin-list { display: grid; gap: 9px; }
.category-admin-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.4fr) 115px 80px auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.input--small { min-height: 38px; padding: 8px 10px; }
.input--color { font-family: var(--font-mono, monospace); }
.input--order { max-width: 80px; }
.danger-soft { color: #fca5a5; border-color: rgba(239,68,68,.26); }
.category-create-form { align-items: end; }
@media (max-width: 1000px) {
  .category-admin-row { grid-template-columns: 1fr; }
  .input--order { max-width: none; }
}

/* V13 — categorías configurables sin códigos crudos */
.category-create-card .card__head { align-items: flex-start; }
.category-help { margin: 5px 0 0; max-width: 980px; line-height: 1.45; }
.color-picker-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  padding: 8px 10px;
}
.color-picker-field__text { color: var(--soft); font-weight: 800; }
.input--color-picker {
  width: 52px;
  min-width: 52px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.input--color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.input--color-picker::-webkit-color-swatch { border: 1px solid var(--line-strong); border-radius: 10px; }
.input--color-picker::-moz-color-swatch { border: 1px solid var(--line-strong); border-radius: 10px; }
.category-admin-row {
  grid-template-columns: minmax(160px, .9fr) minmax(210px, 1.3fr) 82px 92px auto auto;
  align-items: end;
}
.mini-field {
  display: grid;
  gap: 5px;
}
.mini-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.mini-field--color .input--color-picker { width: 58px; }
.category-admin-pill { align-self: center; }
.inline-edit--wide {
  min-width: 250px;
}
.inline-edit--wide .inline-edit__input {
  min-width: 190px;
}
@media (max-width: 1000px) {
  .category-admin-row { grid-template-columns: 1fr; align-items: stretch; }
}

/* V14 — aviso no bloqueante para categorías cuando Firestore deniega esa colección */
.inline-error {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid rgba(239, 68, 68, 0.42);
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.10);
  color: #fecaca;
  font-size: 13px;
  line-height: 1.4;
}


.kpi-card--income-breakdown { min-height: 172px; }
.kpi-card--income-breakdown .kpi-card__value { margin-bottom: 4px; }
.kpi-card__breakdown {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: grid;
  gap: 8px;
}
.kpi-card__detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.kpi-card__detail strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.kpi-card__detail--highlight span { color: var(--soft); font-weight: 700; }
.kpi-card__detail--highlight strong { color: var(--green); font-size: 15px; }

/* V18 — gestoría/cierres */
.gestoria-panel { gap: 12px; }
.gestoria-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-note {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(245, 185, 66, .26);
  background: rgba(245, 185, 66, .08);
  color: var(--soft);
  line-height: 1.45;
}
.closure-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
  display: grid;
  gap: 8px;
}
.closure-summary > strong { color: var(--green); }
.closure-summary > span { color: var(--muted); }
.taxes-page .status-summary-grid { margin-top: 4px; }
.taxes-page .fiscal-rule-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }


.treasury-payments-card .gestoria-actions { margin-bottom: 10px; }
.treasury-payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}
.treasury-payment-row__amounts {
  display: grid;
  gap: 2px;
  text-align: right;
}
.treasury-payment-row__amounts small {
  color: var(--muted);
  font-size: 11px;
}
.inline-note {
  border: 1px solid rgba(245,185,66,.22);
  border-radius: 14px;
  padding: 12px;
  background: rgba(245,185,66,.08);
  color: var(--soft);
  line-height: 1.45;
}
.inline-error {
  border: 1px solid rgba(239,68,68,.32);
  border-radius: 14px;
  padding: 12px;
  background: rgba(239,68,68,.10);
  color: #fecaca;
  line-height: 1.45;
}

.closure-main-card {
  border-color: rgba(250, 193, 21, .35);
  box-shadow: 0 0 0 1px rgba(250, 193, 21, .08), 0 18px 55px rgba(0,0,0,.18);
}
.attachment-list-mini {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  font-size: 12px;
}
.attachment-chip a { color: var(--yellow); text-decoration: none; font-weight: 700; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--red-soft, #ff9b9b);
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}

/* V39 · Backup rápido + disaster recovery */
.backup-choice-grid { align-items: stretch; }
.backup-card { height: 100%; }
.backup-card .card__body { display: grid; gap: 12px; align-content: start; height: 100%; }
.backup-card .card__body .btn, .backup-card .card__body .input { margin-top: auto; }
.backup-card--full { border-color: rgba(245,185,66,.34); background: linear-gradient(180deg, rgba(245,185,66,.06), rgba(15,28,43,.98)); }
.backup-progress-card { border-color: rgba(59,130,246,.32); }
.backup-progress-card[hidden] { display: none !important; }

/* V45 — backup/restauración directa desde la barra superior */
.backup-menu { position: relative; }
.backup-menu__toggle { white-space: nowrap; }
.backup-menu__panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 120;
  width: min(330px, calc(100vw - 32px));
  display: none;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #101c2b;
  box-shadow: 0 22px 60px rgba(0,0,0,.38);
}
.backup-menu.is-open .backup-menu__panel { display: grid; gap: 5px; }
.backup-menu__item {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 12px 13px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}
.backup-menu__item:hover { background: rgba(255,255,255,.055); border-color: var(--line); }
.backup-menu__item strong { font-size: 13px; }
.backup-menu__item span { color: var(--muted); font-size: 11px; line-height: 1.35; }
.backup-menu__item--restore { border-top: 1px solid var(--line); margin-top: 3px; }
