/* =========================================================================
   Calling Manager — Design System v2 (see Docs/DESIGNv2.md)
   Monochrome "transit kiosk": white canvas, black structural bars,
   8px radii, 1px hairlines, no shadows. Color is reserved for the
   tab-strip active state (faded teal) and functional status signals.

   Readability rules (deviations from DESIGNv2 on purpose):
   - Ash Gray (#afafaf) is never used for text on white (2.3:1 contrast).
     Muted text uses Slate (#5e5e5e, 6.4:1). Ash Gray is only used on black.
   - Minimum text size is 12px; form controls are 16px so iOS Safari
     does not zoom the page when an input is focused.
   ========================================================================= */

:root {
  /* Colors — DESIGNv2 */
  --color-jet-black: #000000;
  --color-paper-white: #ffffff;
  --color-mist-gray: #f6f6f6;
  --color-charcoal: #333333;
  --color-iron-gray: #767676;
  --color-ash-gray: #afafaf;
  --color-slate: #5e5e5e;
  --color-graphite: #4b4b4b;
  --color-faded-teal: #9dcdd6;
  --color-hairline: #d4d4d4;          /* non-text dividers between rows */
  --color-box-border: #9a9a9a;        /* outlines around panels, cards and tables */
  --box-border: 2px solid var(--color-box-border);
  --color-hover: #eeeeee;             /* one step past mist for hover */

  /* Functional status colors (text is AA on its own tint) */
  --status-good-fg: #0b6b33;
  --status-good-bg: #e5f3ea;
  --status-good-line: #1f8a4c;
  --status-warn-fg: #7a4100;
  --status-warn-bg: #fdf0dc;
  --status-warn-line: #c77700;
  --status-bad-fg: #a3231b;
  --status-bad-bg: #fce8e6;
  --status-bad-line: #d0352b;

  /* Typography */
  --font-ubermove: 'Inter', 'Helvetica Neue', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-ubermovetext: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-caption: 12px;
  --leading-caption: 1.5;
  --text-body-sm: 14px;
  --leading-body-sm: 1.5;
  --text-body: 16px;
  --leading-body: 1.5;
  --text-subheading: 18px;
  --leading-subheading: 1.33;
  --text-heading-sm: 24px;
  --leading-heading-sm: 1.33;
  --text-heading: 36px;
  --leading-heading: 1.22;
  --text-display: 52px;
  --leading-display: 1.23;

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;

  /* Spacing (4px base) */
  --spacing-4: 4px;
  --spacing-8: 8px;
  --spacing-12: 12px;
  --spacing-16: 16px;
  --spacing-20: 20px;
  --spacing-24: 24px;
  --spacing-28: 28px;
  --spacing-32: 32px;
  --spacing-36: 36px;
  --spacing-48: 48px;
  --spacing-64: 64px;

  /* Layout */
  --page-max-width: 1200px;
  --board-max-width: 1600px;
  --section-gap: 64px;
  --card-padding: 24px;
  --element-gap: 16px;
  --header-height: 64px;
  --brand-ray-blue: #007da5;
  /* Decorative rays from the Church sign-in page, loaded from its source (not vendored) */
  --header-rays: url("https://id.churchofjesuschrist.org/images/blueRays.svg");
  --gutter: 24px;

  /* Radii — binary: 8px or full pill */
  --radius-tabs: 8px;
  --radius-cards: 8px;
  --radius-inputs: 8px;
  --radius-buttons: 8px;
  --radius-pills: 9999px;

  /* Surfaces */
  --surface-paper-white: #ffffff;
  --surface-mist-gray: #f6f6f6;
  --surface-jet-black: #000000;

  /* Legacy aliases — older markup still references these names */
  --color-obsidian: var(--color-jet-black);
  --color-pure-white: var(--color-paper-white);
  --color-mist: var(--color-mist-gray);
  --color-ash-border: var(--color-hairline);
  --color-smoke: var(--color-ash-gray);
  --color-onyx: var(--color-jet-black);
  --color-webflow-blue: var(--color-jet-black);
  --color-indigo-ink: var(--color-charcoal);
  --surface-canvas: var(--surface-paper-white);
  --surface-tinted: var(--surface-mist-gray);
  --surface-card: var(--surface-paper-white);
  --surface-inverted: var(--surface-jet-black);
  --navy: var(--color-jet-black);
  --blue: var(--color-jet-black);
  --bg: var(--surface-paper-white);
  --line: var(--color-hairline);
  --muted: var(--color-slate);
}

/* -------------------------------------------------------------------------
   Dark mode — set by the header toggle (html[data-theme="dark"]; see App.razor).
   The ink/paper tokens swap, so most rules need no dark-specific CSS:
   text and primary buttons go light, panels and inputs go dark.
   ------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --color-jet-black: #f5f5f7;         /* ink: text, primary buttons, active chips */
  --color-paper-white: #1a1a1d;       /* panels, cards, inputs, modals */
  --color-mist-gray: #242428;
  --color-hover: #2e2e33;
  --color-charcoal: #d1d1d6;
  --color-iron-gray: #8e8e93;
  --color-ash-gray: #8e8e93;
  --color-slate: #a8a8ad;             /* muted text: 7.4:1 on panels */
  --color-graphite: #c7c7cc;
  --color-faded-teal: #1d5866;        /* active tab: light text on deep teal */
  --color-hairline: #35353a;
  --color-box-border: #5a5a60;

  --surface-paper-white: #0f0f11;     /* page canvas, one step below panels */
  --surface-mist-gray: #242428;
  /* --surface-jet-black stays #000: the header bar is black in both themes */

  --status-good-fg: #7ddc9f;
  --status-good-bg: #13321f;
  --status-good-line: #34a865;
  --status-warn-fg: #f7c070;
  --status-warn-bg: #3a2a12;
  --status-warn-line: #d48a1a;
  --status-bad-fg: #ff9b91;
  --status-bad-bg: #401a17;
  --status-bad-line: #e5574c;
}

