/* ──────────────────────────────────────────────────────────────────────────
   Concentrador — Design System
   POS de originación de préstamos personales
   Paleta: navy + amarillo retail; geometric sans (Manrope)
   ────────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --c-navy-900: #0b285f;
  --c-navy-800: #11387d;      /* primary */
  --c-navy-700: #144f99;
  --c-navy-600: #104389;
  --c-navy-500: #2573b8;      /* interactive */
  --c-navy-400: #4b96d0;
  --c-navy-100: #e6eef7;
  --c-navy-50:  #f1f5fb;

  --c-yellow:   #f3b646;      /* accent / ganadora */
  --c-yellow-dark: #d99a22;
  --c-yellow-soft: #fef3d8;

  /* Status */
  --c-green:   #16a34a;
  --c-green-soft: #dcfce7;
  --c-red:     #dc2626;
  --c-red-soft: #fee2e2;
  --c-amber:   #d97706;

  /* Neutrals */
  --c-bg:      #f5f7fb;
  --c-surface: #ffffff;
  --c-line:    #e4e8ef;
  --c-line-strong: #cdd4e0;
  --c-ink-900: #0d1424;
  --c-ink-700: #2c3447;
  --c-ink-500: #5a6478;
  --c-ink-400: #7a839a;
  --c-ink-300: #a7afc2;

  /* Type */
  --font-sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Google Sans', sans-serif;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Shadows */
  --sh-1: 0 1px 2px rgba(13, 20, 36, 0.04), 0 1px 1px rgba(13, 20, 36, 0.03);
  --sh-2: 0 4px 12px rgba(13, 20, 36, 0.06), 0 1px 3px rgba(13, 20, 36, 0.04);
  --sh-3: 0 12px 32px rgba(13, 20, 36, 0.10), 0 4px 12px rgba(13, 20, 36, 0.06);
  --sh-glow: 0 0 0 4px rgba(37, 115, 184, 0.15);
  --sh-glow-yellow: 0 0 0 6px rgba(243, 182, 70, 0.22);

  /* Density (toggled via data-density on root) */
  --pad-card: 24px;
  --pad-cell: 14px 16px;
  --gap-stack: 20px;
  --row-h: 52px;
  --font-base: 14px;
}

[data-density="compact"] {
  --pad-card: 16px;
  --pad-cell: 10px 12px;
  --gap-stack: 12px;
  --row-h: 40px;
  --font-base: 13px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-ink-900);
  font-family: var(--font-sans);
  font-size: var(--font-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: inherit; text-decoration: none; }

/* ─── Layout shell ─────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.app.sidebar-collapsed {
  grid-template-columns: 72px 1fr;
}

/* ─── Sidebar collapsed states ────────────────────────────────────── */
.app.sidebar-collapsed .sidebar {
  padding-left: 10px;
  padding-right: 10px;
}
.app.sidebar-collapsed .brand {
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 18px;
  align-items: center;
}
.app.sidebar-collapsed .brand-meta { display: none; }
.app.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px;
  position: relative;
}
.app.sidebar-collapsed .nav-item-text { display: none; }
.app.sidebar-collapsed .nav-section-label { display: none; }
.app.sidebar-collapsed .nav-divider { margin: 12px 8px; }
.app.sidebar-collapsed .nav-foot {
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
}
.app.sidebar-collapsed .nav-foot-meta { display: none; }

/* Tooltip on hover when collapsed */
.app.sidebar-collapsed .nav-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--c-navy-900);
  color: #fff;
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.app.sidebar-collapsed .nav-item:hover::before {
  content: '';
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--c-navy-900);
  z-index: 100;
  pointer-events: none;
}

.sidebar-toggle {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: 0;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s, transform 0.22s;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.app.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
  transform: rotate(180deg);
}

.sidebar {
  background: var(--c-navy-800);
  color: #fff;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  margin-bottom: 16px;
}

.brand-logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand-sub {
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  margin-top: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.78);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-size: 13.5px;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 600;
}
.nav-item .ic {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  color: var(--c-yellow);
  flex-shrink: 0;
}
.nav-item:not(.active) .ic { color: rgba(255,255,255,0.55); }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.40);
  padding: 4px 12px 6px;
}
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.10);
  margin: 14px 8px;
}

.nav-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: rgba(0,0,0,0.18);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-navy-500), var(--c-navy-700));
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}
.nav-foot .who { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.nav-foot .where { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 2px; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.topbar .crumb {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-ink-400);
}

.content {
  padding: 28px;
  flex: 1;
  max-width: 1500px;
  width: 100%;
}

[data-density="compact"] .content { padding: 18px; }
[data-density="compact"] .topbar { padding: 10px 18px; }

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary {
  background: var(--c-navy-800);
  color: #fff;
}
.btn-primary:hover { background: var(--c-navy-900); }
.btn-yellow {
  background: var(--c-yellow);
  color: var(--c-navy-900);
  box-shadow: 0 1px 0 rgba(0,0,0,0.06), inset 0 -2px 0 rgba(0,0,0,0.08);
}
.btn-yellow:hover { background: var(--c-yellow-dark); }
.btn-ghost {
  background: transparent;
  color: var(--c-ink-700);
  border-color: var(--c-line);
}
.btn-ghost:hover { background: var(--c-navy-50); border-color: var(--c-line-strong); }
.btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #f3c4c4;
}
.btn-danger:hover { background: #fde3e3; border-color: #e79a9a; }
.btn-text {
  background: transparent;
  color: var(--c-navy-500);
  padding: 6px 10px;
}
.btn-text:hover { background: var(--c-navy-100); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-lg {
  padding: 14px 26px;
  font-size: 15px;
  border-radius: var(--r-lg);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--r-sm);
}

/* ─── Cards ───────────────────────────────────────────────────────────── */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: var(--pad-card);
  box-shadow: var(--sh-1);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0;
}
.card-sub {
  font-size: 12px;
  color: var(--c-ink-500);
  margin-top: 2px;
}

