/* ══════════════════════════════════════════════════════════════
   impuestos.css — Impuestos page (Phase 1)
   Onboarding, régimen chip/cards, facturas upload + table.
   Reuses shared tokens from style.css; layout borrows accounts/debts.
══════════════════════════════════════════════════════════════ */

/* ─── Loading / util ─────────────────────────────────────────── */
.imp-loading { padding: 3rem 0; text-align: center; color: var(--text-tertiary); font-family: var(--font-mono); }
.imp-muted   { color: var(--text-tertiary); }
.imp-mb { margin-bottom: .75rem; }
.imp-mt { margin-top: 1rem; }
.imp-hint {
  margin-top: .4rem; font-size: .8rem; color: var(--down);
  font-family: var(--font-mono);
}
.imp-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--link); font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.imp-link:hover { color: var(--accent); }

/* Educational footnote — non-negotiable copy. */
.imp-note {
  margin-top: 1rem; font-size: .78rem; line-height: 1.5;
  color: var(--text-tertiary); font-style: italic;
  border-top: 1px dashed var(--border-subtle); padding-top: .75rem;
}
/* Page-level footer note (shows under every sub-tab, not just one panel). */
.imp-note--footer { margin-top: 1.5rem; text-align: center; }

/* ─── Régimen chip (topbar) ──────────────────────────────────── */
.regimen-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--bg-panel-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .45rem .8rem;
  color: var(--text-secondary); font-size: .85rem; cursor: pointer;
  font-family: var(--font-mono); white-space: nowrap;
}
.regimen-chip:hover { border-color: var(--accent); color: var(--text-primary); }
.regimen-chip__action { color: var(--accent); }
.regimen-chip[hidden] { display: none !important; }

/* ─── Person switcher (topbar, optional 2nd person) ──────────── */
.imp-person-switcher { display: inline-flex; align-items: center; }
.imp-person-switcher:empty { display: none; }

/* Opt-in button, shown until a second person is added. */
.imp-add-person {
  display: inline-flex; align-items: center;
  background: transparent; border: 1px dashed var(--border);
  border-radius: var(--radius-sm); padding: .45rem .8rem;
  color: var(--text-tertiary); font-size: .85rem; cursor: pointer;
  font-family: var(--font-mono); white-space: nowrap;
}
.imp-add-person:hover { border-color: var(--accent); color: var(--accent); }

/* Segmented "Persona 1 / Persona 2" control + rename/remove actions. */
.imp-person-switch {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-panel-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 2px;
}
.imp-person-tab {
  background: transparent; border: none; border-radius: calc(var(--radius-sm) - 2px);
  padding: .35rem .7rem; color: var(--text-secondary); font-size: .82rem;
  cursor: pointer; font-family: var(--font-mono); white-space: nowrap;
  max-width: 12ch; overflow: hidden; text-overflow: ellipsis;
}
.imp-person-tab:hover { color: var(--text-primary); }
.imp-person-tab.is-active { background: var(--accent); color: #fff; }
.imp-person-act {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-tertiary); font-size: .8rem; padding: .3rem .4rem;
  border-radius: calc(var(--radius-sm) - 2px); line-height: 1;
}
.imp-person-act:hover { color: var(--text-primary); background: var(--bg-panel); }
.imp-person-act--danger:hover { color: var(--down); }

/* ─── Onboarding ─────────────────────────────────────────────── */
.imp-onboarding { max-width: 860px; margin: 1rem auto 3rem; }
.imp-onboarding__inner {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow-card);
}
.imp-onboarding__title { font-family: var(--font-display); font-size: 1.6rem; margin: 0 0 .4rem; color: var(--text-primary); }
.imp-onboarding__sub { color: var(--text-secondary); margin: 0 0 1.5rem; line-height: 1.5; }
.imp-onboarding__field { margin-top: 1.25rem; max-width: 340px; }
.imp-onboarding__actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap;
}