/* The black header keeps its light-theme palette (white text, white active pill) in dark mode */
:root[data-theme="dark"] .app-header {
  color-scheme: dark;
  --color-jet-black: #000000;
  --color-paper-white: #ffffff;
  --color-mist-gray: #f6f6f6;
  --color-charcoal: #333333;
  --color-ash-gray: #afafaf;
  --color-iron-gray: #767676;
  --color-hover: #eeeeee;
}

@media (max-width: 767px) {
  :root {
    --gutter: 16px;
    --card-padding: 16px;
    --text-heading: 28px;
    --leading-heading: 1.25;
    --text-heading-sm: 22px;
  }
}

/* -------------------------------------------------------------------------
   Base
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--surface-paper-white);
  color: var(--color-jet-black);
  font-family: var(--font-ubermovetext);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font-family: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ubermove);
  color: var(--color-jet-black);
  font-weight: var(--font-weight-regular);
  margin-top: 0;
  letter-spacing: normal;
}

h1 { font-size: var(--text-heading); line-height: var(--leading-heading); margin-bottom: var(--spacing-8); }
h2 { font-size: var(--text-heading-sm); line-height: var(--leading-heading-sm); margin-bottom: var(--spacing-8); }
h3 { font-size: var(--text-subheading); line-height: var(--leading-subheading); font-weight: var(--font-weight-medium); margin-bottom: var(--spacing-8); }
h4 { font-size: var(--text-body); line-height: var(--leading-body); font-weight: var(--font-weight-medium); margin-bottom: var(--spacing-8); }

p { margin: 0 0 var(--spacing-12); }

a { color: var(--color-jet-black); text-underline-offset: 3px; }
a:hover { color: var(--color-charcoal); }

b, strong { font-weight: var(--font-weight-medium); }

small { font-size: var(--text-caption); line-height: var(--leading-caption); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-mist-gray);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Blazor's FocusOnNavigate moves focus to the page h1; don't box it */
h1:focus, h1:focus-visible { outline: none; }

:focus-visible {
  outline: 2px solid var(--color-jet-black);
  outline-offset: 2px;
}

.muted, .text-muted { color: var(--color-slate); }
.text-sm { font-size: var(--text-body-sm); line-height: var(--leading-body-sm); }
.text-caption { font-size: var(--text-caption); line-height: var(--leading-caption); }
.text-medium { font-weight: var(--font-weight-medium); }
.text-bad { color: var(--status-bad-fg); }
.text-good { color: var(--status-good-fg); }
.mono { font-family: var(--font-mono); font-size: var(--text-body-sm); }

.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;
}

/* Layout helpers (replace one-off inline styles) */
.row { display: flex; align-items: center; gap: var(--spacing-8); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-12); flex-wrap: wrap; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: var(--spacing-8); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--spacing-8); }
.stack-lg { display: flex; flex-direction: column; gap: var(--element-gap); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--element-gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--element-gap); }
.w-full { width: 100%; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-8 { margin-top: var(--spacing-8); }
.mt-16 { margin-top: var(--spacing-16); }
.mt-24 { margin-top: var(--spacing-24); }
.mb-0 { margin-bottom: 0 !important; }
.mb-16 { margin-bottom: var(--spacing-16); }
.divider { border: 0; border-top: 1px solid var(--color-hairline); margin: var(--spacing-16) 0; }
.only-mobile { display: none !important; }

@media (max-width: 767px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .hide-mobile { display: none !important; }
  .only-mobile { display: initial !important; }
}

/* -------------------------------------------------------------------------
   Top navigation bar — black structural band
   ------------------------------------------------------------------------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  background: var(--surface-jet-black);
  color: var(--color-paper-white);
  position: sticky;
  top: 0;
  z-index: 40;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 3px solid var(--brand-ray-blue);
}

/* Blue rays fan out from the left edge behind the logo, with a soft glow
   so the translucent rays read on the black band. */
.app-header::before,
.app-header::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: var(--header-height);
  pointer-events: none;
  z-index: -1;
}

.app-header::before {
  width: 520px;
  background: radial-gradient(110% 160% at 0% 50%, rgba(0, 125, 165, 0.35) 0%, rgba(0, 125, 165, 0.1) 50%, rgba(0, 0, 0, 0) 80%);
}

.app-header::after {
  width: 480px;
  background: var(--header-rays) no-repeat left 42% / auto 400%;
  filter: brightness(1.3);
  -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent 95%);
  mask-image: linear-gradient(90deg, #000 45%, transparent 95%);
}

.header-bar {
  height: var(--header-height);
  max-width: var(--board-max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--spacing-24);
}

.brand-title {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--color-paper-white);
  white-space: nowrap;
}

.brand-title:hover { color: var(--color-paper-white); }

.brand-logo { display: inline-flex; align-items: center; gap: 12px; }
.brand-icon { width: 38px; height: 38px; flex: 0 0 auto; }
.brand-words { display: flex; flex-direction: column; line-height: 1.1; }

.brand-mark {
  font-family: var(--font-ubermove);
  font-weight: var(--font-weight-bold);
  font-size: 21px;
  letter-spacing: -0.01em;
  color: var(--color-paper-white);
}

.brand-tagline {
  font-size: var(--text-caption);
  color: #e3f3f9;
  letter-spacing: 0.02em;
}

.ward-context {
  display: flex;
  align-items: center;
  gap: var(--spacing-8);
  min-width: 0;
  font-size: var(--text-body-sm);
  color: var(--color-ash-gray);
}

.ward-context .ward-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-paper-white);
  flex: 0 0 auto;
}

.ward-context b { color: var(--color-paper-white); font-weight: var(--font-weight-medium); }
.ward-context { flex: 0 1 auto; }
.ward-context .stake-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ward picker: pill on the black bar */
.ward-select, .role-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-charcoal) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23fff' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--color-paper-white);
  border: 0;
  border-radius: var(--radius-pills);
  padding: 6px 32px 6px 14px;
  font-size: var(--text-body-sm);
  font-weight: var(--font-weight-medium);
  max-width: 280px;
  cursor: pointer;
}

