:root {
  color-scheme: light;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  --bg-canvas: #d9edf9;
  --bg-surface: rgba(255, 255, 255, 0.92);
  --bg-elevated: rgba(255, 255, 255, 0.97);
  --bg-input: #f4f8fc;
  --text-primary: #19324b;
  --text-secondary: #36516b;
  --text-muted: #526f86;
  --border: rgba(75, 117, 148, 0.3);
  --border-strong: rgba(35, 104, 153, 0.58);
  --accent-cyan: #089fd5;
  --accent-indigo: #6366f1;
  --accent-blue: #2563eb;
  --focus: #0369a1;
  --success-bg: #e9f8f1;
  --success-text: #176444;
  --warning-bg: #fff1f0;
  --warning-text: #a02c35;
  --shadow: 0 18px 46px rgba(58, 98, 133, 0.16);
  --shadow-hover: 0 18px 38px rgba(58, 98, 133, 0.22);
}

:root[data-home-theme='dark'] {
  color-scheme: dark;
  --bg-canvas: #05070e;
  --bg-surface: rgba(15, 21, 34, 0.8);
  --bg-elevated: rgba(18, 26, 42, 0.94);
  --bg-input: rgba(5, 11, 22, 0.72);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(56, 189, 248, 0.5);
  --accent-cyan: #38bdf8;
  --accent-indigo: #818cf8;
  --accent-blue: #60a5fa;
  --focus: #7dd3fc;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-text: #a7f3d0;
  --warning-bg: rgba(239, 68, 68, 0.12);
  --warning-text: #fecaca;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.46);
  --shadow-hover: 0 20px 44px rgba(0, 0, 0, 0.58);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg-canvas); }
