/*
 * KikundiDesk — the group's desk. One stylesheet for the public door and the app.
 *
 * The design language is the one already used on www.betki.co.tz: Apple's greys, the #0071e3 accent,
 * Inter, a frosted-glass header, pill buttons, 1rem card corners, large-blur low-alpha shadows and the
 * easeOutQuint spring. The TOKENS are ported from that theme's variables.css so the two surfaces cannot
 * drift apart; the COMPONENTS below are written fresh, because a marketing page and a working tool want
 * different things. The 100vh gradient hero belongs on the door, never inside the desk.
 *
 * Inter is SELF-HOSTED (public/fonts/), never a CDN — the same reason lib/report-charts.js draws its own
 * SVG: this runs on a box whose outbound access we do not control, and a katibu on a Dar es Salaam phone
 * should not wait on fonts.googleapis.com to read what their group owes.
 *
 * Mobile first. The katibu records a loan standing in a meeting, on a phone, so the phone layout is the
 * base and the desk layout is the media query — not the other way round.
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Inter-Variable.woff2') format('woff2');
}

/* ══ Tokens ════════════════════════════════════════════════════════════════════════════════════════ */
:root {
  /* Colour */
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: rgba(0, 113, 227, 0.08);
  --heading: #1d1d1f;
  --body: #6e6e73;
  --muted: #86868b;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --white: #ffffff;
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --bg-dark: #1d1d1f;

  /* Meaning. Money is never decorative, so these are the only non-neutral hues in the app. */
  --good: #1a7a44;
  --good-bg: #e8f6ee;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --bad: #c8232c;
  --bad-bg: #fdeced;

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', SFMono-Regular, Consolas, Menlo, monospace;
  --text-xs:   clamp(0.75rem,   0.70rem + 0.25vw, 0.8125rem);
  --text-sm:   clamp(0.8125rem, 0.76rem + 0.26vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.88rem + 0.28vw, 1.0625rem);
  --text-lg:   clamp(1.125rem,  1.05rem + 0.38vw, 1.25rem);
  --text-xl:   clamp(1.25rem,   1.10rem + 0.75vw, 1.5rem);
  --text-2xl:  clamp(1.5rem,    1.20rem + 1.50vw, 2rem);
  --text-3xl:  clamp(1.875rem,  1.40rem + 2.40vw, 2.75rem);
  --text-4xl:  clamp(2.25rem,   1.50rem + 3.75vw, 3.5rem);
  --text-5xl:  clamp(2.75rem,   1.80rem + 4.75vw, 4.5rem);
  --weight-regular: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;
  --leading-tight: 1.1; --leading-snug: 1.25; --leading-normal: 1.5; --leading-relaxed: 1.7;
  --tracking-tight: -0.02em; --tracking-wide: 0.02em; --tracking-wider: 0.06em;

  /* Space */
  --space-xs: 0.5rem; --space-sm: 0.75rem; --space-md: 1rem; --space-lg: 1.5rem;
  --space-xl: 2rem;   --space-2xl: 3rem;   --space-3xl: 4rem; --space-4xl: 6rem;
  --space-section: clamp(3rem, 2rem + 5vw, 7rem);

  /* Shape */
  --radius-sm: 0.5rem; --radius-md: 0.75rem; --radius-lg: 1rem; --radius-xl: 1.5rem; --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.10);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.12);

  /* Motion */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-spring: 500ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Frame */
  --header-height: 3.25rem;
  --header-bg: rgba(255, 255, 255, 0.72);
  --header-bg-scrolled: rgba(255, 255, 255, 0.92);
  --nav-width: 15rem;
  --container: 1100px;
  --container-narrow: 720px;
  --pad: clamp(1rem, 0.75rem + 1.5vw, 2rem);

  --z-sticky: 200; --z-overlay: 300; --z-modal: 400; --z-toast: 500;
}