.ward-select option, .role-select option { color: var(--color-jet-black); background: var(--color-paper-white); }

.main-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  margin-left: auto;
}

.main-nav a {
  padding: 8px 12px;
  text-decoration: none;
  color: var(--color-paper-white);
  font-size: var(--text-body-sm);
  font-weight: var(--font-weight-regular);
  border-radius: var(--radius-pills);
  white-space: nowrap;
}

.main-nav a:hover { background: var(--color-charcoal); color: var(--color-paper-white); }
.main-nav a.active { background: var(--color-paper-white); color: var(--color-jet-black); font-weight: var(--font-weight-medium); }

.user-cluster {
  display: flex;
  align-items: center;
  gap: var(--spacing-12);
  white-space: nowrap;
}

.user-cluster .user-name { font-size: var(--text-body-sm); color: var(--color-paper-white); font-weight: var(--font-weight-medium); }
.user-cluster .user-role { font-size: var(--text-caption); color: var(--color-ash-gray); }

/* White pill button — the one element that inverts the black bar */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-paper-white);
  color: var(--color-jet-black);
  border: 0;
  border-radius: var(--radius-pills);
  padding: 6px 16px;
  font-size: var(--text-body-sm);
  font-weight: var(--font-weight-regular);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.pill-btn:hover { background: var(--color-mist-gray); color: var(--color-jet-black); }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--color-paper-white);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-buttons);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.nav-toggle:hover { background: var(--color-charcoal); }
.nav-toggle svg { width: 22px; height: 22px; }

/* Light/dark toggle: shows a moon in light mode (go dark) and a sun in dark mode (go light) */
.theme-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-pills);
  color: var(--color-paper-white);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--color-charcoal); }
.theme-toggle:focus-visible { outline: 2px solid var(--brand-ray-blue); outline-offset: 2px; }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Mobile / tablet menu panel */
.mobile-menu {
  display: none;
  border-top: 1px solid var(--color-charcoal);
  padding: var(--spacing-8) var(--gutter) var(--spacing-16);
  /* The header is sticky with overflow hidden: without a cap, items below the fold (Sign out) are unreachable */
  max-height: calc(100vh - var(--header-height));
  max-height: calc(100dvh - var(--header-height));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-menu a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 var(--spacing-12);
  color: var(--color-paper-white);
  text-decoration: none;
  font-size: var(--text-body);
  border-radius: var(--radius-buttons);
}

.mobile-menu a:hover { background: var(--color-charcoal); }
.mobile-menu a.active { background: var(--color-paper-white); color: var(--color-jet-black); font-weight: var(--font-weight-medium); }

.mobile-menu .menu-section {
  border-top: 1px solid var(--color-charcoal);
  margin-top: var(--spacing-8);
  padding-top: var(--spacing-12);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
}

.mobile-menu .menu-label { font-size: var(--text-caption); color: var(--color-ash-gray); }
.mobile-menu .ward-select, .mobile-menu .role-select { max-width: none; width: 100%; font-size: var(--text-body); padding: 10px 36px 10px 16px; }

@media (max-width: 1799px) {
  .ward-context .stake-name, .ward-context .ward-sep { display: none; }
}

@media (max-width: 1499px) {
  .user-cluster .user-name, .user-cluster .user-role { display: none; }
  .ward-select { max-width: 220px; }
}

@media (max-width: 1365px) {
  .ward-context .stake-name, .ward-context .ward-sep { display: inline; }
  .main-nav, .header-bar .user-cluster { display: none; }
  .theme-toggle { margin-left: auto; }
  .nav-toggle { display: inline-flex; margin-left: 0; }
  .mobile-menu.open { display: block; }
}

@media (max-width: 767px) {
  .header-bar { gap: var(--spacing-12); }
  .ward-context .stake-name, .ward-context .ward-sep { display: none; }
  .ward-context .ward-select { display: none; }
  .brand-mark { font-size: 18px; }
  .brand-icon { width: 34px; height: 34px; }
  .brand-tagline { display: none; }
}

/* -------------------------------------------------------------------------
   Main content
   ------------------------------------------------------------------------- */
main {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
  max-width: var(--board-max-width);
  margin: 0 auto;
  padding: var(--spacing-24) var(--gutter) var(--spacing-48);
}

/* Narrow reading container for admin / import pages */
.page {
  max-width: var(--page-max-width);
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--spacing-16);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-32);
}

.page-header h1 { margin-bottom: var(--spacing-4); }
.page-header p { color: var(--color-slate); margin: 0; max-width: 720px; }

.section { margin-top: var(--spacing-48); }
.section-title { font-size: var(--text-heading-sm); line-height: var(--leading-heading-sm); margin-bottom: var(--spacing-16); }

.admin-eyebrow {
  display: block;
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-slate);
  margin-bottom: var(--spacing-4);
}

/* -------------------------------------------------------------------------
   Buttons — black filled primary, outline secondary, 8px radius
   ------------------------------------------------------------------------- */
.primary, button.primary, a.primary {
  background: var(--color-jet-black);
  color: var(--color-paper-white);
  border: 1px solid var(--color-jet-black);
  border-radius: var(--radius-buttons);
  padding: 12px 16px;
  font-size: var(--text-body);
  font-weight: var(--font-weight-regular);
  line-height: 1.25;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-8);
  text-decoration: none;
  min-height: 44px;
}

.primary:hover, button.primary:hover, a.primary:hover { background: var(--color-charcoal); border-color: var(--color-charcoal); color: var(--color-paper-white); }

.secondary, button.secondary, a.secondary {
  background: var(--color-paper-white);
  color: var(--color-jet-black);
  border: 1px solid var(--color-iron-gray);
  border-radius: var(--radius-buttons);
  padding: 12px 16px;
  font-size: var(--text-body);
  font-weight: var(--font-weight-regular);
  line-height: 1.25;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-8);
  text-decoration: none;
  min-height: 44px;
}

