/* Dark is the default. Light is opt-in via data-theme on <html>, which the
   page sets before first paint so there is no flash of the wrong theme. */
:root {
  --bg: #090c10;
  --bg-glow: rgba(59, 130, 246, 0.06);
  --panel: #11161d;
  --panel-2: #171e28;
  --panel2: #171e28;
  --line: #232c3a;
  --line-strong: #303c4e;
  --text: #edf1f7;
  --muted: #8896ab;
  --bull: #10b981;
  --bear: #f43f5e;
  --neutral: #64748b;
  --accent: #4f94f8;
  --accent-hover: #6aa6fb;
  --accent-fg: #050e1d;
  --warn: #f59e0b;
  --gold: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.36);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-glow: rgba(37, 99, 235, 0.05);
  --panel: #ffffff;
  --panel-2: #edf1f7;
  --panel2: #edf1f7;
  --line: #dbe2ec;
  --line-strong: #c5d0df;
  --text: #0f172a;
  --muted: #5b677a;
  /* Tuned for WCAG contrast on white panels */
  --bull: #059669;
  --bear: #dc2626;
  --neutral: #5b677a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-fg: #ffffff;
  --warn: #b45309;
  --gold: #b45309;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.09);
  color-scheme: light;
}

/* Follow the operating system on a first visit, until a choice is made. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f4f6fa;
    --bg-glow: rgba(37, 99, 235, 0.05);
    --panel: #ffffff;
    --panel-2: #edf1f7;
    --panel2: #edf1f7;
    --line: #dbe2ec;
    --line-strong: #c5d0df;
    --text: #0f172a;
    --muted: #5b677a;
    --bull: #059669;
    --bear: #dc2626;
    --neutral: #5b677a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-fg: #ffffff;
    --warn: #b45309;
    --gold: #b45309;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.09);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 80% 380px at 50% -120px, var(--bg-glow), transparent);
  background-repeat: no-repeat;
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card {
  width: 100%; max-width: 390px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 28px;
  box-shadow: var(--shadow-sm);
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 20px; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 4px;
  line-height: 1.25;
}
.brand-logo {
  width: 26px; height: 26px; max-width: 26px; max-height: 26px;
  border-radius: 7px; flex: 0 0 26px; object-fit: contain;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin: 14px 0 6px; }
input {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 148, 248, 0.16);
}
button {
  width: 100%; margin-top: 20px; font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 14px; border-radius: 9px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-fg);
  transition: background .15s ease, border-color .15s ease, transform .08s ease;
}
button:hover:not(:disabled) { background: var(--accent-hover); }
button:active:not(:disabled) { transform: translateY(0.5px); }
button:disabled { opacity: .48; cursor: not-allowed; }
.msg {
  display: none; margin-top: 16px; padding: 10px 13px; border-radius: 9px; font-size: 13px;
}
.msg.show { display: block; }
.msg.err { background: rgba(244, 63, 94, .1); border: 1px solid rgba(244, 63, 94, .32); color: var(--bear); }
.msg.ok { background: rgba(16, 185, 129, .1); border: 1px solid rgba(16, 185, 129, .3); color: var(--bull); }
.alt { margin-top: 20px; text-align: center; font-size: 13px; color: var(--muted); }
.alt a { color: var(--accent); text-decoration: none; font-weight: 500; }
.alt a:hover { text-decoration: underline; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { padding-right: 58px; }
button.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: auto; margin: 0; padding: 4px 8px; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 500; cursor: pointer;
}
button.pw-toggle:hover:not(:disabled) {
  background: var(--panel-2); color: var(--text); border-color: var(--line);
}
button.pw-toggle:active:not(:disabled) { transform: translateY(-50%); }
input[readonly] {
  background: var(--panel-2); color: var(--muted); cursor: default;
}
