:root {
  --bg: #0f172a; --panel: #1e293b; --txt: #e2e8f0; --muted: #94a3b8;
  --linea: #334155; --azul: #2563eb; --ok: #22c55e; --off: #ef4444; --cand: #f59e0b;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--txt); }
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--linea); }
header h1 { font-size: 18px; margin: 0; } header small { color: var(--muted); font-weight: 400; }
.estado-conex { font-size: 13px; }
.header-der { display: flex; align-items: center; gap: 16px; }
.sesion-info { font-size: 13px; color: var(--muted); }
.sesion-info a { color: var(--azul); text-decoration: none; }

/* --- Login --- */
.login-overlay { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--linea); border-radius: 14px; padding: 28px 24px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login-logo { font-size: 20px; font-weight: 700; text-align: center; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.login-card input { padding: 12px; font-size: 16px; background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 8px; }
.login-card .btn { padding: 12px; font-size: 16px; text-align: center; }
.login-msg { color: var(--off); font-size: 13px; text-align: center; min-height: 18px; }
.tabs { display: flex; gap: 6px; padding: 10px 18px; border-bottom: 1px solid var(--linea); flex-wrap: wrap; }
.tab { background: var(--panel); color: var(--txt); border: 1px solid var(--linea); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.tab.activa { background: var(--azul); border-color: var(--azul); }
.tab:disabled { opacity: .45; cursor: not-allowed; }
.panel { padding: 18px; } .oculto { display: none; }
h2 { font-size: 16px; } .ayuda { color: var(--muted); font-size: 13px; }
.tabla { width: 100%; border-collapse: collapse; margin-top: 10px; }
.tabla th, .tabla td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--linea); }
.tabla.compacta th, .tabla.compacta td { padding: 4px 7px; font-size: 13px; }
.ok { color: var(--ok); } .off { color: var(--off); }
.cols { display: flex; gap: 16px; margin-top: 12px; }
.col-izq { width: 320px; flex: 0 0 320px; } .col-der { flex: 1; min-width: 0; }
#filtroTabla { width: 100%; padding: 8px; background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 6px; margin-bottom: 8px; }
.lista { max-height: 70vh; overflow: auto; border: 1px solid var(--linea); border-radius: 8px; }
.item-tabla { padding: 6px 10px; border-bottom: 1px solid var(--linea); cursor: pointer; }
.item-tabla:hover { background: var(--panel); }
.item-tabla.cand { color: var(--cand); font-weight: 600; }
.item-tabla small { color: var(--muted); float: right; font-weight: 400; }
.detalle { border: 1px solid var(--linea); border-radius: 8px; padding: 14px; min-height: 200px; }
.muestra { background: var(--bg); border: 1px solid var(--linea); border-radius: 6px; padding: 10px; overflow: auto; max-height: 40vh; font-size: 12px; }