.secondary:hover, button.secondary:hover, a.secondary:hover { background: var(--color-mist-gray); }

.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-4);
  padding: 6px 12px;
  min-height: 36px;
  font-size: var(--text-body-sm);
  font-weight: var(--font-weight-regular);
  line-height: 1.3;
  border-radius: var(--radius-buttons);
  border: 1px solid var(--color-iron-gray);
  background: var(--color-paper-white);
  color: var(--color-jet-black);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm:hover:not(:disabled) { background: var(--color-mist-gray); }

.primary.btn-sm, button.primary.btn-sm {
  padding: 6px 12px;
  min-height: 36px;
  font-size: var(--text-body-sm);
}

.btn-danger, .btn-sm.btn-danger {
  border-color: var(--status-bad-line) !important;
  color: var(--status-bad-fg) !important;
  background: var(--color-paper-white) !important;
}

.btn-danger:hover:not(:disabled) { background: var(--status-bad-bg) !important; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-iron-gray);
  border-radius: var(--radius-buttons);
  background: var(--color-paper-white);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { background: var(--color-mist-gray); }

button:disabled, .primary:disabled, .secondary:disabled, .btn-sm:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: var(--color-mist-gray) !important;
  border-color: var(--color-hairline) !important;
  color: var(--color-slate) !important;
}

/* Busy (saving) buttons keep their own colors so the spinner reads as "working", not "unavailable" */
button[aria-busy="true"], button[aria-busy="true"]:disabled {
  cursor: progress;
  opacity: 0.85;
  gap: var(--spacing-8);
}
.primary[aria-busy="true"]:disabled { background: var(--color-jet-black) !important; color: var(--color-paper-white) !important; border-color: var(--color-jet-black) !important; }
.btn-danger[aria-busy="true"]:disabled { background: var(--color-paper-white) !important; color: var(--status-bad-fg) !important; }
.btn-sm[aria-busy="true"]:disabled:not(.primary):not(.btn-danger) { background: var(--color-paper-white) !important; color: var(--color-jet-black) !important; }

.spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.125em;
  animation: cm-spin 0.7s linear infinite;
}

@keyframes cm-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

/* -------------------------------------------------------------------------
   Forms — white field, 1px iron hairline, 8px radius, 16px text
   ------------------------------------------------------------------------- */
.form-group { margin-bottom: var(--spacing-16); text-align: left; }

.form-group > label, .field-label {
  display: block;
  font-weight: var(--font-weight-medium);
  font-size: var(--text-body-sm);
  color: var(--color-jet-black);
  margin-bottom: var(--spacing-8);
}

.form-group input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]),
.form-group select,
.form-group textarea,
.input,
.global-search,
.member-head input {
  width: 100%;
  border: 1px solid var(--color-iron-gray);
  border-radius: var(--radius-inputs);
  padding: 12px 14px;
  background: var(--color-paper-white);
  font-size: var(--text-body);
  line-height: 1.4;
  color: var(--color-jet-black);
  outline: none;
  min-height: 44px;
}

.form-group select, select.input {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-paper-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23000' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center;
  padding-right: 40px;
}

.form-group input::placeholder, .form-group textarea::placeholder,
.global-search::placeholder, .member-head input::placeholder, .input::placeholder {
  color: var(--color-slate);
  opacity: 1;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus,
.global-search:focus, .member-head input:focus, .input:focus {
  border-color: var(--color-jet-black);
  box-shadow: inset 0 0 0 1px var(--color-jet-black);
}

.form-group input:disabled, .form-group select:disabled, .form-group textarea:disabled {
  background: var(--color-mist-gray);
  color: var(--color-slate);
  border-color: var(--color-hairline);
}

.form-group textarea { min-height: 96px; resize: vertical; }

.form-group input[type=color] {
  width: 64px;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--color-iron-gray);
  border-radius: var(--radius-inputs);
  background: var(--color-paper-white);
  cursor: pointer;
}

.form-group small, .help-text {
  display: block;
  color: var(--color-slate);
  font-size: var(--text-caption);
  margin-top: var(--spacing-4);
}

.check-label {
  display: flex !important;
  align-items: center;
  gap: var(--spacing-8);
  min-height: 44px;
  cursor: pointer;
  font-weight: var(--font-weight-regular) !important;
  font-size: var(--text-body) !important;
}

.check-label input[type=checkbox], .check-label input[type=radio] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-jet-black);
  margin: 0;
}

/* -------------------------------------------------------------------------
   Notices
   ------------------------------------------------------------------------- */
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--spacing-8) var(--spacing-12);
  padding: var(--spacing-12) var(--spacing-16);
  background: var(--color-mist-gray);
  border-radius: var(--radius-cards);
  border-left: 4px solid var(--color-jet-black);
  color: var(--color-jet-black);
  font-size: var(--text-body-sm);
  line-height: var(--leading-body-sm);
  margin-bottom: var(--spacing-16);
}

.notice.warn, .warning { background: var(--status-warn-bg); border-left-color: var(--status-warn-line); color: var(--status-warn-fg); }
.notice.danger { background: var(--status-bad-bg); border-left-color: var(--status-bad-line); color: var(--status-bad-fg); }
.notice.success { background: var(--status-good-bg); border-left-color: var(--status-good-line); color: var(--status-good-fg); }
.notice.info { background: var(--color-mist-gray); border-left-color: var(--color-jet-black); color: var(--color-jet-black); }

/* -------------------------------------------------------------------------
   Cards — mist surface on white, no border, no shadow
   ------------------------------------------------------------------------- */
.page-card {
  background: var(--surface-paper-white);
  border: var(--box-border);
  border-radius: var(--radius-cards);
  padding: var(--card-padding);
  margin-bottom: var(--spacing-24);
}

.page-card.tinted, .suggestion-card {
  background: var(--surface-mist-gray);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: var(--element-gap);
  margin-top: var(--spacing-24);
}

.admin-grid .page-card {
  margin-bottom: 0;
  background: var(--surface-mist-gray);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-8);
}

