/* =============== BASE =============== */
* { box-sizing: border-box; }

:root{
  --bg: #f3f6fb;
  --text: #0f172a;
  --muted: #64748b;

  --card: #ffffff;
  --border: #e5e7eb;

  --sidebar-bg: #0b1220;
  --sidebar-border: rgba(148,163,184,.25);
  --sidebar-text: #e5e7eb;

  --primary: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --purple: #a855f7;

  --shadow: 0 10px 26px rgba(15,23,42,.12);
}

body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a{ color: inherit; }

/* =============== LAYOUT =============== */
.sidebar{
  width:260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  min-height:100vh;
  padding:16px 12px;
  position:fixed;
  left:0;
  top:0;
  overflow-y:auto;
  transition: transform .25s ease;
  z-index:1500;
  border-right: 1px solid var(--sidebar-border);
}

.main-content{
  margin-left:260px;
  padding:20px;
}

/* Botón hamburguesa (solo en móvil) */
.sidebar-toggle{
  position:fixed;
  top:10px;
  left:10px;
  z-index:2001;
  background:#0f172a;
  color:#e5e7eb;
  border:none;
  border-radius:999px;
  width:38px;
  height:38px;
  font-size:20px;
  display:none;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow: var(--shadow);
}

/* Header sidebar */
.sidebar-header{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:16px;
  padding-bottom:10px;
  border-bottom:1px solid rgba(148,163,184,.25);
}

.sidebar-logo{ font-size:22px; }
.sidebar-title{ font-weight:700; font-size:16px; }

/* Usuario */
.sidebar-user{
  margin-bottom:16px;
  font-size:13px;
  padding:10px 10px;
  border-radius:12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(148,163,184,.18);
}
.sidebar-user-name{ font-weight:700; }
.sidebar-user-role{ opacity:.85; }

/* Menú */
.sidebar-menu{ display:flex; flex-direction:column; gap:4px; }

.sidebar-section-title{
  margin-top:14px;
  margin-bottom:6px;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.08em;
  opacity:.65;
  padding-left:6px;
}

.sidebar-link{
  display:flex;
  align-items:center;
  gap:8px;
  padding:9px 12px;
  border-radius:12px;
  color: var(--sidebar-text);
  text-decoration:none;
  font-size:14px;
  transition: background .18s ease, transform .18s ease;
}
.sidebar-link:hover{
  background: rgba(148,163,184,.14);
  transform: translateX(2px);
}
.sidebar-link--danger{ color:#fecaca; }

/* =============== CARD / BOTONES / ALERTAS =============== */
.card{
  background: var(--card);
  color: var(--text);
  border-radius:16px;
  padding:18px 18px 16px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom:20px;
}

.card h2{
  margin:0 0 12px 0;
  font-size:20px;
  font-weight:800;
}
.card p{ color: var(--muted); }

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 14px;
  border-radius:999px;
  border:none;
  cursor:pointer;
  background: var(--success);
  color:#052e16;
  font-size:13px;
  font-weight:800;
  text-decoration:none;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(34,197,94,.25);
  filter: saturate(1.05);
}
.btn-secondary{
  background:#0f172a;
  color:#e5e7eb;
}
.btn-secondary:hover{
  box-shadow: 0 10px 18px rgba(15,23,42,.25);
}

.alert{
  padding:10px 12px;
  border-radius:12px;
  font-size:13px;
  margin-bottom:10px;
  border: 1px solid transparent;
}
.alert-success{
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.35);
  color:#14532d;
}
.alert-error{
  background: rgba(239,68,68,.10);
  border-color: rgba(239,68,68,.30);
  color:#7f1d1d;
}

/* =============== TABLAS =============== */
table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
  margin-bottom:10px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
}

table th, table td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  vertical-align:middle;
}

table th{
  text-align:left;
  background:#0b1220;
  color:#e5e7eb;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.06em;
}

table tr:last-child td{ border-bottom:none; }

table tbody tr:nth-child(even) td{
  background:#f7f9fc;
}

/* Evitar que “Acciones” se vaya para abajo */
td.col-acciones,
th.col-acciones{
  white-space: nowrap;
  width: 260px;            /* ajusta si quieres más/menos */
}

/* Si no tienes clase col-acciones, aplica al último td */
table td:last-child{
  white-space: nowrap;
}