/* ══ Base ══════════════════════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  color: var(--heading);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }
p  { margin: 0 0 var(--space-md); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-hover); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

.muted     { color: var(--muted); }
.small     { font-size: var(--text-sm); }
.mono      { font-family: var(--mono); font-size: var(--text-sm); letter-spacing: 0; }
.num       { font-variant-numeric: tabular-nums; }   /* money lines up in a column */
.center    { text-align: center; }
.right     { text-align: right; }
.hide      { display: none !important; }
.stack > * + * { margin-top: var(--space-md); }
.row       { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.row .spacer { flex: 1 1 auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ══ Buttons ═══════════════════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  padding: 0.7rem 1.5rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  color: var(--heading);
  background: var(--bg-alt);
  border: none;
  border-radius: var(--radius-full);
  transition: background var(--transition-base), color var(--transition-base),
              transform var(--transition-base), box-shadow var(--transition-base);
  white-space: nowrap;
}
.btn:hover { background: #ebebef; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn.primary { background: var(--accent); color: var(--white); }
.btn.primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn.secondary:hover { background: var(--accent); color: var(--white); }
.btn.ghost { background: transparent; color: var(--body); }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.04); color: var(--heading); }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px rgba(200, 35, 44, 0.35); }
.btn.danger:hover { background: var(--bad); color: var(--white); box-shadow: none; }
.btn.lg { padding: 0.95rem 2.1rem; font-size: var(--text-base); }
.btn.sm { padding: 0.45rem 1rem; font-size: var(--text-xs); }
.btn.block { display: flex; width: 100%; }

/* ══ The shell ═════════════════════════════════════════════════════════════════════════════════════ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-sticky);
  height: var(--header-height);
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 0 var(--pad);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.07);
}
.topbar .brand { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.topbar .brand img { height: 1.35rem; width: auto; display: block; }
.topbar .brand b {
  font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--heading);
  letter-spacing: var(--tracking-tight); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.topbar .spacer { flex: 1 1 auto; }

/* The hamburger only exists on a phone; the nav is always present on a desk. */
.navtoggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; padding: 0;
  background: transparent; border: none; border-radius: var(--radius-full);
  color: var(--heading);
}
.navtoggle:hover { background: rgba(0, 0, 0, 0.05); }

/* Language is a two-state pill, not a dropdown: there are exactly two languages and both are first-class. */
.langpick { display: inline-flex; background: var(--bg-alt); border-radius: var(--radius-full); padding: 2px; }
.langpick button {
  border: none; background: transparent; color: var(--muted);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  padding: 0.3rem 0.7rem; border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.langpick button.on { background: var(--white); color: var(--heading); box-shadow: var(--shadow-sm); }

.app { display: block; padding-top: var(--header-height); }

.nav {
  position: fixed; top: var(--header-height); bottom: 0; left: 0; width: min(84vw, var(--nav-width));
  z-index: var(--z-modal);
  padding: var(--space-md) var(--space-sm) var(--space-xl);
  background: var(--white);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--transition-spring);
}
.nav.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0, 0, 0, 0.15); }
.nav a {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 0.6rem 0.8rem; margin-bottom: 2px;
  color: var(--heading);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav a:hover { background: rgba(0, 0, 0, 0.04); }
.nav a.active { background: var(--accent-light); color: var(--accent); font-weight: var(--weight-semibold); }
.nav a .count {
  margin-left: auto; min-width: 1.35rem; padding: 0 0.4rem; height: 1.35rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bad); color: var(--white);
  font-size: var(--text-xs); font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
}
.nav a .count:empty, .nav a .count.zero { display: none; }
.nav .group-label {
  padding: 0 0.8rem var(--space-sm);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--muted);
}
.nav .foot { margin-top: var(--space-lg); padding: var(--space-md) 0.8rem 0; border-top: 1px solid var(--border-light); font-size: var(--text-xs); color: var(--muted); }

.scrim {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: rgba(0, 0, 0, 0.3);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition-base);
}
.scrim.show { opacity: 1; pointer-events: auto; }

.content { padding: var(--space-lg) var(--pad) var(--space-4xl); max-width: var(--container); }
.content > header { margin-bottom: var(--space-lg); }
.content > header h1 { font-size: var(--text-2xl); }
.content > header .sub { color: var(--muted); font-size: var(--text-sm); margin-top: 0.25rem; }

