*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red: #E60012;
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #888;
  --border: #e5e5e5;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
}

.login {
  width: 100%;
  max-width: 380px;
  padding: 24px 20px;
}

.login__logo {
  text-align: center;
  margin-bottom: 28px;
}

.login__logo svg { margin: 0 auto 12px; display: block; }

.login__logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--red);
}

.login__tagline {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  margin-top: 4px;
}

.auth-back {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.auth-back:active { color: var(--red); }

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: #f5f5f5;
  padding: 4px;
  border-radius: 12px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.auth-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form[hidden] { display: none; }

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.auth-field span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.auth-field small {
  font-size: 0.72rem;
  color: var(--muted);
}

.auth-field input {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(230,0,18,.1);
}

.auth-error {
  color: var(--red);
  font-size: 0.85rem;
  text-align: center;
  font-weight: 500;
}

.auth-error[hidden] { display: none; }

.auth-submit {
  padding: 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 4px;
  cursor: pointer;
}

.auth-submit:disabled { opacity: 0.6; cursor: wait; }
.auth-submit:active:not(:disabled) { opacity: 0.9; }

.auth-install {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
  padding: 14px 16px;
  border: 2px solid var(--red);
  border-radius: 10px;
  background: #fff;
  color: var(--red);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}

.auth-install[hidden] { display: none; }
.auth-install:active { background: #fff5f5; }

.auth-note {
  margin-top: 16px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

/* PWA install modal */
.install-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.install-modal[hidden] { display: none; }

.install-modal__box {
  background: #fff;
  color: var(--text);
  border-radius: 16px 16px 12px 12px;
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 400px;
  position: relative;
  text-align: center;
}

@media (min-width: 500px) {
  .install-modal { align-items: center; }
  .install-modal__box { border-radius: 16px; }
}

.install-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: #f0f0f0;
  color: var(--text);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
}

.install-modal__icon img {
  border-radius: 14px;
  margin: 0 auto 12px;
}

.install-modal__box h2 {
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.install-modal__sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.install-steps {
  text-align: left;
  background: #f8f8f8;
  border-radius: 12px;
  padding: 14px 16px 14px 28px;
  margin-bottom: 16px;
}

.install-steps[hidden] { display: none; }

.install-steps__title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 10px;
  margin-left: -12px;
  color: var(--red);
}

.install-steps ol {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #444;
}

.install-steps li { margin-bottom: 8px; }
.install-steps strong { color: var(--text); }

.install-modal__ok {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
}

.toast[data-show="1"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.pending__text {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.pending__hint {
  text-align: center;
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 16px;
}

.pending__link {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border: none;
  background: transparent;
  color: var(--red);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.pending__link--muted {
  color: var(--muted);
  font-weight: 500;
}
