/* ==========================================================================
   Auth screens + dashboard shell
   Palette
     Primary   red      var(--c-primary)  (deep var(--c-deep) -> bright var(--c-light))
     Secondary ink      #170B10  (red-black, for text and the page backdrop)
     Tertiary  amber    #F5A524  (focus rings, gradient tail, "medium" states)
   ========================================================================== */

:root {
  /* Colour theme. The admin picks a palette in Settings; each palette only changes these values. */
  --c-primary: #e5142d;  --c-primary-rgb: 229, 20, 45;
  --c-light: #ff4056;    --c-light-rgb: 255, 64, 86;
  --c-coral: #ff5a4d;
  --c-dark: #8f0f20;
  --c-dark2: #a8101f;
  --c-deep: #5c0614;
  --c-btn: #c8102a;
  --c-text-dark: #ff6b7b;
  --red: var(--c-primary);
  --red-bright: var(--c-light);
  --red-deep: var(--c-deep);
  --red-text: var(--c-btn);
  --ink: #170b10;
  --ink-soft: #2b1620;
  --muted: #6b5b61;
  --line: #ead8dc;
  --line-strong: #d6bcc2;
  --wash: #fff6f6;
  --amber: #f5a524;
  --green: #12a150;
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red-text); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, .input:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

/* ---------- Page backdrop ---------- */

.auth-body, .app-body {
  min-height: 100vh;
  background:
    radial-gradient(60rem 38rem at 88% -8%, rgba(var(--c-primary-rgb), 0.55), transparent 62%),
    radial-gradient(48rem 36rem at -8% 108%, rgba(245, 165, 36, 0.20), transparent 62%),
    linear-gradient(160deg, #1d0a11 0%, #2c0b14 46%, #120609 100%);
  background-attachment: fixed;
}

.auth-body { position: relative; overflow-x: hidden; }

/* faint grid that fades out toward the edges */
.auth-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 38%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse at 50% 38%, #000 0%, transparent 72%);
}

.auth {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(24px, 6vh, 72px) 16px 64px;
}

/* ---------- Card ---------- */

.auth-card {
  position: relative;
  width: 100%;
  background: #fff;
  border-radius: 28px;
  padding: 56px 64px 48px;
  overflow: hidden;
  box-shadow: 0 40px 90px -24px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.07);
  animation: card-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

/* gradient edge across the top: deep red -> red -> amber */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red-deep), var(--red) 55%, var(--amber));
}

