:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --border: #dde3ee;
  --text: #16202e;
  --muted: #64748b;
  --brand: #2f5fe0;
  --brand-strong: #1f47b8;
  --brand-soft: #e8eeff;
  --ok: #158a5a;
  --ok-soft: #e2f6ec;
  --warn: #a86416;
  --warn-soft: #fdf1dd;
  --danger: #c0392b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .05), 0 8px 24px rgba(16, 30, 54, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131c;
    --surface: #161d29;
    --surface-2: #1d2634;
    --border: #2a3444;
    --text: #e8edf6;
    --muted: #94a3b8;
    --brand: #6c92ff;
    --brand-strong: #85a6ff;
    --brand-soft: #1c2740;
    --ok: #46c58c;
    --ok-soft: #12301f;
    --warn: #e0a760;
    --warn-soft: #2e2415;
    --danger: #f0796b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }

a { color: var(--brand); }

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.narrow { max-width: 460px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }

/* --- Forms --- */

label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

/*
 * Every text-like input, styled by exclusion rather than by listing the types
 * we happen to use today. Listing them is how the email field ended up looking
 * nothing like the password field above it.
 */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
select {
  width: 100%;
  padding: 14px 14px;
  font-size: 17px;
  font-family: inherit;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  outline: none;
  /* Safari on iOS otherwise imposes its own chrome on email and date fields. */
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

/*
 * A date field's inner field-wrapper inherits the padding above and stacks it
 * on top of the field's own, leaving the date box 2px taller than the select
 * sitting next to it in the toolbar.
 */
input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/*
 * Chrome paints autofilled fields with its own background, which made the
 * remembered email address show up as a white box in the dark theme. There is
 * no property to turn that off, so the inset shadow overpaints it instead.
 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--text);
  transition: background-color 100000s ease-in-out 0s;
}

.field + .field { margin-top: 16px; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  border: 1.5px solid transparent;
  padding: 14px 18px;
  background: var(--brand);
  color: #fff;
  transition: background .15s ease, transform .05s ease;
}

button:hover { background: var(--brand-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }

button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
button.secondary:hover { background: var(--surface-2); }

button.block { width: 100%; }

button.link {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px 8px;
  font-weight: 500;
}
button.link:hover { color: var(--danger); background: none; }

/* --- Messages --- */

.msg {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
}
.msg.error { background: var(--warn-soft); color: var(--warn); }
.msg:empty { display: none; }

/* --- Layout bits --- */

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.spread { justify-content: space-between; }
.grow { flex: 1 1 180px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.brandmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.dot {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.hidden { display: none !important; }

/* --- Back button --- */

.backbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px 9px 11px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.backbtn:hover { background: var(--surface-2); }
.backbtn svg { width: 16px; height: 16px; }

/* Sits just ahead of the page links, with a hairline between. */
.nav .backbtn { margin-right: 6px; }
.nav .backbtn + a { border-left-width: 1.5px; }

/* --- Page navigation --- */

.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.nav a:hover { background: var(--surface-2); }

.nav a.current {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  cursor: default;
}

.nav a svg { width: 16px; height: 16px; }

/* --- Language switch (EN | AF) --- */

.langswitch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.langswitch button {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.langswitch button:hover { background: transparent; color: var(--text); }

.langswitch button.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 2px rgba(16, 30, 54, .12);
}