/* ─── Régimen cards grid ─────────────────────────────────────── */
.regimen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.regimen-card {
  position: relative; text-align: left; cursor: pointer;
  background: var(--bg-panel-alt); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 1rem 1rem 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .3rem; transition: border-color .15s, background .15s;
}
.regimen-card:hover { border-color: var(--accent-dim); }
.regimen-card--selected { border-color: var(--accent); background: var(--selected); }
.regimen-card__label { font-weight: 500; color: var(--text-primary); font-size: .95rem; }
.regimen-card__desc { font-size: .8rem; color: var(--text-tertiary); line-height: 1.45; }
.regimen-card__ejemplos { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.regimen-card__ejemplo {
  font-size: .68rem; padding: .1rem .4rem; border-radius: 999px;
  background: var(--bg-panel-alt); border: 1px solid var(--border); color: var(--text-tertiary);
}
.regimen-card__check {
  position: absolute; top: .6rem; right: .6rem; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); color: #fff;
  display: none; align-items: center; justify-content: center; font-size: .7rem;
}
.regimen-card--selected .regimen-card__check { display: flex; }

/* ─── Explainer ──────────────────────────────────────────────── */
.imp-explainer {
  margin-top: 1.5rem; padding: 1.25rem; background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
}
.imp-explainer__title { font-family: var(--font-display); font-size: 1.15rem; margin: 0 0 .5rem; color: var(--text-primary); }
.imp-explainer__p { color: var(--text-secondary); line-height: 1.55; margin: 0 0 1rem; font-size: .9rem; }
.imp-explainer__list { display: flex; flex-direction: column; gap: .6rem; }
.imp-explainer__item { display: flex; flex-direction: column; gap: .1rem; }
.imp-explainer__name { font-weight: 500; color: var(--text-primary); font-size: .88rem; }
.imp-explainer__text { color: var(--text-tertiary); font-size: .82rem; line-height: 1.45; }

/* ─── Tabs (match the shared pill bar used on Pasivos) ───────── */
.imp-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.imp-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.imp-tabs-row__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.imp-tabs-row__actions[hidden] { display: none !important; }
.imp-tabs {
  width: max-content;
  max-width: 100%;
  margin: 0;
}
.imp-tabs .tab {
  font-size: 12px;
  padding: 7px 18px;
  letter-spacing: 0.6px;
}
/* Each tab panel restores the column layout + gap that .main gives its own
   direct children (the panels here are nested a level deeper). */
.imp-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.imp-tab-panel[hidden] { display: none !important; }

/* ─── "Próximamente" panels ──────────────────────────────────── */
.imp-soon__msg { color: var(--text-secondary); line-height: 1.55; margin: .5rem 0 0; }

/* ─── Dropzone ───────────────────────────────────────────────── */
.imp-dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
  background: var(--bg-panel-alt); padding: 1.75rem; text-align: center;
  transition: border-color .15s, background .15s;
}
.imp-dropzone--over { border-color: var(--accent); background: var(--selected); }
.imp-dropzone__icon { font-size: 1.6rem; color: var(--accent); }
.imp-dropzone__text { margin-top: .5rem; color: var(--text-primary); }
.imp-dropzone__hint { margin-top: .3rem; font-size: .8rem; color: var(--text-tertiary); }
.imp-upload-status {
  margin-top: 1rem; padding: .7rem .9rem; border-radius: var(--radius-sm);
  font-size: .85rem; font-family: var(--font-mono); text-align: left;
}
.imp-upload-status--busy { background: var(--bg-panel); color: var(--text-secondary); }
.imp-upload-status--ok   { background: var(--up-dim); color: var(--up); }
.imp-upload-status--warn { background: var(--warn); color: var(--text-primary); }
.imp-upload-fails { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .8rem; }
.imp-upload-fails li { margin: .15rem 0; }
.imp-us-chip {
  display: inline-block; padding: .15rem .5rem; margin-right: .35rem; border-radius: var(--radius-sm);
  font-size: .8rem; cursor: default;
}
.imp-us-chip--dup { background: var(--bg-panel-alt); color: var(--text-secondary); border: 1px dashed var(--border); cursor: help; }
.imp-us-chip--ok, .imp-us-chip--fail { background: transparent; padding-left: 0; }
.imp-us-chip--fail { color: var(--down); }

/* ─── Summary KPI grid (3-up, e.g. Facturas tab) ─────────────── */
.accounts-kpi-grid--3 { grid-template-columns: 1.4fr 1fr 1fr; }
@media (max-width: 1100px) { .accounts-kpi-grid--3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px)  { .accounts-kpi-grid--3 { grid-template-columns: 1fr; } }

