/* ============================================================
   MUNDO FINANCIERA — Estilos principales
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --blue:        #1a56b0;
  --blue-light:  #e8f0fd;
  --blue-dark:   #0f3a7a;
  --green:       #0e8a4f;
  --green-light: #e5f5ed;
  --orange:      #f07c00;
  --orange-light:#fff3cd;
  --red:         #c0391a;
  --red-light:   #faecea;
  --gray-50:     #f8f9fc;
  --gray-100:    #f1f3f7;
  --gray-200:    #e4e7ef;
  --gray-400:    #9ba3b5;
  --gray-600:    #5a6275;
  --gray-800:    #1e2330;
  --white:       #ffffff;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.06);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);
  --radius:      12px;
  --radius-sm:   8px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.55; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
ul { list-style: none; }

/* ── Login ──────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f3a7a 0%, #1a56b0 55%, #2176d9 100%);
  padding: 1rem;
}
.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--blue);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.login-logo h1 { font-size: 1.4rem; font-weight: 600; color: var(--gray-800); }
.login-logo p  { font-size: .82rem; color: var(--gray-400); margin-top: 2px; }
.login-card .form-group { margin-bottom: 1.1rem; }
.login-card label { display: block; font-size: .82rem; font-weight: 500; color: var(--gray-600); margin-bottom: 5px; }
.login-card input {
  width: 100%; padding: .65rem .9rem;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font-size: .93rem; outline: none; transition: border .2s;
}
.login-card input:focus { border-color: var(--blue); }
.login-card .btn-login {
  width: 100%; padding: .75rem;
  background: var(--blue); color: var(--white);
  border: none; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 500; cursor: pointer;
  margin-top: .5rem; transition: background .2s;
}
.login-card .btn-login:hover { background: var(--blue-dark); }
.login-error {
  background: var(--red-light); color: var(--red);
  border-radius: var(--radius-sm); padding: .6rem .9rem;
  font-size: .85rem; margin-bottom: 1rem;
}

/* ── Layout principal ───────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 200; transition: transform .3s;
}
.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: var(--blue); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo svg { color: #fff; }
.sidebar-title { font-size: .95rem; font-weight: 600; color: var(--gray-800); line-height: 1.2; }
.sidebar-sub   { font-size: .72rem; color: var(--gray-400); }

.sidebar-nav { flex: 1; padding: 1rem .75rem; overflow-y: auto; }
.nav-section-title {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--gray-400); padding: .5rem .6rem .3rem;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .75rem; border-radius: var(--radius-sm);
  color: var(--gray-600); font-size: .88rem; cursor: pointer;
  transition: background .15s, color .15s; margin-bottom: 2px;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 500; }
.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 1rem .75rem;
  border-top: 1px solid var(--gray-200);
}
.user-info {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .75rem; border-radius: var(--radius-sm);
  background: var(--gray-100);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 600; flex-shrink: 0;
}
.user-name  { font-size: .84rem; font-weight: 500; color: var(--gray-800); }
.user-role  { font-size: .72rem; color: var(--gray-400); }
.btn-logout {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; margin-top: .5rem;
  border-radius: var(--radius-sm); border: none;
  background: transparent; color: var(--gray-600);
  font-size: .83rem; cursor: pointer; width: 100%;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: var(--red-light); color: var(--red); }

/* Main content */
.main-content {
  margin-left: 240px;
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  height: 58px; background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.75rem; position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.hamburger {
  display: none; border: none; background: transparent;
  cursor: pointer; padding: .4rem; border-radius: 6px;
}
.hamburger:hover { background: var(--gray-100); }
.page-title { font-size: 1.05rem; font-weight: 500; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-user {
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: var(--gray-600);
}
.topbar-user .user-avatar { width: 30px; height: 30px; font-size: .75rem; }

.page-body { padding: 1.5rem 1.75rem; flex: 1; }

/* ── Cards / Panels ─────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: .98rem; font-weight: 500; color: var(--gray-800); }
.card-body { padding: 1.25rem; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-label  { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-400); margin-bottom: .4rem; }
.stat-value  { font-size: 1.7rem; font-weight: 600; line-height: 1; }
.stat-sub    { font-size: .78rem; color: var(--gray-400); margin-top: .3rem; }
.stat-blue   { color: var(--blue); }
.stat-green  { color: var(--green); }
.stat-red    { color: var(--red); }
.stat-orange { color: var(--orange); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .55rem 1.1rem;
  border-radius: var(--radius-sm); font-size: .87rem; font-weight: 500;
  cursor: pointer; border: 1.5px solid transparent; transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-success   { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #0b6e3e; }
.btn-outline   { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn-outline:hover { background: var(--blue-light); }
.btn-danger    { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-light); }
.btn-ghost     { background: transparent; color: var(--gray-600); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 500; color: var(--gray-600); margin-bottom: 5px; }
.form-label .req { color: var(--red); margin-left: 2px; }
.form-control {
  width: 100%; padding: .6rem .9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: .9rem;
  outline: none; transition: border .2s, box-shadow .2s;
  background: var(--white); color: var(--gray-800);
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,86,176,.1); }
.form-control:disabled { background: var(--gray-100); cursor: not-allowed; }
select.form-control { cursor: pointer; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
.table thead tr { background: var(--gray-50); border-bottom: 1.5px solid var(--gray-200); }
.table th {
  padding: .75rem 1rem; text-align: left;
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--gray-400); white-space: nowrap;
}
.table td {
  padding: .8rem 1rem; border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800); vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr.row-vencida { background: #fff8f7; }
.table tbody tr.row-pagada  { background: var(--gray-50); color: var(--gray-400); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .22rem .75rem; border-radius: 20px;
  font-size: .75rem; font-weight: 500; white-space: nowrap;
}
.badge-blue   { background: var(--blue-light);   color: var(--blue); }
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-gray   { background: var(--gray-100);     color: var(--gray-600); }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 1rem; opacity: 0;
  pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--white); border-radius: 16px;
  width: 100%; box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
  transform: translateY(16px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-sm  { max-width: 380px; }
.modal-md  { max-width: 500px; }
.modal-lg  { max-width: 680px; }
.modal-xl  { max-width: 860px; }
.modal-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.05rem; font-weight: 500; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--gray-100);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--gray-600); transition: background .15s;
}
.modal-close:hover { background: var(--gray-200); }
.modal-body   { padding: 1.25rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: .75rem;
}

/* ── Alerts / Toast ─────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  font-size: .87rem; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .5rem;
}
.alert-error   { background: var(--red-light);    color: var(--red); }
.alert-success { background: var(--green-light);  color: var(--green); }
.alert-info    { background: var(--blue-light);   color: var(--blue); }
.alert-warning { background: var(--orange-light); color: var(--orange); }

#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  padding: .8rem 1.2rem; border-radius: 10px;
  font-size: .88rem; font-weight: 500; color: #fff;
  box-shadow: var(--shadow-md); min-width: 240px;
  animation: slideIn .3s ease;
}
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--blue); }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ── Filters bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: flex-end; gap: .75rem;
  flex-wrap: wrap; margin-bottom: 1.25rem;
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-control { min-width: 160px; }
.search-input { position: relative; }
.search-input input { padding-left: 2.2rem; }
.search-input .si {
  position: absolute; left: .65rem; top: 50%;
  transform: translateY(-50%); color: var(--gray-400);
  pointer-events: none;
}

/* ── Plan de pagos progress ─────────────────────────────────── */
.progress-bar { background: var(--gray-200); border-radius: 99px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--blue); transition: width .4s; }

/* ── Resumen financiacion ───────────────────────────────────── */
.fin-summary {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
  margin-bottom: 1.25rem;
}
.fin-item { background: var(--gray-50); border-radius: var(--radius-sm); padding: .8rem 1rem; }
.fin-item-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: var(--gray-400); }
.fin-item-value { font-size: .98rem; font-weight: 500; margin-top: .25rem; }

/* ── Paginación ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: .4rem; margin-top: 1rem; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 .5rem;
  border-radius: 6px; border: 1px solid var(--gray-200);
  background: var(--white); color: var(--gray-600);
  font-size: .83rem; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover   { border-color: var(--blue); color: var(--blue); }
.page-btn.current { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Sidebar overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 190;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .fin-summary { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .page-body { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .fin-summary { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { min-width: unset; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
  .table th, .table td { padding: .65rem .75rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value  { font-size: 1.35rem; }
  .login-card  { padding: 2rem 1.25rem; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-muted  { color: var(--gray-400); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-500      { font-weight: 500; }
.fw-600      { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
