:root {
  /* ─── Surfaces ─── */
  --bg-primary: #0a0a0b;
  --bg-secondary: #101011;
  --bg-tertiary: #17171a;
  --bg-elevated: #101011;

  /* ─── Text ─── */
  --text-primary: #f4f0e9;
  --text-secondary: #908b81;
  --text-dim: #5d594f;

  /* ─── Accent ─── */
  --accent: #d4a017;
  --accent-light: #f0b040;
  --accent-dim: rgba(212, 160, 23, 0.10);
  --accent-soft: rgba(212, 160, 23, 0.12);
  --accent-glow: 0 0 24px rgba(212, 160, 23, 0.18);
  --accent-ink: #ffffff;

  --success: #3b9f5a;
  --danger: #dc3b30;

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --font-sans: 'Geologica', -apple-system, 'Segoe UI', sans-serif;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6), 0 18px 50px -28px rgba(0, 0, 0, 0.95);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --transition-speed: 0.5s;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-primary: #f4f1ea;
  --bg-secondary: #ffffff;
  --bg-tertiary: #ece8de;
  --bg-elevated: #ffffff;

  --text-primary: #1a1813;
  --text-secondary: #5f5a4f;
  --text-dim: #938d7e;

  --accent: #9a6c06;
  --accent-light: #b8830a;
  --accent-dim: rgba(154, 108, 6, 0.08);
  --accent-soft: rgba(154, 108, 6, 0.10);
  --accent-glow: 0 0 20px rgba(154, 108, 6, 0.12);
  --accent-ink: #ffffff;

  --border: rgba(26, 24, 19, 0.12);
  --border-strong: rgba(26, 24, 19, 0.22);

  --shadow-lg: 0 8px 24px rgba(26, 24, 19, 0.08);

  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  font-family: var(--font-mono);
  overflow: hidden;
  min-height: 100vh;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(212, 160, 23, 0.02) 2px, rgba(212, 160, 23, 0.02) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

body::after {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  z-index: 9998;
}

header {
  position: absolute;
  top: 0; width: 100%;
  padding: 20px 24px;
  box-sizing: border-box;
  z-index: 10;
}

.head_body { display: flex; align-items: center; gap: 16px; }
.head_logo_img { width: 48px; height: auto; border-radius: 6px; }

.head_title h1 {
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: 3px;
  text-shadow: 0 0 12px var(--glow, rgba(212, 160, 23, 0.2));
  text-transform: uppercase;
  margin: 0;
  font-family: var(--font-sans);
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.auth-box {
  width: 380px;
  min-height: 240px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border-radius: var(--radius);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
  box-shadow: var(--shadow-lg);
}

.auth-box::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scanLine 4s linear infinite;
}

@keyframes scanLine {
  0% { left: -100%; }
  100% { left: 100%; }
}

#start-btn {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  padding: 14px 44px;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-speed) var(--ease);
  z-index: 2;
  font-family: var(--font-mono);
  letter-spacing: 3px;
  text-transform: uppercase;
  box-shadow: 0 0 12px var(--glow, rgba(212, 160, 23, 0.08));
  border-radius: 8px;
}

#start-btn:hover {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--accent-glow);
  transform: translateY(-2px);
}

.move-down { transform: translateY(300px); opacity: 0; }

.input-fields {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 75%;
  z-index: 1;
}

#login-field { transform: translateY(-300px); transition: transform var(--transition-speed) var(--ease); }
#pass-field { transform: translateY(300px); transition: transform var(--transition-speed) var(--ease); }

.auth-input {
  border: none; outline: none;
  border-bottom: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  padding: 10px 6px;
  font-family: var(--font-mono);
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.9rem;
  transition: border-color 0.3s var(--ease);
}
.auth-input:focus { border-bottom-color: var(--accent); box-shadow: 0 4px 12px var(--accent-dim); }

#login-submit {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
  font-size: 0.9rem; padding: 10px 24px;
  transform: translateY(300px); opacity: 0;
  cursor: pointer;
  position: absolute; bottom: 16px;
  transition: all var(--transition-speed) var(--ease);
  font-family: var(--font-mono);
  letter-spacing: 2px; text-transform: uppercase;
  border-radius: 6px;
}
#login-submit.ready { transform: translateY(0); opacity: 1; }
#login-submit:hover { background: var(--accent); color: var(--accent-ink); }