/* ─── Filters toolbar ────────────────────────────────────────── */
.imp-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 45px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}
.imp-filters__lead {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding-right: 10px;
  margin-right: 2px;
  border-right: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.imp-filters__lead svg { width: 13px; height: 13px; }

.imp-filters__field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Compact pill selects (mirror .cat-filter-select) */
.imp-select {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px 26px 6px 10px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, color 0.15s;
  /* custom caret so all browsers match */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}
.imp-select:hover, .imp-select:focus { border-color: var(--accent); color: var(--text-primary); }

/* Search field with leading icon */
.imp-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 180px;
  min-width: 150px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  transition: border-color 0.15s;
}
.imp-search:focus-within { border-color: var(--accent); }
.imp-search svg { width: 14px; height: 14px; color: var(--text-tertiary); flex: 0 0 auto; }
.imp-search input {
  border: none; background: transparent; outline: none;
  color: var(--text-primary); font-family: var(--font-body); font-size: 12px;
  width: 100%; padding: 0;
}
.imp-search input::placeholder { color: var(--text-tertiary); }

.imp-filters__clear {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.imp-filters__clear:hover { border-color: var(--down); color: var(--down); }
.imp-filters__clear[hidden] { display: none !important; }

/* ─── Table ──────────────────────────────────────────────────── */
.imp-table-panel { padding: 0; overflow: hidden; }
/* Panel padding is zeroed above for an edge-to-edge table, but that leaves
   the title flush against the card corner — restore it on the header only,
   matching the .panel--table pattern used elsewhere (style.css). */
.imp-table-panel .panel__header { padding: 18px 24px 0; margin-bottom: 16px; }
.imp-table-wrap { overflow-x: auto; }
.imp-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.imp-table thead th {
  text-align: left; padding: .8rem 1rem; font-size: .72rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-tertiary);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.imp-table tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.imp-table tbody tr:hover { background: var(--bg-hover); }
.imp-th--sortable { cursor: pointer; user-select: none; }
.imp-th--sortable:hover { color: var(--text-secondary); }
.imp-th--sortable::after { content: '↕'; margin-left: .35em; opacity: .35; font-size: .9em; }
.imp-th--sort-asc::after { content: '↑'; opacity: 1; color: var(--text-primary); }
.imp-th--sort-desc::after { content: '↓'; opacity: 1; color: var(--text-primary); }
.imp-num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
/* Desglose mensual + Recibos de nómina: numeric columns centered instead of
   right-aligned (scoped here so other tables keep the default right-align). */
#n-meses-panel .imp-num, #n-table .imp-num { text-align: center; }
.imp-center { text-align: center; }
.imp-nowrap { white-space: nowrap; }
.imp-desc { max-width: 260px; color: var(--text-secondary); }
.imp-table__empty { text-align: center; color: var(--text-tertiary); padding: 2rem 1rem; }

/* ─── Pagination (mirrors transactions.css — not loaded on this page) ─── */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px 16px; border-top: 1px solid var(--border-subtle);
  margin-top: 4px; gap: 12px; flex-wrap: wrap;
}
.pg-range { font-size: 12px; font-family: var(--font-mono); color: var(--text-tertiary); }
.pg-controls { display: flex; align-items: center; gap: 4px; }
.pg-btn {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  font-family: var(--font-mono); font-size: 13px; cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s; line-height: 1;
}
.pg-btn:hover:not(:disabled):not(.pg-btn--active) { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.pg-btn--active { background: var(--accent); color: #fff; border-color: var(--accent); cursor: default; }
.pg-btn--nav { font-size: 16px; }
.pg-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pg-ellipsis { color: var(--text-tertiary); font-size: 13px; padding: 0 4px; user-select: none; }

.imp-emisor { display: flex; align-items: center; gap: .4rem; }
.imp-emisor__name { color: var(--text-primary); }
.imp-emisor__link {
  background: none; border: none; padding: 0; text-align: left; cursor: pointer;
  font: inherit; color: var(--text-primary); border-bottom: 1px dashed transparent;
}
.imp-emisor__link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.imp-emisor__rfc { font-size: .74rem; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: .15rem; }

/* Tipo badge */
.tipo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: var(--radius-sm);
  font-size: .7rem; font-weight: 600; font-family: var(--font-mono);
  background: var(--bg-panel-alt); color: var(--text-secondary); border: 1px solid var(--border);
}
.tipo-badge--N { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-dim); }
.tipo-badge--E { background: var(--down-dim); color: var(--down); }

