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

    :root {
      --bg:         #08090a;
      --bg2:        #0f1011;
      --surface:    #0f1011;
      --border:     #23252a;
      --primary:    #e4f222;
      --primary-h:  #d4e217;
      --primary-fg: #08090a;
      --indigo:     #5e6ad2;
      --text:       #f7f8f8;
      --muted:      #8a8f98;
      --label:      #d0d6e0;
      --input-bg:   #1c1e22;
      --input-border: #2e3035;
      --input-focus-ring: rgba(94,106,210,.18);
      --input-focus-border: #5e6ad2;
      --error:      #eb5757;
      --toggle-bg:  rgba(255,255,255,.07);
      --toggle-border: rgba(255,255,255,.13);
      --toggle-hover: rgba(255,255,255,.14);
      --sep-color:  #23252a;
      --sep-text:   #62666d;
      --ghost-bg:   #161718;
      --ghost-border: #2e3035;
      --ghost-text: #c8cdd6;
      --ghost-hover-bg: #1e2023;
      --card-shadow:
        inset 0 0 0 1px #23252a,
        0 2px 4px rgba(0,0,0,.4),
        0 4px 32px rgba(8,9,10,.6);
    }

    :root[data-theme="light"] {
      --bg:         #f0f2f5;
      --bg2:        #e8eaed;
      --surface:    #ffffff;
      --border:     #e2e8f0;
      --primary:    #000000;
      --primary-h:  #1a1a1a;
      --primary-fg: #ffffff;
      --indigo:     #4f6ad6;
      --text:       #0f172a;
      --muted:      #64748b;
      --label:      #374151;
      --input-bg:   #f8fafc;
      --input-border: #e2e8f0;
      --input-focus-ring: rgba(37,99,235,.12);
      --input-focus-border: #4f6ad6;
      --error:      #dc2626;
      --toggle-bg:  rgba(0,0,0,.06);
      --toggle-border: rgba(0,0,0,.12);
      --toggle-hover: rgba(0,0,0,.1);
      --sep-color:  #e2e8f0;
      --sep-text:   #94a3b8;
      --ghost-bg:   #f8fafc;
      --ghost-border: #e2e8f0;
      --ghost-text: #475569;
      --ghost-hover-bg: #f1f5f9;
      --card-shadow:
        0 1px 3px rgba(0,0,0,.06),
        0 4px 24px rgba(0,0,0,.08);
    }

    html {
      overflow-x: clip;
      background: var(--bg2);
    }

    html, body {
      width: 100%;
      min-height: 100%;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--text);
      transition: background .2s, color .2s;
    }

    body {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
      min-height: 100dvh;
      padding: 12px 16px;
      padding-top: max(12px, env(safe-area-inset-top));
      padding-bottom: max(12px, env(safe-area-inset-bottom));
      background:
        radial-gradient(circle at 20% 5%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 95%, rgba(255,255,255,0.06) 0%, transparent 55%),
        linear-gradient(135deg, var(--bg) 0%, var(--bg2) 100%);
    }

    body::before {
      content: '';
      position: fixed;
      inset: 0;
      background-image:
        linear-gradient(rgba(228,242,34,.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(228,242,34,.025) 1px, transparent 1px);
      background-size: 96px 96px; background-position: 100% 0;
      pointer-events: none;
      opacity: 1;
      transition: opacity .2s;
    }
    :root[data-theme="light"] body::before {
      opacity: 1;
      /* жёлтая линия на .025 alpha не видна на светлом фоне — на свету сетка
         тёмно-серая (тон текста), а не лаймовая */
      background-image:
        linear-gradient(rgba(15,23,42,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15,23,42,.05) 1px, transparent 1px);
    }

    :root[data-theme="light"] body {
      background:
        radial-gradient(ellipse 540px 380px at 14% 8%, rgba(96,165,250,0.10), transparent 60%),
        radial-gradient(ellipse 640px 460px at 86% 92%, rgba(1,21,102,0.05), transparent 60%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
    }

    .theme-toggle {
      position: fixed;
      top: 16px; right: 16px;
      z-index: 100;
      width: 36px; height: 36px;
      border-radius: 8px;
      background: var(--toggle-bg);
      border: 1px solid var(--toggle-border);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: var(--muted);
      padding: 0;
      transition: background .15s, border-color .15s, color .15s;
    }
    .theme-toggle:hover { background: var(--toggle-hover); color: var(--text); }
    .theme-toggle .ic { width: 18px; height: 18px; align-items: center; justify-content: center; }
    .theme-toggle .ic svg { width: 18px; height: 18px; display: block; }
    .theme-toggle .ic-moon { display: none; }
    .theme-toggle .ic-sun  { display: inline-flex; }
    :root[data-theme="light"] .theme-toggle .ic-moon { display: inline-flex; }
    :root[data-theme="light"] .theme-toggle .ic-sun  { display: none; }

    .card {
      position: relative;
      z-index: 1;
      width: 100%;
      max-width: 400px;
      background: var(--surface);
      border-radius: 16px;
      padding: 24px 28px 20px;
      box-shadow: var(--card-shadow);
      text-align: center;
      transition: background .2s, box-shadow .2s;
    }

    .logo-wrap {
      display: block;
      text-align: center;
      text-decoration: none;
      margin: 0 auto 14px;
      /* оптическая коррекция: иконка+текст в SVG визуально не равновесны
         (плотная цветная иконка слева тянет взгляд), сдвигаем на глаз */
      transform: translateX(-5px);
    }
    .logo-wrap .logo-dark,
    .logo-wrap .logo-light {
      max-width: 240px;
      width: 100%;
      height: auto;
      margin: 0 auto;
    }
    .logo-wrap .logo-dark  { display: block; }
    .logo-wrap .logo-light { display: none; }
    :root[data-theme="light"] .logo-wrap .logo-dark  { display: none; }
    :root[data-theme="light"] .logo-wrap .logo-light { display: block; }

    h1 {
      font-size: 22px;
      font-weight: 600;
      letter-spacing: -0.3px;
      line-height: 1.25;
      color: var(--text);
      margin: 0 0 16px;
      transition: color .2s;
    }

    .field {
      margin-bottom: 10px;
      text-align: left;
    }
    label {
      display: block;
      font-size: 13px;
      font-weight: 500;
      color: var(--label);
      margin-bottom: 6px;
      transition: color .2s;
    }
    input {
      width: 100%;
      background: var(--input-bg);
      border: 1px solid var(--input-border);
      border-radius: 2px;
      padding: 10px 14px;
      font-size: 15px;
      font-family: inherit;
      color: var(--text);
      outline: none;
      transition: border-color .12s, box-shadow .12s, background .2s;
    }
    input:focus {
      border-color: var(--input-focus-border);
      box-shadow: 0 0 0 3px var(--input-focus-ring);
    }
    input::placeholder { color: var(--muted); }
    input:-webkit-autofill {
      -webkit-box-shadow: 0 0 0 40px var(--input-bg) inset;
      -webkit-text-fill-color: var(--text);
    }

    .pwd-wrap { position: relative; }
    .pwd-wrap input { padding-right: 42px; }
    .pwd-toggle {
      position: absolute;
      right: 8px; top: 50%;
      transform: translateY(-50%);
      background: transparent;
      border: 0;
      cursor: pointer;
      padding: 6px;
      color: var(--muted);
      line-height: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 6px;
      transition: color .12s;
    }
    .pwd-toggle:hover { color: var(--text); }
    .pwd-toggle svg { display: block; width: 18px; height: 18px; }

    .btn-primary {
      width: 100%;
      margin-top: 6px;
      padding: 11px;
      background: var(--primary);
      color: var(--primary-fg);
      font-size: 15px;
      font-weight: 700;
      font-family: inherit;
      border: none;
      border-radius: 2px;
      cursor: pointer;
      position: relative;
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,.25),
        0 1px 2px rgba(0,0,0,.2);
      transition: background .12s, transform .08s, opacity .12s;
    }
    .btn-primary:hover  { background: var(--primary-h); }
    .btn-primary:active { transform: scale(.98); }
    .btn-primary:disabled { opacity: .5; cursor: not-allowed; }

    .btn-ghost {
      width: 100%;
      margin-top: 8px;
      padding: 10px 16px;
      background: var(--ghost-bg);
      color: var(--ghost-text);
      font-size: 14px;
      font-weight: 500;
      font-family: inherit;
      border: 1px solid var(--ghost-border);
      border-radius: 2px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: background .12s, border-color .12s, transform .08s, opacity .12s;
    }
    .btn-ghost:hover  { background: var(--ghost-hover-bg); }
    .btn-ghost:active { transform: scale(.98); }
    .btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
    .btn-ghost svg { flex-shrink: 0; }

    .spinner {
      display: none;
      width: 17px; height: 17px;
      border: 2px solid rgba(0,0,0,.2);
      border-top-color: var(--primary-fg);
      border-radius: 50%;
      animation: spin .6s linear infinite;
      margin: 0 auto;
    }
    .btn-primary.loading .btn-text { display: none; }
    .btn-primary.loading .spinner  { display: block; }

    .spinner-sm {
      display: inline-block;
      width: 15px; height: 15px;
      border: 2px solid rgba(255,255,255,.2);
      border-top-color: var(--ghost-text);
      border-radius: 50%;
      animation: spin .6s linear infinite;
      flex-shrink: 0;
    }
    :root[data-theme="light"] .spinner-sm { border-top-color: var(--ghost-text); }

    @keyframes spin { to { transform: rotate(360deg); } }

    .sep {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 12px 0 2px;
      font-size: 11px;
      letter-spacing: .05em;
      text-transform: none;
      color: var(--sep-text);
      font-weight: 400;
    }
    .sep::before, .sep::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--sep-color);
    }

    .error-msg {
      display: none;
      margin-top: 12px;
      padding: 10px 14px;
      border: 1px solid rgba(235,87,87,.25);
      border-radius: 8px;
      font-size: 13px;
      color: var(--error);
      text-align: left;
      background: rgba(235,87,87,.07);
      line-height: 1.5;
    }
    .error-msg.visible { display: block; }
    .error-msg a { color: inherit; }

    .info-msg {
      display: none;
      margin-top: 12px;
      padding: 10px 14px;
      border: 1px solid rgba(94,106,210,.25);
      border-radius: 8px;
      font-size: 13px;
      color: #a8b4f8;
      text-align: left;
      background: rgba(94,106,210,.07);
      line-height: 1.5;
    }
    :root[data-theme="light"] .info-msg { color: #3f4fba; background: rgba(79,106,214,.06); border-color: rgba(79,106,214,.2); }
    .info-msg.visible { display: block; }
    .info-msg a { color: inherit; }

    .back-link {
      position: relative;
      z-index: 1;
      display: block;
      text-align: center;
      margin-top: 20px;
      font-size: 13px;
      color: var(--muted);
      text-decoration: none;
      transition: color .12s;
    }
    .back-link:hover { color: var(--text); }

    .trust-note {
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px solid var(--sep-color);
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
      text-align: center;
    }
    .trust-note a {
      color: var(--label);
      text-decoration: underline;
      text-underline-offset: 2px;
    }

  .legal-links {
    margin-top: 16px;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
  }
  .legal-links a {
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .legal-links a:hover { color: var(--text); }
  .forgot-link {
    font-size: 0.9rem;
    color: var(--indigo);
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.9;
  }
  .forgot-link:hover { opacity: 1; }

@media (max-width: 600px) {
  body {
    justify-content: flex-start;
    padding-top: max(24px, env(safe-area-inset-top, 24px));
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
  .card { padding: 18px 16px 14px; border-radius: 14px; }
  h1 { font-size: 18px; margin-bottom: 12px; }
  .logo-wrap .logo-dark,
  .logo-wrap .logo-light { max-width: 190px; }
  .logo-wrap { margin-bottom: 10px; }
  input { font-size: 16px; }
  .btn-primary { font-size: 15px; padding: 11px; }
  .btn-ghost { font-size: 14px; padding: 10px 12px; }
  .theme-toggle { top: max(40px, calc(env(safe-area-inset-top, 20px) + 26px)); right: 30px; width: 32px; height: 32px; }
  .back-link { margin-top: 14px; }
}

@media (max-width: 360px) {
  .card { padding: 14px 12px 12px; }
  h1 { font-size: 17px; }
}