.admin-grid .page-card:hover { background: var(--color-hover); }
.admin-grid .page-card h3 { margin-bottom: 0; }
.admin-grid .page-card p { color: var(--color-slate); font-size: var(--text-body-sm); }
.card-link { font-weight: var(--font-weight-medium); text-decoration: underline; font-size: var(--text-body-sm); margin-top: auto; }

/* -------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: var(--box-border);
  border-radius: var(--radius-cards);
  background: var(--color-paper-white);
  margin-top: var(--spacing-16);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-sm);
  line-height: var(--leading-body-sm);
  text-align: left;
}

.data-table th {
  background: var(--color-mist-gray);
  padding: 12px 16px;
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-slate);
  border-bottom: 1px solid var(--color-hairline);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-hairline);
  vertical-align: middle;
  color: var(--color-jet-black);
}

@media (min-width: 1024px) {
  .data-table td > .row { flex-wrap: nowrap; }
}

.data-table .stack { align-items: flex-start; }

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--color-mist-gray); }

/* Phones and iPad portrait: tables marked .stack-mobile turn each row into
   a card. Cells need data-label="Column" to show their header. */
@media (max-width: 1023px) {
  .table-wrapper:has(.stack-mobile) { border: 0; background: transparent; overflow: visible; }
  .data-table.stack-mobile thead { display: none; }
  .data-table.stack-mobile, .data-table.stack-mobile tbody,
  .data-table.stack-mobile tr, .data-table.stack-mobile td { display: block; width: 100%; }
  .data-table.stack-mobile tr {
    background: var(--color-mist-gray);
    border-radius: var(--radius-cards);
    padding: var(--spacing-12) var(--spacing-16);
    margin-bottom: var(--spacing-12);
  }
  .data-table.stack-mobile tbody tr:hover td { background: transparent; }
  .data-table.stack-mobile td {
    border: 0;
    padding: 6px 0;
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: var(--spacing-12);
    align-items: start;
    overflow-wrap: anywhere;
  }
  .data-table.stack-mobile td[data-label]::before {
    content: attr(data-label);
    font-size: var(--text-caption);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-slate);
    padding-top: 2px;
  }
  .data-table.stack-mobile td > * { justify-self: start; max-width: 100%; }
  .data-table.stack-mobile td:not([data-label]) { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------------------
   Badges & tags — 4px is not in the system; badges use the 8px radius
   ------------------------------------------------------------------------- */
.badge, .pill, em.warn, em.manual {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-4);
  padding: 2px 8px;
  border-radius: var(--radius-buttons);
  font-size: var(--text-caption);
  font-style: normal;
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  white-space: nowrap;
  background: var(--color-mist-gray);
  color: var(--color-jet-black);
  border: 1px solid transparent;
}

.badge-success { background: var(--status-good-bg); color: var(--status-good-fg); }
.badge-info { background: var(--color-jet-black); color: var(--color-paper-white); }
.badge-warn, em.warn { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.badge-danger { background: var(--status-bad-bg); color: var(--status-bad-fg); }
.badge-secondary { background: var(--color-mist-gray); color: var(--color-slate); border-color: var(--color-hairline); }
.badge-manual, em.manual { background: var(--color-paper-white); color: var(--color-jet-black); border-color: var(--color-iron-gray); }

button.badge { cursor: pointer; font-family: inherit; }
button.badge:hover { filter: brightness(0.96); }

/* Filter chips — pill toggles */
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: var(--text-body-sm);
  font-weight: var(--font-weight-regular);
  border: 0;
  background: var(--color-mist-gray);
  color: var(--color-jet-black);
  border-radius: var(--radius-pills);
  padding: 4px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover { background: var(--color-hover); }
.chip.active { background: var(--color-jet-black); color: var(--color-paper-white); }

/* Segmented pill toggle (DESIGNv2 "trip type toggle") */
.segmented {
  display: inline-flex;
  background: var(--color-mist-gray);
  border-radius: var(--radius-pills);
  padding: 4px;
  gap: 4px;
}

.segmented button {
  border: 0;
  background: transparent;
  border-radius: var(--radius-pills);
  padding: 8px 16px;
  min-height: 40px;
  font-size: var(--text-body-sm);
  cursor: pointer;
  color: var(--color-jet-black);
  flex: 1 1 0;
  white-space: nowrap;
}

.segmented button.active {
  background: var(--color-jet-black);
  color: var(--color-paper-white);
}

/* -------------------------------------------------------------------------
   Tab strip — the only chromatic UI element (faded teal active state)
   ------------------------------------------------------------------------- */
.sub-tabs, .tab-strip {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: var(--spacing-24);
}

.sub-tabs::-webkit-scrollbar, .tab-strip::-webkit-scrollbar { display: none; }

.sub-tab {
  background: none;
  border: 0;
  border-radius: var(--radius-tabs);
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  font-size: var(--text-body);
  font-weight: var(--font-weight-regular);
  color: var(--color-jet-black);
  white-space: nowrap;
}

.sub-tab:hover { background: var(--color-mist-gray); }
.sub-tab.active { background: var(--color-faded-teal); color: var(--color-jet-black); }

/* -------------------------------------------------------------------------
   Modals — centered on desktop, bottom sheet on phones
   ------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-16);
}

.modal-card {
  background: var(--color-paper-white);
  border-radius: var(--radius-cards);
  padding: var(--spacing-32);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  position: relative;
}

.modal-card.modal-lg { max-width: 880px; }

.modal-card h3 {
  font-family: var(--font-ubermove);
  font-size: var(--text-heading-sm);
  line-height: var(--leading-heading-sm);
  font-weight: var(--font-weight-regular);
  margin-bottom: var(--spacing-12);
  padding-right: var(--spacing-32);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--spacing-8);
  margin-top: var(--spacing-24);
}

@media (max-width: 767px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-card, .modal-card.modal-lg {
    max-width: none;
    border-radius: var(--radius-cards) var(--radius-cards) 0 0;
    padding: var(--spacing-24) var(--gutter) calc(var(--spacing-24) + env(safe-area-inset-bottom));
    max-height: 92vh;
    max-height: 92dvh;
  }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions > button, .modal-actions > a { width: 100%; }
}

/* -------------------------------------------------------------------------
   Calling board — three panels
   ------------------------------------------------------------------------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-12) var(--spacing-24);
  margin-bottom: var(--spacing-16);
}

.stats { font-size: var(--text-body-sm); color: var(--color-slate); display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-4) var(--spacing-12); }
.stats b { color: var(--color-jet-black); font-weight: var(--font-weight-medium); }
.stats .user-badge { padding: 2px 10px; background: var(--color-mist-gray); border-radius: var(--radius-pills); font-size: var(--text-caption); color: var(--color-jet-black); }

.toolbar-msg {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: var(--status-good-bg);
  color: var(--status-good-fg);
  border-radius: var(--radius-pills);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
}

.search-box { position: relative; width: 100%; max-width: 380px; }
.global-search { max-width: none; }

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-paper-white);
  border: 2px solid var(--color-iron-gray);
  border-radius: var(--radius-cards);
  z-index: 50;
  max-height: min(480px, 70vh);
  overflow-y: auto;
}

.search-group + .search-group { border-top: 1px solid var(--color-iron-gray); }

.search-group-title {
  padding: 10px 16px 6px;
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-jet-black);
}

.search-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--color-hairline);
  background: var(--color-paper-white);
  text-align: left;
  font: inherit;
  padding: 10px 16px;
  min-height: 48px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-item:focus-visible { outline-offset: -2px; }
.search-empty, .search-more { padding: 12px 16px; font-size: var(--text-body-sm); color: var(--color-slate); }
.search-more { font-size: var(--text-caption); padding-top: 8px; }

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--color-mist-gray); }
.search-item b { font-size: var(--text-body-sm); }
.search-item small { color: var(--color-slate); }

/* Phone-only switch between the callings list and the member roster */
.board-switch { display: none; width: 100%; margin-bottom: var(--spacing-12); }

.board-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 340px;
  grid-template-areas: "orgs callings members";
  gap: var(--element-gap);
  height: calc(100vh - var(--header-height) - 120px);
  height: calc(100dvh - var(--header-height) - 120px);
  min-height: 520px;
}