/* Uso CFDI badge */
.uso-badge {
  display: inline-block; padding: .2rem .5rem; border-radius: var(--radius-sm);
  font-size: .72rem; font-family: var(--font-mono);
  background: var(--bg-panel-alt); color: var(--text-secondary); border: 1px solid var(--border);
}
.uso-badge--ded { background: var(--up-dim); color: var(--up); border-color: transparent; }

/* Deducible dot */
.ded-dot {
  width: 12px; height: 12px; border-radius: 50%; border: none; cursor: pointer;
  padding: 0; display: inline-block; vertical-align: middle;
}
.ded-dot--on  { background: var(--up); box-shadow: 0 0 0 3px var(--up-dim); }
.ded-dot--off { background: var(--border); }
.ded-dot:hover { outline: 2px solid var(--accent-dim); outline-offset: 2px; }
.ded-dot--blocked {
  width: 16px; height: 16px; border-radius: 50%; border: none; cursor: help;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--down-dim); color: var(--down); font-size: .6rem; line-height: 1;
}

/* Row actions */
.imp-actions { white-space: nowrap; }
.imp-icon-btn {
  background: var(--bg-panel-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .25rem .5rem; margin: 0 .1rem;
  font-size: .72rem; font-family: var(--font-mono); color: var(--text-secondary); cursor: pointer;
}
.imp-icon-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.imp-icon-btn--danger:hover { border-color: var(--down); color: var(--down); }

/* ─── Empty state ────────────────────────────────────────────── */
.imp-empty { text-align: center; padding: 3rem 1.5rem; }
.imp-empty__icon { font-size: 2rem; color: var(--text-tertiary); }
.imp-empty__title { font-family: var(--font-display); font-size: 1.25rem; margin: .5rem 0 .3rem; color: var(--text-primary); }
.imp-empty__msg { color: var(--text-secondary); max-width: 420px; margin: 0 auto 1rem; line-height: 1.5; }
.imp-empty__cta { display: inline-block; margin-top: .25rem; }
.imp-donde {
  max-width: 460px; margin: 1rem auto 0; text-align: left;
  background: var(--bg-panel-alt); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 1rem 1.25rem; font-size: .85rem; color: var(--text-secondary);
}
.imp-donde ol { margin: .5rem 0 0; padding-left: 1.2rem; line-height: 1.6; }

/* ─── Modal actions ──────────────────────────────────────────── */
.modal__actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }

/* ─── Factura viewer modal (details + embedded PDF) ──────────── */
.imp-factura-modal { width: 940px; }
.imp-fm-body { display: flex; gap: 1.25rem; align-items: stretch; }
.imp-fm-details { flex: 0 0 280px; min-width: 0; }
.imp-fm-details__list { margin: 0; display: flex; flex-direction: column; gap: .7rem; }
.imp-fm-detail { display: flex; flex-direction: column; gap: .1rem; }
.imp-fm-detail__label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary);
}
.imp-fm-detail__val { margin: 0; color: var(--text-primary); font-size: .9rem; word-break: break-word; }
.imp-fm-detail__val--mono { font-family: var(--font-mono); }
.imp-fm-detail__sub {
  display: block; font-size: .74rem; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: .1rem;
}

