/* ────────────────────────────────────────────────────────────────────────
 * Navio Sentinel login — mobile-app aesthetic.
 *
 * Design goals:
 *  - feels like a native app inside the browser
 *  - 44px+ touch targets, generous spacing
 *  - smooth step-to-step transitions, no jarring layout shifts
 *  - safe-area aware for notched iPhones
 *  - large 6-box OTP input that supports paste + autofill
 *  - haptic-style press feedback on every interactive element
 * ──────────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: #c9d1d9;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2034 0%, transparent 60%),
    radial-gradient(800px 600px at 100% 100%, #18221a 0%, transparent 50%),
    #0d1117;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell + screen ──────────────────────────────────────────────────── */
.app-shell {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(28px, env(safe-area-inset-top))
           20px
           max(20px, env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}
.screen {
  width: 100%;
  max-width: 420px;
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(48, 54, 61, 0.7);
  border-radius: 22px;
  padding: 28px 22px 24px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 60px rgba(0, 0, 0, 0.55);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Brand header ────────────────────────────────────────────────────── */
.brand-header {
  text-align: center;
  margin-bottom: 24px;
}
.logo-mark {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f6feb 0%, #58a6ff 100%);
  border-radius: 16px;
  color: #fff;
  font-weight: 700; font-size: 24px;
  box-shadow:
    0 8px 24px rgba(31, 111, 235, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.2) inset;
}
.brand-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #f0f6fc;
  letter-spacing: -0.3px;
}
.brand-suffix { color: #8b949e; font-weight: 500; }
.brand-tagline {
  margin: 6px 0 0;
  font-size: 13px;
  color: #8b949e;
}

/* ── Step transitions ────────────────────────────────────────────────── */
.step {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: stepIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.step[hidden] { display: none; }
@keyframes stepIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.step-meta { flex: 1; }
.step-title { margin: 0; font-size: 16px; font-weight: 600; color: #f0f6fc; }
.step-sub   { margin: 2px 0 0; font-size: 13px; color: #8b949e; }
.step-sub span { color: #c9d1d9; font-weight: 500; }

.icon-btn {
  width: 36px; height: 36px;
  border: none; background: transparent;
  color: #c9d1d9; font-size: 18px;
  border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: rgba(255, 255, 255, 0.06); }
.icon-btn:active { background: rgba(255, 255, 255, 0.1); }

/* ── Tabs (channel selector) ─────────────────────────────────────────── */
.tabs {
  display: flex;
  background: #0d1117;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #30363d;
  position: relative;
}
.tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 12px;
  background: transparent;
  border: none; border-radius: 9px;
  color: #8b949e;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.05s;
}
.tab:active { transform: scale(0.98); }
.tab-active {
  background: #21262d;
  color: #f0f6fc;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.tab-icon { font-size: 13px; }

/* ── Inputs ──────────────────────────────────────────────────────────── */
.input-group {
  display: flex; flex-direction: column; gap: 6px;
}
label {
  font-size: 13px; font-weight: 500; color: #c9d1d9;
  padding-left: 2px;
}
input[type="email"],
input[type="tel"],
input[type="text"]:not(.otp-box):not(.hidden-code-input) {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;        /* 16px+ prevents iOS auto-zoom on focus */
  font-family: inherit;
  color: #f0f6fc;
  background: #0d1117;
  border: 1.5px solid #30363d;
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: #6e7681; }
input:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.18);
}
input[aria-invalid="true"] {
  border-color: #f85149;
  box-shadow: 0 0 0 4px rgba(248, 81, 73, 0.15);
}

.hint {
  margin: 2px 2px 0; font-size: 12px; color: #6e7681;
}

.field-error {
  margin: 4px 2px 0;
  font-size: 13px;
  color: #ffa198;
  display: flex; align-items: flex-start; gap: 6px;
  animation: shake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
/* `display:flex` above outranks the UA `[hidden]{display:none}` rule, so the
   empty error slot (and its `::before` ⚠) showed even when hidden. Restore it. */
.field-error[hidden] { display: none; }
.field-error::before {
  content: '⚠'; font-size: 13px; line-height: 1;
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}

/* ── 6-box OTP input ─────────────────────────────────────────────────── */
.hidden-code-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 1px; width: 1px;
}
.otp-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 6px 0;
}
.otp-box {
  width: 100%;
  aspect-ratio: 1 / 1.15;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  color: #f0f6fc;
  background: #0d1117;
  border: 1.5px solid #30363d;
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.12s, transform 0.06s, box-shadow 0.12s;
  caret-color: #58a6ff;
}
.otp-box:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25);
  transform: translateY(-1px);
}
.otp-box.filled {
  background: #161b22;
  border-color: #58a6ff;
  color: #f0f6fc;
}
.otp-boxes[aria-invalid="true"] .otp-box {
  border-color: #f85149;
  box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.15);
}
@media (max-width: 380px) {
  .otp-box { font-size: 20px; }
  .otp-boxes { gap: 6px; }
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  min-height: 50px;
  padding: 13px 16px;
  border: none; border-radius: 12px;
  background: linear-gradient(180deg, #2ea043 0%, #238636 100%);
  color: #fff;
  font-family: inherit;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.06s, box-shadow 0.15s, filter 0.15s;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.15) inset,
    0 4px 14px rgba(35, 134, 54, 0.32);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn-primary:active:not(:disabled) {
  transform: scale(0.985);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 2px 8px rgba(35, 134, 54, 0.28);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary[data-busy] .btn-label { opacity: 0; }
.btn-primary[data-busy] .btn-spinner {
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-link {
  background: transparent; border: none;
  color: #58a6ff;
  font-family: inherit;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.btn-link:hover:not(:disabled) { color: #79c0ff; background: rgba(88, 166, 255, 0.08); }
.btn-link:disabled { color: #6e7681; cursor: not-allowed; }

.resend-row {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 2px;
}

/* ── Toast / inline alert ────────────────────────────────────────────── */
.toast {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 11px;
  font-size: 13px;
  text-align: center;
  border: 1px solid;
  animation: stepIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.toast-info    { background: #0a2b4d; color: #79c0ff; border-color: #1f6feb; }
.toast.toast-success { background: #0f2d1a; color: #56d364; border-color: #1a7f37; }
.toast.toast-error   { background: #2d1117; color: #ffa198; border-color: #5a2025; }

/* ── Tenant picker cards ─────────────────────────────────────────────── */
.tenant-list { display: flex; flex-direction: column; gap: 10px; }
.tenant-card {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: #0d1117;
  border: 1.5px solid #30363d;
  border-radius: 12px;
  color: #f0f6fc;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.06s, background 0.15s;
}
.tenant-card:hover { border-color: #58a6ff; background: rgba(88, 166, 255, 0.05); }
.tenant-card:active { transform: scale(0.99); }
.tenant-name {
  font-size: 15px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.tenant-role { font-size: 12px; color: #8b949e; }
.tenant-card::after {
  content: '›';
  font-size: 22px; color: #6e7681; margin-left: 8px;
}

.muted { color: #8b949e; }
.muted.small { font-size: 12px; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.app-footer {
  margin-top: 24px;
  text-align: center;
  color: #6e7681;
}

/* ── Narrow-screen tightening ────────────────────────────────────────── */
@media (max-width: 380px) {
  .screen { padding: 22px 18px 20px; border-radius: 18px; }
  .brand-title { font-size: 20px; }
  .logo-mark { width: 50px; height: 50px; font-size: 22px; }
}

/* ── Reduced-motion respect ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