/* ─── Forms ───────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-ink-700);
  letter-spacing: 0.01em;
}
.field-hint {
  font-size: 11.5px;
  color: var(--c-ink-400);
}
.field-error { color: var(--c-red); }

.input, .select, .textarea {
  background: var(--c-surface);
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--c-ink-900);
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-navy-500);
  box-shadow: var(--sh-glow);
}
.input::placeholder { color: var(--c-ink-300); }

[data-density="compact"] .input,
[data-density="compact"] .select { padding: 8px 12px; font-size: 13px; }

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .btn { border-radius: 0 var(--r-md) var(--r-md) 0; }

.radio-group, .seg {
  display: inline-flex;
  background: var(--c-navy-50);
  padding: 4px;
  border-radius: var(--r-md);
  gap: 2px;
}
.seg button {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-ink-500);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
}
.seg button.active {
  background: var(--c-surface);
  color: var(--c-navy-800);
  box-shadow: var(--sh-1);
}

/* Toggle switch */
.switch {
  --w: 38px; --h: 22px;
  position: relative;
  width: var(--w); height: var(--h);
  background: var(--c-line-strong);
  border-radius: var(--r-pill);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: calc(var(--h) - 4px);
  height: calc(var(--h) - 4px);
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.switch.on { background: var(--c-green); }
.switch.on::after { transform: translateX(calc(var(--w) - var(--h))); }

/* ─── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
  white-space: nowrap;
}
.badge-success { background: var(--c-green-soft); color: #14532d; }
.badge-danger  { background: var(--c-red-soft); color: #7f1d1d; }
.badge-warn    { background: #fef3c7; color: #78350f; }
.badge-info    { background: var(--c-navy-100); color: var(--c-navy-800); }
.badge-yellow  { background: var(--c-yellow-soft); color: #78350f; }
.badge-muted   { background: #f1f3f7; color: var(--c-ink-500); }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.dot-green { background: var(--c-green); }
.dot-red   { background: var(--c-red); }
.dot-amber { background: var(--c-amber); }

/* ─── Tables ──────────────────────────────────────────────────────────── */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tbl th, .tbl td {
  padding: var(--pad-cell);
  text-align: left;
  vertical-align: middle;
}
.tbl thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  border-bottom: 1px solid var(--c-navy-900);
  background: var(--c-navy-800);
  white-space: nowrap;
}
.tbl tbody tr {
  border-bottom: 1px solid var(--c-line);
  transition: background 0.08s;
}
.tbl tbody tr:hover { background: var(--c-navy-50); }
.tbl tbody tr:last-child { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── KPI ─────────────────────────────────────────────────────────────── */

.kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-ink-400);
}
.kpi-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--c-navy-900);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.kpi-delta {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kpi-delta.up   { color: var(--c-green); }
.kpi-delta.down { color: var(--c-red); }
.kpi-decoration {
  position: absolute;
  right: -12px; top: -12px;
  width: 64px; height: 64px;
  border-radius: 50%;
  opacity: 0.08;
}

/* ─── Misc ────────────────────────────────────────────────────────────── */

.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--c-ink-500); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.h3 { font-size: 16px; font-weight: 700; margin: 0; }
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-ink-400);
}

/* Financiera logo chip — placeholder-style monogram */
.flogo {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.10);
}
.flogo.sm { width: 28px; height: 28px; font-size: 10.5px; border-radius: 8px; }
.flogo.lg { width: 64px; height: 64px; font-size: 22px; border-radius: 14px; }

/* Variante con isologo real: fondo blanco + encuadre en color de marca */
.flogo-img {
  background: #fff;
  border: 1.5px solid var(--c-line);
  box-shadow: 0 1px 2px rgba(13, 20, 36, 0.06);
  overflow: hidden;
  padding: 4px;
}
.flogo-img img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.flogo-img.sm { padding: 3px; }
.flogo-img.lg { padding: 7px; }

/* Scrollbars in tables */
.scroll-x { overflow-x: auto; }

/* Animations */
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(243, 182, 70, 0.5); }
  100% { box-shadow: 0 0 0 18px rgba(243, 182, 70, 0); }
}
@keyframes spin-in { from { transform: rotate(-30deg) scale(0.8); opacity: 0; } to { transform: rotate(0) scale(1); opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes tw-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes scan {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

.fade-up { animation: fade-up 0.35s ease-out both; }