.extra-container {
  position: absolute;
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 75%;
  z-index: 12;
  transform: translateY(-300px);
  transition: transform var(--transition-speed) var(--ease);
}
.extra-show { display: flex !important; transform: translateY(0) !important; }

#final-access-btn {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
  font-size: 0.9rem; padding: 10px 24px;
  transform: translateY(300px); opacity: 0;
  cursor: pointer;
  position: absolute; bottom: 16px;
  transition: all var(--transition-speed) var(--ease);
  font-family: var(--font-mono);
  letter-spacing: 2px; text-transform: uppercase;
  border-radius: 6px;
  z-index: 11;
}
#final-access-btn.ready { transform: translateY(0); opacity: 1; }
#final-access-btn:hover { background: var(--accent); color: var(--accent-ink); }

*:focus { outline: none; }
.hidden-btn, .extra-container:not(.extra-show) { display: none; }
.ready, .extra-show { display: flex !important; }

#login-submit, #final-access-btn {
  opacity: 0;
  transform: translateY(300px);
  pointer-events: none;
  transition: all var(--transition-speed) var(--ease);
}
#login-submit.ready, #final-access-btn.ready {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.input-fields { display: flex; }
.extra-container { display: none; }
.extra-container.extra-show { display: flex !important; transform: translateY(0); }

/* PRELOADER */
.preloader-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  position: relative;
  z-index: 1;
}

.glitch-text {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  color: var(--accent);
  text-shadow: 0 0 20px var(--glow, rgba(212, 160, 23, 0.2));
  letter-spacing: 8px;
  animation: glitchFlicker 1.5s infinite;
}

.loading-bar-container {
  width: 300px; height: 3px;
  background: var(--border);
  margin-top: 32px;
  border-radius: 4px;
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%; height: 100%;
  background: var(--accent);
  animation: loadBar 2.5s ease-in-out forwards;
  box-shadow: 0 0 12px var(--glow, rgba(212, 160, 23, 0.2));
}

.loading-status {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 16px;
  letter-spacing: 2px;
}

@keyframes loadBar {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

@keyframes glitchFlicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.3; }
  94% { opacity: 1; }
  96% { opacity: 0.1; }
  97% { opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease; }

/* KEY MODAL */
#key-modal { animation: fadeIn 0.3s ease-out; }

#key-modal .modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  padding: 30px;
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

#key-modal .modal-content::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent));
  animation: scanLine 3s linear infinite;
}

#modal-key-display {
  background: var(--bg-elevated);
  border: 1.5px dashed var(--accent);
  padding: 15px;
  margin: 20px 0;
  word-break: break-all;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s var(--ease);
  font-family: var(--font-mono);
  border-radius: 6px;
}
#modal-key-display:hover { background: var(--accent-dim); }

/* ─── TOAST SYSTEM ─── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 999999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 8px; font-family: var(--font-sans); font-size: 0.8rem; backdrop-filter: blur(12px); border: 1px solid var(--border); box-shadow: var(--shadow-lg); pointer-events: auto; animation: toastIn 0.25s var(--ease); min-width: 250px; max-width: 380px; }
.toast-success { background: rgba(63,185,80,0.12); border-color: rgba(63,185,80,0.3); color: #3fb950; }
.toast-error { background: rgba(248,81,73,0.12); border-color: rgba(248,81,73,0.3); color: #f85149; }
.toast-warning { background: rgba(210,153,34,0.12); border-color: rgba(210,153,34,0.3); color: #d29922; }
.toast-info { background: rgba(88,166,255,0.12); border-color: rgba(88,166,255,0.3); color: #58a6ff; }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-text { flex: 1; }
.toast-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.1rem; opacity: 0.5; padding: 0; line-height: 1; flex-shrink: 0; }
.toast-close:hover { opacity: 1; }
.toast.removing { animation: toastOut 0.2s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(30px); } }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

::selection {
  background: rgba(212, 160, 23, 0.2);
  color: var(--text-primary);
}
