/* CrediVip - SistemasVIP - estilos base (sin dependencias, offline) */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e4e8ef;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #0e7c66;
  --brand-2: #10a37f;
  --brand-soft: #e6f5f1;
  --accent: #f59e0b;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --panel: #111a2e; --panel-2: #0f1729; --line: #1f2a44;
    --text: #e5e9f2; --muted: #8b97ad; --brand-soft: #0d2f29;
    --ok-soft: #0f2e1c; --warn-soft: #33260b; --bad-soft: #3a1414; --info-soft: #132446;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --panel: #111a2e; --panel-2: #0f1729; --line: #1f2a44;
  --text: #e5e9f2; --muted: #8b97ad; --brand-soft: #0d2f29;
  --ok-soft: #0f2e1c; --warn-soft: #33260b; --bad-soft: #3a1414; --info-soft: #132446;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 19px; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-size: 17px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 12px 4px; }
.sidebar-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; }

.main { padding: 22px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 24px; }
.topbar .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.span2 { grid-column: span 2; }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .lbl { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .val { font-size: 26px; font-weight: 700; }
.kpi .foot { font-size: 12.5px; color: var(--muted); }
.kpi.alert .val { color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 9px 16px; border-radius: 10px; font: 600 14px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.lg { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.icon-btn svg { width: 20px; height: 20px; display: block; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: 15px var(--font); outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.search .input { padding-left: 44px; }
.search.big .input { padding: 16px 16px 16px 48px; font-size: 17px; border-radius: 14px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge svg, a.card > svg { width: 20px; height: 20px; flex: none; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-mute { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
table.t .r { text-align: right; }
table.t tr.paid td { color: var(--muted); }
table.t tr.late td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.who b { display: block; font-weight: 600; }
.who span { font-size: 12.5px; color: var(--muted); }

.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

.progress { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: 600 14px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 999px; font: 600 14px var(--font); cursor: pointer; color: var(--text); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Pasos (wizard nuevo prestamo) */
.steps { display: flex; gap: 8px; margin-bottom: 18px; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 14px; }
.step i { font-style: normal; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; }
.step.on { border-color: var(--brand); color: var(--text); }
.step.on i, .step.done i { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Resumen grande (simulador / pago) */
.hero-num { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-radius: var(--radius); padding: 20px; }
.hero-num .lbl { opacity: .85; font-size: 13px; font-weight: 500; }
.hero-num .val { font-size: 34px; font-weight: 800; margin: 4px 0; }
.hero-num .row { display: flex; justify-content: space-between; font-size: 13.5px; opacity: .92; padding-top: 6px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }

/* Chart barras */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; max-width: 38px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; transition: height .4s; }
.bars .b.today i { background: var(--accent); }
.bars .b span { font-size: 11.5px; color: var(--muted); }

/* Formulario por secciones + fotos */
.sec { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); border-bottom: 1px solid var(--line); padding: 10px 0 6px; margin-top: 4px; }
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.foto-slot { position: relative; aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; overflow: hidden; background: var(--panel-2); color: var(--muted); text-align: center; padding: 6px; }
.foto-slot svg { width: 26px; height: 26px; }
.foto-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto-slot b { position: relative; font-size: 12px; font-weight: 600; }
.foto-slot img ~ b { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; padding: 3px; }
.foto-slot.nueva { border: 2px solid var(--brand); }
.foto-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55) !important; color: #fff !important; border-radius: 50%; padding: 4px; }
.foto-del svg { width: 14px; height: 14px; }

/* Ruta de cobro: grupos por color */
.grupo { margin-bottom: 16px; }
.grupo-h { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; padding: 6px 4px 8px; }
.grupo-h i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; }
.g-ok .grupo-h i { background: var(--ok); } .g-warn .grupo-h i { background: var(--warn); } .g-bad .grupo-h i { background: var(--bad); }
.cobro-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-left-width: 5px; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.g-ok .cobro-row { border-left-color: var(--ok); } .g-warn .cobro-row { border-left-color: var(--warn); } .g-bad .cobro-row { border-left-color: var(--bad); }
.cobro-row.on { background: var(--brand-soft); border-color: var(--brand); }
.cobro-row .ck { width: 24px; height: 24px; flex: none; accent-color: var(--brand); }
.cr-info { flex: 1; min-width: 0; cursor: pointer; }
.cr-info b { display: block; } .cr-info span { display: block; font-size: 12.5px; color: var(--muted); }
.g-warn .cr-info span b { color: var(--warn) !important; } .g-bad .cr-info span b { color: var(--bad) !important; }
.cr-info .crece { color: var(--bad); font-weight: 600; }
.cr-monto { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cr-monto input { width: 110px; text-align: right; font-weight: 700; padding: 8px; }
.cobro-bar { position: fixed; left: 240px; right: 0; bottom: 0; background: var(--panel); border-top: 2px solid var(--brand); display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 28px; z-index: 45; box-shadow: 0 -4px 20px rgba(0,0,0,.12); }
@media (max-width: 820px) { .cobro-bar { left: 0; bottom: 62px; padding: 10px 14px; } .cobro-bar .btn.lg { padding: 11px 14px; } }

/* Lista de clientes por estado */
table.t tr.est-ok td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
table.t tr.est-warn td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
table.t tr.est-bad td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.chip .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.chip.g-ok .dot { background: var(--ok); } .chip.g-warn .dot { background: var(--warn); } .chip.g-bad .dot { background: var(--bad); }

/* Partes de pago (pago mixto) */
.parte { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); }
.parte-fila { display: flex; gap: 8px; align-items: center; }

/* Boton flotante de soporte */
.btn-reporte { position: fixed; right: 16px; bottom: 16px; z-index: 44; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); border-radius: 999px; padding: 8px 12px; font: 600 12.5px var(--font); cursor: pointer; box-shadow: var(--shadow); opacity: .85; }
.btn-reporte:hover { opacity: 1; color: var(--bad); border-color: var(--bad); }
.btn-reporte svg { width: 16px; height: 16px; }
@media (max-width: 820px) { .btn-reporte { bottom: 78px; right: 10px; padding: 8px; } .btn-reporte span { display: none; } }

/* Modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.modal { background: var(--panel); border-radius: 18px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal header h2 { font-size: 18px; }
.modal .body { padding: 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; z-index: 60; box-shadow: var(--shadow); animation: fade .2s; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Bottom nav movil */
.bottom-nav { display: none; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(145deg, #0b5d4d, #10a37f); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 38px; max-width: 460px; }
.login-art p { opacity: .85; max-width: 420px; font-size: 16px; }
.login-form { display: grid; place-items: center; padding: 24px; }
.login-form .box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }

/* Ticket impresion */
.ticket { font-family: "Consolas", monospace; font-size: 12.5px; width: 300px; margin: 0 auto; color: #000; background: #fff; padding: 12px; }
.ticket .c { text-align: center; }
.ticket hr { border: 0; border-top: 1px dashed #000; }
.ticket .ln { display: flex; justify-content: space-between; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; left: 0; top: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px 16px 90px; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .kpi .val { font-size: 22px; }
  .steps .step span { display: none; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); z-index: 40; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 600; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--brand); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .hide-m { display: none; }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .topbar h1 { font-size: 20px; }
}