.imp-fm-viewer {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .6rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-panel-alt); overflow: hidden;
}
.imp-fm-frame { width: 100%; flex: 1 1 auto; min-height: 62vh; border: none; background: #fff; }
.imp-fm-viewer-actions { display: flex; justify-content: flex-end; padding: .5rem .6rem; }
.imp-fm-loading, .imp-fm-nopdf {
  flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; text-align: center; padding: 2rem 1.5rem; min-height: 62vh; color: var(--text-secondary);
}
.imp-fm-nopdf__icon { font-size: 2rem; }
.imp-fm-nopdf__title { color: var(--text-primary); font-weight: 500; margin: 0; }
.imp-fm-nopdf__msg { max-width: 320px; line-height: 1.5; margin: 0 0 .4rem; font-size: .85rem; }

@media (max-width: 720px) {
  .imp-fm-body { flex-direction: column; }
  .imp-fm-details { flex-basis: auto; }
  .imp-fm-frame, .imp-fm-loading, .imp-fm-nopdf { min-height: 52vh; }
}

/* ─── Responsive (380px pass) ────────────────────────────────── */
@media (max-width: 640px) {
  .imp-onboarding__inner { padding: 1.25rem; }
  .regimen-grid { grid-template-columns: 1fr; }
  .imp-select { flex: 1 1 45%; }
  .imp-search { flex: 1 1 100%; }
  .imp-desc { max-width: 160px; }
}

/* ─── Nómina tab ─────────────────────────────────────────────── */
.kpi__value--pos { color: var(--up); }
.kpi__value--neg { color: var(--down); }

/* Shared with the Deducciones tab's "tope" methodology note. */
.imp-proyeccion__metodo { margin: .75rem 0 0; font-size: .8rem; color: var(--text-tertiary); line-height: 1.5; }

/* Recibos table extras */
#tab-nomina .imp-table-panel { margin-top: 1rem; }
.origen-badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .68rem; font-family: var(--font-mono); letter-spacing: .03em;
  border: 1px solid var(--border); color: var(--text-secondary); background: var(--bg-panel-alt);
}
.origen-badge--cfdi { border-color: var(--accent-dim); color: var(--accent); }
.imp-empty__actions { display: flex; gap: .6rem; margin-top: .75rem; flex-wrap: wrap; justify-content: center; }

/* Recibo modal */
.imp-recibo-modal { max-width: 560px; width: 100%; }
.imp-recibo-form { display: flex; flex-direction: column; gap: .8rem; }
/* Without this, `display: flex` above beats the browser's default
   `[hidden] { display: none }` UA rule (author styles win over UA styles
   regardless of specificity) — pr-factura-fields and pr-nomina-fields would
   both render at once instead of toggling with .hidden. */
.imp-recibo-form[hidden] { display: none !important; }
.imp-recibo-form__row { display: flex; gap: .75rem; }
.imp-recibo-form__row > .form-group { flex: 1; }
.imp-hint--info { color: var(--text-tertiary); }
.imp-recibo-neto {
  border-top: 1px dashed var(--border); padding-top: .7rem;
  font-size: .85rem; color: var(--text-secondary);
}
.imp-recibo-neto strong { font-family: var(--font-mono); color: var(--text-primary); font-weight: 500; }

.imp-recibo-deposit { margin-top: .7rem; }
.imp-recibo-deposit .form-group { margin-top: .6rem; }

@media (max-width: 640px) {
  .imp-recibo-form__row { flex-direction: column; gap: .8rem; }
}

/* ─── Deducciones tab ────────────────────────────────────────────── */
.imp-tope-panel { margin-top: 1rem; }
.imp-tope-bar-wrap { margin-top: .75rem; }
.imp-tope-bar {
  height: 10px; border-radius: 999px; background: var(--bg-panel-alt);
  border: 1px solid var(--border); overflow: hidden;
}
.imp-tope-bar__fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.imp-tope-bar__fill--over { background: var(--down); }
.imp-tope-bar__labels {
  display: flex; justify-content: space-between; margin-top: .4rem;
  font-size: .78rem; color: var(--text-secondary); font-family: var(--font-mono);
}
#tab-deducciones .imp-table-panel { margin-top: 1rem; }

/* ─── Calendario tab ─────────────────────────────────────────────── */
.imp-banner {
  border-left: 3px solid var(--accent); padding: .9rem 1.1rem;
}
.imp-banner--warn { border-left-color: var(--warn, var(--down)); }
.imp-banner--muted { border-left-color: var(--border); }
.imp-banner__title { font-weight: 500; color: var(--text-primary); margin-bottom: .3rem; }
.imp-banner__body { font-size: .85rem; color: var(--text-secondary); line-height: 1.5; margin: 0; }

.imp-cal-list { display: flex; flex-direction: column; gap: .1rem; }
.imp-cal-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem 0; border-bottom: 1px solid var(--border);
}
.imp-cal-item:last-child { border-bottom: none; }
.imp-cal-item__icon {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-panel-alt); border: 1px solid var(--border); color: var(--accent); font-size: .85rem;
}
.imp-cal-item__body { flex: 1 1 auto; min-width: 0; }
.imp-cal-item__label { font-weight: 500; color: var(--text-primary); font-size: .9rem; }
.imp-cal-item__nota { font-size: .78rem; color: var(--text-tertiary); margin-top: .15rem; line-height: 1.4; }
.imp-cal-item__fecha {
  flex: 0 0 auto; font-family: var(--font-mono); font-size: .82rem; color: var(--text-secondary);
  white-space: nowrap; padding-left: .5rem;
}

