<!DOCTYPE html>
<html lang="en">
<head>
  <script>
    (function(){
      var t=localStorage.getItem('theme');
      if(!t){t=window.matchMedia('(prefers-color-scheme:dark)').matches?'original-dark':'original-light';}
      document.documentElement.setAttribute('data-theme',t);
    })();
  </script>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SimpleX Manager — Login</title>
  <style>
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    [data-theme="original-light"] {
      --bg: #f5f5f7; --card: #fff; --text: #1d1d1f;
      --accent: #0053D0; --border: #e0e0e5;
      --btn-light-text: #fff;
    }
    [data-theme="original-dark"] {
      --bg: #111827; --card: #0B2A59; --text: #f5f5f7;
      --accent: #70F0F9; --border: #1e3a5f;
      --btn-light-text: #000;
    }
    [data-theme="matrix"] {
      --bg: #000; --card: #050d05; --text: #00ff41;
      --accent: #00ff41; --border: #0f3d0f;
      --btn-light-text: #000; --muted: #2e8b57;
    }

    body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
           background: var(--bg); color: var(--text); min-height: 100vh;
           display: flex; flex-direction: column; }
    .login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
    .box { background: var(--card); border-radius: 12px; padding: 36px 32px;
           width: 100%; max-width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,0.1); }
    h1 { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 24px; text-align: center; }
    label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
    input { width: 100%; padding: 10px 12px; font-size: 15px; border: 1px solid var(--border);
            border-radius: 8px; background: var(--bg); color: var(--text); outline: none; margin-bottom: 16px; }
    input:focus { border-color: var(--accent); }
    button { width: 100%; padding: 10px; background: var(--accent); color: var(--btn-light-text);
             border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
    .error { color: #DD0000; font-size: 13px; margin-bottom: 12px; text-align: center; }
    .site-footer { flex-shrink: 0; text-align: center; padding: 18px 20px;
                   border-top: 1px solid var(--border); color: var(--muted, #6e6e73);
                   font-size: 12px; line-height: 1.6; }
    .site-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
    .site-footer a:hover { text-decoration: underline; }
    .site-footer .sep { margin: 0 8px; opacity: 0.5; }
  </style>
</head>
<body>
  <div class="login-main">
    <div class="box">
      <h1>SimpleX Manager</h1>
      {% if error %}<div class="error">{{ error }}</div>{% endif %}
      <form method="post" action="/login">
        <label for="token">Access Token</label>
        <input type="password" id="token" name="token" placeholder="Enter token…" autofocus>
        <button type="submit">Sign in</button>
      </form>
    </div>
  </div>
  <footer class="site-footer">
    © Bournemouth Technology Ltd
    <span class="sep">·</span>
    built on © SimpleX Network
    <span class="sep">·</span>
    <a href="https://simplex.chat/downloads/" target="_blank" rel="noopener">Get SimpleX App</a>
  </footer>
</body>
</html>
