:root {
  --bg: #0f172a;
  --hero-from: #1e1b4b;
  --hero-to: #312e81;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #7c6cf0;
  --primary-hover: #6b5ce0;
  --primary-soft: #f0edff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --accent: #5ec4b6;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
html { height: -webkit-fill-available; }

.hidden { display: none !important; }

.brand-mark {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.brand-mark-sm {
  width: 36px;
  height: 36px;
  gap: 2px;
}

.brand-tile {
  border-radius: 4px;
  display: block;
  width: 100%;
  min-height: 16px;
  background-clip: padding-box;
}
.brand-tile.tl, .brand-tile.br { background: #a89cf5; }
.brand-tile.tr, .brand-tile.bl { background: var(--accent); }
.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: block;
  flex-shrink: 0;
  background: #0f172a;
  object-fit: cover;
}
.login-card-head .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.login-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.login-hero {
  position: relative;
  display: flex;
  align-items: center;
  padding: 48px 56px;
  overflow: hidden;
  color: #fff;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 40%, rgba(124, 108, 240, 0.45), transparent),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(94, 196, 182, 0.25), transparent),
    linear-gradient(145deg, var(--hero-from) 0%, var(--hero-to) 55%, #1e293b 100%);
}

.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black 40%, transparent);
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 440px;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.1;
}

.hero-tagline {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 4px;
}

.hero-desc {
  font-size: 1.05rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 28px;
}

.hero-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 40px;
}

.hero-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.78);
}

.feat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  color: var(--accent);
}

.hero-footer {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
  border: 1px solid var(--border);
  animation: cardIn 0.45s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 28px;
}

.login-card-head h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.login-card-head p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field input::placeholder { color: #94a3b8; }

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 44px; }

.btn-toggle-pass {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
}

.btn-toggle-pass:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-enter {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #6b5ce0 100%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(124, 108, 240, 0.4);
  margin-top: 6px;
}

.btn-enter:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 108, 240, 0.5);
}

.btn-enter:disabled,
.btn-enter.is-busy {
  opacity: .72;
  cursor: wait;
  transform: none;
}

.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  margin: 0 0 18px;
  line-height: 1.4;
}

.login-copy {
  margin-top: 28px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { padding: 36px 28px 32px; }
  .hero-features, .hero-footer { display: none; }
}

@media (max-width: 480px) {
  .login-panel { padding: 24px 16px; }
  .login-card { padding: 28px 22px 22px; }
}

@media (max-width: 900px) and (pointer: coarse) {
  html, body {
    min-height: 100%;
    overflow-x: hidden;
    background: #f8fafc;
  }
  .login-page {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, #312e81 0, #312e81 148px, #f8fafc 148px, #f1f5f9 100%);
  }
  .login-hero {
    min-height: 138px;
    padding: calc(20px + env(safe-area-inset-top)) 20px 24px;
    align-items: flex-start;
  }
  .hero-brand { margin-bottom: 0; }
  .hero-title { font-size: 1.45rem; }
  .hero-desc, .hero-features, .hero-footer { display: none; }
  .login-panel {
    justify-content: flex-start;
    min-height: calc(100dvh - 138px);
    padding: 0 14px 18px;
    background: transparent;
  }
  .login-card {
    margin-top: -14px;
    padding: 24px 20px 20px;
    border-radius: 18px;
  }
  .login-card-head .brand-mark { display: none; }
  .field input, .field select {
    min-height: 52px;
    font-size: 16px;
  }
  .btn-enter { min-height: 52px; }
}