/* =============== FORMULARIOS =============== */
label{
  display:block;
  font-size:13px;
  margin-bottom:8px;
  color: var(--text);
  font-weight:600;
}
label input, label select, label textarea{
  width:100%;
  margin-top:5px;
  padding:9px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  color: var(--text);
  font-size:13px;
  outline:none;
}
label input:focus, label select:focus, label textarea:focus{
  border-color: rgba(37,99,235,.45);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

/* =============== DETALLE CLIENTE / PRÉSTAMO =============== */
.cliente-detalle{
  display:flex;
  gap:14px;
  flex-wrap:wrap;
}
.cliente-detalle-block{
  flex:1 1 260px;
  background:#0b1220;
  color:#e5e7eb;
  border-radius:14px;
  padding:12px 14px;
  border:1px solid rgba(148,163,184,.25);
}
.cliente-detalle-block h4{
  margin:0 0 10px 0;
  font-size:14px;
  font-weight:800;
}
.cliente-detalle-tabla{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
}
.cliente-detalle-tabla th,
.cliente-detalle-tabla td{
  border:none;
  padding:4px 2px;
}
.cliente-detalle-tabla th{
  width:35%;
  color:#9ca3af;
}

/* =============== ACCIONES (ICONOS) =============== */
.acciones-prestamo{
  display:inline-flex;
  gap:6px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap: nowrap;       /* ✅ NO se bajan */
}

.btn-icon{
  display:inline-flex;
  justify-content:center;
  align-items:center;
  width:24px;              /* ✅ más compactos */
  height:24px;
  border-radius:999px;
  font-size:14px;
  text-decoration:none;
  color:#fff;
  border:none;
  cursor:pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn-icon:hover{
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 8px 16px rgba(15,23,42,.20);
  opacity:.95;
}

/* Colores por acción */
.btn-icon--ver       { background: var(--primary); }
.btn-icon--cal       { background: var(--info); }
.btn-icon--tarjeta   { background: var(--success); }
.btn-icon--garantia  { background: var(--purple); }
.btn-icon--pagos     { background: var(--warning); color:#111827; }
.btn-icon--editar    { background: #64748b; }
.btn-icon--eliminar  { background: var(--danger); }

/* =============== DASHBOARD (TARJETAS) =============== */
/* Si tu dashboard ya tiene clases propias, estas reglas lo mejoran sin romper nada */
.dashboard-cards,
.dash-cards,
.stats-cards{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:14px;
  margin-top:12px;
}

.stat-card,
.dashboard-card,
.kpi-card{
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px 14px;
  box-shadow: var(--shadow);
  color: var(--text);
  position:relative;
  overflow:hidden;
}

.stat-card h3,
.dashboard-card h3,
.kpi-card h3{
  margin:0;
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color: var(--muted);
  font-weight:900;
}

.stat-card .value,
.dashboard-card .value,
.kpi-card .value{
  margin-top:8px;
  font-size:26px;
  font-weight:900;
  color: var(--text);
}

.stat-card .desc,
.dashboard-card .desc,
.kpi-card .desc{
  margin-top:4px;
  font-size:12px;
  color: var(--muted);
}

/* Chips tipo “Vigentes / Cancelados…” */
.chips,
.dashboard-chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:8px;
}
.chip{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  font-size:12px;
  font-weight:800;
  color:#0f172a;
}
.chip--success{ border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.10); }
.chip--danger { border-color: rgba(239,68,68,.30); background: rgba(239,68,68,.10); }
.chip--info   { border-color: rgba(14,165,233,.35); background: rgba(14,165,233,.10); }
.chip--warn   { border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.10); }

/* =============== RESPONSIVE =============== */
@media (max-width: 1100px){
  .dashboard-cards, .dash-cards, .stats-cards{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px){
  .sidebar{ transform: translateX(-100%); }
  .sidebar.sidebar--open{ transform: translateX(0); }
  .sidebar-toggle{ display:inline-flex; }

  .main-content{
    margin-left:0;
    padding-top:60px;
  }

  table{
    display:block;
    width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    white-space:nowrap;
  }
}

@media (max-width: 520px){
  .dashboard-cards, .dash-cards, .stats-cards{
    grid-template-columns: 1fr;
  }
}
/* ===============================
   FIX GLOBAL: NO DESBORDES (TABLAS/CONTENEDORES)
================================= */
html, body{
  max-width: 100%;
  overflow-x: hidden;
}

.app-shell, .main, .content, .container, .card{
  max-width: 100%;
}

/* ===============================
   TABLAS RESPONSIVE (sin JS)
   - En PC normal se ven normal
   - En móvil / "sitio PC" hacen scroll horizontal
================================= */
table{
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

/* wrapper recomendado */
.table-responsive{
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}

/* si hay tablas sin wrapper, igual no reventamos */
@media (max-width: 1024px){
  table{
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}

/* padding/lectura en móvil */
@media (max-width: 600px){
  th, td{
    padding: 10px 12px;
    font-size: 13px;
  }
}