:root {
  --bg-gradient-1: #071411;
  --bg-gradient-2: #12352d;
  --card-bg: #ffffff;
  --primary: #047857;
  --primary-hover: #065f46;
  --primary-dark: #064e3b;
  --accent: #d97706;
  --ink: #0b1220;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --surface: #f8fafc;
  --border: #d8e2dc;
  --border-focus: #10b981;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 22px 55px rgba(15, 23, 42, 0.18);
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --radius-sm: 8px;
  --radius-full: 9999px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body.login-page {
  min-height: 100%;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  padding:
    max(clamp(12px, 3vw, 20px), env(safe-area-inset-top))
    max(clamp(12px, 3vw, 20px), env(safe-area-inset-right))
    max(clamp(12px, 3vw, 20px), env(safe-area-inset-bottom))
    max(clamp(12px, 3vw, 20px), env(safe-area-inset-left));
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: 100%;
  max-width: min(980px, 100%);
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 440px);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  margin: auto;
}

.brand {
  text-align: left;
  margin-bottom: 0;
  animation: slideDown 0.35s ease-out both;
  color: #ffffff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.42);
}

.brand-logo {
  width: clamp(64px, 12vw, 88px);
  height: clamp(64px, 12vw, 88px);
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  margin-bottom: clamp(18px, 3vw, 24px);
  box-shadow: var(--shadow-lg);
  touch-action: manipulation;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-title {
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 800;
  color: #ffffff;
  margin-bottom: clamp(10px, 2vw, 16px);
  letter-spacing: 0;
  line-height: 1.02;
  max-width: 10ch;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.42);
}

.brand-subtitle {
  max-width: 520px;
  font-size: clamp(15px, 2.5vw, 18px);
  color: rgba(255, 255, 255, 0.76);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.7;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.38);
}

.brand-highlights {
  display: grid;
  gap: 10px;
  margin-top: clamp(24px, 4vw, 34px);
  max-width: 460px;
}

.brand-highlights span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.34);
}

.brand-highlights span::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
  flex: 0 0 auto;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: clamp(24px, 5vw, 40px) clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.35s ease-out both;
  border: 1px solid rgba(255, 255, 255, 0.55);
  contain: layout style paint;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-title {
  font-size: clamp(20px, 4.5vw, 24px);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: clamp(6px, 1.5vw, 8px);
  line-height: 1.2;
}

.card-subtitle {
  font-size: clamp(13px, 2.5vw, 14px);
  color: var(--text-secondary);
  margin-bottom: clamp(20px, 4vw, 24px);
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: clamp(6px, 1.5vw, 8px);
  padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 16px);
  border-radius: var(--radius-full);
  font-size: clamp(12px, 2.5vw, 13px);
  font-weight: 600;
  margin-bottom: clamp(20px, 4vw, 24px);
  animation: fadeIn 0.35s ease-out both;
  line-height: 1.4;
  width: 100%;
  justify-content: center;
  text-align: center;
}

.badge.ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge.warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.badge.bad {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.form-group {
  margin-bottom: clamp(16px, 3.5vw, 20px);
}

label {
  display: block;
  font-size: clamp(13px, 2.5vw, 14px);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: clamp(6px, 1.5vw, 8px);
}

.input-wrapper {
  position: relative;
}

.input {
  width: 100%;
  padding: clamp(12px, 2.5vw, 14px) clamp(14px, 3vw, 16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: clamp(16px, 3vw, 16px);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  outline: none;
  min-height: 48px;
  touch-action: manipulation;
}

.input:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.13);
}

.input::placeholder {
  color: var(--text-muted);
}

.password-row {
  display: flex;
  gap: clamp(8px, 2vw, 12px);
  align-items: stretch;
}

.password-row .input {
  flex: 1;
  min-width: 0;
}

.toggle-btn {
  padding: clamp(12px, 2.5vw, 14px) clamp(16px, 3.5vw, 20px);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: clamp(13px, 2.5vw, 14px);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  min-height: 48px;
  min-width: 70px;
  touch-action: manipulation;
  flex-shrink: 0;
}

.toggle-btn:hover {
  background: #f3f4f6;
  border-color: #b7c8bf;
}

.toggle-btn:active {
  transform: scale(0.98);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 10px);
  font-size: clamp(13px, 2.5vw, 14px);
  font-weight: 500;
  color: var(--text-secondary);
  margin: clamp(16px, 3.5vw, 20px) 0;
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
  touch-action: manipulation;
  min-height: 44px;
}

.checkbox-label input[type="checkbox"] {
  width: clamp(18px, 4vw, 20px);
  height: clamp(18px, 4vw, 20px);
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.btn {
  width: 100%;
  padding: clamp(14px, 3vw, 16px) clamp(20px, 4vw, 24px);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: none;
  border-radius: var(--radius-sm);
  font-size: clamp(15px, 3vw, 16px);
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: var(--shadow);
  margin-top: clamp(6px, 1.5vw, 8px);
  letter-spacing: 0.3px;
  min-height: 52px;
  touch-action: manipulation;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-dark) 100%);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: clamp(12px, 2.5vw, 14px) clamp(14px, 3vw, 16px);
  border-radius: var(--radius-sm);
  font-size: clamp(13px, 2.5vw, 14px);
  font-weight: 600;
  margin-bottom: clamp(16px, 3.5vw, 20px);
  display: flex;
  align-items: flex-start;
  gap: clamp(8px, 2vw, 10px);
  animation: shake 0.35s ease;
  line-height: 1.5;
  word-break: break-word;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.footer {
  margin-top: clamp(24px, 5vw, 32px);
  text-align: center;
  font-size: clamp(12px, 2.5vw, 13px);
  color: var(--text-muted);
  padding-top: clamp(20px, 4vw, 24px);
  border-top: 1px solid var(--border);
  line-height: 1.6;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
  word-break: break-word;
}

