/* ============================================================
   PrestamosApp - Panel de Gerencia (escritorio)
   ============================================================ */
:root {
    --g-primary: #0f766e;
    --g-primary-d: #0b5b54;
    --g-side: #0f172a;
    --g-side-2: #1e293b;
    --g-bg: #f1f5f9;
    --g-surface: #ffffff;
    --g-text: #0f172a;
    --g-muted: #64748b;
    --g-border: #e2e8f0;
    --g-ok: #16a34a;
    --g-warn: #d97706;
    --g-bad: #dc2626;
    --g-shadow: 0 1px 3px rgba(15,23,42,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--g-bg); color: var(--g-text); }
h2, h3 { margin: 0; }
.g-muted { color: var(--g-muted); font-size: .85rem; }
.loading-progress, .loading-progress-text { display: none; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fee2e2; color: #991b1b; padding: 10px 16px; z-index: 1000; }

/* ---------- Shell ---------- */
.g-shell { display: flex; min-height: 100vh; }
.g-sidebar { width: 236px; background: var(--g-side); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.g-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px; border-bottom: 1px solid var(--g-side-2); }
.g-brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; padding: 2px; }
.g-brand-emoji { font-size: 1.8rem; }
.g-brand strong { display: block; color: #fff; font-size: .95rem; line-height: 1.1; }
.g-brand span { font-size: .72rem; color: #94a3b8; }

.g-menu { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.g-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: #cbd5e1; text-decoration: none; font-size: .9rem; }
.g-item span { width: 20px; text-align: center; }
.g-item:hover { background: var(--g-side-2); color: #fff; }
.g-item.active { background: var(--g-primary); color: #fff; }
.g-side-foot { padding: 14px 16px; border-top: 1px solid var(--g-side-2); font-size: .8rem; }
.g-side-foot span { display: block; color: #e2e8f0; margin-bottom: 8px; }
.g-side-foot button { width: 100%; background: transparent; border: 1px solid #475569; color: #cbd5e1; border-radius: 8px; padding: 7px; cursor: pointer; }
.g-side-foot button:hover { background: var(--g-bad); border-color: var(--g-bad); color: #fff; }

.g-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.g-topbar { height: 58px; background: var(--g-surface); border-bottom: 1px solid var(--g-border); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; position: sticky; top: 0; z-index: 30; }
.g-topbar-title { font-weight: 700; }
.g-topbar-right { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--g-muted); }
.g-content { padding: 22px; }

/* ---------- Titulos ---------- */
.g-title { font-size: 1.35rem; margin-bottom: 16px; }
.g-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- Inputs / botones ---------- */
.g-input { padding: 8px 10px; border: 1px solid var(--g-border); border-radius: 8px; font-size: .9rem; background: #fff; }
.g-input:focus { outline: none; border-color: var(--g-primary); }
.g-input-fecha { width: auto; }
.g-select { padding: 6px 8px; border: 1px solid var(--g-border); border-radius: 8px; background: #fff; font-size: .85rem; }
.g-btn-primario { background: var(--g-primary); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-weight: 600; cursor: pointer; }
.g-btn-primario:hover { background: var(--g-primary-d); }
.g-btn-sec { background: var(--g-bg); color: var(--g-text); border: 1px solid var(--g-border); border-radius: 8px; padding: 9px 14px; cursor: pointer; }
.g-btn-sm { padding: 7px 12px; font-size: .85rem; }
.g-rango-filtros { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.g-rango-filtros label { font-size: .8rem; color: var(--g-muted); }

/* ---------- KPIs ---------- */
.g-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.g-kpi { background: var(--g-surface); border-radius: 12px; padding: 16px; box-shadow: var(--g-shadow); border-left: 4px solid var(--g-primary); }
.g-kpi-num { display: block; font-size: 1.35rem; font-weight: 800; }
.g-kpi-lbl { font-size: .78rem; color: var(--g-muted); }
.g-kpi-ok { border-left-color: var(--g-ok); }
.g-kpi-ok .g-kpi-num { color: var(--g-ok); }
.g-kpi-bad { border-left-color: var(--g-bad); }
.g-kpi-bad .g-kpi-num { color: var(--g-bad); }

/* ---------- Cards / grid ---------- */
.g-card { background: var(--g-surface); border-radius: 12px; padding: 18px; box-shadow: var(--g-shadow); margin-bottom: 18px; }
.g-card h3 { font-size: 1rem; margin-bottom: 14px; }
.g-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .g-grid2 { grid-template-columns: 1fr; } .g-sidebar { width: 64px; } .g-brand div, .g-item, .g-side-foot span { font-size: 0; } }

/* ---------- Barras horizontales ---------- */
.g-bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 10px; margin-bottom: 10px; }
.g-bar-lbl { font-size: .82rem; color: var(--g-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-bar-track { background: var(--g-bg); border-radius: 6px; height: 20px; overflow: hidden; }
.g-bar-fill { height: 100%; background: var(--g-primary); border-radius: 0 6px 6px 0; min-width: 3px; transition: width .4s; }
.g-bar-fill.g-verde { background: var(--g-ok); }
.g-bar-fill.g-amarillo { background: var(--g-warn); }
.g-bar-fill.g-rojo { background: var(--g-bad); }
.g-bar-val { font-size: .82rem; font-weight: 700; white-space: nowrap; }

/* ---------- Columnas (tendencia) ---------- */
.g-cols { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 6px; }
.g-cols-wide { height: 220px; overflow-x: auto; }
.g-col { flex: 1; min-width: 26px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.g-col-v { font-size: .62rem; color: var(--g-muted); height: 14px; }
.g-col-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.g-col-bar { width: 66%; margin: 0 auto; background: var(--g-primary); border-radius: 5px 5px 0 0; min-height: 3px; transition: height .4s; }
.g-col-l { font-size: .6rem; color: var(--g-muted); margin-top: 4px; }

/* ---------- Tablas ---------- */
.g-tabla { width: 100%; border-collapse: collapse; font-size: .85rem; }
.g-tabla th, .g-tabla td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--g-border); white-space: nowrap; }
.g-tabla th { color: var(--g-muted); font-weight: 600; background: #f8fafc; }

/* ---------- Mapa ---------- */
.g-mapa { width: 100%; height: 68vh; min-height: 440px; border-radius: 12px; box-shadow: var(--g-shadow); z-index: 0; }
.mapa-pin { width: 28px; height: 28px; border-radius: 50%; background: var(--g-primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .82rem; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.45); }
.mapa-pin-cobrado { background: var(--g-ok); }
.mapa-pin-visitado { background: var(--g-warn); }
.mapa-pin-pendiente { background: var(--g-primary); }
.g-leyenda { display: flex; gap: 16px; font-size: .82rem; color: var(--g-muted); }
.g-leyenda span { display: inline-flex; align-items: center; gap: 5px; }
.lp { width: 12px; height: 12px; border-radius: 50%; }
.lp-cob { background: var(--g-ok); }
.lp-vis { background: var(--g-warn); }
.lp-pen { background: var(--g-primary); }
.g-vacio { padding: 30px; text-align: center; color: var(--g-muted); background: var(--g-surface); border-radius: 12px; }

/* ---------- Carga / login ---------- */
.g-carga { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--g-border); border-top-color: var(--g-primary); border-radius: 50%; animation: g-girar .8s linear infinite; }
@keyframes g-girar { to { transform: rotate(360deg); } }
.g-auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #0b1220, #0f172a); }
.g-login-card { background: var(--g-surface); border-radius: 16px; padding: 34px 28px; width: 360px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.g-login-logo { font-size: 2.6rem; }
.g-login-card h1 { font-size: 1.4rem; color: var(--g-primary); margin: 6px 0 0; }
.g-login-card p { color: var(--g-muted); margin: 2px 0 18px; }
.g-campo { text-align: left; margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.g-campo label { font-size: .8rem; color: var(--g-muted); font-weight: 600; }
.g-campo .g-input { width: 100%; }
.g-login-card .g-btn-primario { width: 100%; margin-top: 6px; }
.g-alerta { background: #fef2f2; color: var(--g-bad); padding: 9px; border-radius: 8px; font-size: .85rem; margin-bottom: 10px; }

/* Reutiliza EstadoCarga/Semaforo del CSS compartido (app.css) */
.estado-carga, .estado-error { padding: 30px; text-align: center; color: var(--g-muted); }

/* ---------- Filas clicables / buscador ---------- */
.g-tabla tr.g-click { cursor: pointer; }
.g-tabla tr.g-click:hover td { background: #f8fafc; }
.g-buscar { display: flex; gap: 8px; margin-bottom: 14px; max-width: 480px; }
.g-buscar .g-input { flex: 1; }
.g-acciones { display: flex; gap: 8px; }
.g-btn-mini { padding: 5px 10px; font-size: .8rem; border-radius: 7px; border: 1px solid var(--g-border); background: #fff; cursor: pointer; }
.g-btn-mini:hover { background: var(--g-bg); }
.g-btn-danger { color: var(--g-bad); border-color: #fecaca; }

/* ---------- Badges ---------- */
.g-badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.g-badge-ok { background: #dcfce7; color: #166534; }
.g-badge-no { background: #fee2e2; color: #991b1b; }
.g-badge-info { background: #e0e7ff; color: #3730a3; }
.g-badge-warn { background: #fef9c3; color: #854d0e; }

/* ---------- Modal ---------- */
.g-modal-fondo { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: grid; place-items: center; padding: 20px; }
.g-modal { background: var(--g-surface); border-radius: 14px; padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.g-modal h3 { margin-bottom: 14px; }
.g-modal-acc { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.g-form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g-check { display: flex; align-items: center; gap: 6px; font-size: .88rem; }
.g-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.g-alerta-ok { background: #f0fdf4; color: #166534; padding: 9px; border-radius: 8px; font-size: .85rem; margin: 8px 0; }

/* ---------- Enrutamiento ---------- */
.g-enrutar-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; background: var(--g-surface); border: 1px solid var(--g-border); border-radius: 8px; margin-bottom: 6px; }
.g-orden-num { width: 30px; height: 30px; border-radius: 50%; background: #ccfbf1; color: var(--g-primary-d); display: grid; place-items: center; font-weight: 700; }
.g-orden-btn { width: 34px; height: 34px; border: 1px solid var(--g-border); background: #fff; border-radius: 7px; cursor: pointer; }
.g-orden-btn:disabled { opacity: .35; }
.g-side-sep { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; padding: 12px 14px 4px; }
.g-foto-logo { max-width: 160px; max-height: 90px; object-fit: contain; border: 1px solid var(--g-border); border-radius: 8px; padding: 4px; background: #fff; }

/* ---------- Impresion / PDF ---------- */
/* Centro de alertas (dashboard) */
.g-alertas { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.g-alerta-card { display: flex; flex-direction: column; gap: 2px; background: var(--g-surface); border: 1px solid var(--g-border); border-left: 4px solid var(--g-primary); border-radius: 10px; padding: 12px 16px; min-width: 170px; cursor: pointer; box-shadow: var(--g-shadow); transition: transform .1s; }
.g-alerta-card:hover { transform: translateY(-2px); }
.g-alerta-card > span:last-child { font-size: .82rem; color: var(--g-muted); }
.g-alerta-num { font-size: 1.5rem; font-weight: 700; }
.g-alerta-card.g-alerta-bad { border-left-color: var(--g-bad); }
.g-alerta-card.g-alerta-bad .g-alerta-num { color: var(--g-bad); }
.g-alerta-card.g-alerta-warn { border-left-color: var(--g-warn); }
.g-alerta-card.g-alerta-warn .g-alerta-num { color: var(--g-warn); }

@media print {
    .g-sidebar, .g-topbar, .no-print { display: none !important; }
    .g-content { padding: 0 !important; }
    .g-card { box-shadow: none !important; border: 1px solid #ccc; break-inside: avoid; }
    body { background: #fff; }
}