/* ─── Optimización tab ───────────────────────────────────────────── */
.imp-opt-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .9rem;
}
.imp-opt-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-panel); padding: 1rem 1.1rem;
}
.imp-opt-card__title { font-weight: 500; color: var(--text-primary); margin-bottom: .4rem; }
.imp-opt-card__body { font-size: .84rem; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.imp-opt-card__stat {
  margin-top: .6rem; font-size: .82rem; color: var(--text-secondary);
  font-family: var(--font-mono);
}
.imp-opt-card__stat strong { color: var(--text-primary); font-weight: 500; }
.imp-opt-card__alertas {
  margin: .6rem 0 0; padding-left: 1.1rem; font-size: .78rem; color: var(--text-tertiary); line-height: 1.5;
}
.imp-opt-card__alertas li { margin: .2rem 0; }

@media (max-width: 640px) {
  .imp-cal-item { flex-wrap: wrap; }
  .imp-cal-item__fecha { padding-left: 0; margin-left: 44px; }
  .imp-opt-grid { grid-template-columns: 1fr; }
}

/* ─── PDF source badges (facturas + recibos, source: 'pdf') ─────────── */
.imp-pdf-badge {
  display: inline-block; padding: .1rem .4rem; margin-left: .35rem; border-radius: var(--radius-sm);
  font-size: .65rem; font-family: var(--font-mono); letter-spacing: .03em;
  background: var(--warn); color: #1a1400; vertical-align: middle;
}
.origen-badge--pdf { border-color: var(--warn); color: var(--warn); }

/* ─── PDF review modal (extract → review → confirm) ──────────────────── */
.imp-pr-status-row { display: flex; align-items: center; gap: .5rem; }
.pr-confidence-badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 999px;
  font-size: .72rem; font-family: var(--font-mono);
  border: 1px solid var(--border); background: var(--bg-panel-alt); color: var(--text-secondary);
}
.pr-confidence-badge--alta { border-color: var(--up-dim); color: var(--up); background: var(--up-dim); }
.pr-confidence-badge--media { border-color: var(--warn); color: var(--warn); background: transparent; }
.pr-validation {
  /* Sits right after .imp-recibo-form as a sibling, outside its row gap —
     needs its own top margin or it sits flush against the last row. */
  margin: .8rem 0 0; padding: .6rem .8rem; border-radius: var(--radius-sm);
  font-size: .82rem; font-family: var(--font-mono); line-height: 1.4;
}
.pr-validation--ok   { background: var(--up-dim); color: var(--up); }
.pr-validation--warn { background: var(--down-dim); color: var(--down); }

/* ─── PDF viewer (pdf.js) — dark chrome, white canvas ────────────────── */
.pdf-viewer { display: flex; flex-direction: column; }
.pdf-viewer__toolbar {
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
  padding: .5rem .9rem; border-bottom: 1px solid var(--border); background: var(--bg-panel-alt);
}
.pdf-viewer__spacer { flex: 1 1 auto; }
.pdf-viewer__page-indicator {
  font-family: var(--font-mono); font-size: .78rem; color: var(--text-secondary); white-space: nowrap;
}
.pdf-viewer__canvas-host {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px;
  display: flex; align-items: flex-start; justify-content: center;
  background: #0a0c14;
}
.pdf-viewer__canvas {
  background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.4); max-width: 100%;
}
.pdf-viewer__status {
  margin: auto; padding: 2rem 1rem; text-align: center; color: var(--text-secondary); font-size: .88rem;
}

@media (max-width: 640px) {
  .pdf-viewer__toolbar { gap: .2rem; padding: .4rem .5rem; }
  .pdf-viewer__toolbar .imp-icon-btn { padding: .25rem .4rem; font-size: .68rem; }
  .pdf-viewer__page-indicator { font-size: .7rem; }
}

