/* ============================================================
   TEMA v2 · 67 · ALERTAS y DEUDAS  ·  Administración
   Bordó, como Gastos. Bandeja de recordatorios, avisos automáticos y cuentas pendientes.
   ============================================================ */
html[data-route="alertas"], html[data-route="deudas"] { --accent: #8e2c3a; --accent-hover: #8e2c3a; --accent-solid: #8e2c3a; --accent-solid-hover: #8e2c3a; --accent-soft: #f5dde0; --bg: #f5ecea; --hdr: #6e1f2c; }
html[data-theme="dark"][data-route="alertas"], html[data-theme="dark"][data-route="deudas"] { --accent: #e0707f; --accent-hover: #e0707f; --accent-solid: #8e2c3a; --accent-solid-hover: #8e2c3a; --accent-soft: #33161a; --bg: #150f10; --hdr: #33161a; }
#view[data-route="alertas"] .page-title, #view[data-route="deudas"] .page-title { background: var(--hdr); }
.al-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* acciones principales: Deudas bien a la vista, arriba */
.al-acciones { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.al-deudas { justify-content: center; text-align: center; white-space: normal; line-height: 1.2; }
.al-deudas-n { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; margin-left: 8px; border-radius: 999px; background: #fff; color: var(--accent-solid); font-size: 14px; font-weight: 800; }
.al-deudas-n[hidden] { display: none; }

/* alertas automáticas */
.al-auto { display: grid; gap: 8px; }
.al-auto:empty { display: none; }
.al-auto-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-left: 6px solid var(--border-strong); border-radius: 14px; background: var(--surface); }
.al-auto-main { min-width: 0; overflow-wrap: anywhere; display: grid; gap: 2px; }
.al-auto-main small { color: var(--text-muted); font-size: 12px; }
.al-auto-n { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px; text-align: center; }
.al-sev { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--surface-2); color: var(--text-muted); }
.al-sev-grave { border-left-color: #b3261e; } .al-sev-grave .al-sev { background: #b3261e; color: #fff; }
.al-sev-importante { border-left-color: #e0a800; } .al-sev-importante .al-sev { background: #e0a800; color: #1f1f1f; }
.al-sev-info { border-left-color: #3b7ea1; } .al-sev-info .al-sev { background: #3b7ea1; color: #fff; }

/* recordatorios */
.al-filtros { flex-wrap: wrap; }
.al-lista { display: grid; }
.al-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--border); }
.al-item:first-child { border-top: 0; }
.al-est-vencida { background: color-mix(in srgb, #b3261e 7%, transparent); }
.al-est-hoy { background: color-mix(in srgb, #e0a800 9%, transparent); }
.al-est-completada { opacity: .72; }
.al-est-completada .al-titulo { text-decoration: line-through; }
.al-main { min-width: 0; overflow-wrap: anywhere; display: grid; gap: 4px; }
.al-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.al-titulo { font-size: 16px; }
.al-fecha { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.al-nota { font-size: 14px; color: var(--text-muted); }
.al-acc { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.al-acc .icon-btn { min-width: 44px; min-height: 44px; }
.al-mas { border: 1px dashed var(--border-strong); border-radius: 14px; padding: 0 12px 4px; }
.al-mas > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.al-mas > .field { margin-bottom: 10px; }
.al-hist { display: grid; gap: 6px; }
.al-hist-fila { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; }

/* deudas */
.de-resumen { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: stretch; }
.de-nueva { align-self: stretch; }
.de-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.de-card { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-left: 6px solid var(--accent-solid); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); min-width: 0; }
.de-card.de-pagada { border-left-color: #2e8b57; opacity: .85; }
.de-card.de-anulada { border-left-color: var(--border-strong); opacity: .6; }
.de-card.de-vencida { border-left-color: #b3261e; }
.de-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.de-top h3 { margin: 0; font-family: var(--font-num); font-size: 24px; letter-spacing: .03em; text-transform: uppercase; overflow-wrap: anywhere; }
.de-sub { color: var(--text-muted); font-size: 13px; }
.de-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.de-nums > div { display: grid; gap: 2px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.de-nums span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.de-nums b { font-family: var(--font-num); font-size: 20px; overflow-wrap: anywhere; }
.de-nums .de-saldo { background: var(--accent-soft); } .de-nums .de-saldo b { color: var(--accent); }
.de-obs { font-size: 14px; color: var(--text-muted); overflow-wrap: anywhere; }
.de-acc { display: flex; gap: 8px; flex-wrap: wrap; }
.de-acc .btn { min-height: 44px; }

/* detalle de la venta / de la deuda */
.vd { display: grid; gap: 10px; }
.vd h4 { margin: 8px 0 0; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.vd-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-muted); font-size: 14px; }
.vd-items { display: grid; gap: 6px; }
.vd-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; overflow-wrap: anywhere; }
.vd-item small, .vd-fila small { display: block; color: var(--text-muted); font-weight: 500; }
.vd-fila { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.vd-fila.vd-anulado { text-decoration: line-through; opacity: .6; }
.vd-total b, .vd-saldo b { font-family: var(--font-num); font-size: 22px; }
.vd-saldo b { color: var(--accent); }
/* FIADO como medio de pago dentro del cobro */
.pay-row.es-fiado select { border-color: #8a6a43; background: #f3e8d6; font-weight: 800; }
.fiado-box { margin-top: 10px; padding: 10px 12px; border: 2px dashed #8a6a43; border-radius: 12px; background: #faf3e6; display: grid; gap: 8px; }
.fiado-box[hidden] { display: none; }
.fiado-box .field { margin: 0; }
.fiado-mas summary { cursor: pointer; font-size: 13px; color: var(--text-muted); min-height: 32px; display: flex; align-items: center; }
.fiado-mas .field { margin-top: 8px; }
.pay-desglose { display: grid; gap: 4px; width: 100%; }
.pay-desglose > div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.pay-desglose > div.pend { border-top: 1px solid currentColor; padding-top: 4px; font-weight: 800; }
.pay-desglose b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* contador en el menú */
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #b3261e; color: #fff; font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; }
#bn-mas.con-alertas { position: relative; }
#bn-mas.con-alertas::after { content: ""; position: absolute; top: 6px; right: calc(50% - 20px); width: 10px; height: 10px; border-radius: 50%; background: #b3261e; border: 2px solid var(--surface, #fff); }

@media (max-width: 640px) {
  .al-acciones { grid-template-columns: 1fr; }
  .al-item { flex-direction: column; }
  .al-acc { justify-content: flex-start; width: 100%; }
  .al-acc .btn-primary { flex: 1 1 auto; min-height: 44px; }
  .de-resumen { grid-template-columns: 1fr 1fr; }
  .de-resumen .de-nueva { grid-column: 1 / -1; min-height: 52px; }
  .de-nums { grid-template-columns: 1fr; }
  .de-nums > div { display: flex; justify-content: space-between; align-items: center; }
}

/* E6 (N01): contador no disponible */
.nav-badge.nav-badge-nd { background: #8a6d00; }
.al-deudas-n.al-nd { min-width: 0; font-size: 12px; color: #8a6d00; }
.alertas-hoy[data-nd], #alertas-hoy[data-nd] { border-style: dashed; }
