:root {
      --verde: #16a34a;
      --verde-oscuro: #065f46;
      --gris-texto: #1e293b;
      --gris-suave: #94a3b8;
      --borde: #e2e8f0;
      --bg-body: #f8fafc;
      --bg-card: #ffffff;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }

    body {
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", "Roboto", "Segoe UI", sans-serif;
      background: radial-gradient(circle at 20% 20%, rgba(22,163,74,0.08) 0%, rgba(0,0,0,0) 60%),
                  radial-gradient(circle at 80% 20%, rgba(59,130,246,0.07) 0%, rgba(0,0,0,0) 60%),
                  var(--bg-body);
      color: var(--gris-texto);
      min-height: 100vh;
      min-height: 100dvh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }

    /* ============================================
       ANIMACIONES
    ============================================ */
    @keyframes fadeSlideUp {
      from { opacity: 0; transform: translateY(28px) scale(0.98); }
      to   { opacity: 1; transform: translateY(0) scale(1); }
    }
    @keyframes shake {
      0%, 100% { transform: translateX(0); }
      20%       { transform: translateX(-8px); }
      40%       { transform: translateX(8px); }
      60%       { transform: translateX(-6px); }
      80%       { transform: translateX(6px); }
    }
    @keyframes pulse-logo {
      0%, 100% { box-shadow: 0 12px 24px rgba(22,163,74,0.28); }
      50%       { box-shadow: 0 12px 32px rgba(22,163,74,0.55); }
    }
    @keyframes fadeSlideOut {
      from { opacity: 1; transform: translateY(0) scale(1); }
      to   { opacity: 0; transform: translateY(-20px) scale(0.97); }
    }
    @keyframes rowIn {
      from { opacity: 0; transform: translateX(-16px); }
      to   { opacity: 1; transform: translateX(0); }
    }
    @keyframes cellPop {
      0%   { transform: scale(1); }
      50%  { transform: scale(1.12); }
      100% { transform: scale(1); }
    }
    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    /* ============================================
       LOGIN CARD
    ============================================ */
    .login-card {
      background: var(--bg-card);
      border: 1px solid var(--borde);
      border-radius: 24px;
      box-shadow: 0 30px 80px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
      width: 100%;
      max-width: 400px;
      padding: 32px 24px 28px;
      animation: fadeSlideUp .45s cubic-bezier(.22,.68,0,1.2) both;
    }
    .login-card.saliendo { animation: fadeSlideOut .3s ease forwards; pointer-events: none; }
    .login-header { text-align: center; margin-bottom: 28px; }
    .login-logo {
      width: 68px; height: 68px; border-radius: 16px;
      background: #fff; border: 2px solid var(--verde);
      box-shadow: 0 12px 24px rgba(22,163,74,0.28);
      object-fit: contain; margin: 0 auto 14px; padding: 6px;
      display: block; animation: pulse-logo 2.4s ease-in-out infinite;
    }
    .login-titulo { font-size: 1.1rem; font-weight: 700; color: var(--gris-texto); line-height: 1.3; }
    .login-sub { font-size: .85rem; color: var(--gris-suave); line-height: 1.4; margin-top: 4px; }
    .form-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
    .form-label { font-size: .95rem; font-weight: 600; color: var(--gris-texto); }
    .form-input {
      font-family: inherit; font-size: 1.1rem; border-radius: 12px;
      border: 1.5px solid var(--borde); padding: 14px 16px; outline: none;
      line-height: 1.4; background: #fff; color: var(--gris-texto);
      transition: all .2s ease; -webkit-text-size-adjust: 100%;
    }
    .form-input:focus { border-color: rgba(22,163,74,.6); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
    .form-input.error-shake {
      border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.15);
      animation: shake .4s ease;
    }
    .error-msg { font-size: .85rem; line-height: 1.3; color: #dc2626; min-height: 1.2em; }
    .btn-submit {
      width: 100%; background: var(--verde); color: #fff; font-weight: 700;
      border: 0; border-radius: 14px; padding: 16px; font-size: 1.05rem;
      cursor: pointer; box-shadow: 0 16px 28px rgba(22,163,74,.38);
      transition: background .15s ease, transform .1s ease;
      display: flex; align-items: center; justify-content: center;
      gap: 8px; min-height: 52px; touch-action: manipulation;
    }
    .btn-submit:active { transform: scale(.97); background: var(--verde-oscuro); }
    .btn-spinner {
      width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4);
      border-top-color: #fff; border-radius: 50%;
      animation: spin .6s linear infinite; display: none;
    }
    .btn-submit.cargando .btn-spinner { display: block; }
    .btn-submit.cargando .btn-texto   { opacity: .7; }
    .nota-legal {
      text-align: center; font-size: .75rem; color: var(--gris-suave);
      line-height: 1.5; margin-top: 18px;
    }

    /* ============================================
       BILLETERA CARD
    ============================================ */
    .billetera-card {
      background: var(--bg-card); border: 1px solid var(--borde);
      border-radius: 24px;
      box-shadow: 0 20px 60px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.05);
      width: 100%; max-width: 1100px; padding: 20px 16px 24px; display: none;
    }
    .billetera-card.visible {
      display: block;
      animation: fadeSlideUp .5s cubic-bezier(.22,.68,0,1.2) both;
    }
    .billetera-card.saliendo { animation: fadeSlideOut .3s ease forwards; pointer-events: none; }

    /* Header */
    .billetera-head {
      text-align: center; margin-bottom: 20px;
      padding-bottom: 16px; border-bottom: 1px solid var(--borde);
    }
    .billetera-titulo { font-size: 1.3rem; font-weight: 700; color: var(--gris-texto); line-height: 1.2; }

    /* Info pills */
    .info-pills {
      display: flex; flex-wrap: wrap; justify-content: center;
      gap: 8px; margin-top: 10px;
    }
    .info-pill {
      display: inline-flex; align-items: center; gap: 5px;
      background: #f1f5f9; border: 1px solid var(--borde);
      border-radius: 100px; padding: 4px 12px;
      font-size: .78rem; font-weight: 500; color: #475569;
    }
    .info-pill strong { color: var(--gris-texto); }
    .info-pill.actualizacion { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

    /* Badge saldo */
    .saldo-badge {
      display: inline-flex; align-items: center; gap: 6px;
      margin-top: 10px; background: #f0fdf4; border: 1px solid #bbf7d0;
      border-radius: 100px; padding: 6px 14px;
      font-size: .85rem; font-weight: 600; color: var(--verde-oscuro);
    }
    .saldo-badge.negativo { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
    .saldo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--verde); }
    .saldo-badge.negativo .saldo-dot { background: #dc2626; }

    /* ============================================
       TABLA
    ============================================ */
    .scroll-hint {
      display: none; text-align: center; font-size: .72rem;
      color: var(--gris-suave); margin-bottom: 6px;
    }
    .tabla-scroll-wrapper {
      overflow-x: auto; border-radius: 12px; border: 1px solid #cbd5e1;
      -webkit-overflow-scrolling: touch;
    }

    table {
      border-collapse: collapse; width: 100%;
      font-size: .78rem; text-align: center; table-layout: auto;
    }
    thead th {
      border: 1px solid #cbd5e1; padding: 8px 6px;
      font-weight: 700; background: #f1f5f9;
      font-size: .72rem; letter-spacing: .02em; color: #475569;
      white-space: nowrap;
    }
    thead th:first-child { background: #e2e8f0; }

    thead th.col-saldo-ini-header {
      background: #fefce8 !important;
      border-right: 2px solid #fde68a !important;
      color: #713f12;
      font-size: .7rem;
      line-height: 1.4;
      text-align: center;
    }

    /* Columna TOTAL SALDO */
    thead th.col-total,
    tbody td.col-total {
      background: #f0fdf4 !important;
      border-left: 2px solid #86efac !important;
      font-weight: 700;
    }

    /* Separador visual entre meses y seguro */
    thead th.sep-seguro,
    tbody td.sep-seguro {
      background: #f8fafc !important;
      border-left: 3px solid #cbd5e1 !important;
    }

    /* Fila seguro */
    tbody tr.fila-seguro td {
      background: #fff7ed !important;
      border-top: 2px solid #fed7aa !important;
    }
    tbody tr.fila-seguro td.row-title {
      background: #ffedd5 !important;
      color: #9a3412;
      font-weight: 700;
    }
    td.seguro-deuda {
      color: #dc2626 !important;
      font-weight: 700 !important;
    }
    td.seguro-ok {
      color: var(--verde) !important;
      font-weight: 700 !important;
    }

    tbody td {
      border: 1px solid #cbd5e1; padding: 10px 6px;
      font-weight: 500; height: 42px; vertical-align: middle;
      background: #fff; transition: background .15s ease;
      white-space: nowrap;
    }
    tbody tr:nth-child(1) { animation: rowIn .4s .15s ease both; }
    tbody tr:nth-child(2) { animation: rowIn .4s .28s ease both; }
    tbody tr:nth-child(3) { animation: rowIn .4s .41s ease both; }
    tbody tr:nth-child(4) { animation: rowIn .4s .54s ease both; }

    /* Fila TOTAL */
    tbody tr.fila-total td {
      background: #f8fafc; font-weight: 700;
      border-top: 2px solid #94a3b8;
    }

    tbody td.row-title {
      font-size: .75rem; font-weight: 700; background: #f1f5f9;
      text-align: left; padding-left: 8px; white-space: nowrap;
      color: #334155; letter-spacing: .03em; min-width: 90px;
    }
    td.has-value { animation: cellPop .3s ease; }
    tbody td:not(.row-title):hover { background: #f0fdf4; }

    /* Celdas ocultas (meses futuros) */
    td.mes-futuro {
      background: #f8fafc !important;
      color: #cbd5e1 !important;
      font-size: .65rem;
      cursor: not-allowed;
    }

    .tabla-nota {
      font-size: .7rem; line-height: 1.5; color: var(--gris-suave);
      text-align: center; margin-top: 10px;
    }

    /* Botón salir */
    .volver-wrapper { margin-top: 20px; text-align: center; }
    .btn-volver {
      appearance: none; background: transparent;
      border: 2px solid var(--verde); color: var(--verde-oscuro);
      font-weight: 700; font-size: .95rem; border-radius: 12px;
      padding: 12px 28px; cursor: pointer; transition: all .15s ease;
      min-height: 48px; touch-action: manipulation;
    }
    .btn-volver:active { background: var(--verde); color: #fff; transform: scale(.97); }

    /* ============================================
       MOBILE
    ============================================ */
    @media (max-width: 600px) {
      body { padding: 12px; align-items: flex-start; padding-top: 24px; }
      .billetera-card { border-radius: 20px; padding: 16px 12px 20px; }
      .billetera-titulo { font-size: 1.05rem; }
      .scroll-hint { display: block; }
      table { font-size: .68rem; }
      thead th { padding: 6px 3px; font-size: .62rem; }
      tbody td { padding: 8px 3px; height: 36px; }
      tbody td.row-title { min-width: 75px; font-size: .65rem; padding-left: 5px; }
      .btn-volver { width: 100%; }
    }