:root {
    --bg: #09090f;
    --surface: #12121c;
    --border: rgba(255,255,255,0.09);
    --accent: #d6ea6a;
    --accent-dim: rgba(214, 234, 106, 0.14);
    --text: #ececf1;
    --muted: #9499a8;
    --error: #ff8a8a;
  }

  body.light {
    --bg: #f0f1f4;
    --surface: #ffffff;
    --border: rgba(15, 23, 42, 0.12);
    --accent: #141428;
    --accent-dim: rgba(20, 20, 40, 0.08);
    --text: #111118;
    --muted: #5c6470;
    --error: #b42318;
  }

  body.light::before { background-image: linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px); }
  body.light::after { background: radial-gradient(ellipse, rgba(26,26,46,0.04) 0%, transparent 70%); }
  body.light .btn { color: #f5f5f0; }
  body.light .logo-icon {
    background: linear-gradient(165deg, #ecf59a 0%, #d6ea6a 45%, #c4d94a 100%);
    border: 1px solid rgba(17, 17, 24, 0.18);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
  }

  .theme-btn.login-theme-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    z-index: 100;
    cursor: pointer;
    user-select: none;
    color: var(--muted2);
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
  }
  .theme-btn.login-theme-btn:focus,
  .theme-btn.login-theme-btn:focus-visible {
    outline: none;
    box-shadow: none;
  }
  .theme-btn.login-theme-btn:hover {
    border-color: var(--accent);
  }
  body.light .theme-btn.login-theme-btn:hover {
    border-color: rgba(17, 17, 24, 0.22);
    color: var(--text);
  }
  body:not(.light) .theme-btn.login-theme-btn {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(214, 234, 106, 0.24);
    color: #e6ebf5;
  }
  body:not(.light) .theme-btn.login-theme-btn:hover {
    background: rgba(214, 234, 106, 0.1);
    border-color: rgba(214, 234, 106, 0.52);
    color: #f8fbff;
  }
  .theme-btn.login-theme-btn span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 1;
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  /* Login: pie legal en flujo (scroll), no fixed — no tapa el formulario */
  body.page-login {
    align-items: flex-start;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
    box-sizing: border-box;
  }
  body.page-login .login-page-wrap {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    justify-content: center;
    min-height: calc(100vh - 80px);
    min-height: calc(100svh - max(40px, env(safe-area-inset-top)) - max(40px, env(safe-area-inset-bottom)));
  }
  body.page-login .page-login-footer {
    flex-shrink: 0;
    width: 100%;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
  }
  body.page-login .page-login-footer .vv-content-notice {
    margin-bottom: 10px;
    text-align: center;
  }

  /* Grid background */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
  }

  /* Glow */
  body::after {
    content: '';
    position: fixed;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(214, 234, 106, 0.07) 0%, transparent 70%);
    pointer-events: none;
  }

  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 52px 48px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    animation: fadeUp 0.5s ease both;
    box-sizing: border-box;
  }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 36px;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .logo-icon svg { width: 18px; height: 18px; }

  .logo-text {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.5px;
    color: var(--text);
  }

  h1 {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 28px;
    letter-spacing: -1px;
    margin-bottom: 6px;
  }

  .subtitle {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 36px;
  }

  .field {
    margin-bottom: 18px;
  }

  label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 8px;
  }

  input {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
  }

  input:focus {
    border-color: var(--accent);
    background: var(--accent-dim);
  }

  .btn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: #0a0a0f;
    border: none;
    border-radius: 10px;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s, transform 0.1s;
    position: relative;
    overflow: hidden;
  }

  .btn:hover { opacity: 0.9; }
  .btn:active { transform: scale(0.98); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .error-msg {
    background: rgba(255,85,85,0.1);
    border: 1px solid rgba(255,85,85,0.3);
    color: var(--error);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    margin-top: 16px;
    display: none;
  }

  .error-msg.visible { display: block; animation: shake 0.3s ease; }

  @keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
  }

  @media (max-width: 480px) {
    .card { padding: 32px 20px; border-radius: 16px; }
    h1 { font-size: 22px; }
    .subtitle { font-size: 13px; margin-bottom: 28px; }
    .theme-btn.login-theme-btn {
      top: 14px;
      right: 14px;
      padding: 6px 10px;
    }
  }
