:root {
  --red: #c0392b; --red-dark: #96281b;
  --primary: #2980b9;
  --gray-100: #f1f3f5; --gray-200: #e9ecef; --gray-300: #dee2e6;
  --gray-500: #adb5bd; --gray-600: #6c757d; --gray-700: #495057; --gray-800: #343a40;
  --text: #212529; --border: #dee2e6; --white: #ffffff;
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
}
[data-theme="dark"] {
  --text: #e9ecef; --white: #1e1e2e; --border: #495057;
  --gray-100: #2e2e42; --gray-200: #383850; --gray-300: #424260;
  --gray-500: #8a8aa8; --gray-600: #a0a0c0; --gray-700: #cdd6f4; --gray-800: #e0e0fa;
  --primary: #74b0e8; --red: #e06c75; --red-dark: #c04f58;
  --shadow-lg: 0 8px 32px rgba(0,0,0,.45);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--gray-100);
}

/* ── MAIN ──────────────────────────────────────────────────── */
#lnd-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 16px;
}

/* ── CARD (shared base) ────────────────────────────────────── */
.lnd-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 40px 44px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── LOGO INSIDE CARD ──────────────────────────────────────── */
.lnd-card-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}
.lnd-logo-img { height: 44px; }
.logo-dark  { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: block; }

.lnd-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
  text-align: center;
  margin-top: -4px;
}

/* ── LOGIN CARD ────────────────────────────────────────────── */
.lnd-field { display: flex; flex-direction: column; gap: 6px; }
.lnd-field label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.lnd-field input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 16px; /* < 16px makes iOS Safari zoom on focus */
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color .15s;
}
@media (min-width: 768px) { .lnd-field input { font-size: 14px; } }
.lnd-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(41,128,185,.12); }
.lnd-field input.invalid { border-color: var(--red); }

.lnd-error {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  color: #c0392b;
  text-align: center;
}
[data-theme="dark"] .lnd-error { background: #3d1015; border-color: #7a2030; color: #f8818a; }

.lnd-btn-primary {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background .15s, opacity .15s;
}
.lnd-btn-primary:hover:not(:disabled) { background: var(--red-dark); }
.lnd-btn-primary:disabled { opacity: .6; cursor: default; }

/* ── MICROSOFT SIGN-IN ─────────────────────────────────────── */
#lnd-ms { display: flex; flex-direction: column; gap: 14px; }
#lnd-ms.hidden { display: none; }
.lnd-btn-ms {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid #8c8c8c; border-radius: 6px; padding: 10px 20px;
  background: #fff; color: #5e5e5e; font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background .15s;
}
.lnd-btn-ms:hover { background: #f3f3f3; }
[data-theme="dark"] .lnd-btn-ms { background: #2f2f2f; color: #fff; border-color: #5e5e5e; }
[data-theme="dark"] .lnd-btn-ms:hover { background: #3a3a3a; }
.lnd-or { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--gray-600); }
.lnd-or::before, .lnd-or::after { content: ''; flex: 1; border-top: 1px solid var(--gray-300, #ddd); }

/* ── FORGOT / RESET PASSWORD ──────────────────────────────── */
.lnd-link-row { text-align: center; margin-top: 2px; }
.lnd-link {
  background: none; border: none; padding: 0;
  color: var(--primary); font-size: 13px; cursor: pointer; text-decoration: underline;
}
.lnd-sub { font-size: 13px; color: var(--gray-600); text-align: center; margin: 0; }
.lnd-success {
  background: #eafaf1; border: 1px solid #b7e4c7; border-radius: 6px;
  padding: 9px 12px; font-size: 13px; color: #1e8449; text-align: center; margin: 0;
}
[data-theme="dark"] .lnd-success { background: #12301f; border-color: #1f5a37; color: #7ddc9f; }

/* ── PICKER CARD ───────────────────────────────────────────── */
.lnd-card-picker {
  max-width: 520px;
  gap: 24px;
}

/* Three app cards (admins) need more room than two, or the third wraps to a
   full-width row on its own. Added by showPicker() when 3+ cards are visible. */
.lnd-card-picker.wide { max-width: 700px; }

#lnd-apps {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.lnd-app-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 32px 24px;
  flex: 1;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.lnd-app-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0,0,0,.15);
  border-color: var(--primary);
  color: var(--text);
}
[data-theme="dark"] .lnd-app-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.5); }

.lnd-app-icon { font-size: 48px; line-height: 1; user-select: none; }
.lnd-app-name { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.lnd-app-desc { font-size: 11px; color: var(--gray-600); text-align: center; line-height: 1.5; }

/* Desktop-only apps when the screen is too small — visible but not clickable. */
.lnd-app-card.lnd-app-disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Explanation shown below the cards on small screens. */
.lnd-small-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--gray-600);
  text-align: center;
  max-width: 460px;
}

/* ── META LINE (user + logout, below card) ─────────────────── */
#lnd-meta {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
}
#lnd-meta a { color: var(--primary); text-decoration: none; }
#lnd-meta a:hover { text-decoration: underline; }
.lnd-meta-sep { color: var(--gray-300); }

/* ── UTILITIES ─────────────────────────────────────────────── */
.hidden { display: none !important; }

.lnd-btn-primary.loading::after {
  content: '';
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