.auth-card--narrow { max-width: 580px; }
.auth-card--wide { max-width: 900px; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Brand ---------- */

.auth-brand { margin-bottom: 44px; }

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 54px; height: 54px; flex: none; filter: drop-shadow(0 6px 10px rgba(var(--c-primary-rgb), 0.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-size: 26px; font-weight: 700; letter-spacing: 0.02em; }
.brand-tag {
  margin-top: 5px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  background: linear-gradient(90deg, var(--red), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Headings ---------- */

.auth-title { margin: 0 0 10px; font-size: 46px; line-height: 1.1; font-weight: 600; letter-spacing: -0.01em; }
.auth-sub { margin: 0 0 36px; max-width: 48ch; color: var(--muted); font-size: 19px; }

/* ---------- Form layout ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 28px; }
.form-grid--single { grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; min-width: 0; }
.field label { margin-bottom: 10px; font-size: 16px; font-weight: 500; color: var(--ink-soft); }
.req { margin-left: 2px; color: var(--red); }

.input {
  width: 100%;
  height: 60px;
  padding: 0 18px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.input::placeholder { color: #a6969c; }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px rgba(var(--c-primary-rgb), 0.14); }

.is-readonly .input { background: var(--wash); color: var(--muted); }
.is-readonly .input:focus { box-shadow: none; border-color: var(--line); }

.input--select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c8102a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
  cursor: pointer;
}

/* password field with show/hide button */
.input-wrap { position: relative; }
.input--toggle { padding-right: 60px; }
.eye {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 0.15s, background-color 0.15s;
}
.eye:hover { color: var(--red-text); background: var(--wash); }
.eye svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eye .eye-off { display: none; }
.eye[aria-pressed="true"] .eye-on { display: none; }
.eye[aria-pressed="true"] .eye-off { display: block; }

/* errors */
.has-error .input { border-color: #d92d20; background: #fff8f7; }
.has-error .input:focus { box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.16); }
.field-error, .hint { margin: 10px 0 0; font-size: 15px; line-height: 1.4; }
.field-error { color: #b42318; font-weight: 500; }
.hint--error { color: #b42318; }
.hint[hidden] { display: none; }
.field-error--check { margin-top: 10px; }

/* password strength: four segments */
.meter { margin-top: 10px; }
.meter-bars { display: flex; gap: 6px; }
.meter-bars span { flex: 1; height: 6px; border-radius: 99px; background: #f1e4e7; transition: background-color 0.2s; }
.meter-label { margin: 8px 0 0; min-height: 1.2em; font-size: 14px; color: var(--muted); }
.meter[data-level="1"] .meter-bars span:nth-child(-n + 1) { background: var(--red); }
.meter[data-level="2"] .meter-bars span:nth-child(-n + 2) { background: var(--amber); }
.meter[data-level="3"] .meter-bars span:nth-child(-n + 3) { background: #7cc24a; }
.meter[data-level="4"] .meter-bars span:nth-child(-n + 4) { background: var(--green); }

/* checkbox row */
.check { display: flex; align-items: center; gap: 14px; margin: 30px 0 26px; }
.check input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 26px;
  height: 26px;
  margin: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  background: #fff center / 16px no-repeat;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.check input:hover { border-color: var(--red); }
.check input:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.check input:checked {
  border-color: transparent;
  background-color: var(--red);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"), linear-gradient(135deg, var(--red-bright), var(--red-deep));
  background-size: 16px, 100%;
  background-repeat: no-repeat;
  background-position: center;
}
.check.has-error input { border-color: #d92d20; }
.check label { font-size: 16px; color: var(--ink-soft); }

.forgot { margin: 16px 0 30px; text-align: right; font-size: 16px; }
.forgot a { font-weight: 500; }

/* ---------- Buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font: 600 16px/1 var(--font);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  background-image: linear-gradient(90deg, #2a0510 0%, var(--c-dark) 36%, var(--c-primary) 72%, var(--c-coral) 100%);
  background-size: 165% 100%;
  background-position: 0 0;
  box-shadow: 0 14px 28px -10px rgba(var(--c-primary-rgb), 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: background-position 0.45s ease, transform 0.15s, box-shadow 0.2s;
}
.btn:hover { background-position: 100% 0; transform: translateY(-1px); text-decoration: none; box-shadow: 0 18px 32px -10px rgba(var(--c-primary-rgb), 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.8; cursor: progress; transform: none; }
.btn--link { margin-top: 8px; }

.btn.is-loading .btn-label::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 12px;
  vertical-align: -3px;
  border: 2.5px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-switch { margin: 28px 0 0; text-align: center; font-size: 17px; color: var(--ink); }

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 22px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid;
  font-size: 16px;
}
.alert p { margin: 0; overflow-wrap: anywhere; }
.alert svg { flex: none; width: 22px; height: 22px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.alert--error   { color: #912018; background: #fff1f0; border-color: #f7c5c0; }
.alert--success { color: #0b6b36; background: #ecfaf2; border-color: #b6e6c9; }
.alert--info    { color: #7a4a06; background: #fff7e6; border-color: #f6dba5; }

/* ---------- Dashboard shell (placeholder until the real dashboard is built) ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--red-deep), var(--red), var(--amber)) 1;
}
.topbar .brand-mark { width: 38px; height: 38px; }
.topbar .brand-name { font-size: 19px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, var(--red-bright), var(--red-deep));
}
.topbar-name { font-weight: 500; }
.btn-ghost {
  min-height: 44px;
  height: 44px;
  padding: 0 18px;
  font: 600 14px/1 var(--font);
  color: var(--red-text);
  background: #fff;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.btn-ghost:hover { border-color: var(--red); background: var(--wash); }

.dash { max-width: 960px; margin: 0 auto; padding: 40px 16px 64px; }
.dash-card {
  margin-bottom: 20px;
  padding: 28px 32px;
  color: var(--ink);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.6);
}
.dash-card h1 { margin: 0 0 6px; font-size: 32px; font-weight: 600; }
.dash-card h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.dash-card p { margin: 0; color: var(--muted); }
.refbox { margin-top: 16px; padding: 14px 16px; overflow-x: auto; background: var(--wash); border: 1px dashed var(--line-strong); border-radius: 12px; }
.refbox code { font-size: 15px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Responsive ---------- */

/* Big monitors: one more step up so the card doesn't look lost */
@media (min-width: 1440px) {
  .auth-card--narrow { max-width: 620px; }
  .auth-card--wide { max-width: 960px; }
  .auth-card { padding: 64px 72px 54px; }
  .auth-title { font-size: 50px; }
}

/* Tablets and small laptops */
@media (max-width: 900px) {
  .auth-card { padding: 46px 40px 40px; }
  .auth-title { font-size: 40px; }
  .form-grid { gap: 22px 22px; }
}

/* Phones */
@media (max-width: 680px) {
  /* "fixed" backgrounds stutter on mobile browsers */
  .auth-body, .app-body { background-attachment: scroll; }

  .auth {
    padding: max(20px, env(safe-area-inset-top)) 14px calc(36px + env(safe-area-inset-bottom));
  }
  .auth-card { padding: 32px 22px 28px; border-radius: 22px; }
  .auth-card::before { height: 4px; }
  .auth-brand { margin-bottom: 26px; }
  .brand-mark { width: 46px; height: 46px; }
  .brand-name { font-size: 23px; }
  .brand-tag { font-size: 13px; }

  .auth-title { font-size: 32px; }
  .auth-sub { margin-bottom: 26px; font-size: 16px; }

  .form-grid { grid-template-columns: 1fr; gap: 20px; }
  .field label { font-size: 15px; margin-bottom: 8px; }

  /* 16px+ text in fields stops iPhones from zooming in on focus */
  .input { height: 56px; font-size: 16px; padding: 0 16px; }
  .input--toggle { padding-right: 56px; }
  .input--select { padding-right: 44px; }

  .check { align-items: flex-start; margin: 24px 0 22px; gap: 12px; }
  .check input { margin-top: 1px; }
  .check label { font-size: 15px; line-height: 1.5; }
  .forgot { margin: 14px 0 24px; }

  .btn { height: 60px; min-height: 60px; font-size: 15px; }
  .auth-switch { margin-top: 24px; font-size: 16px; }
  .alert { padding: 14px 16px; font-size: 15px; }

  .topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .topbar .brand-mark { width: 36px; height: 36px; }
  .topbar .brand-name { font-size: 18px; }
  .topbar-name { display: none; }
  .dash { padding: 24px 14px calc(48px + env(safe-area-inset-bottom)); }
  .dash-card { padding: 22px 20px; border-radius: 18px; }
  .dash-card h1 { font-size: 26px; }
}

/* Small phones (iPhone SE, older Androids) */
@media (max-width: 380px) {
  .auth { padding-left: 10px; padding-right: 10px; }
  .auth-card { padding: 28px 16px 24px; border-radius: 18px; }
  .auth-title { font-size: 28px; }
  .brand-name { font-size: 21px; }
  .btn { letter-spacing: 0.04em; font-size: 14px; }
  .check label { font-size: 14px; }
}

/* Phones turned sideways: very little height, so tighten vertical space */
@media (max-height: 520px) and (orientation: landscape) {
  .auth { padding-top: 16px; }
  .auth-brand { margin-bottom: 16px; }
  .auth-card { padding-top: 24px; padding-bottom: 22px; }
  .auth-sub { margin-bottom: 18px; }
  .form-grid { gap: 14px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Colour themes ---- */
:root[data-palette="scarlet"] {
  --c-primary: #dc2626;  --c-primary-rgb: 220, 38, 38;
  --c-light: #f87171;    --c-light-rgb: 248, 113, 113;
  --c-coral: #fb7c5c;
  --c-dark: #991b1b;
  --c-dark2: #b91c1c;
  --c-deep: #450a0a;
  --c-btn: #b91c1c;
  --c-text-dark: #fca5a5;
}

/* The built-in logo mark follows the theme too */
.brand-mark stop:nth-child(1) { stop-color: var(--c-deep); }
.brand-mark stop:nth-child(2) { stop-color: var(--c-primary); }
.brand-mark stop:nth-child(3) { stop-color: var(--amber); }

.brand-img { display: block; height: 52px; width: auto; max-width: 240px; object-fit: contain; }

/* =====================================================================
   Compact sign-in / sign-up cards (v2): a normal-sized card, centred on
   the screen, on phones and desktops alike. Scoped to .auth-card so the
   dashboards are not touched.
   ===================================================================== */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  padding: 24px 16px;
  box-sizing: border-box;
}
.auth-card { padding: 38px 40px 34px; border-radius: 22px; }
.auth-card--narrow { max-width: 440px; }
.auth-card--wide { max-width: 720px; }
.auth-card .auth-brand { margin-bottom: 26px; }
.auth-card .brand-mark { width: 42px; height: 42px; }
.auth-card .brand-name { font-size: 22px; }
.auth-card .brand-tag { font-size: 13px; margin-top: 3px; }
.auth-card .brand-img { height: 40px; max-width: 200px; }
.auth-card .auth-title { font-size: 30px; margin-bottom: 8px; }
.auth-card .auth-sub { margin-bottom: 24px; font-size: 16px; }
.auth-card .form-grid { gap: 18px 20px; }
.auth-card .field label { font-size: 15px; margin-bottom: 7px; }
.auth-card .input { height: 50px; font-size: 16px; border-radius: 12px; padding: 0 15px; }
.auth-card .input--toggle { padding-right: 54px; }
.auth-card .input--select { padding-right: 42px; }
.auth-card .eye { width: 40px; height: 40px; right: 6px; }
.auth-card .field-error, .auth-card .hint { font-size: 14px; margin-top: 7px; }
.auth-card .forgot { margin: 12px 0 22px; font-size: 15px; }
.auth-card .form-grid + .btn { margin-top: 24px; }       /* the admin form has no "forgot" line above the button */
.auth-card .btn { height: 52px; min-height: 52px; font-size: 15px; }
.auth-card .check { margin: 20px 0 20px; }
.auth-card .check label { font-size: 14.5px; }
.auth-card .auth-switch { margin-top: 20px; font-size: 15px; }
.auth-card .alert { padding: 12px 14px; font-size: 14.5px; margin-bottom: 16px; }

@media (max-width: 680px) {
  .auth { padding: max(16px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom)); }
  .auth-card { max-width: 380px; margin: 0 auto; padding: 26px 20px 22px; border-radius: 18px; }
  .auth-card--narrow, .auth-card--wide { max-width: 380px; }
  .auth-card .auth-brand { margin-bottom: 18px; }
  .auth-card .brand-mark { width: 36px; height: 36px; }
  .auth-card .brand-name { font-size: 19px; }
  .auth-card .brand-tag { font-size: 12px; }
  .auth-card .brand-img { height: 34px; max-width: 170px; }
  .auth-card .auth-title { font-size: 24px; margin-bottom: 6px; }
  .auth-card .auth-sub { margin-bottom: 18px; font-size: 14.5px; }
  .auth-card .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .auth-card .field label { font-size: 14px; margin-bottom: 6px; }
  .auth-card .input { height: 46px; padding: 0 14px; }     /* font stays 16px so iPhones don't zoom */
  .auth-card .input--toggle { padding-right: 50px; }
  .auth-card .eye { width: 38px; height: 38px; }
  .auth-card .forgot { margin: 10px 0 18px; font-size: 14px; }
  .auth-card .form-grid + .btn { margin-top: 20px; }
  .auth-card .btn { height: 48px; min-height: 48px; font-size: 14px; }
  .auth-card .check { margin: 16px 0 16px; gap: 10px; }
  .auth-card .check label { font-size: 13.5px; }
  .auth-card .auth-switch { margin-top: 16px; font-size: 14px; }
  .auth-card .field-error, .auth-card .hint { font-size: 13px; }
}
@media (max-width: 380px) {
  .auth { padding-left: 12px; padding-right: 12px; }
  .auth-card { padding: 22px 16px 20px; }
  .auth-card .auth-title { font-size: 22px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .auth { align-items: flex-start; }
}

/* email code screen */
.auth-resend { margin: 14px 0 0; text-align: center; }
.link-btn { padding: 6px 10px; border: 0; background: none; color: var(--c-primary, #c8102a); font: 600 14px/1.2 inherit; font-family: inherit; cursor: pointer; text-decoration: underline; }
.auth-card input[name="code"] { text-align: center; letter-spacing: 0.4em; font-weight: 700; }