.footer a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.version {
  margin-top: clamp(6px, 1.5vw, 8px);
  font-size: clamp(10px, 2vw, 11px);
  color: var(--text-muted);
  opacity: 0.7;
}

.contact-info {
  display: block;
  margin-top: clamp(10px, 2.5vw, 12px);
  font-size: clamp(11px, 2.5vw, 12px);
  color: var(--text-secondary);
  line-height: 1.6;
  word-break: break-word;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: clamp(16px, 4vw, 20px);
  animation: fadeIn 0.2s ease;
  overflow-y: auto;
}

.modal {
  width: 100%;
  max-width: min(480px, 100%);
  background: #ffffff;
  border-radius: var(--radius);
  padding: clamp(24px, 5vw, 32px) clamp(20px, 4vw, 28px);
  box-shadow: var(--shadow-xl);
  animation: modalSlide 0.2s ease;
  margin: auto;
}

@keyframes modalSlide {
  from { opacity: 0; transform: scale(0.96) translateY(-12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: clamp(10px, 2.5vw, 12px);
  line-height: 1.3;
}

.modal p {
  font-size: clamp(14px, 3vw, 15px);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: clamp(10px, 2.5vw, 12px);
  word-break: break-word;
}

.modal .muted {
  color: var(--text-muted);
  font-size: clamp(13px, 2.5vw, 14px);
}

.modal .actions {
  display: flex;
  gap: clamp(10px, 2.5vw, 12px);
  margin-top: clamp(20px, 4vw, 24px);
  flex-wrap: wrap;
}

.modal .btn {
  flex: 1;
  margin-top: 0;
  min-width: 120px;
}

.modal .btn.secondary {
  background: var(--border);
  color: var(--text-primary);
}

.modal .btn.secondary:hover {
  background: #cbd5e1;
}

@media (max-width: 640px) {
  body.login-page {
    align-items: flex-start;
    padding:
      max(14px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .container {
    display: block;
    max-width: 440px;
    margin: 0 auto;
  }

  .brand {
    text-align: center;
    margin-bottom: 20px;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
  }

  .brand-title {
    max-width: none;
    font-size: 25px;
    line-height: 1.18;
  }

  .brand-subtitle {
    font-size: 13px;
    line-height: 1.5;
  }

  .brand-highlights {
    display: none;
  }

  .password-row {
    flex-direction: column;
    gap: 10px;
  }

  .toggle-btn {
    width: 100%;
    justify-content: center;
    display: flex;
    align-items: center;
  }

  .modal .actions {
    flex-direction: column;
    gap: 10px;
  }

  .modal .btn {
    min-width: 100%;
  }

  .badge {
    font-size: 12px;
    padding: 8px 12px;
  }

  .error {
    font-size: 13px;
    padding: 12px 14px;
  }
}

@media (max-width: 380px) {
  body.login-page {
    padding:
      max(10px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .card {
    padding: 20px 16px;
  }

  .brand-title {
    font-size: 20px;
  }

  .card-title {
    font-size: 18px;
  }

  .input, .toggle-btn, .btn {
    font-size: 14px;
  }

  .modal {
    padding: 20px 16px;
  }

  .contact-info {
    font-size: 11px;
  }
}

@media (max-height: 760px) {
  body.login-page {
    align-items: flex-start;
  }

  .container {
    margin: 0 auto;
  }

  .brand-highlights {
    display: none;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  body.login-page {
    padding: 12px;
    align-items: flex-start;
  }

  .container {
    margin: 12px auto;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .brand {
    margin-bottom: 16px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
  }

  .brand-title {
    font-size: 20px;
    max-width: none;
    margin-bottom: 4px;
  }

  .brand-highlights {
    display: none;
  }

  .card {
    padding: 20px 24px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .footer {
    margin-top: 16px;
    padding-top: 16px;
  }
}

@media (min-width: 641px) and (max-width: 768px) {
  .container {
    max-width: 720px;
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .brand {
    text-align: center;
  }

  .brand-title {
    max-width: none;
  }

  .brand-highlights {
    display: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  .btn,
  .toggle-btn,
  .checkbox-label,
  .input {
    min-height: 48px;
  }

  .checkbox-label input[type="checkbox"] {
    min-width: 20px;
    min-height: 20px;
  }

  .btn:hover:not(:disabled) {
    transform: none;
  }
}

.hint {
  display: block;
  margin-top: clamp(6px, 1.5vw, 8px);
  font-size: clamp(11px, 2vw, 12px);
  color: var(--text-muted);
  line-height: 1.5;
}

.btn.loading {
  position: relative;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.btn .btn-loader {
  display: none;
}

.btn.loading .btn-label {
  visibility: hidden;
}

.btn.loading .btn-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #ffffff;
}

.btn.loading .btn-loader::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

*:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
