/* =============================================
   EM Financiera — Institutional Banking UI
   DM Serif Display · Figtree · DM Mono
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Figtree:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg:          #f4f2ee;
  --surface:     #ffffff;
  --surface-2:   #faf9f7;
  --border:      #e2ddd6;
  --border-soft: #ece9e3;

  --ink:         #0d0d0b;
  --ink-2:       #3d3b37;
  --ink-3:       #7a7670;
  --ink-4:       #b0aca5;

  --verde:       #1b4332;
  --verde-mid:   #2d6a4f;
  --verde-light: #d8f3dc;
  --verde-tint:  #f0faf2;

  --gold:        #9a7b3f;
  --gold-light:  #fdf3de;

  --rojo:        #991b1b;
  --rojo-light:  #fef2f2;
  --rojo-tint:   #fee2e2;

  --amarillo:    #92400e;
  --amarillo-light: #fffbeb;
  --amarillo-tint:  #fef3c7;

  --ff-serif: 'DM Serif Display', Georgia, serif;
  --ff-body:  'Figtree', system-ui, sans-serif;
  --ff-mono:  'DM Mono', 'Courier New', monospace;

  --radius:   8px;
  --radius-lg: 12px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ── Body ── */
body {
  font-family: var(--ff-body);
  font-size: 0.9375rem;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 2.5rem;
  height: 58px;
  gap: 0;
}

.brand {
  font-family: var(--ff-serif);
  font-size: 1.2rem;
  color: var(--ink);
  letter-spacing: 0.01em;
  margin-right: 3rem;
  flex-shrink: 0;
}

.brand span {
  color: var(--verde);
}

.nav-links {
  display: flex;
  gap: 0;
  height: 100%;
  align-items: stretch;
}

.nav-links a {
  display: flex;
  align-items: center;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 0.845rem;
  font-weight: 500;
  padding: 0 1.1rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--ink);
}

.nav-links a.active {
  color: var(--verde);
  border-bottom-color: var(--verde);
  font-weight: 600;
}

/* ── Main ── */
main {
  padding: 2.25rem 2.5rem;
  max-width: 1320px;
  margin: 0 auto;
}

/* ── Headings ── */
h2 {
  font-family: var(--ff-serif);
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 1.5rem;
}

h3 {
  font-family: var(--ff-body);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.85rem;
}

h4 {
  font-family: var(--ff-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.6rem;
}

/* ── Section title row ── */
.seccion-titulo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.seccion-titulo h2 { margin-bottom: 0; }

/* ── Cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.card {
  background: var(--surface);
  padding: 1.25rem 1.4rem;
  position: relative;
  transition: background 0.15s;
}

.card:hover {
  background: var(--surface-2);
}

.card .label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.card .value {
  font-family: var(--ff-mono);
  font-size: 1.45rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* ── Stat bar ── */
.stat-bar-wrap {
  background: var(--border-soft);
  border-radius: 2px;
  height: 3px;
  overflow: hidden;
  margin-top: 0.6rem;
}

.stat-bar {
  height: 100%;
  background: var(--verde-mid);
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(.4, 0, .2, 1);
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-xs);
}

thead {
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 0.7rem 1.1rem;
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  background: var(--surface-2);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.875rem;
  color: var(--ink-2);
  vertical-align: middle;
}

tr:hover td {
  background: var(--verde-tint);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-verde {
  background: var(--verde-light);
  color: var(--verde);
}

.badge-amarillo {
  background: var(--amarillo-tint);
  color: var(--amarillo);
}

.badge-rojo {
  background: var(--rojo-tint);
  color: var(--rojo);
}

.badge-azul {
  background: #dbeafe;
  color: #1e40af;
}

/* ── Buttons ── */
button {
  font-family: var(--ff-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.845rem;
  font-weight: 600;
  transition: all 0.15s;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn-primary {
  background: var(--verde);
  color: #fff;
  border-color: var(--verde);
}

.btn-primary:hover {
  background: var(--verde-mid);
  border-color: var(--verde-mid);
  box-shadow: 0 2px 8px rgba(27, 67, 50, .25);
}

.btn-primary:active {
  background: #163d2a;
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--border);
  margin-left: 0.5rem;
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--ink-3);
  color: var(--ink);
}

/* ── Forms ── */
form {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  max-width: 660px;
  box-shadow: var(--shadow-xs);
}

.form-group {
  margin-bottom: 1.1rem;
}

label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--ff-body);
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--verde);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(27, 67, 50, .1);
}

input::placeholder { color: var(--ink-4); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%237a7670' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.6;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--verde);
  cursor: pointer;
  margin-right: 0.45rem;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

small {
  font-size: 0.775rem;
  color: var(--ink-3);
  margin-top: 0.3rem;
  display: block;
  line-height: 1.5;
}

/* ── Messages ── */
.msg-error {
  display: inline-block;
  color: var(--rojo);
  font-size: 0.845rem;
  margin-top: 0.6rem;
  padding: 0.5rem 0.85rem;
  background: var(--rojo-light);
  border-radius: var(--radius);
  border: 1px solid var(--rojo-tint);
}

.msg-ok {
  display: inline-block;
  color: var(--verde);
  font-size: 0.845rem;
  margin-top: 0.6rem;
  padding: 0.5rem 0.85rem;
  background: var(--verde-tint);
  border-radius: var(--radius);
  border: 1px solid var(--verde-light);
}

/* ── Preview / info box ── */
.preview-box {
  margin: 0.85rem 0;
  padding: 0.85rem 1.1rem;
  background: var(--verde-tint);
  border-radius: var(--radius);
  border: 1px solid var(--verde-light);
  border-left: 3px solid var(--verde-mid);
  font-size: 0.875rem;
  color: var(--ink-2);
}

/* ── Divider ── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}

/* ── Mono numbers ── */
.mono {
  font-family: var(--ff-mono);
  font-size: 0.875rem;
}

/* ── Subtle entry animation ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

main > * {
  animation: fadeUp 0.22s ease both;
}

main > *:nth-child(2) { animation-delay: 0.04s; }
main > *:nth-child(3) { animation-delay: 0.08s; }
main > *:nth-child(4) { animation-delay: 0.12s; }

/* ── Responsive ── */
@media (max-width: 900px) {
  main { padding: 1.5rem 1.25rem; }
  .navbar { padding: 0 1.25rem; }
  .brand { margin-right: 1.5rem; }
  .nav-links a { padding: 0 0.75rem; font-size: 0.8rem; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  h2 { font-size: 1.4rem; }
}

@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .seccion-titulo { flex-direction: column; align-items: flex-start; }
  table { font-size: 0.8rem; }
  td, th { padding: 0.55rem 0.65rem; }
}