/* ─── Resumen tab: fiscal equation hero + chart + retenciones + comparación ── */
.imp-resumen-missing { display: flex; flex-direction: column; gap: .4rem; }
.imp-resumen-missing[hidden] { display: none !important; }
.imp-resumen-missing__row {
  font-size: .84rem; color: var(--text-tertiary); background: var(--bg-panel-alt);
  border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .6rem .85rem;
}

/* Ghosted sample preview behind the empty state — same technique as
   .analisis-zones--ghost on Pasivos: never a forked markup path. */
.imp-resumen-zone--ghost { opacity: .45; pointer-events: none; filter: saturate(.6); user-select: none; }

/* r-zones holds every Resumen widget (hero, banners, chart, retenciones,
   comparación, links) as flat siblings — give it the same flex column + gap
   every other tab panel gets, so widgets/cards never touch. Notes nested
   directly in here already get that gap, so their own margin-top would double
   it up — zeroed out below. */
#r-zones { display: flex; flex-direction: column; gap: 20px; }
#r-zones > .imp-note,
#r-retenciones-note .imp-note { margin-top: 0; }
#r-banners:empty, #r-retenciones-note:empty, .imp-resumen-links:empty { display: none; }

/* Hero: the fiscal equation strip — 4 cells, 2×2 on mobile. */
.imp-resumen-hero {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem;
}
.imp-resumen-hero__cell {
  display: flex; flex-direction: column; gap: .3rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-panel-alt); padding: .9rem 1rem;
}
.imp-resumen-hero__cell--pos { border-color: var(--up-dim); background: var(--up-dim); }
.imp-resumen-hero__cell--neg { border-color: var(--down-dim); background: var(--down-dim); }
.imp-resumen-hero__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); }
.imp-resumen-hero__value { font-family: var(--font-mono); font-size: 1.35rem; color: var(--text-primary); }
.imp-resumen-hero__cell--pos .imp-resumen-hero__value { color: var(--up); }
.imp-resumen-hero__cell--neg .imp-resumen-hero__value { color: var(--down); }
.imp-resumen-hero__sub { font-size: .76rem; color: var(--text-tertiary); line-height: 1.4; }
.imp-resumen-hero__sub .imp-link { font-size: inherit; }

.imp-chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; min-height: 180px; color: var(--text-tertiary); font-size: .88rem;
}
/* The base rule's `display: flex` overrides the UA `[hidden]{display:none}`, so
   the `hidden` attribute alone won't hide the empty message — restore it here,
   otherwise the message stays on top of (and clips) the rendered chart. */
.imp-chart-empty[hidden] { display: none; }

/* ─── Comparar (año vs año) ──────────────────────────────────────────────── */
/* Stack the chart + table panels with the same gap the tab panels use (the
   wrapper div doesn't inherit .imp-tab-panel's flex gap on its own). */
#cmp-content { display: flex; flex-direction: column; gap: 20px; }
#cmp-content[hidden] { display: none; }
.imp-cmp-filters { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.imp-cmp-vs { color: var(--text-tertiary); font-size: .8rem; font-family: var(--font-mono); }
.imp-cmp-table th:first-child, .imp-cmp-table td:first-child { white-space: nowrap; }
/* Center the two year columns + Cambio (override .imp-num's right align). */
.imp-cmp-table th:not(:first-child), .imp-cmp-table td:not(:first-child) { text-align: center; }
.imp-cmp-delta { font-family: var(--font-mono); font-size: .82rem; white-space: nowrap; }
.imp-cmp-delta--up { color: #34d399; }   /* value went up vs. the other year */
.imp-cmp-delta--down { color: #f87171; } /* value went down vs. the other year */
.imp-cmp-delta--flat { color: var(--text-tertiary); }

/* Ingresos por mes (3/4) beside Facturas por mes (1/4, horizontal bars). */
.imp-resumen-charts-row {
  display: grid; grid-template-columns: 3fr 1fr; gap: 1rem; align-items: start;
}
@media (max-width: 900px) {
  .imp-resumen-charts-row { grid-template-columns: 1fr; }
}

/* Two columns: "Retenido vs. deberías pagar" on the left, and the two
   retenciones cards ("ISR retenido…" above "No todo…") stacked in the right
   column. */
.imp-resumen-retcompare {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem; align-items: start;
}
.imp-resumen-retcompare > #r-retenciones-row {
  display: grid; grid-template-columns: 1fr; gap: 1rem; align-content: start;
}
@media (max-width: 900px) {
  .imp-resumen-retcompare { grid-template-columns: 1fr; }
}

/* Retenciones: 2–3 compact cards side by side. */
.imp-resumen-retenciones-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem;
}
.imp-resumen-ret-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-panel); padding: 1rem 1.1rem;
}
.imp-resumen-ret-card__title { font-weight: 500; color: var(--text-primary); margin-bottom: .5rem; font-size: .9rem; }
.imp-resumen-ret-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: .6rem;
  padding: .35rem 0; border-bottom: 1px solid var(--border-subtle);
}
.imp-resumen-ret-row:last-child { border-bottom: none; }
.imp-resumen-ret-row__name { font-size: .82rem; color: var(--text-secondary); }
.imp-resumen-ret-row__rfc { font-size: .7rem; color: var(--text-tertiary); font-family: var(--font-mono); margin-left: .3rem; }
.imp-resumen-ret-row__val { font-family: var(--font-mono); font-size: .86rem; color: var(--text-primary); white-space: nowrap; }
.imp-resumen-ret-card__headline { font-family: var(--font-mono); font-size: 1.1rem; color: var(--text-primary); margin-top: .3rem; }
.imp-resumen-ret-card__explainer { font-size: .78rem; color: var(--text-tertiary); line-height: 1.45; margin-top: .5rem; }