body {
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.34), transparent 54%),
    linear-gradient(160deg, #87bde3 0%, #c8e5f7 52%, #edf8ff 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font: 15px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
:root[data-home-theme='dark'] body {
  background:
    radial-gradient(ellipse at 54% 18%, rgba(217, 119, 6, 0.14), transparent 38%),
    radial-gradient(circle at 20% 80%, rgba(79, 70, 229, 0.2), transparent 52%),
    linear-gradient(rgba(4, 6, 12, 0.4), rgba(4, 6, 12, 0.72)),
    url('/auth/static/brand/galaxy-desktop.jpeg') center / cover fixed #04060c;
}
a { color: #126f9f; text-decoration-thickness: 1px; text-underline-offset: 3px; }
:root[data-home-theme='dark'] a { color: #7dd3fc; }
a, button, input, select, textarea { transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }

.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.pixel-cloud { position: absolute; left: -150px; width: 42px; height: 10px; background: rgba(255,255,255,.84); box-shadow: 10px -10px 0 rgba(255,255,255,.84), 22px -4px 0 rgba(255,255,255,.84), -10px 1px 0 rgba(255,255,255,.68), 9px 10px 0 rgba(255,255,255,.62); animation: cloud-drift 220s linear infinite; }
.pixel-cloud:nth-child(1) { top: 15%; }
.pixel-cloud:nth-child(2) { top: 42%; animation-delay: -90s; scale: .72; }
.pixel-cloud:nth-child(3) { top: 72%; animation-delay: -160s; scale: .86; }
.pixel-cloud:nth-child(4) { top: 58%; animation-delay: -40s; scale: .58; }
.pixel-starship { display: none; position: absolute; top: 64px; left: -100px; width: 72px; animation: ship-drift 170s linear infinite; }
:root[data-home-theme='dark'] .pixel-cloud { display: none; }
:root[data-home-theme='dark'] .pixel-starship { display: block; }
:root[data-home-theme='dark'] .pixel-cat { display: none; }
@keyframes cloud-drift { to { translate: calc(100vw + 220px) 0; } }
@keyframes ship-drift { to { translate: calc(100vw + 180px) 0; } }

.site-header {
  position: relative;
  z-index: 5;
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-surface);
  box-shadow: 0 8px 26px rgba(58, 98, 133, 0.1);
  backdrop-filter: blur(20px) saturate(160%);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text-primary); text-decoration: none; margin-right: auto; }
.brand-logo, .hero-logo { display: grid; place-items: center; flex: none; background: linear-gradient(145deg, #20a9df, #1762b8); box-shadow: 0 7px 18px rgba(23, 118, 182, .25), inset 0 1px 0 rgba(255,255,255,.32); }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; }
.brand-logo img { width: 34px; height: 34px; object-fit: contain; }
.brand strong { display: block; font-size: 18px; line-height: 1.15; letter-spacing: -.025em; }
.brand small { display: block; color: var(--text-muted); font-size: 11px; line-height: 1.4; margin-top: 3px; }
.account-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.account-nav a { padding: 8px 10px; border-radius: 9px; color: var(--text-secondary); text-decoration: none; font-size: 12px; font-weight: 600; }
.account-nav a:hover { color: var(--text-primary); background: var(--bg-input); }
.theme-toggle { position: relative; flex: none; width: 40px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 11px; color: #245577; background: var(--bg-elevated); cursor: pointer; }
:root[data-home-theme='dark'] .theme-toggle { color: #fde68a; }
.theme-toggle:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); }
.theme-toggle svg { width: 18px; height: 18px; }
:root:not([data-home-theme='dark']) .icon-moon, :root[data-home-theme='dark'] .icon-sun { display: none; }

.page { position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 0 20px 34px; }
.masthead { position: relative; max-width: 780px; margin: 34px auto 26px; text-align: center; }
.hero-logo { width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 15px; }
.hero-logo img { width: 44px; height: 44px; object-fit: contain; }
.eyebrow { display: block; color: var(--text-muted); font-size: 10px; font-weight: 750; letter-spacing: .16em; line-height: 1.5; text-transform: uppercase; }
.masthead h1 { margin: 7px 0 6px; color: var(--text-primary); font-size: clamp(30px, 4vw, 43px); line-height: 1.12; letter-spacing: -.045em; text-shadow: 0 2px 12px rgba(255,255,255,.26); }
.masthead p { max-width: 630px; margin: 0 auto; color: var(--text-secondary); font-size: 14px; }
.pixel-cat { position: absolute; width: 88px; right: -58px; top: -42px; image-rendering: pixelated; pointer-events: none; }
.console-page .masthead { margin: 24px auto 20px; }
.console-page .masthead h1 { font-size: clamp(27px, 3vw, 36px); }
.console-page .hero-logo { width: 50px; height: 50px; }
.console-page .hero-logo img { width: 38px; height: 38px; }

.panel {
  min-width: 0;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--bg-surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(160%);
}
.panel:hover { border-color: var(--border-strong); }
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.form-card { padding: 28px; }
h1, h2, h3 { color: var(--text-primary); line-height: 1.25; letter-spacing: -.025em; }
h2 { margin: 0 0 12px; font-size: 21px; }
h3 { margin: 18px 0 8px; font-size: 15px; }
p { margin: 0 0 12px; }
.muted { color: var(--text-muted); }
.section-heading { padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.section-heading h2 { margin: 4px 0 6px; }
.section-heading p { margin: 0; color: var(--text-muted); }

.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
form p { margin: 0 0 13px; }
label { display: block; margin-bottom: 5px; color: var(--text-primary); font-size: 12px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  box-shadow: inset 0 1px 2px rgba(25, 50, 75, .035);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent-cyan); box-shadow: 0 0 0 3px rgba(8, 159, 213, .12); }
input[readonly] { font-family: var(--font-mono); font-size: 12px; }
input[type='checkbox'], input[type='radio'] { width: 18px; min-height: 18px; height: 18px; padding: 0; vertical-align: middle; accent-color: var(--accent-blue); }
input[type='checkbox'] + label, input[type='radio'] + label { display: inline; margin-left: 7px; }
textarea { min-height: 120px; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; resize: vertical; }
select { cursor: pointer; }
fieldset { margin: 4px 0; padding: 16px; border: 1px solid var(--border); border-radius: 12px; }
legend { padding: 0 7px; color: var(--text-secondary); font-size: 12px; font-weight: 700; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); transform: translateY(-1px); }
button:active, .button:active { transform: translateY(0); }
button.primary, .button.primary { border-color: rgba(255,255,255,.2); background: linear-gradient(135deg, #0ea5d2, #2563eb); color: #fff; box-shadow: 0 7px 18px rgba(37, 99, 235, .2); }
button.secondary, .button.secondary { background: var(--bg-input); color: var(--text-secondary); }
button.danger, .button.danger { border-color: rgba(220, 38, 38, .3); color: #dc2626; background: var(--warning-bg); }
:root[data-home-theme='dark'] button.danger { color: #fca5a5; }
button.inline { min-height: 32px; padding: 6px 10px; font-size: 11px; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
ul.actions { list-style: none; margin: 0; padding: 0; }
hr { margin: 22px 0; border: 0; border-top: 1px solid var(--border); }

.messages, .warning, .notice, .allauth-alert {
  margin: 0 0 18px;
  padding: 13px 16px;
  border: 1px solid rgba(16, 148, 104, .24);
  border-radius: 12px;
  background: var(--success-bg);
  color: var(--success-text);
}
.messages { list-style: none; }
.warning { border-color: rgba(220, 38, 38, .25); background: var(--warning-bg); color: var(--warning-text); }
.warning a { color: inherit; font-weight: 700; }
.errorlist, .errornote { margin: 5px 0; padding: 0; color: #dc2626; font-size: 12px; list-style: none; }
:root[data-home-theme='dark'] .errorlist, :root[data-home-theme='dark'] .errornote { color: #fca5a5; }
.helptext, .field-help, form span { color: var(--text-muted); font-size: 11px; }
.secret { font-family: var(--font-mono); overflow-wrap: anywhere; }
code, pre { font-family: var(--font-mono); }
code { padding: 2px 5px; border-radius: 5px; background: var(--bg-input); color: var(--text-secondary); overflow-wrap: anywhere; }
pre { max-width: 100%; overflow-x: auto; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); color: var(--text-secondary); }
.totp-qr { display: block; width: min(260px, 100%); height: auto; margin: 0 auto 20px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { padding: 17px 18px; }
.stat-card strong { display: block; margin-top: 3px; color: var(--text-primary); font-size: 26px; line-height: 1.15; letter-spacing: -.04em; }
.stat-card span { color: var(--text-muted); font-size: 11px; }

.console-shell { display: grid; grid-template-columns: 205px minmax(0, 1fr); gap: 20px; align-items: start; }
.console-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.console-nav a { display: flex; align-items: center; min-height: 38px; padding: 8px 11px; border: 1px solid transparent; border-radius: 9px; color: var(--text-secondary); font-size: 12px; font-weight: 650; text-decoration: none; }
.console-nav a:hover { background: var(--bg-input); color: var(--text-primary); }
.console-nav a[aria-current='page'] { border-color: rgba(8, 159, 213, .2); background: rgba(8, 159, 213, .11); color: #126f9f; }
:root[data-home-theme='dark'] .console-nav a[aria-current='page'] { color: #7dd3fc; }
.console-content { min-width: 0; }
.console-content > h1 { margin: 0 0 8px; font-size: 26px; }
.console-content > p { color: var(--text-muted); }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 13px; background: var(--bg-surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: transparent; font-size: 12px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--bg-input); color: var(--text-muted); font-size: 10px; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
td { color: var(--text-secondary); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover, tr:hover td { background: rgba(8, 159, 213, .035); }
td select { min-width: 92px; min-height: 34px; padding: 6px 8px; font-size: 11px; }
.status-pill { display: inline-flex; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-input); color: var(--text-secondary); font-size: 10px; font-weight: 700; white-space: nowrap; }
.mfa-panel { max-width: 760px; margin-left: auto; margin-right: auto; }
.mfa-panel ul { margin-bottom: 0; }
.page-footer { display: flex; justify-content: space-between; gap: 14px; margin-top: 26px; padding: 16px 4px 0; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 10px; }
.page-footer a { color: inherit; }

@media (max-width: 900px) {
  .site-header { margin: 10px 12px 0; }
  .console-shell { grid-template-columns: 1fr; }
  .console-nav { position: static; flex-direction: row; overflow-x: auto; padding: 7px; }
  .console-nav a { flex: none; }
  .pixel-cat { right: -8px; }
}
@media (max-width: 600px) {
  :root[data-home-theme='dark'] body { background: linear-gradient(rgba(4,6,12,.42), rgba(4,6,12,.76)), url('/auth/static/brand/galaxy-mobile.png') center / cover fixed #04060c; }
  body { font-size: 14px; }
  .site-header { flex-wrap: wrap; gap: 9px; padding: 10px; border-radius: 15px; }
  .brand-logo { width: 40px; height: 40px; }
  .brand small { font-size: 10px; }
  .account-nav { order: 3; width: 100%; justify-content: flex-start; border-top: 1px solid var(--border); padding-top: 7px; }
  .account-nav:empty { display: none; }
  .account-nav a { padding: 6px 8px; }
  .page { padding: 0 12px 24px; }
  .masthead { margin: 26px auto 20px; }
  .masthead h1 { font-size: 30px; }
  .masthead p { font-size: 13px; }
  .pixel-cat { width: 66px; top: -36px; right: 0; }
  .panel, .form-card { padding: 17px; border-radius: 15px; }
  .grid { grid-template-columns: 1fr; }
  .console-content > h1 { font-size: 23px; }
  th, td { padding: 9px 10px; }
  .page-footer { flex-direction: column; gap: 4px; }
  input, select, textarea { min-height: 46px; font-size: 16px; }
  td select { min-height: 36px; font-size: 13px; }
  button, .button { min-height: 42px; }
  button.inline { min-height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .pixel-cloud, .pixel-starship { display: none !important; }
}