.board-grid > * { min-width: 0; }
.org-tabs { grid-area: orgs; }
.calling-pane { grid-area: callings; }
.member-pane { grid-area: members; }

.org-tabs, .calling-pane, .member-pane {
  background: var(--color-paper-white);
  border: var(--box-border);
  border-radius: var(--radius-cards);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.org-tab-list, .calling-list { overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.org-tabs { overflow-y: auto; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-8);
  padding: var(--spacing-12) var(--spacing-12) var(--spacing-12) var(--spacing-16);
  border-bottom: 1px solid var(--color-hairline);
}

.pane-title {
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  color: var(--color-slate);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.org-tab {
  width: 100%;
  border: 0;
  background: var(--color-paper-white);
  padding: 10px 16px;
  min-height: 52px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--spacing-12);
  cursor: pointer;
  border-radius: 0;
}

.org-tab:hover:not(.active) { background: var(--color-mist-gray); }
.org-tab.active { background: var(--color-faded-teal); }

.org-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent, var(--color-jet-black));
  flex: 0 0 auto;
}

.org-tab-text { display: flex; flex-direction: column; min-width: 0; }
.org-tab-text span, .org-tab > span { font-weight: var(--font-weight-medium); font-size: var(--text-body-sm); color: var(--color-jet-black); }
.org-tab small { color: var(--color-slate); font-size: var(--text-caption); }
.org-tab.active small { color: var(--color-jet-black); }

.pane-heading {
  border-bottom: 1px solid var(--color-hairline);
  padding: var(--spacing-16) var(--spacing-16) var(--spacing-12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-12);
  flex-wrap: wrap;
}

.pane-heading small { color: var(--color-slate); }
.pane-heading h2 { margin: 0; font-size: var(--text-heading-sm); line-height: var(--leading-heading-sm); }

.column-head {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1.4fr;
  gap: var(--spacing-12);
  padding: 10px 16px;
  background: var(--color-mist-gray);
  color: var(--color-slate);
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--font-weight-medium);
  border-bottom: 1px solid var(--color-hairline);
}

.calling-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--color-hairline);
  border-left: 4px solid transparent;
  background: var(--color-paper-white);
  padding: 12px 16px 12px 12px;
  text-align: left;
  align-items: start;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1.4fr;
  gap: var(--spacing-12);
  font-size: var(--text-body-sm);
  line-height: var(--leading-body-sm);
}

.calling-row:hover { background: var(--color-mist-gray); }

.calling-row.selected {
  background: var(--color-mist-gray);
  outline: 2px solid var(--color-jet-black);
  outline-offset: -2px;
}

.calling-row > span { display: flex; flex-direction: column; align-items: flex-start; gap: var(--spacing-4); min-width: 0; }
.calling-row b { font-weight: var(--font-weight-medium); }

/* Candidate health: color stripe + labelled badge (never color alone) */
.calling-row.row-candidate-green { border-left-color: var(--status-good-line); }
.calling-row.row-candidate-yellow { border-left-color: var(--status-warn-line); }
.calling-row.row-candidate-red { border-left-color: var(--status-bad-line); }

.cell-label {
  display: none;
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-slate);
}

.current { color: var(--color-jet-black); }
.vacant-cell { color: var(--color-slate); font-style: italic; }

.status {
  display: inline-flex;
  padding: 1px 8px;
  border-radius: var(--radius-pills);
  background: var(--color-jet-black);
  color: var(--color-paper-white);
  font-weight: var(--font-weight-medium);
  font-size: var(--text-caption);
}

.candidate-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-buttons);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  width: fit-content;
}