/* Comparación: two horizontal bars, same scale. */
.imp-resumen-bars { display: flex; flex-direction: column; gap: .7rem; margin-top: .5rem; }
.imp-resumen-bar__label {
  display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-secondary);
  margin-bottom: .3rem;
}
.imp-resumen-bar__label strong { font-family: var(--font-mono); color: var(--text-primary); font-weight: 500; }
.imp-resumen-bar__track {
  height: 12px; border-radius: 999px; background: var(--bg-panel-alt); border: 1px solid var(--border); overflow: hidden;
}
.imp-resumen-bar__fill { height: 100%; border-radius: 999px; transition: width .25s ease; }
.imp-resumen-bar__fill--retenido { background: var(--accent); }
.imp-resumen-bar__fill--causado { background: var(--up); }
.imp-resumen-tasas { font-size: .84rem; color: var(--text-secondary); margin: .9rem 0 0; }
.imp-resumen-tasas strong { font-family: var(--font-mono); color: var(--text-primary); font-weight: 500; }

/* De cada MX$100 que ganas: stacked bar + 4-row table. */
.imp-resumen-100 { margin-top: 1.25rem; }
.imp-resumen-100__bar {
  display: flex; height: 22px; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border);
}
.imp-resumen-100__seg { height: 100%; }
.imp-resumen-100__seg--neto  { background: var(--up); }
.imp-resumen-100__seg--isr   { background: var(--accent); }
.imp-resumen-100__seg--imss  { background: var(--warn, #d9a441); }
.imp-resumen-100__seg--otras { background: var(--down); }
.imp-resumen-100__table { width: 100%; border-collapse: collapse; margin-top: .75rem; font-size: .85rem; }
.imp-resumen-100__table td { padding: .35rem 0; border-bottom: 1px solid var(--border-subtle); }
.imp-resumen-100__table td:last-child { text-align: right; font-family: var(--font-mono); color: var(--text-primary); }
.imp-resumen-100__dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .5rem; vertical-align: middle; }
.imp-resumen-100__dot--neto  { background: var(--up); }
.imp-resumen-100__dot--isr   { background: var(--accent); }
.imp-resumen-100__dot--imss  { background: var(--warn, #d9a441); }
.imp-resumen-100__dot--otras { background: var(--down); }

.imp-resumen-links { display: flex; flex-direction: column; gap: .1rem; }
.imp-resumen-link-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: .75rem;
  padding: .7rem 0; border-bottom: 1px solid var(--border);
  font-size: .85rem; color: var(--text-secondary);
}
.imp-resumen-link-row:last-child { border-bottom: none; }

@media (max-width: 640px) {
  .imp-resumen-hero { grid-template-columns: repeat(2, 1fr); }
  .imp-resumen-hero__value { font-size: 1.15rem; }
  .imp-resumen-100__table td:first-child { max-width: 140px; }
}