/* ══ Cards, KPIs, panels ═══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.card + .card { margin-top: var(--space-md); }
.card > h3 { margin-bottom: 0.25rem; }
.card > .sub { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--space-md); }
.card.tap { transition: transform var(--transition-spring), box-shadow var(--transition-spring), border-color var(--transition-spring); }
.card.tap:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); border-color: transparent; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
.kpi {
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}
.kpi .l {
  font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--muted);
  letter-spacing: var(--tracking-wide);
}
.kpi .n {
  margin-top: 0.35rem;
  font-size: var(--text-xl); font-weight: var(--weight-semibold); color: var(--heading);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
}
.kpi .s { margin-top: 0.2rem; font-size: var(--text-xs); color: var(--muted); }
.kpi.accent { background: var(--heading); }
.kpi.accent .l, .kpi.accent .s { color: rgba(255, 255, 255, 0.62); }
.kpi.accent .n { color: var(--white); }
.kpi.alert { background: var(--bad-bg); }
.kpi.alert .n { color: var(--bad); }

/* ══ Status chips ══════════════════════════════════════════════════════════════════════════════════ */
.tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  background: var(--bg-alt); color: var(--body);
  white-space: nowrap;
}
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad  { background: var(--bad-bg);  color: var(--bad); }
.tag .led { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }

/* ══ Banners — one sentence the katibu must read ═══════════════════════════════════════════════════ */
.banner {
  display: flex; gap: var(--space-sm); align-items: flex-start;
  padding: var(--space-md) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--bg-alt); color: var(--heading);
  margin-bottom: var(--space-md);
}
/* A banner is a row — an icon beside a sentence. `.stack` is for the ones that carry several lines: a
   heading, one line per thing to say, and a note. Without it those become flex ITEMS side by side and a
   three-line warning renders as three squashed columns on a phone. */
.banner.stack { flex-direction: column; gap: 0.35rem; }
.banner.good { background: var(--good-bg); color: var(--good); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad  { background: var(--bad-bg);  color: var(--bad); }
.banner b { font-weight: var(--weight-semibold); }

/* ══ Forms ═════════════════════════════════════════════════════════════════════════════════════════ */
.field { margin-bottom: var(--space-md); }
.field > label {
  display: block; margin-bottom: 0.35rem;
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--heading);
}
/* Radios and checkboxes are deliberately excluded: they live inside .choice, where they are a control
   beside a sentence, not a box the katibu types into. */
.field input:not([type="radio"]):not([type="checkbox"]), .field select, .field textarea {
  display: block; width: 100%;
  /* 17px minimum: below that iOS Safari zooms the whole page on focus, which loses the katibu's place. */
  font-size: max(1.0625rem, var(--text-base));
  padding: 0.7rem 0.9rem;
  color: var(--heading); background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none; appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2386868b' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.9rem center; padding-right: 2.2rem;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.field input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(200, 35, 44, 0.1); }
/* The one-line explanation under a choice. Section B: the plain language lives HERE, not in the label. */
.field .help { margin-top: 0.35rem; font-size: var(--text-sm); color: var(--muted); line-height: var(--leading-snug); }
.field .err  { margin-top: 0.35rem; font-size: var(--text-sm); color: var(--bad); }
.field .unit { display: flex; align-items: center; gap: 0.55rem; }
.field .unit input { flex: 0 1 9rem; }
.field .unit span { font-size: var(--text-sm); color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: var(--space-sm); }
.field.inline > label { margin: 0; }

fieldset { margin: 0 0 var(--space-lg); padding: 0; border: none; }
fieldset > legend {
  padding: 0; margin-bottom: var(--space-sm);
  font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--heading);
}
.choices { display: grid; gap: 0.5rem; }
.choice {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.choice:hover { border-color: var(--muted); }
.choice input { width: auto; margin: 0.15rem 0 0; accent-color: var(--accent); flex: none; }
.choice > span { min-width: 0; }
.choice.on { border-color: var(--accent); background: var(--accent-light); }
.choice .t { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--heading); }
.choice .h { font-size: var(--text-sm); color: var(--muted); line-height: var(--leading-snug); }

.form-actions {
  display: flex; gap: var(--space-sm); align-items: center;
  margin-top: var(--space-lg); padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}
.form-actions .spacer { flex: 1 1 auto; }

/* A row of choices rather than a save/cancel pair: it wraps, because the labels are sentences and
   Kiswahili's run half again as long as English's. Without the wrap, "Hizi hazikuwa fedha za kikundi"
   is clipped at the card's edge on a phone — which is exactly where this is read. */