/* --- Morosidad --- */
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.switch { display: inline-flex; align-items: center; gap: 7px; margin: 6px 0 4px; cursor: pointer; color: var(--muted); }
.kpis { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0 6px; }
.kpi { background: var(--panel); border: 1px solid var(--linea); border-radius: 10px; padding: 14px 18px; min-width: 190px; flex: 1; }
.kpi-val { font-size: 24px; font-weight: 700; line-height: 1.1; }
.kpi-lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }
.aging { margin: 10px 0 4px; max-width: 760px; }
.aging-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.aging-lbl { width: 100px; flex: 0 0 100px; font-size: 13px; color: var(--muted); }
.aging-bar { flex: 1; background: var(--bg); border: 1px solid var(--linea); border-radius: 6px; height: 18px; overflow: hidden; }
.aging-fill { height: 100%; background: var(--azul); }
.aging-fill.viejo { background: var(--off); }
.aging-fill.sCatv { background: #8b5cf6; }
.aging-fill.sInet { background: #06b6d4; }
.aging-fill.ingreso { background: var(--ok); }
.aging-fill.ingreso.parcial { background: #15803d; }

/* --- Padrón: solapas Planes / Por proveedor --- */
.btn-mini { padding: 2px 9px; font-size: 14px; line-height: 1.4; margin-left: 8px; vertical-align: middle; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.subtab { background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.subtab:hover { border-color: var(--azul); }
.subtab.activa { background: var(--azul); border-color: var(--azul); color: #fff; }
.subtab small { color: inherit; opacity: .8; }
.filtro-padron { width: 100%; max-width: 360px; padding: 8px; background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 6px; margin: 4px 0 2px; }
.ayuda-box { background: var(--panel); border: 1px solid var(--linea); border-left: 3px solid var(--azul); border-radius: 8px; padding: 4px 16px; margin: 6px 0 10px; max-width: 900px; font-size: 13px; }
.ayuda-box ul { margin: 8px 0; padding-left: 20px; }
.ayuda-box li { margin-bottom: 8px; }

/* --- Libro IVA --- */
.iv-filtros { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 8px 0 4px; }
.iv-filtros label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.iv-filtros select { background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 6px; padding: 7px 9px; font: inherit; }
.btn { background: var(--azul); color: #fff; border: 1px solid var(--azul); border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.1); }
.iv-botones { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.iv-botones .btn { background: var(--panel); color: var(--txt); border-color: var(--linea); }
.iv-botones .btn:hover { border-color: var(--azul); filter: none; }

/* --- Prueba de abonado --- */
.ab-buscar { display: flex; gap: 10px; margin: 12px 0; max-width: 520px; }
#abCodigo { flex: 1; padding: 11px 12px; font-size: 16px; background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 8px; }
.ab-buscar .btn { padding: 11px 22px; font-size: 15px; }
.sel-dur { background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 8px; padding: 0 10px; font: inherit; }
.ab-card { border: 1px solid var(--linea); border-left-width: 6px; border-radius: 10px; padding: 16px 18px; margin-top: 12px; max-width: 620px; background: var(--panel); }
.ab-v-probando { border-left-color: var(--azul); } .ab-v-probando .ab-titulo { color: #60a5fa; }
.ab-prog { margin: 8px 0 4px; font-size: 14px; font-variant-numeric: tabular-nums; }
.ab-barra { height: 6px; background: var(--bg); border: 1px solid var(--linea); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.ab-barra > i { display: block; height: 100%; background: var(--azul); width: 0; transition: width .3s; }
.ab-card .ab-titulo { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.ab-card .ab-msg { color: var(--muted); margin: 4px 0 10px; }
.ab-datos { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 6px; }
.ab-dato { font-size: 13px; } .ab-dato b { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.ab-vel { color: var(--ok); font-weight: 600; }
.ab-rx-warn { color: #eab308; }
.ab-salida { font-weight: 600; }
.ab-salida-telecom { color: #38bdf8; }
.ab-salida-telco { color: #f59e0b; }
.ab-acciones { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ab-accion { background: var(--panel); border-color: var(--linea); color: var(--txt); }
.ab-accion:hover { border-color: var(--azul); filter: none; }
.ab-accion.ab-danger { border-color: var(--off); color: #fca5a5; }
.ab-accion.ab-danger:hover { background: rgba(239, 68, 68, .15); }
.ab-accion.ab-okbtn { border-color: var(--ok); color: #86efac; }
.ab-accion.ab-okbtn:hover { background: rgba(34, 197, 94, .15); }
.ab-accion:disabled { opacity: .5; cursor: default; }
.ab-accion-msg { font-size: 13px; }
.ab-v-suspendido { border-left-color: var(--off); } .ab-v-suspendido .ab-titulo { color: #f87171; }
.ab-graf { margin-top: 12px; }
.ab-graf-cont:not(:empty) { margin-top: 10px; display: flex; flex-direction: column; gap: 12px; }
.ab-graf-box { background: #fff; border: 1px solid var(--linea); border-radius: 8px; padding: 8px; }
.ab-graf-lbl { color: #334155; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.ab-graf-img { display: block; max-width: 100%; }
#cabIframe { display: flex; flex-direction: column; gap: 12px; }
.ab-onu { margin-top: 12px; padding: 9px 12px; border-radius: 8px; background: rgba(245,158,11,.14); border: 1px solid var(--cand); color: #fbbf24; font-size: 13px; }
.ab-v-ok { border-left-color: var(--ok); } .ab-v-ok .ab-titulo { color: var(--ok); }
.ab-v-retardo { border-left-color: #eab308; } .ab-v-retardo .ab-titulo { color: #eab308; }
.ab-v-inestable { border-left-color: #f97316; } .ab-v-inestable .ab-titulo { color: #f97316; }
.ab-v-caido { border-left-color: var(--off); } .ab-v-caido .ab-titulo { color: var(--off); }
.ab-v-sin_conexion { border-left-color: var(--muted); } .ab-v-sin_conexion .ab-titulo { color: var(--muted); }
.ab-v-inexistente, .ab-v-error { border-left-color: var(--muted); } .ab-v-inexistente .ab-titulo, .ab-v-error .ab-titulo { color: var(--muted); }
.ab-v-multiples { border-left-color: var(--cand); } .ab-v-multiples .ab-titulo { color: var(--cand); }
.ab-cand { padding: 8px 10px; border: 1px solid var(--linea); border-radius: 7px; margin-top: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.ab-cand:hover { border-color: var(--azul); }

/* --- Cabecera / red --- */
.sel-mini { background: var(--bg); color: var(--txt); border: 1px solid var(--linea); border-radius: 6px; padding: 3px 6px; font-size: 12px; margin-left: 8px; font-weight: 400; }
.caja-graf { background: var(--panel); border: 1px solid var(--linea); border-radius: 8px; padding: 8px; margin-top: 6px; }
.aging-fill.sCatv { background: #8b5cf6; }
.aging-imp { width: 170px; flex: 0 0 170px; text-align: right; font-size: 13px; }
.aging-imp small { color: var(--muted); }

/* --- Celular (PWA) --- */
@media (max-width: 640px) {
  header { padding: 10px 12px; flex-wrap: wrap; gap: 4px; }
  header h1 { font-size: 16px; } header h1 small { display: none; }
  .tabs { padding: 8px 10px; gap: 5px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { padding: 8px 11px; white-space: nowrap; flex: 0 0 auto; }
  .panel { padding: 12px; }
  .ab-buscar { flex-wrap: wrap; }
  #abCodigo { min-width: 0; }
  .ab-card { max-width: 100%; }
  .cols { flex-direction: column; }
  .col-izq { width: 100%; flex: 1 1 auto; }
  .kpi { min-width: 140px; }
  .tabla-scroll, .panel { overflow-x: auto; }
  .iv-filtros label { font-size: 12px; }
}