.candidate-badge.green { background: var(--status-good-bg); color: var(--status-good-fg); }
.candidate-badge.yellow { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.candidate-badge.red { background: var(--status-bad-bg); color: var(--status-bad-fg); }

.inline-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-8);
  margin-top: var(--spacing-8);
  align-items: center;
}

.select-hint { color: var(--color-jet-black); font-weight: var(--font-weight-medium); font-size: var(--text-caption); }

/* Member roster */
.member-head {
  border-bottom: 1px solid var(--color-hairline);
  padding: var(--spacing-16);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
}

.member-head h2 { margin: 0; font-size: var(--text-subheading); line-height: var(--leading-subheading); font-weight: var(--font-weight-medium); }

.filter-row {
  display: flex;
  gap: var(--spacing-8);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filter-row::-webkit-scrollbar { display: none; }

.member-list { overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.member-card {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--color-hairline);
  border-left: 4px solid transparent;
  background: var(--color-paper-white);
  padding: 12px 16px 12px 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-4);
  cursor: pointer;
  font-size: var(--text-body-sm);
}

.member-card:hover { background: var(--color-mist-gray); }
.member-card.selected { background: var(--color-mist-gray); outline: 2px solid var(--color-jet-black); outline-offset: -2px; }
.member-card b { font-weight: var(--font-weight-medium); font-size: var(--text-body); }
.member-card small { color: var(--color-slate); font-size: var(--text-caption); }
.member-card > span:empty { display: none; }
.member-card > span { display: flex; gap: var(--spacing-4); flex-wrap: wrap; }

.member-card.member-card-green { border-left-color: var(--status-good-line); }
.member-card.member-card-yellow { border-left-color: var(--status-warn-line); }
.member-card.member-card-red { border-left-color: var(--status-bad-line); }

.calling-proposed-label {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-4);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  color: var(--color-paper-white);
  background: var(--color-jet-black);
  padding: 1px 8px;
  border-radius: var(--radius-pills);
}

/* Member detail drawer — floating panel on desktop, bottom sheet on phone */
.drawer {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  width: 420px;
  max-height: calc(100vh - var(--header-height) - 48px);
  max-height: calc(100dvh - var(--header-height) - 48px);
  overflow-y: auto;
  background: var(--color-paper-white);
  border: 2px solid var(--color-iron-gray);
  border-radius: var(--radius-cards);
  padding: var(--spacing-24);
  z-index: 50;
}

.drawer h3 { font-size: var(--text-heading-sm); font-weight: var(--font-weight-regular); padding-right: var(--spacing-36); }
.drawer-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-8); margin-top: var(--spacing-12); }
.drawer-action { margin-top: var(--spacing-16); border-top: 1px solid var(--color-hairline); padding-top: var(--spacing-16); }
.drawer-action .primary { width: 100%; }

.close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-pills);
  background: var(--color-mist-gray);
  font-size: 22px;
  line-height: 1;
  color: var(--color-jet-black);
  cursor: pointer;
}

.close:hover { background: var(--color-hover); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--spacing-12) var(--element-gap);
  margin: var(--spacing-16) 0;
}

.detail-grid > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

.detail-grid > div > label {
  color: var(--color-slate);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.detail-grid > .form-group > label { text-transform: none; letter-spacing: normal; color: var(--color-jet-black); font-size: var(--text-body-sm); }
.detail-grid > .form-group { margin-bottom: 0; }

/* Sticky black action bar (DESIGNv2 "sticky bottom bar") */
.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 56px;
  background: var(--color-jet-black);
  color: var(--color-paper-white);
  padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom));
  display: flex;
  gap: var(--spacing-16);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  z-index: 60;
}

.action-bar span { font-size: var(--text-body-sm); color: var(--color-ash-gray); }

/* -------------------------------------------------------------------------
   Imports
   ------------------------------------------------------------------------- */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--element-gap);
  margin: var(--spacing-24) 0;
}

.upload-grid label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  padding: var(--spacing-24);
  background: var(--color-mist-gray);
  border: 2px dashed var(--color-box-border);
  border-radius: var(--radius-cards);
  cursor: pointer;
  min-height: 140px;
  gap: var(--spacing-8);
}

.upload-grid label:hover { background: var(--color-hover); border-color: var(--color-jet-black); }
.upload-grid label b { font-size: var(--text-body); font-weight: var(--font-weight-medium); }

.upload-grid label input[type="file"] {
  display: block;
  max-width: 100%;
  font-size: var(--text-body-sm);
  color: var(--color-jet-black);
  cursor: pointer;
}

.file-name {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 4px 10px;
  background: var(--color-paper-white);
  color: var(--color-jet-black);
  border-radius: var(--radius-buttons);
  font-size: var(--text-caption);
  font-family: var(--font-mono);
}

.preview-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: var(--spacing-12);
  margin-bottom: var(--spacing-24);
}

.metric-card {
  background: var(--color-mist-gray);
  border-radius: var(--radius-cards);
  padding: var(--spacing-16);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.metric-card .metric-label {
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-slate);
}

.metric-card .metric-val {
  font-family: var(--font-ubermove);
  font-size: var(--text-heading-sm);
  font-weight: var(--font-weight-regular);
  color: var(--color-jet-black);
  line-height: 1.2;
}

.metric-card .metric-val.green { color: var(--status-good-fg); }
.metric-card .metric-val.blue { color: var(--color-jet-black); }
.metric-card .metric-val.amber { color: var(--status-warn-fg); }
.metric-card .metric-val.red { color: var(--status-bad-fg); }
.metric-card .metric-sub { font-size: var(--text-caption); color: var(--color-slate); }

/* -------------------------------------------------------------------------
   Two-pane admin layout (list + detail), stacks on phones
   ------------------------------------------------------------------------- */
.split {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: var(--spacing-24);
  align-items: start;
}

.select-list { display: flex; flex-direction: column; gap: var(--spacing-8); }
.select-list > .row { flex-wrap: nowrap; }