.choice-actions {
  display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center;
  margin-top: var(--space-md); padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}
.choice-actions .btn { white-space: normal; text-align: center; }

/* ══ Tables ════════════════════════════════════════════════════════════════════════════════════════ */
/* A phone cannot widen, so a wide table scrolls inside its own box and the page never does. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--space-lg)); padding: 0 var(--space-lg); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th {
  text-align: left; white-space: nowrap;
  padding: 0.5rem 0.7rem;
  font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--muted);
  letter-spacing: var(--tracking-wide);
  border-bottom: 1px solid var(--border);
}
td { padding: 0.7rem; border-bottom: 1px solid var(--border-light); color: var(--heading); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th.right, td.right { text-align: right; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { padding: var(--space-xl) var(--space-md); text-align: center; color: var(--muted); font-size: var(--text-sm); }

/* ══ Wizard ════════════════════════════════════════════════════════════════════════════════════════ */
.stepper { display: flex; gap: 0.4rem; margin-bottom: var(--space-lg); }
.stepper .s {
  flex: 1 1 0; height: 0.25rem; border-radius: var(--radius-full);
  background: var(--border-light);
  transition: background var(--transition-base);
}
.stepper .s.done { background: var(--accent); }
.stepper .s.now  { background: var(--accent); opacity: 0.55; }
.step-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }

/* Repeating rows — members, positions, bands, reasons money goes out. */
.rows { display: grid; gap: var(--space-sm); }
.rows .r {
  display: grid; gap: var(--space-sm);
  padding: var(--space-md);
  border: 1px solid var(--border-light); border-radius: var(--radius-md);
  background: var(--white);
}
.rows .r .head { display: flex; align-items: center; gap: var(--space-sm); }
.rows .r .head .who { font-weight: var(--weight-semibold); color: var(--heading); flex: 1 1 auto; min-width: 0; }
.rows .r .field { margin-bottom: 0; }
.rows .r .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
.iconbtn {
  flex: none; width: 2rem; height: 2rem; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: var(--radius-full);
  color: var(--muted); font-size: var(--text-lg); line-height: 1;
}
.iconbtn:hover { background: var(--bad-bg); color: var(--bad); }

/* The file drop / pick area on the statement steps. */
.drop {
  display: block; padding: var(--space-xl) var(--space-md);
  text-align: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
  background: var(--bg-alt);
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-light); }
.drop b { display: block; color: var(--heading); font-weight: var(--weight-semibold); }
.drop span { display: block; margin-top: 0.3rem; font-size: var(--text-sm); color: var(--muted); }

