* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; }
html { min-height: 100%; }
body {
  font-family: "Plus Jakarta Sans", "Segoe UI", Tahoma, sans-serif;
  font-weight: 500;
  color: #2B2C46;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body.is-ar { font-family: "Cairo", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif; font-weight: 600; }

.login-screen {
  min-height: 100vh;
  min-height: 100svh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(68px, calc(env(safe-area-inset-top) + 52px)) max(16px, env(safe-area-inset-right)) max(58px, calc(env(safe-area-inset-bottom) + 42px)) max(16px, env(safe-area-inset-left));
  background: #B56567 url("login-bg.jpg?v=2") center / cover no-repeat;
  position: relative;
  isolation: isolate;
  overflow-x: clip;
}
.login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(30,34,69,.10), transparent 52%, rgba(30,34,69,.08));
  pointer-events: none;
  z-index: -1;
}

.lang-switch {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid rgba(226, 232, 240, .8);
  background: rgba(255,255,255,.95);
  border-radius: 8px;
  padding: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.theme-opt {
  border: 0;
  background: transparent;
  color: #64748b;
  border-radius: 6px;
  padding: 6px 8px;
  font: 700 11px/1 "Plus Jakarta Sans", sans-serif;
  cursor: pointer;
}
.theme-opt.is-on { background: #1E2245; color: #fff; }
body.is-ar .lang-switch { right: auto; left: max(12px, env(safe-area-inset-left)); }
.lang-switch label { position: relative; display: inline-flex; align-items: center; }
.lang-switch svg {
  position: absolute;
  left: 8px;
  width: 14px;
  height: 14px;
  stroke: #64748b;
  fill: none;
  stroke-width: 1.8;
  pointer-events: none;
}
body.is-ar .lang-switch svg { left: auto; right: 8px; }
.lang-switch select {
  appearance: none;
  border: 1px solid rgba(226, 232, 240, .8);
  background: rgba(255,255,255,.95);
  color: #1e293b;
  font: 600 12px/1 "Plus Jakarta Sans", sans-serif;
  border-radius: 8px;
  padding: 6px 10px 6px 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  cursor: pointer;
}
body.is-ar .lang-switch select {
  font-family: "Cairo", sans-serif;
  padding: 6px 24px 6px 10px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  max-width: 420px;
  background: #fff;
  border: 1px solid rgba(241, 245, 249, .8);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
  padding: 36px;
}
.logo-wrap { display: flex; justify-content: center; margin-bottom: 24px; }
.logo-wrap img { display: block; width: min(100%, 220px); height: auto; max-height: 56px; object-fit: contain; }

h1 {
  margin: 0 0 24px;
  color: #EAA100;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
body.is-ar h1 { font-family: "Cairo", sans-serif; font-weight: 900; letter-spacing: 0; }
.field {
  display: block;
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
}
input[type="email"], input[type="text"], input[type="password"], input[inputmode="numeric"] {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #1e293b;
  border-radius: 8px;
  padding: 12px 14px;
  font: 600 15px/1.35 "Plus Jakarta Sans", sans-serif;
}
body.is-ar input { font-family: "Cairo", sans-serif; font-weight: 600; }
input:focus {
  outline: none;
  border-color: #007A55;
  box-shadow: 0 0 0 1px #007A55;
}
.password-wrap { position: relative; }
.password-wrap input { padding-right: 40px; }
body.is-ar .password-wrap input { padding-right: 14px; padding-left: 40px; }
#toggle-password {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #94a3b8;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
body.is-ar #toggle-password { right: auto; left: 12px; }
#toggle-password svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
#toggle-password svg[hidden] { display: none !important; }
.forgot-row { display: flex; justify-content: flex-end; padding-top: 4px; }
.forgot {
  border: 0;
  background: transparent;
  color: #2B2C46;
  font: 700 13px/1 "Plus Jakarta Sans", sans-serif;
  cursor: pointer;
  padding: 5px 0;
  line-height: 1.4;
}
.forgot:hover { color: #007A55; }
label.field + input, .password-wrap { margin-bottom: 0; }
form .field:first-of-type { margin-top: 0; }
#login-email { margin-bottom: 20px; }

.login-btn, .modal-actions button, .logout-btn {
  border: 0;
  cursor: pointer;
  background: #007A55;
  color: #fff;
  font-weight: 700;
}
.login-btn {
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
body.is-ar .login-btn { text-transform: none; letter-spacing: 0; font-family: "Cairo", sans-serif; font-weight: 800; }
.login-btn:hover { background: #006646; }

.or-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
}
.or-row::before, .or-row::after {
  content: "";
  height: 1px;
  background: #e2e8f0;
  flex: 1;
}
.passkey {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  font: 800 13px/1.35 "Plus Jakarta Sans", sans-serif;
  cursor: pointer;
}
.passkey:hover { background: #f1f5f9; }
.passkey svg { width: 16px; height: 16px; stroke: #4f46e5; fill: none; stroke-width: 1.8; }

.alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 12px;
  border-radius: 8px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #be123c;
  font-size: 12px;
  line-height: 1.4;
}
.alert[hidden] { display: none; }
.alert svg { width: 16px; height: 16px; stroke: #e11d48; fill: none; stroke-width: 2; flex: none; margin-top: 1px; }

.announce {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  background: rgba(30, 34, 69, .88);
}
.announce-track {
  display: flex;
  width: max-content;
  animation: ticker 64s linear infinite;
}
.announce-track div { display: flex; align-items: center; }
.announce-track span {
  color: #fff;
  font-family: "Cairo", sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0;
  white-space: nowrap;
  padding: 0 16px;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.announce-track i {
  color: rgba(255,255,255,.4);
  font-style: normal;
  padding: 0 24px;
  font-size: 12px;
}
@keyframes ticker {
  from { transform: translate3d(0,0,0); }
  to { transform: translate3d(-50%,0,0); }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,.5);
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%;
  max-width: 384px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
  padding: 24px;
}
.modal-card h3 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0; color: #475569; font-size: 12px; line-height: 1.6; }
.modal-card strong { color: #007A55; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.modal-actions button {
  min-height: 44px;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
}
.modal-actions button:hover { background: #006646; }

.home-body { background: #f8fafc; min-height: 100vh; }
.home-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.home-bar img { height: 36px; width: auto; }
.logout-btn { border-radius: 8px; padding: 8px 14px; font-size: 13px; }
.logout-btn:hover { background: #006646; }
.home-main { width: min(100%, 720px); margin: 0 auto; padding: 64px 24px; }
.eyebrow { margin: 0 0 8px; color: #007A55; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.home-main h1 { margin: 0; color: #20233D; font-size: 32px; }
.role { margin: 10px 0 0; color: #EAA100; font-weight: 800; }
.signed { margin: 6px 0 0; color: #64748b; }

@media (max-width: 640px) {
  .login-screen { background-position: 56% center; }
  .login-card { max-width: 420px; padding: 30px 24px; }
  .logo-wrap { margin-bottom: 20px; }
  h1 { margin-bottom: 20px; font-size: 24px; }
}
@media (max-width: 360px) {
  .login-screen { padding-right: 12px; padding-left: 12px; }
  .lang-switch { right: 12px; gap: 5px; }
  body.is-ar .lang-switch { right: auto; left: 12px; }
  .theme-opt { padding: 6px; font-size: 10px; }
  .lang-switch select { max-width: 132px; font-size: 11px; }
  .login-card { padding: 24px 18px; border-radius: 14px; }
  .logo-wrap img { width: min(100%, 200px); }
  .passkey { padding-right: 8px; padding-left: 8px; font-size: 11px; }
  .announce-track span { font-size: 11px; }
}
@media (max-height: 620px) and (min-width: 641px) {
  .login-screen { align-items: flex-start; padding-top: 66px; }
  .login-card { padding: 24px 32px; }
  .logo-wrap { margin-bottom: 14px; }
  .logo-wrap img { max-height: 44px; }
  h1 { margin-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .announce-track { animation: none; }
}

html.theme-dark { color-scheme: dark; }
html.theme-dark .login-screen::after { background: linear-gradient(to bottom, rgba(8,10,18,.25), rgba(8,10,18,.55)); }
html.theme-dark .login-card,
html.theme-dark .modal-card { background: #171B2E; border-color: #2C3348; color: #E6E8F0; }
html.theme-dark .field,
html.theme-dark .forgot,
html.theme-dark .modal-card p,
html.theme-dark .modal-card h3 { color: #E6E8F0; }
html.theme-dark input[type="email"],
html.theme-dark input[type="text"],
html.theme-dark input[type="password"],
html.theme-dark input[inputmode="numeric"],
html.theme-dark .lang-switch select,
html.theme-dark .theme-switch { background: #10131E; color: #F4F6FB; border-color: #3A425C; }
html.theme-dark .theme-opt { color: #94A3B8; }
html.theme-dark .theme-opt.is-on { background: #EAA100; color: #1E2245; }
html.theme-dark .passkey { background: #10131E; color: #E6E8F0; border-color: #3A425C; }
html.theme-dark .or-row::before,
html.theme-dark .or-row::after { background: #3A425C; }