.select-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--spacing-12);
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  background: var(--color-mist-gray);
  border: 0;
  border-radius: var(--radius-cards);
  text-align: left;
  font-size: var(--text-body-sm);
  cursor: pointer;
}

.search-input { max-width: 380px; }
.select-item:hover { background: var(--color-hover); }
.select-item.active { background: var(--color-faded-teal); }

@media (max-width: 1023px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------------------
   Responsive — calling board
   ------------------------------------------------------------------------- */

/* iPad landscape / small laptop */
@media (max-width: 1279px) {
  .board-grid { grid-template-columns: 200px minmax(0, 1fr) 300px; }
}

/* iPad portrait: org strip on top, callings + members side by side */
@media (max-width: 1023px) {
  .board-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "orgs orgs"
      "callings members";
    height: calc(100vh - var(--header-height) - 120px);
    height: calc(100dvh - var(--header-height) - 120px);
  }

  .org-tabs { flex-direction: row; align-items: center; overflow: hidden; }
  .org-tabs .pane-header { border-bottom: 0; border-right: 1px solid var(--color-hairline); flex: 0 0 auto; }
  .org-tabs .pane-header .pane-title { display: none; }
  .org-tab-list {
    display: flex;
    flex-direction: row;
    gap: 4px;
    padding: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .org-tab-list::-webkit-scrollbar { display: none; }
  .org-tab { width: auto; flex: 0 0 auto; border-radius: var(--radius-tabs); min-height: 48px; padding: 6px 14px; }

  .drawer { width: min(420px, calc(100vw - 2 * var(--gutter))); }
}

/* Phones: one column, switch between callings and members */
@media (max-width: 767px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }

  .board-switch { display: flex; }

  .board-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    gap: var(--spacing-12);
  }

  .board-grid.show-members .calling-pane { display: none; }
  .board-grid.show-callings .member-pane { display: none; }
  .board-grid.show-members .org-tabs { display: none; }

  .calling-pane, .member-pane { overflow: visible; border: 0; border-radius: 0; }
  .member-list, .calling-list { overflow: visible; }

  .pane-heading { padding: var(--spacing-8) 0 var(--spacing-12); }
  .column-head { display: none; }

  .calling-row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-8);
    background: var(--color-mist-gray);
    border-bottom: 0;
    border-radius: var(--radius-cards);
    margin-bottom: var(--spacing-8);
    padding: var(--spacing-16);
  }

  .calling-row:hover { background: var(--color-hover); }
  .calling-row.selected { background: var(--color-paper-white); }
  .calling-row .cell-label { display: block; }
  .calling-row b { font-size: var(--text-body); }
  .inline-row-actions > button { flex: 1 1 auto; min-height: 44px; }

  .member-head { padding: 0 0 var(--spacing-12); border-bottom: 0; }
  .member-card {
    background: var(--color-mist-gray);
    border-bottom: 0;
    border-radius: var(--radius-cards);
    margin-bottom: var(--spacing-8);
    padding: var(--spacing-12) var(--spacing-16);
  }

  .drawer {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    border: 0;
    border-top: 1px solid var(--color-iron-gray);
    border-radius: var(--radius-cards) var(--radius-cards) 0 0;
    padding: var(--spacing-24) var(--gutter) calc(var(--spacing-24) + env(safe-area-inset-bottom));
    max-height: 85vh;
    max-height: 85dvh;
  }

  .drawer-actions > button { flex: 1 1 auto; }

  .page-header { margin-bottom: var(--spacing-24); }
  .section { margin-top: var(--spacing-32); }
}

/* Organization picker: tabs on desktop, dropdown from iPad portrait down
   (the horizontal tab strip hides every organization past the first few). */
.org-select { display: none; }

@media (max-width: 1023px) {
  .org-tabs { border: 0; background: transparent; overflow: visible; }
  .org-tabs .pane-header { flex: 1 1 auto; min-width: 0; border-right: 0; padding: 0; }
  .org-select {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 44px;
    font-size: 16px; /* 16px stops iOS Safari zooming on focus */
  }
  .org-tab-list { display: none; }
}

@media (max-width: 767px) {
  /* Keep the Callings / Pick member switch in reach while scrolling long lists */
  .board-switch {
    position: sticky;
    top: var(--header-height);
    z-index: 30;
    box-shadow: 0 0 0 4px var(--surface-paper-white);
  }

  /* Wrap the member filter chips instead of hiding them in an invisible horizontal scroll */
  .filter-row { flex-wrap: wrap; overflow-x: visible; }
}

.board-grid.is-working { cursor: progress; }
.board-grid.is-working .calling-row, .board-grid.is-working .member-card { pointer-events: none; opacity: 0.7; }
.toolbar-msg.working { gap: var(--spacing-8); background: var(--color-mist-gray); color: var(--color-jet-black); }
.confirm-text { font-size: var(--text-body-sm); font-weight: var(--font-weight-medium); color: var(--status-bad-fg); flex-basis: 100%; }

/* Touch devices: comfortable hit targets */
@media (pointer: coarse) {
  .btn-sm, .primary.btn-sm, .icon-btn { min-height: 44px; }
  .icon-btn { width: 44px; }
  .chip { min-height: 40px; }
  .main-nav a { padding: 10px 14px; }
}

/* -------------------------------------------------------------------------
   Changes board
   ------------------------------------------------------------------------- */
.stage-filter {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.stage-filter::-webkit-scrollbar { display: none; }
.stage-filter button { flex: 0 0 auto; }

@media (max-width: 767px) {
  .stage-filter {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
    border-radius: var(--radius-cards);
  }
  .stage-filter button { flex: 1 1 auto; }
}

.stage-filter .count {
  display: inline-block;
  min-width: 22px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: var(--radius-pills);
  background: var(--color-paper-white);
  color: var(--color-jet-black);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  text-align: center;
}

.stepper { display: inline-flex; gap: 3px; }
.stepper span { width: 18px; height: 6px; border-radius: var(--radius-pills); background: var(--color-hairline); }
.stepper span.done { background: var(--color-jet-black); }