/* ══ Modal — a centred card on a desk, a bottom sheet on a phone ═══════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal-bg.show { display: flex; }
.modal {
  width: 100%; max-height: 92vh; overflow-y: auto;
  padding: var(--space-lg) var(--space-lg) var(--space-xl);
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up var(--transition-spring);
}
@keyframes sheet-up { from { transform: translateY(12px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal > h3 { margin-bottom: 0.25rem; }
.modal > .sub { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--space-md); }

/* ══ Spinner ═══════════════════════════════════════════════════════════════════════════════════════ */
.spinner {
  display: inline-block; width: 1rem; height: 1rem;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 700ms linear infinite;
  vertical-align: -0.15rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ The public door ═══════════════════════════════════════════════════════════════════════════════ */
.door { min-height: 100vh; display: flex; flex-direction: column; }
.hero {
  position: relative; overflow: hidden;
  padding: calc(var(--header-height) + var(--space-2xl)) var(--pad) var(--space-2xl);
  color: var(--white);
  background: linear-gradient(135deg, #1d1d1f 0%, #2c2c2e 30%, #1a3a5c 62%, #0071e3 100%);
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 62% 38%, rgba(0, 113, 227, 0.18) 0%, transparent 60%);
  pointer-events: none;
}
.hero .inner { position: relative; z-index: 1; max-width: var(--container); margin: 0 auto; }
.hero h1 { color: var(--white); font-size: var(--text-4xl); font-weight: var(--weight-bold); }
.hero .lede { margin-top: var(--space-md); font-size: var(--text-lg); color: rgba(255, 255, 255, 0.72); max-width: 34rem; }
.hero .cta { margin-top: var(--space-xl); display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.btn.white { background: var(--white); color: var(--heading); }
.btn.white:hover { background: #f0f0f2; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn.onDark { background: rgba(255, 255, 255, 0.14); color: var(--white); }
.btn.onDark:hover { background: rgba(255, 255, 255, 0.24); }

.section { padding: var(--space-section) var(--pad); }
.section.alt { background: var(--bg-alt); }
.section .inner { max-width: var(--container); margin: 0 auto; }
.section h2 { margin-bottom: var(--space-lg); }
.steps { display: grid; gap: var(--space-md); list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  padding: var(--space-lg);
  background: var(--white); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  transition: transform var(--transition-spring), box-shadow var(--transition-spring), border-color var(--transition-spring);
}
.steps li:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); border-color: transparent; }
.steps li::before {
  counter-increment: step; content: counter(step);
  display: flex; align-items: center; justify-content: center;
  width: 1.9rem; height: 1.9rem; margin-bottom: var(--space-sm);
  background: var(--accent-light); color: var(--accent);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
}
.steps b { display: block; color: var(--heading); font-weight: var(--weight-semibold); margin-bottom: 0.3rem; }

.door footer { margin-top: auto; padding: var(--space-xl) var(--pad); background: var(--bg-dark); color: rgba(255, 255, 255, 0.55); font-size: var(--text-sm); }
.door footer .inner { max-width: var(--container); margin: 0 auto; display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: center; }
.door footer a { color: rgba(255, 255, 255, 0.8); }

/* The door's own header is dark, because it sits directly on the hero. A light bar over a dark gradient
   reads as two pages stacked; the desk's header stays light because the desk behind it is. */
.door .topbar { background: rgba(29, 29, 31, 0.62); box-shadow: none; }
.door .topbar .brand b { color: var(--white); }
.door .topbar .langpick { background: rgba(255, 255, 255, 0.14); }
.door .topbar .langpick button { color: rgba(255, 255, 255, 0.62); }
.door .topbar .langpick button.on { background: rgba(255, 255, 255, 0.92); color: var(--heading); }
.door .topbar .btn { background: rgba(255, 255, 255, 0.16); color: var(--white); }
.door .topbar .btn:hover { background: rgba(255, 255, 255, 0.26); }

/* The sign-in / create-a-group card, used on the door and on the verify page. */
.auth-wrap { padding: var(--space-2xl) var(--pad) var(--space-2xl); background: var(--bg-alt); }
.auth-card {
  max-width: 26rem; margin: 0 auto;
  padding: var(--space-xl);
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}
.auth-card h2 { font-size: var(--text-xl); }
.auth-card > .sub { color: var(--muted); font-size: var(--text-sm); margin: 0.3rem 0 var(--space-lg); }
.auth-card .alt-action { margin-top: var(--space-lg); padding-top: var(--space-md); border-top: 1px solid var(--border-light); font-size: var(--text-sm); color: var(--muted); text-align: center; }
.tabs { display: flex; background: var(--bg-alt); border-radius: var(--radius-full); padding: 3px; margin-bottom: var(--space-lg); }
.tabs button {
  flex: 1 1 0; border: none; background: transparent; color: var(--muted);
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  padding: 0.5rem 0.75rem; border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tabs button.on { background: var(--white); color: var(--heading); box-shadow: var(--shadow-sm); }

/* ══ Desk ══════════════════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 46rem) {
  :root { --header-height: 3.5rem; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-md); }
  .rows .r { grid-template-columns: 1fr; }
  .rows .r .cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal-bg { align-items: center; }
  .modal { max-width: 32rem; border-radius: var(--radius-xl); }
  .hero { padding-top: calc(var(--header-height) + var(--space-3xl)); padding-bottom: var(--space-3xl); }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 64rem) {
  .navtoggle { display: none; }
  .app { padding-left: var(--nav-width); }
  .nav { transform: none; box-shadow: none; }
  .scrim { display: none; }
  .content { padding: var(--space-xl) var(--space-xl) var(--space-4xl); }
  .table-wrap { margin: 0; padding: 0; }
}

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