/* ============================================================
   Church Management System — interface styles.

   Two layouts, one stylesheet. On a desktop the navigation sits
   down the left, always visible. On a phone it slides in from the
   left over the content, because an usher recording a collection
   needs the whole screen for the task, not for a menu.

   No build step and no web fonts: this is uploaded over FTP to a
   shared host and has to work the moment it lands, on a phone with
   one bar of signal.
   ============================================================ */

:root {
  --ink:        #101822;
  --ink-2:      #38465a;
  /*
   * Two greys for secondary and tertiary text, and both of them have to be
   * readable. They were #64748b and #8695a8, which measure 4.43 and 3.05
   * against the grounds they are actually used on — under the 4.5 that
   * ordinary text needs, and 3.05 is a date on a phone in Ghanaian sunlight
   * that simply cannot be read. Nobody reports it, because faint grey small
   * print looks like a design.
   *
   * They are still two distinct levels; the levels are now made by weight and
   * size rather than by fading the second one past the point of legibility.
   */
  --muted:      #55637a;
  --muted-2:    #64707e;
  --line:       #e4e9f0;
  --line-soft:  #f0f3f8;

  --bg:         #f5f7fa;
  --card:       #ffffff;
  /*
   * The ground under a box somebody types into, and under a ghost button.
   *
   * It has to be a token of its own rather than #fff, and this is not a
   * refinement — every text box in the application was `background: #fff` with
   * `color: var(--ink)`, and in dark mode --ink is #e8edf4. Somebody working
   * in the dark typed their name into a white box in near-white letters and
   * could not read a word of it. The suites never saw it because a test fills
   * a field by setting its value, and a screenshot of the sign-in screen is
   * the only place it shows without being looked for.
   */
  --field:      #ffffff;

  --brand:      #1f4e78;
  --brand-dark: #10283d;
  --brand-deep: #0a1d2e;
  --brand-mid:  #2b6299;
  --brand-soft: #eef4fa;
  /* The brand lifted towards white, for text on a dark ground. The server
     recomputes this from the church's own colour; this is the default navy's. */
  --brand-lift: #7a9ec1;
  --accent:     #c9a227;

  /* What colour brand-coloured text is. In the light that is the brand; in
     the dark the brand is too close to the background to read. */
  --brand-text: var(--brand);

  --good: #12704a;  --good-soft: #e8f5ee;
  --bad:  #a3231c;  --bad-soft:  #fdeceb;
  --warn: #8a6410;  --warn-soft: #fdf6e6;

  --radius:    14px;
  --radius-sm: 9px;
  --tap:       44px;
  --nav-w:     252px;

  --shadow-sm: 0 1px 2px rgba(16,24,34,.05);
  --shadow:    0 3px 10px rgba(16,24,34,.07);
  --shadow-lg: 0 18px 44px rgba(10,29,46,.28);

  /* Text that sits on the brand colour. Worked out from the brand's own
     luminance on the server, so a church that picks a bright yellow gets dark
     text on it rather than white on yellow, which nobody would report as a bug
     because it looks like a choice. */
  --on-brand: #ffffff;
}

/*
 * Dark.
 *
 * Only the neutrals move. The brand and accent are the church's own colours
 * and must be recognisably the same in both, so they are set once — here in
 * the stylesheet as a default, and overridden by the few lines index.php
 * writes from the settings.
 *
 * The switch is an attribute on <html> rather than a class on <body>, because
 * it is set before the stylesheet finishes loading. A theme applied after
 * first paint is a white flash in a dark room, which is exactly when somebody
 * is using the dark one.
 */
html[data-theme="dark"] {
  --ink:       #e8edf4;
  --ink-2:     #b9c4d2;
  --muted:     #8b99ac;
  --muted-2:   #818fa1;   /* 3.95 against the card, which is not readable */
  --line:      #26313f;
  --line-soft: #1b242f;

  --bg:        #10161e;
  --card:      #171f2a;
  /* A shade under the card, so a field reads as a well rather than a slab. */
  --field:     #0e151d;

  --brand-soft: #1b2836;
  --brand-text: var(--brand-lift);

  --good-soft: #12291f;
  --bad-soft:  #2b1613;
  --warn-soft: #2a2113;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 3px 10px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 44px rgba(0,0,0,.6);
}
/* The three message colours need lifting in the dark; the light versions are
   too low-contrast against a dark ground to read. */
html[data-theme="dark"] {
  --good: #4ec48c;
  --bad:  #f08a80;
  --warn: #e0b95c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* One rule sizes and colours every icon in the set. */
.ico { width: 20px; height: 20px; flex: 0 0 auto; display: block; }
svg.ico { color: inherit; }

/* ---------- shell -------------------------------------------- */
.app { display: none; }
.app.on { display: block; }

nav.side {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--nav-w);
  background: var(--brand-deep); color: #fff; z-index: 40;
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .22s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
nav.side.open { transform: translateX(0); }

nav.side .mark {
  padding: 1.15rem 1.15rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: flex-start; gap: .7rem;
}
nav.side .mark .seal {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center; color: var(--accent);
}
nav.side .mark .seal .ico { width: 18px; height: 18px; }
nav.side .mark .txt { min-width: 0; }
nav.side .mark .church {
  font-size: .94rem; font-weight: 600; line-height: 1.3;
  display: block; overflow-wrap: anywhere;
}
nav.side .mark .sub {
  font-size: .68rem; opacity: .5; letter-spacing: .07em;
  text-transform: uppercase; margin-top: .15rem; display: block;
}

nav.side .items { flex: 1 1 auto; overflow-y: auto; padding: .7rem .6rem; }
nav.side button {
  width: 100%; min-height: 42px;
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .7rem; border: 0; background: none; cursor: pointer;
  color: rgba(255,255,255,.7); font: inherit; font-size: .89rem;
  text-align: left; border-radius: var(--radius-sm);
  transition: background .12s ease, color .12s ease;
}
nav.side button .ico { opacity: .75; }
nav.side button:hover { background: rgba(255,255,255,.07); color: #fff; }
nav.side button:hover .ico { opacity: 1; }
nav.side button.on {
  background: rgba(255,255,255,.11); color: #fff; font-weight: 600;
}
nav.side button.on .ico { opacity: 1; color: var(--accent); }

nav.side .foot {
  border-top: 1px solid rgba(255,255,255,.08); padding: .9rem 1.15rem;
  font-size: .78rem;
}
nav.side .foot .name { display: block; font-weight: 500; color: #fff; }
nav.side .foot .role { display: block; opacity: .55; text-transform: capitalize;
                       margin-top: .05rem; }
nav.side .foot button {
  margin-top: .65rem; padding: .4rem .8rem; min-height: 34px;
  border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius-sm);
  width: auto; font-size: .78rem; color: rgba(255,255,255,.85);
  display: inline-flex; justify-content: center;
}
nav.side .foot button:hover { background: rgba(255,255,255,.1); }

#scrim {
  position: fixed; inset: 0; background: rgba(10,29,46,.5);
  z-index: 35; opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
#scrim.on { opacity: 1; pointer-events: auto; }

header.bar {
  position: sticky; top: 0; z-index: 25;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: .5rem .9rem; display: flex; align-items: center; gap: .7rem;
  min-height: 54px;
}
header.bar h1 {
  font-size: 1.02rem; margin: 0; font-weight: 600; flex: 1 1 auto;
  letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#navtoggle {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-sm);
  width: 40px; height: 40px; flex: 0 0 auto; cursor: pointer;
  color: var(--ink-2); line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
#navtoggle:hover { background: var(--line-soft); }
header.bar .who { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/*
 * Every screen uses the whole width it is given.
 *
 * It was held to a 960-pixel column in the middle, which on a phone is the
 * phone and on an office monitor is a strip down the centre with a hand's
 * width of grey either side — reported from a church office as the dashboard
 * looking unfinished. Readability is kept where it actually lives: a form field
 * keeps a sane measure (see the desktop rules), long prose keeps .prose, and
 * screens with several independent cards lay them in columns with .cols.
 */
main { padding: 1.1rem .9rem 4rem; width: 100%; margin: 0; }

#netbar {
  display: none; padding: .55rem .9rem; font-size: .85rem; text-align: center;
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
#netbar.on { display: flex; align-items: center; justify-content: center; gap: .5rem; }
#netbar .ico { width: 17px; height: 17px; }
#netbar span { text-align: left; }
#netbar b { font-weight: 600; }
#netbar a { color: var(--warn); font-weight: 600; }

/* ---------- cards and rows ----------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.05rem 1.1rem;
  margin-bottom: .8rem; box-shadow: var(--shadow-sm);
}

/*
 * Card headings used to be small uppercase grey micro-caps, every one of
 * them, which flattened every screen into the same tone of voice and read
 * like a spreadsheet. They are sentences now, in ink, at a size that says
 * "this is the heading of this card" without shouting.
 */
.card h2 {
  font-size: 1rem; margin: 0 0 .8rem; font-weight: 600;
  color: var(--ink); letter-spacing: -.01em;
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
}
.card h2 .sub {
  font-weight: 400; color: var(--muted); font-size: .82rem;
  letter-spacing: 0;
}

/* A heading that leads with an icon sits it on the line, not on the baseline. */
.card h2 > .ico { align-self: center; color: var(--accent); width: 18px; height: 18px; }

.row {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 0; border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.row .title { font-weight: 500; color: var(--ink); }
.row .meta { color: var(--muted); font-size: .8rem; margin-top: .12rem; }
.row .amt { font-variant-numeric: tabular-nums; font-weight: 600;
            white-space: nowrap; color: var(--ink); }
.row .amt.neg { color: var(--bad); }
.row.tap { cursor: pointer; min-height: var(--tap); margin: 0 -.55rem;
           padding: .7rem .55rem; border-radius: var(--radius-sm);
           transition: background .12s ease; }
.row.tap:hover { background: var(--line-soft); }
.row.tap:active { background: var(--brand-soft); }
/* A row may lead with an icon and end with a chevron; neither competes with
   the words between them. */
.row > .ico { color: var(--muted-2); }
.row.tap > .ico:first-child { color: var(--brand-text); }
.row .go { color: var(--muted-2); width: 18px; height: 18px; }

/* An empty state should say what to do next, not just that there is
   nothing here. */
.empty { color: var(--muted); text-align: center; padding: 1.7rem 1rem;
         font-size: .88rem; }
/*
 * Sixty-seven places in the interface say "nothing here yet". Rather than
 * put a picture in sixty-seven templates, one rule draws it, so the mark is
 * identical everywhere and changing it is a one-line change. It is inlined
 * as a data URI for the same reason the icon set is inlined: this runs from
 * an uploaded folder with no build step and no second request to make.
 */
.empty::before {
  content: ''; display: block; width: 28px; height: 28px; margin: 0 auto .55rem;
  opacity: .55;
  background: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238695a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 13.5 6 5.2h12l2.5 8.3v4.3a1.5 1.5 0 0 1-1.5 1.5H5a1.5 1.5 0 0 1-1.5-1.5Z'/%3E%3Cpath d='M3.5 13.5h4l1 2.2h7l1-2.2h4'/%3E%3C/svg%3E");
}
/* Loading is not empty: it is this screen a moment before it has its data. */
.empty.loading::before { display: none; }
.empty .ico { width: 26px; height: 26px; margin: 0 auto .5rem; color: var(--muted-2); }

/* ---------- figures ------------------------------------------ */
.figures { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem;
           margin-bottom: .8rem; }
.fig {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem .95rem; box-shadow: var(--shadow-sm);
}
.fig .lbl { color: var(--muted); font-size: .74rem; font-weight: 500;
            letter-spacing: 0; }
.fig .val { font-size: 1.4rem; font-weight: 660; font-variant-numeric: tabular-nums;
            margin-top: .25rem; letter-spacing: -.02em; line-height: 1.2; }
.fig .meta { color: var(--muted-2); font-size: .75rem; margin-top: .15rem; }
.fig.restricted { border-left: 3px solid var(--brand-text); }

/*
 * The lead figure. Seven funds shown as seven identical tiles of GHS 0.00
 * told you nothing about what to look at first. One figure carries the
 * weight and the rest support it.
 */
.figures.lead { grid-template-columns: 1fr; }
.figures.lead .fig.hero {
  background: linear-gradient(155deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-color: transparent; color: var(--on-brand); padding: 1.15rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}
.figures.lead .fig.hero .lbl { color: rgba(255,255,255,.72); }
.figures.lead .fig.hero .val { font-size: 2rem; color: #fff; }
.figures.lead .fig.hero .meta { color: rgba(255,255,255,.66); }
.figures.lead .pair { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; }

/* A quiet strip of figures inside a card, for funds and the like. */
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
         gap: .55rem; }
.strip .cell { border: 1px solid var(--line); border-radius: var(--radius-sm);
               padding: .6rem .7rem; background: var(--line-soft); }
.strip .cell .lbl { font-size: .74rem; color: var(--muted); }
.strip .cell .val { font-weight: 620; font-variant-numeric: tabular-nums;
                    margin-top: .1rem; }
.strip .cell.restricted { border-left: 3px solid var(--brand-text); }

/* ---------- greeting ----------------------------------------- */
.hello { margin: 0 0 .9rem; }
.hello h2 { font-size: 1.35rem; margin: 0; font-weight: 650; letter-spacing: -.02em; }
.hello p { margin: .18rem 0 0; color: var(--muted); font-size: .88rem; }

/* ---------- quick actions ------------------------------------ */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
         gap: .6rem; margin-bottom: .8rem; }
.quick button {
  display: flex; align-items: center; gap: .6rem; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem .85rem; cursor: pointer; font: inherit; color: var(--ink);
  min-height: 58px; box-shadow: var(--shadow-sm);
  transition: border-color .12s ease, background .12s ease;
}
.quick button:hover { border-color: var(--brand-text); background: var(--brand-soft); }
.quick button .ico { color: var(--brand-text); }
.quick button span { font-weight: 500; font-size: .88rem; line-height: 1.25; }

/* ---------- progress, for project fundraising ----------------
   div.bar rather than .bar, and this is not tidiness.

   A bar chart draws <rect class="bar">, and in a modern browser `height` is a
   CSS property of an SVG rect just as it is of a div — so this rule's
   `height: 8px` beat the height the chart had worked out, on every rect, in
   every bar chart in the application. Each one rendered as a row of
   eight-pixel squares floating at the right heights with no columns beneath
   them: the church's income over twelve months, the scorecard's trends, all of
   it. The attribute said 142.1 and the browser drew 8.

   Nothing caught it because every test asserted the chart was there, the bars
   were there and the figures in them were right — which they all were. The
   only thing wrong was what a person saw. ui_test.py now measures a bar's
   rendered height against the height it was given.
   ------------------------------------------------------------- */
div.bar { height: 8px; background: var(--line); border-radius: 99px;
       overflow: hidden; margin: .5rem 0 .3rem; }
div.bar span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
div.bar.done span { background: var(--good); }

/* ---------- forms -------------------------------------------- */
label { display: block; font-size: .82rem; color: var(--ink-2);
        margin: .9rem 0 .32rem; font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: .6rem .78rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--field); font: inherit; color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  /* The ring was a fixed navy tint, so a church that chose ember got a navy
     glow on every field it focused. It follows the brand now, and the border
     colour above is what makes focus unmistakable if the glow is subtle. */
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input[readonly] { background: var(--line-soft); color: var(--ink-2); }
input[type="file"] { padding: .5rem .6rem; }
textarea { min-height: 4.5rem; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }

/* Password with a reveal. The eye sits inside the field. */
.pw { position: relative; }
.pw input { padding-right: 3.1rem; }
.pw button {
  position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
  width: 2.5rem; height: calc(var(--tap) - .5rem);
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 1rem; line-height: 1; border-radius: var(--radius-sm);
}
.pw button:hover { color: var(--brand-text); background: var(--line-soft); }

.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: var(--tap); padding: .6rem 1.15rem; border-radius: var(--radius-sm);
  border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand);
  font: inherit; font-weight: 550; cursor: pointer; width: 100%;
  transition: background .12s ease, opacity .12s ease, border-color .12s ease;
  text-decoration: none;
}
.btn:hover { background: var(--brand-mid); border-color: var(--brand-mid); }
.btn:active { opacity: .9; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 18px; height: 18px; }
.btn.ghost { background: var(--field); color: var(--brand-text); border-color: var(--line); }
.btn.ghost:hover { background: var(--brand-soft); border-color: var(--brand-text); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger:hover { filter: brightness(.88); }
.btn.small { min-height: 36px; padding: .35rem .8rem; width: auto; font-size: .83rem; }
.btn.small .ico { width: 15px; height: 15px; }
.btns { display: flex; gap: .55rem; margin-top: 1rem; flex-wrap: wrap; }
.btns .btn { width: auto; flex: 1 1 auto; }
.btns .btn.small { flex: 0 0 auto; }

/* ---------- messages ----------------------------------------- */
.msg { padding: .72rem .9rem; border-radius: var(--radius-sm);
       font-size: .87rem; margin-bottom: .85rem; }
.msg.bad  { background: var(--bad-soft);  color: var(--bad);
            border: 1px solid color-mix(in srgb, var(--bad) 32%, transparent); }
.msg.good { background: var(--good-soft); color: var(--good);
            border: 1px solid color-mix(in srgb, var(--good) 32%, transparent); }
.msg.warn { background: var(--warn-soft); color: var(--warn);
            border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent); }
.msg.info { background: var(--brand-soft);color: var(--brand-text);
            border: 1px solid color-mix(in srgb, var(--brand-text) 28%, transparent); }

.pill { display: inline-block; padding: .12rem .5rem; border-radius: 99px;
        font-size: .7rem; font-weight: 600; vertical-align: middle;
        letter-spacing: .01em; }
.pill.open   { background: var(--warn-soft); color: var(--warn); }
.pill.closed { background: var(--good-soft); color: var(--good); }
.pill.voided { background: var(--bad-soft);  color: var(--bad); }

/* ---------- sign in ------------------------------------------ */
/*
 * The sign-in screen is the first thing anybody sees, and it was a small
 * grey circle floating in a lot of empty blue. It is the church's screen
 * now: its name carries the page, the mark is deliberate, and the form sits
 * where the eye lands rather than halfway down.
 */
.gate {
  display: none; min-height: 100vh; min-height: 100dvh;
  align-items: center; justify-content: center;
  padding: 1.5rem 1.25rem;
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(43,98,153,.55) 0%, transparent 62%),
    radial-gradient(900px 480px at 108% 108%, rgba(201,162,39,.22) 0%, transparent 58%),
    linear-gradient(165deg, var(--brand-deep) 0%, #123651 40%, var(--brand-dark) 100%);
  background-color: var(--brand-deep);
}
.gate.on { display: flex; }
.gate .box { width: 100%; max-width: 400px; }
.gate .brand { text-align: center; margin-bottom: 1.5rem; color: #fff; }
.gate .brand .seal {
  width: 58px; height: 58px; margin: 0 auto .95rem; border-radius: 17px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 8px 24px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.gate .brand .seal .ico { width: 27px; height: 27px; }
.gate .brand h1 {
  font-size: 1.45rem; margin: 0 0 .35rem; font-weight: 640;
  letter-spacing: -.02em; line-height: 1.25;
}
.gate .brand p { margin: 0; color: rgba(255,255,255,.68); font-size: .89rem; }
.gate .card {
  box-shadow: var(--shadow-lg); border: 0; padding: 1.35rem 1.3rem 1.4rem;
  border-radius: 16px;
}
.gate .card label:first-of-type { margin-top: 0; }
.gate .card .btn { margin-top: 1.25rem; }
.gate .note {
  text-align: center; margin-top: 1.15rem; font-size: .78rem;
  color: rgba(255,255,255,.5); line-height: 1.5;
}
/* Which build this is. Quieter still than the note above it — somebody looks
   for it deliberately, nobody should be distracted by it — but present on the
   one screen everybody sees, so "what is actually on the server?" can be
   answered from a phone. */
.gate .note.ver {
  margin-top: .55rem; font-size: .72rem; letter-spacing: .02em;
  color: rgba(255,255,255,.34);
}

/* A folded-away explanation — how to restore a backup, and anything else
   somebody needs once a year and should not have to scroll past monthly. */
details.how { margin-top: .8rem; border-top: 1px solid var(--line-soft); padding-top: .6rem; }
details.how > summary {
  cursor: pointer; font-size: .87rem; font-weight: 550; color: var(--brand-text);
  padding: .35rem 0; list-style: none;
}
details.how > summary::-webkit-details-marker { display: none; }
details.how > summary::before { content: '+ '; font-weight: 700; }
details.how[open] > summary::before { content: '\2212 '; }
details.how p { margin: .55rem 0; line-height: 1.55; }
details.how code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--brand-soft); padding: .1rem .3rem; border-radius: 4px;
  font-size: .85em; overflow-wrap: anywhere;
}

/* The one-time password on the locked-out screen, and the steps above it.
   A password read aloud in a church office has to be unmistakable: a
   monospaced face so that 1 and l are different letters, and big enough to
   read from a phone held at arm's length. */
.gate .code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.15rem; letter-spacing: .02em; text-align: center;
  background: var(--brand-soft); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .8rem .6rem; margin: .4rem 0 .6rem; overflow-wrap: anywhere;
}
.gate .steps { margin: .2rem 0 1rem; }
.gate .steps p { margin: .45rem 0; font-size: .87rem; color: var(--ink-2); line-height: 1.5; }
.gate .note a { color: rgba(255,255,255,.7); }
.gate .note a:hover { color: #fff; }

/* ---------- running total while counting --------------------- */
.counter {
  position: sticky; bottom: 1rem; z-index: 15; margin-top: 1rem;
  background: var(--brand); color: var(--on-brand); border-radius: var(--radius);
  padding: .8rem 1rem; display: flex; align-items: center; gap: .8rem;
  box-shadow: var(--shadow-lg);
}
.counter .lbl { font-size: .72rem; opacity: .82; text-transform: uppercase;
                letter-spacing: .05em; font-weight: 600; }
.counter .val { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.counter .grow { flex: 1 1 auto; }

/* ---------- utility ------------------------------------------ */
.sp { height: .65rem; }
.muted { color: var(--muted); font-size: .84rem; }
.right { text-align: right; }
.hidden { display: none !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.spin { display: inline-block; width: 1rem; height: 1rem;
        border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
        border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- printable documents ------------------------------ */
#printarea { display: none; }
.doc { font-size: 12px; color: #000; }
.doc .head { text-align: center; margin-bottom: 1rem; }
.doc .head .church { font-size: 15px; font-weight: 700; }
.doc .head .branch { font-size: 12px; }
.doc .head .title { font-size: 13px; font-weight: 700; margin-top: .4rem;
                    text-transform: uppercase; letter-spacing: .04em; }
.doc .head .period { font-size: 11px; }
.doc table { width: 100%; border-collapse: collapse; margin-top: .6rem; }
.doc th { text-align: left; border-bottom: 1.5px solid #000; padding: 4px 6px;
          font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.doc td { padding: 4px 6px; border-bottom: 1px solid #ddd; }
.doc td.num, .doc th.num { text-align: right; font-variant-numeric: tabular-nums; }
.doc tr.total td { font-weight: 700; border-top: 1.5px solid #000; border-bottom: 0; }
.doc tr.sub td { font-weight: 600; background: #f2f2f2; }
.doc .note { font-size: 10px; margin-top: .8rem; color: #333; }
.doc .signs { display: flex; gap: 2rem; margin-top: 2.2rem; }
.doc .signs div { flex: 1 1 0; font-size: 11px; }
.doc .signs .line { border-top: 1px solid #000; margin-bottom: .2rem; }

/* ---------- the first-timer's QR code -------------------------
   Always black on white, whatever the theme: a code drawn light on dark
   scans badly on half the phones in a congregation. */
/* A member's request to change their details: what the record says, struck
   through, and what they asked for beside it. */
.request { padding: .75rem 0; border-bottom: 1px solid var(--line-soft); }
.request:last-child { border-bottom: 0; }
.request .title { font-weight: 500; color: var(--ink); margin-bottom: .2rem; }
.request .meta { color: var(--muted); font-size: .86rem; margin-top: .15rem; }
.request s { color: var(--muted-2); }

/* "3 · 25%" in a figure: the share, smaller and quieter than the count. */
.fig .val .pct { font-size: .8rem; color: var(--muted); font-weight: 500; margin-left: .4rem; }
.qrbox { background: #fff; color: #000; padding: 1rem; border-radius: var(--radius-sm);
         text-align: center; max-width: 320px; margin: 1rem auto 0; }
.qrbox svg { width: 100%; height: auto; display: block; }
.qrbox .muted { color: #444; margin-top: .4rem; }
.poster { text-align: center; color: #000; padding-top: 6mm; }
.poster .church { font-size: 26px; font-weight: 700; }
.poster .branch { font-size: 16px; margin-top: 2mm; }
.poster .big { font-size: 40px; font-weight: 800; margin: 12mm 0 4mm; letter-spacing: -.01em; }
.poster .line { font-size: 18px; max-width: 150mm; margin: 0 auto; line-height: 1.4; }
.poster .code { width: 120mm; margin: 10mm auto 4mm; }
.poster .code svg { width: 100%; height: auto; display: block; }
.poster .url { font-size: 12px; color: #333; word-break: break-all; }

@media print {
  body > *:not(#printarea) { display: none !important; }
  #printarea { display: block !important; }
  @page { margin: 14mm; }
}

/* ---------- desktop ------------------------------------------ */
@media (min-width: 900px) {
  nav.side { transform: none; }
  #navtoggle { display: none; }
  #scrim { display: none; }
  .app.on { padding-left: var(--nav-w); }
  header.bar { padding-left: 1.4rem; padding-right: 1.4rem; }
  main { padding: 1.5rem 2rem 4rem; }
  .figures { grid-template-columns: repeat(4, 1fr); }
  /*
   * The lead figure stands the full height of the block down the left, with
   * the supporting pairs stacked beside it. Without the row span the second
   * pair fell back under the hero and the whole block went crooked.
   */
  .figures.lead { grid-template-columns: minmax(270px, 1fr) 1.8fr; align-items: stretch; }
  .figures.lead .fig.hero {
    grid-column: 1; grid-row: 1 / span 2;
    display: flex; flex-direction: column; justify-content: center;
  }
  .figures.lead .pair { grid-column: 2; grid-template-columns: repeat(2, 1fr); }
  .card { padding: 1.15rem 1.25rem; }
  .hello h2 { font-size: 1.55rem; }

  /*
   * A form field nine hundred pixels wide is harder to fill in than one at a
   * comfortable reading width, not easier: the eye loses the line between
   * the label and the box. Everything on a phone stays full width, where the
   * screen is the constraint; on a desktop the fields keep a sane measure
   * and the buttons take the room their words need rather than the room the
   * window happens to have.
   */
  .card input, .card select, .card textarea { max-width: 560px; }
  .card input[type="file"] { max-width: 560px; }
  .btn { width: auto; min-width: 190px; }
  .btn.small { min-width: 0; }
  /* On a phone a pair of buttons shares the row; on a desktop they take the
     width of their words, so a lone "Save" is not a metre wide. */
  .btns .btn { flex: 0 0 auto; }
}

/* ============================================================
   Header controls: the bell, the light switch, the person
   ============================================================ */
.hdr-acts { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.hdr-acts button {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; position: relative;
  transition: background .12s ease, border-color .12s ease;
}
.hdr-acts button:hover { background: var(--line-soft); border-color: var(--muted-2); }
.hdr-acts .ico { width: 18px; height: 18px; }

/* The dot on the bell. A count rather than a plain dot, because "you have
   something" and "you have eleven things" are different messages. */
.hdr-acts .dot {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 99px; background: var(--bad); color: #fff;
  font-size: .64rem; font-weight: 700; line-height: 17px; text-align: center;
  border: 2px solid var(--card);
}
.hdr-acts .me {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand);
  color: var(--on-brand); font-size: .78rem; font-weight: 650; border: 0;
  letter-spacing: .02em;
}
.hdr-acts .me:hover { background: var(--brand-mid); }

/* The bell's own panel. */
.bell {
  position: absolute; top: 52px; right: .9rem; width: min(360px, calc(100vw - 1.8rem));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 60; max-height: 70vh; overflow-y: auto;
}
.bell header {
  display: flex; align-items: center; gap: .5rem; padding: .8rem .9rem;
  border-bottom: 1px solid var(--line-soft); position: sticky; top: 0;
  background: var(--card);
}
.bell header b { flex: 1 1 auto; font-size: .92rem; }
.bell header button {
  border: 0; background: none; color: var(--brand-text); font: inherit;
  font-size: .8rem; cursor: pointer; padding: .2rem .3rem;
}
.bell .note { padding: .75rem .9rem; border-bottom: 1px solid var(--line-soft);
              cursor: pointer; display: flex; gap: .65rem; }
.bell .note:last-child { border-bottom: 0; }
.bell .note:hover { background: var(--line-soft); }
.bell .note.unread { background: var(--brand-soft); }
.bell .note .ico { color: var(--brand-text); margin-top: .12rem; }
.bell .note .t { font-weight: 550; font-size: .87rem; }
.bell .note .b { color: var(--muted); font-size: .79rem; margin-top: .12rem; }
.bell .note .w { color: var(--muted-2); font-size: .72rem; margin-top: .2rem; }

/* ---------- breadcrumbs -------------------------------------- */
.crumbs {
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
  font-size: .82rem; color: var(--muted); margin-bottom: .85rem;
}
.crumbs button {
  border: 0; background: none; font: inherit; color: var(--muted);
  cursor: pointer; padding: 0; text-decoration: none;
}
.crumbs button:hover { color: var(--brand-text); text-decoration: underline; }
.crumbs .ico { width: 13px; height: 13px; color: var(--muted-2); }
.crumbs .here { color: var(--ink); font-weight: 550; }

/* ============================================================
   Charts

   Drawn as inline SVG. No library: this runs from an uploaded folder with
   no build step and no network, and a charting library is 200KB before it
   has drawn anything. Every one of these is a few dozen lines of geometry.
   ============================================================ */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font: inherit; fill: var(--muted); font-size: .72rem; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .bar { transition: opacity .12s ease; }
.chart .bar:hover { opacity: .78; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }

.donut { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
/* .chart sets width:100% so a bar chart fills its card. A doughnut is a fixed
   circle and must keep the size it was drawn at — without this it stretched to
   the full width of the card and pushed its own key onto the next line. */
.donut svg.chart { flex: 0 0 auto; width: auto; }
.donut .mid { font-size: 1.35rem; font-weight: 660; fill: var(--ink);
              font-variant-numeric: tabular-nums; }
.donut .midlbl { font-size: .68rem; fill: var(--muted); }

/* The key. Not a floating tooltip: on a phone there is nothing to hover
   with, and a chart whose labels only appear on hover has no labels. */
.key { display: grid; gap: .45rem; flex: 1 1 150px; min-width: 140px; }
.key .k { display: flex; align-items: center; gap: .5rem; font-size: .82rem; }
.key .k i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.key .k .n { flex: 1 1 auto; color: var(--ink-2); }
.key .k .v { font-weight: 620; font-variant-numeric: tabular-nums; }

/* Time ranges above a chart. */
.ranges { display: flex; gap: .3rem; flex-wrap: wrap; }
.ranges button {
  border: 1px solid transparent; background: none; font: inherit;
  font-size: .78rem; color: var(--muted); padding: .25rem .6rem;
  border-radius: 99px; cursor: pointer;
}
.ranges button:hover { background: var(--line-soft); color: var(--ink); }
.ranges button.on { background: var(--brand); color: var(--on-brand); font-weight: 600; }

/* ============================================================
   The register
   ============================================================ */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end;
           margin-bottom: .5rem; }
.filters > div { flex: 1 1 150px; min-width: 130px; }
.filters label { margin-top: 0; }
.filters input, .filters select { margin-bottom: 0; }

/* A row that can be ticked. The whole row is the target, not a 13px box:
   an usher is doing this standing up with a phone in one hand. */
.tick {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  padding: .6rem .55rem; margin: 0 -.55rem; border: 0; background: none;
  border-bottom: 1px solid var(--line-soft); cursor: pointer; font: inherit;
  text-align: left; color: var(--ink); min-height: var(--tap);
  border-radius: var(--radius-sm);
}
.tick:hover { background: var(--line-soft); }
.tick .box {
  width: 24px; height: 24px; border-radius: 7px; flex: 0 0 auto;
  border: 2px solid var(--line); display: flex; align-items: center;
  justify-content: center; color: transparent;
}
.tick.here .box { background: var(--good); border-color: var(--good); color: #fff; }
.tick.here .box .ico { width: 15px; height: 15px; }
.tick .box .ico { width: 15px; height: 15px; }
.tick .grow { flex: 1 1 auto; min-width: 0; }
.tick .who { font-weight: 500; display: block; }
/* Spans, so they need telling to stack. Left inline the membership number
   ran along the same line as the name and read as part of it. */
.tick .sub { color: var(--muted); font-size: .78rem; display: block;
             margin-top: .1rem; }
.tick .state { font-size: .75rem; font-weight: 600; white-space: nowrap; }
.tick.here .state { color: var(--good); }
.tick .state.away { color: var(--muted-2); }

/* A member's recent attendance, as a row of blocks. Twelve squares says
   more at a glance than "attended 9 of 12" and takes less room. */
.streak { display: flex; gap: 3px; margin-top: .3rem; }
.streak i { width: 12px; height: 16px; border-radius: 3px; background: var(--line); }
.streak i.here { background: var(--good); }

/* ============================================================
   Messages
   ============================================================ */
.cost {
  display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap;
  font-size: .8rem; color: var(--muted); margin-top: .35rem;
}
.cost b { color: var(--ink); font-weight: 620; }
.cost .warnish { color: var(--warn); }
.sms {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .7rem .8rem; background: var(--line-soft); font-size: .85rem;
  white-space: pre-wrap; line-height: 1.5; overflow-wrap: anywhere;
}
.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: .5rem; margin-bottom: .7rem; }
/* The direct children only. Without the ">" this also matched the number and
   the label inside each tile, drawing a box around every one of them. */
.stat > div { border: 1px solid var(--line); border-radius: var(--radius-sm);
              padding: .55rem .7rem; }
.stat .n { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .74rem; color: var(--muted); }

/* ============================================================
   Watching
   ============================================================ */
.player {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; border-radius: var(--radius); overflow: hidden;
  margin-bottom: .8rem;
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.livedot {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .7rem;
  font-weight: 700; letter-spacing: .04em; color: var(--bad);
  text-transform: uppercase;
}
.livedot::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bad); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .livedot::before { animation: none; } }

/* ============================================================
   Appearance
   ============================================================ */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: .6rem; margin-bottom: .8rem; }
.swatch {
  border: 2px solid var(--line); border-radius: var(--radius); padding: .6rem;
  cursor: pointer; background: var(--card); text-align: left; font: inherit;
  color: var(--ink);
}
.swatch.on { border-color: var(--brand-text); }
.swatch .bars { display: flex; gap: 4px; margin-bottom: .45rem; }
.swatch .bars i { height: 26px; flex: 1 1 auto; border-radius: 5px; }
.swatch .nm { font-size: .8rem; font-weight: 550; }
.colourpick { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.colourpick input[type="color"] {
  width: 46px; height: 40px; padding: 2px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  margin: 0; flex: 0 0 auto;
}
.colourpick input[type="text"] { margin: 0; max-width: 140px; font-family: ui-monospace, monospace; }
.markprev {
  display: flex; align-items: center; gap: .8rem; padding: .8rem;
  border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: .6rem;
}
.markprev img { max-height: 48px; max-width: 180px; object-fit: contain; }
.markprev.fav img { max-height: 32px; max-width: 32px; }

/* ---------- which branch you are working in ------------------
   Only shown to somebody who oversees more than one. It sits in the header
   because it describes what the person is doing rather than asking a
   question: an administrator spends a morning on one branch's records and
   then a morning on another's. */
.branchpick { flex: 0 1 auto; min-width: 0; }
.branchpick select {
  margin: 0; min-height: 38px; padding: .3rem 1.8rem .3rem .7rem;
  font-size: .84rem; border-radius: 99px; max-width: 280px;
  background-position: right .55rem center;
}
@media (max-width: 560px) {
  .branchpick select { max-width: 120px; font-size: .78rem; }
  header.bar h1 { font-size: .95rem; }
}

/* ---------- the conversation ---------------------------------
   A button that floats over every screen, and a panel that opens from it.

   It floats because a conversation is not a place you go: it is something you
   do while you are somewhere else — asking the secretary a question without
   losing the register you are half way through taking. And because it floats,
   it will sometimes sit over the one thing you were trying to press, which is
   why it can be dragged anywhere and stays where it was put.

   position: fixed and a z-index above the drawer's scrim, below the toast. The
   toast has to be readable while the panel is open, because that is where
   "held on this device" is said. */

:root { --fab-size: 56px; }   /* CHAT_FAB_SIZE in app.js must match */

.chatfab {
  position: fixed; z-index: 60;
  width: var(--fab-size); height: var(--fab-size); border-radius: 50%;
  border: 0; padding: 0; cursor: grab;
  background: var(--brand); color: var(--on-brand);
  box-shadow: 0 6px 18px rgba(10,29,46,.34);
  display: flex; align-items: center; justify-content: center;
  /* No transition on left/top: the button must sit exactly under the finger
     during a drag, and an eased position lags behind it. */
  transition: transform .12s ease, box-shadow .12s ease;
  touch-action: none;         /* the page must not scroll under the drag */
}
.chatfab .ico { width: 25px; height: 25px; }
.chatfab:active { transform: scale(.94); }
.chatfab.dragging { cursor: grabbing; transform: scale(1.06); box-shadow: var(--shadow-lg); }
.chatfab.has { background: var(--brand-mid); }
/* Out of the way while the panel is open. On a desktop the panel is a
   column in the corner and the button sat behind it, half visible. */
.chatfab.away { display: none; }
.chatfab .dot {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 20px; text-align: center;
  border: 2px solid var(--card);
}

/* On a phone the panel is the screen; on a desktop it is a column in the
   corner. Both are the same markup. */
.chatwrap {
  position: fixed; z-index: 61; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
@media (min-width: 720px) {
  .chatwrap {
    inset: auto 18px 18px auto; width: 378px; height: min(620px, 82vh);
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); overflow: hidden;
  }
}

.chathead {
  display: flex; align-items: center; gap: .5rem; flex: 0 0 auto;
  padding: .6rem .7rem; background: var(--brand-dark); color: #fff;
  /* The phone's notch. Without this the title sits under the status bar when
     the panel is full-screen. */
  padding-top: max(.6rem, env(safe-area-inset-top));
}
.chathead b { font-size: .96rem; }
.chathead b.grow { flex: 1 1 auto; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.chathead .cacts { display: flex; gap: .15rem; margin-left: auto; flex: 0 0 auto; }
.chathead .cicobtn {
  background: transparent; border: 0; color: #fff; opacity: .92;
  min-width: 38px; min-height: 38px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.chathead .cicobtn:hover { background: rgba(255,255,255,.14); }
.chathead .cicobtn.on { color: var(--accent); }

.chatbody { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chatbody .empty { padding: 2.2rem 1rem; }

.chatsec {
  padding: .5rem .85rem .2rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.chatfind { padding: .6rem .7rem .2rem; }
.chatfind input { margin: 0; }

.chatrow {
  display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left;
  padding: .65rem .8rem; background: transparent; border: 0;
  border-bottom: 1px solid var(--line-soft); cursor: pointer; color: var(--ink);
  font: inherit; min-height: var(--tap);
}
.chatrow:hover { background: var(--line-soft); }
.chatrow.unread { background: var(--brand-soft); }
.chatrow .cav {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 650;
}
.chatrow .cav.cgrp { background: var(--accent); color: #22180a; }
.chatrow .cav .ico { width: 19px; height: 19px; }
.chatrow .grow { flex: 1 1 auto; min-width: 0; display: block; }
.chatrow .cname {
  display: block; font-weight: 600; font-size: .9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chatrow.unread .cname { font-weight: 700; }
.chatrow .cprev {
  display: block; color: var(--muted); font-size: .81rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chatrow .cside { flex: 0 0 auto; text-align: right; }
.chatrow .cwhen { display: block; color: var(--muted-2); font-size: .7rem; }
.chatrow .ccount {
  display: inline-block; margin-top: .2rem; min-width: 19px; padding: 0 5px;
  height: 19px; line-height: 19px; border-radius: 99px;
  background: var(--brand); color: var(--on-brand);
  font-size: .68rem; font-weight: 700; text-align: center;
}
.ico.tiny { width: 13px; height: 13px; vertical-align: -2px; }

/* ---------- the messages ---------- */

.chatbody.cmsgs { padding: .7rem .8rem 1rem; background: var(--bg); }
.chatearlier {
  display: block; margin: 0 auto .8rem; padding: .35rem .9rem;
  border: 1px solid var(--line); border-radius: 99px; background: var(--card);
  color: var(--brand-text); font-size: .78rem; cursor: pointer;
}
.cmsg { display: flex; margin-bottom: .4rem; }
.cmsg.mine { justify-content: flex-end; }
.cmsg .cbub {
  max-width: 82%; padding: .45rem .6rem .3rem; border-radius: 13px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
/* The sent side is tinted rather than brand-filled: a column of solid navy
   bubbles with white text is unreadable in sunlight, and the church's brand
   colour can be anything at all — including a pale yellow. */
.cmsg.mine .cbub { background: var(--brand-soft); border-color: var(--brand-soft); }
.cmsg .cbub.cgone {
  /* Tinted rather than transparent. On a dark ground a dashed border in the
     muted grey is all but invisible, and the words then read as loose text
     that has escaped its bubble rather than as a withdrawn message. */
  background: var(--line-soft); border-style: dashed; color: var(--muted);
  font-size: .82rem; font-style: italic;
}
.cmsg .cwho { font-size: .74rem; font-weight: 700; color: var(--brand-text); margin-bottom: .1rem; }
.cmsg .ctext { font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.cmsg .ctext a { color: var(--brand-text); }
.cmsg .cpic { display: block; margin: 0 0 .25rem; }
.cmsg .cpic img {
  display: block; max-width: 100%; height: auto; max-height: 260px;
  border-radius: 9px; object-fit: cover;
}
.cmsg audio { width: 210px; max-width: 100%; margin: .1rem 0; height: 34px; }
.cmsg .cmeta {
  display: flex; align-items: center; gap: .3rem; justify-content: flex-end;
  font-size: .68rem; color: var(--muted-2); margin-top: .1rem;
}
.cmsg .cseen { font-size: .72rem; letter-spacing: -.06em; }
.cmsg .cseen.seen { color: var(--brand-text); font-weight: 700; }
.cmsg .cdots {
  background: transparent; border: 0; padding: 0 0 0 .1rem; cursor: pointer;
  color: var(--muted-2); line-height: 1;
}

/* ---------- writing one ---------- */

.chatfoot {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: .25rem;
  padding: .45rem .5rem; background: var(--card);
  border-top: 1px solid var(--line);
  /* The phone's home bar. Without this the send button sits under it. */
  padding-bottom: max(.45rem, env(safe-area-inset-bottom));
}
.chatfoot .cicobtn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.chatfoot .cicobtn:hover { background: var(--line-soft); color: var(--ink); }
/* Recording is said in colour and in motion, because a microphone that is
   listening and one that is not must never look the same. */
.chatfoot .cicobtn.rec { color: #fff; background: var(--bad); animation: chatrec 1.1s infinite; }
@keyframes chatrec { 50% { opacity: .55; } }
.chatfoot textarea {
  flex: 1 1 auto; margin: 0; resize: none; min-height: 40px; max-height: 96px;
  padding: .5rem .7rem; border-radius: 19px; line-height: 1.35;
}
.chatsend {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--brand); color: var(--on-brand); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.chatsend .ico { width: 20px; height: 20px; }

/* Printing a screen must not print the button over it. */
@media print { .chatfab, .chatwrap { display: none !important; } }

/* A photograph that will not decode. The browser's own broken-image mark says
   nothing a church can act on; this says what happened. */
.cmsg .cpicgone {
  font-size: .8rem; color: var(--muted); font-style: italic;
  border: 1px dashed var(--line); border-radius: 9px;
  padding: .4rem .5rem; margin-bottom: .25rem;
}

/* ---------- the noticeboard ----------------------------------
   A notice is a block of somebody's words with a history attached: who wrote
   it, who it is for, and what has already been done with it. The history is
   on the buttons rather than beside them, because a button that looks the
   same whether it has been pressed or not is a button that gets pressed
   twice — and the second press of "Text the congregation" would have spent
   the church's credit again. */

.notice {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .8rem; margin-bottom: .7rem; background: var(--card);
}
.notice:last-child { margin-bottom: 0; }
/* Pinned reads as pinned without a label: the church's own accent down the
   side, which survives whatever colour they choose. */
.notice.pinned { border-left: 3px solid var(--accent); }
.notice .noticebody {
  white-space: pre-wrap; font-size: .92rem; margin: .35rem 0 .1rem;
  word-break: break-word;
}
.notice .noticebody a { color: var(--brand-text); }
.notice .btns { margin-top: .6rem; flex-wrap: wrap; }
/* Already done. Not a disabled button — a disabled button says "you may not",
   and this says "it happened, here is when". */
.notice .sent {
  display: inline-flex; align-items: center; gap: .3rem; align-self: center;
  font-size: .8rem; font-weight: 600; color: var(--good);
}
.notice .sent .ico { width: 15px; height: 15px; }

.quoteform {
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  padding: .7rem .8rem; margin: .6rem 0;
}
.quoteform textarea, .quoteform input, .quoteform select { margin-bottom: .5rem; }

/* The board on the dashboard: the notices themselves, tighter, with no
   promote buttons — this is where they are read, not managed. */
.noticeboard .notice { padding: .5rem .65rem; }
.noticeboard .notice .noticebody { font-size: .88rem; margin-top: .2rem; }

/* ---------- how the church is doing -------------------------
   A scorecard. The arrow says which way a figure moved; the colour says
   whether that is the good way. They are two different facts, and a screen
   that runs them together — every rise green — misleads about spending twice
   a year, so the server sends the good direction with each measure and this
   only paints it. */

.score {
  display: grid; gap: .6rem; margin-bottom: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}
.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .8rem;
  border-left: 3px solid var(--line);
}
.tile.well   { border-left-color: var(--good); }
.tile.poorly { border-left-color: var(--warn); }
.tile .lbl {
  display: flex; align-items: baseline; gap: .3rem;
  font-size: .78rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.tile .lbl .why {
  flex: 0 0 auto; width: 17px; height: 17px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--field); color: var(--muted);
  font-size: .66rem; font-weight: 700; cursor: pointer; padding: 0; line-height: 1;
}
.tile .lbl .why:hover { border-color: var(--brand); color: var(--brand-text); }
.tile .val {
  font-size: 1.35rem; font-weight: 650; letter-spacing: -.02em;
  margin: .2rem 0 .1rem; color: var(--ink);
}
.tile .cmp { font-size: .76rem; color: var(--muted); display: flex; gap: .3rem; align-items: center; }
/* One arrow, turned by the stylesheet rather than three separate icons. */
.tile .cmp .ico.dir { width: 13px; height: 13px; flex: 0 0 auto; }
.tile .cmp .ico.dir.down { transform: rotate(180deg); }
.tile .cmp .ico.dir.flat { transform: rotate(90deg); opacity: .5; }
.tile.well   .cmp .ico.dir { color: var(--good); }
.tile.poorly .cmp .ico.dir { color: var(--warn); }
/* "Nothing to compare with yet" rather than a triumphant rise from nothing.
   A church in its second month would otherwise be told its giving had risen
   by an impossible figure. */
.tile .cmp .nocmp { font-style: italic; }
/* Folded away, because a figure nobody can interpret is worse than no figure
   — and "average attendance" hides three decisions a church will ask about. */
.tile .note { display: none; font-size: .78rem; color: var(--muted);
              margin-top: .45rem; padding-top: .45rem; border-top: 1px solid var(--line-soft); }
.tile.open .note { display: block; }

/* The scorecard's charts are barChart()'s, which .chart already styles. The
   sparkline rules that were here belonged to a second chart implementation
   that has been removed. */

/* A box holding something that has to be copied exactly — a cron command, a
   web address — with the button that copies it. On a phone, selecting a
   hundred and forty characters by hand is a real struggle, and one wrong
   character means the scheduled messages silently never run. */
.copybox { margin-bottom: .8rem; }
.copybox .sms { margin-bottom: .35rem; user-select: all; }
.copybox .btn.done { color: var(--good); border-color: var(--good); }

/* ---------- a meeting held here -----------------------------
   Tiles, because a meeting is people. On a phone two across; on a desktop as
   many as fit. Sound-only meetings show initials rather than a black
   rectangle: a black rectangle reads as a broken camera, and on a weak
   connection sound-only is the right choice, not a failure. */

.meetroom .tiles {
  display: grid; gap: .6rem; margin-bottom: .9rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.mtile {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius);
  background: var(--brand-dark); color: #fff; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
}
.mtile.me { border-color: var(--accent); }
.mtile.connected { border-color: var(--good); }
.mtile.failed { border-color: var(--bad); }
.mtile.waiting {
  background: var(--card); color: var(--muted); border: 1px dashed var(--line);
  aspect-ratio: auto; padding: 1rem; text-align: center;
}
.mtile .who { font-size: 1.5rem; font-weight: 650; opacity: .85; }
.mtile video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.mtile .lbl {
  position: absolute; left: 0; right: 0; bottom: 0; padding: .3rem .5rem;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  font-size: .76rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mtile.waiting .lbl {
  position: static; background: none; white-space: normal; font-size: .84rem;
}
/* What is wrong, in words. A tile that spins for ever is the failure
   everybody has met and nobody can diagnose. */
.mtile .pstate {
  position: absolute; top: .4rem; left: .4rem; right: .4rem;
  font-size: .72rem; background: rgba(0,0,0,.55); border-radius: 6px;
  padding: .2rem .4rem; text-align: center;
}
.mtile.failed .pstate { background: var(--bad); }

.mcontrols { display: flex; gap: .5rem; flex-wrap: wrap; }
.mcontrols .btn.on { background: var(--bad); color: #fff; border-color: var(--bad); }

/* ------------------------------------------------------------------
   Paging a long list

   Under a list that has more rows than fit. It exists because four screens
   used to stop at a hidden ceiling — the newest two hundred expenses, the
   newest three hundred audit lines — with everything older unreachable from
   any screen. Centred and quiet: it is a way through, not a feature.
   ------------------------------------------------------------------ */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-top: .8rem;
  padding-top: .7rem;
  border-top: 1px solid var(--line);
}
.pager .meta { text-align: center; flex: 1 1 auto; }
/* Room for a thumb either side, and neither button ever collapses to an
   unhittable sliver on a narrow phone. */
.pager .btn { flex: 0 0 auto; min-width: 5.5rem; }

/* ------------------------------------------------------------------
   A person's face

   Shown where a member is identified, and never anywhere a member is merely
   listed in passing. The initials are not a fallback that happens to appear
   when an image fails — they are the ordinary state, because most churches
   will have photographs of some of their members and none of the rest, and a
   roll that is half pictures and half broken-image icons looks broken.
   ------------------------------------------------------------------ */
.face {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 50%; object-fit: cover;
  background: var(--brand-soft); border: 1px solid var(--line);
}
.face.initials {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; letter-spacing: .02em;
  color: var(--brand-text); background: var(--brand-soft);
}
.face.big { width: 96px; height: 96px; font-size: 1.8rem; }
/* The picker sits beside the picture rather than under it, so choosing one
   and seeing the result is a single glance on a phone. */
.photorow { align-items: flex-start; gap: .8rem; }
.photorow input[type=file] { margin-top: .3rem; }

/* ------------------------------------------------------------------
   The finance dashboard
   ------------------------------------------------------------------ */

/* Weekly / Monthly / Yearly. A row of buttons rather than a <select>, because
   the whole point is to flick between them and compare, and a select is two
   taps and a list every time. */
.segs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.segs .btn { flex: 1 1 auto; min-width: 5.5rem; }

/* How much of the whole one line is, drawn rather than only stated. A column
   of percentages is read one number at a time; a column of bars is read at a
   glance, which is what a dashboard is for. */
.sharebar {
  height: 6px; border-radius: 3px; background: var(--brand-soft);
  margin: .35rem 0 .3rem; overflow: hidden;
}
.sharebar i { display: block; height: 100%; border-radius: 3px; }
.treerow { cursor: pointer; }

/* A table that is wider than a phone scrolls sideways inside its card rather
   than making the whole page scroll — a page that slides left when somebody
   means to scroll down is the commonest way a phone screen feels broken. */
.scrollx { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.grid th, table.grid td {
  padding: .45rem .5rem; border-bottom: 1px solid var(--line);
  text-align: left; white-space: nowrap;
}
table.grid th { color: var(--muted); font-weight: 600; font-size: .78rem; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:last-child td { border-bottom: 0; }

/* A row of small period labels — the months a member gave nothing in. Wrapped
   rather than scrolled, because the shape of the block is the information:
   three scattered months reads differently from eleven in a row. */
.pillrow { display: flex; flex-wrap: wrap; gap: .3rem; }

/* A line that belongs to the row above it — the kinds of giving under a month's
   total. Indented and quiet, so the eye reads the totals down the page and the
   detail only when it stops. */
.row.subrow { padding-left: 1rem; border-top: 0; padding-top: .15rem; padding-bottom: .15rem; }

/* ============================================================
   Version 21: layout helpers for a full-width screen
   ============================================================ */

/* Independent cards side by side once there is room for them. Each child is
   a column; a card inside keeps its own margin. */
/* minmax(0, 1fr), not 1fr: a plain 1fr column grows to fit its widest child,
   so one wide table pushed the whole screen sideways on a phone. */
.cols { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
.cols > * { min-width: 0; }
@media (min-width: 1180px) {
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols.wide-left  { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .cols.wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
  .cols > .span2 { grid-column: 1 / -1; }
}
@media (min-width: 1600px) {
  .cols.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Prose stays at a reading measure however wide the screen is. */
.prose, .card > .muted, .card > p { max-width: 82ch; }

/* A screen's own heading: what it is on the left, what you can do on the right. */
.pagehead {
  display: flex; align-items: flex-end; gap: .8rem 1rem; flex-wrap: wrap;
  margin: 0 0 1rem;
}
.pagehead .grow { flex: 1 1 260px; min-width: 0; }
.pagehead h2 { font-size: 1.3rem; margin: 0; font-weight: 650; letter-spacing: -.02em; }
.pagehead p { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; }
.pagehead .acts { display: flex; gap: .5rem; flex-wrap: wrap; }
.pagehead .acts .btn { width: auto; min-width: 0; }
@media (min-width: 900px) { .pagehead h2 { font-size: 1.45rem; } }

/* The period control: presets as one press each, dates for anything else. */
.period { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.period .ranges { background: var(--card); border: 1px solid var(--line);
                  border-radius: 99px; padding: .2rem; gap: .1rem; }
.period .ranges button { padding: .32rem .75rem; font-size: .8rem; }
.periodcustom { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.periodcustom input[type="date"] { width: auto; min-height: 36px; padding: .3rem .55rem;
                                   font-size: .84rem; max-width: 170px; }
.periodcustom .btn.small { min-height: 36px; }
.card .period { margin-bottom: .8rem; }

/* Reports: choose one from the cards, read it as a table. */
.reportpick { display: grid; gap: .55rem; margin-bottom: .9rem;
              grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.reportpick button {
  text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .85rem; cursor: pointer; font: inherit;
  color: var(--ink); display: flex; flex-direction: column; gap: .15rem;
  transition: border-color .12s ease, background .12s ease;
}
.reportpick button b { font-weight: 600; font-size: .9rem; }
.reportpick button span { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.reportpick button:hover { border-color: var(--brand-text); }
.reportpick button.on { border-color: var(--brand-text); background: var(--brand-soft);
                        box-shadow: inset 0 0 0 1px var(--brand-text); }
.rephead { font-size: .92rem; margin: 1rem 0 .4rem; font-weight: 650; }
table.grid.report tfoot td { font-weight: 700; border-top: 1.5px solid var(--ink-2);
                             border-bottom: 0; padding-top: .55rem; }
table.grid.report tbody tr:hover td { background: var(--line-soft); }
a.btn.small { width: auto; }

/* ============================================================
   Dialogs
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(10,20,32,.48);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  animation: fadein .12s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modalbox {
  background: var(--card); color: var(--ink); width: 100%; max-height: 88vh;
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 640px) {
  .modal { align-items: center; padding: 1.5rem; }
  .modalbox { width: min(520px, 100%); border-radius: 16px; }
}
.modalhead { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.1rem .6rem; }
.modalhead h2 { flex: 1 1 auto; margin: 0; font-size: 1.02rem; font-weight: 650; }
.modalbody { padding: 0 1.1rem 1rem; overflow-y: auto; }
.modalbody label:first-child { margin-top: .2rem; }
.modalbody ul { padding-left: 1.1rem; margin: .4rem 0; }
.modalfoot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.1rem 1rem;
             border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.modalfoot .btn { width: auto; min-width: 0; }
.iconbtn { border: 0; background: none; color: var(--muted); cursor: pointer; width: 36px; height: 36px;
           border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:hover { background: var(--line-soft); color: var(--ink); }
.linkbtn { border: 0; background: none; color: var(--brand-text); font: inherit; font-size: .84rem;
           cursor: pointer; padding: .1rem .2rem; text-decoration: underline; text-underline-offset: 2px; }
.btn.ghost.danger-text { color: var(--bad); }
.btn.ghost.danger-text:hover { background: var(--bad-soft); border-color: var(--bad); }

/* ============================================================
   Data tables
   ============================================================ */
.dt { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
      box-shadow: var(--shadow-sm); margin-bottom: .9rem; overflow: hidden; }
.dt-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .8rem .9rem;
            border-bottom: 1px solid var(--line-soft); }
.dt-search { position: relative; flex: 1 1 240px; max-width: 420px; }
.dt-search .ico { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
                  width: 17px; height: 17px; color: var(--muted-2); pointer-events: none; }
.dt-search input { padding-left: 2.2rem; min-height: 38px; margin: 0; max-width: none !important; }
.dt-tools select { width: auto; min-height: 38px; padding: .3rem 1.9rem .3rem .7rem; font-size: .85rem;
                   margin: 0; max-width: 220px !important; flex: 0 1 auto; }
.dt-gap { flex: 1 1 0; }
.dt-export { display: flex; gap: .35rem; }
.dt-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem .9rem;
           background: var(--brand-soft); border-bottom: 1px solid var(--line);
           position: sticky; top: 54px; z-index: 5; }
.dt-count { display: flex; align-items: center; gap: .4rem; font-size: .88rem; }
.dt-acts { display: flex; flex-wrap: wrap; gap: .4rem; }
.dt-acts .btn.small { background: var(--card); }
.dt-body .empty { padding: 2.2rem 1rem; }
.dt-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.dt-table th { text-align: left; font-size: .75rem; font-weight: 600; color: var(--muted);
               letter-spacing: .01em; padding: .55rem .7rem; border-bottom: 1px solid var(--line);
               background: var(--line-soft); white-space: nowrap; }
.dt-table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.dt-table tr:last-child td { border-bottom: 0; }
.dt-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.dt-table tr.tap { cursor: pointer; }
.dt-table tbody tr:hover td { background: var(--line-soft); }
.dt-table tbody tr.on td { background: var(--brand-soft); }
.dt-table .dt-chk { width: 42px; padding-right: 0; }
.dt-table .dt-chk input, .dt-table th.dt-chk input { width: 18px; height: 18px; min-height: 0; margin: 0;
                                                     accent-color: var(--brand); cursor: pointer; }
.dt-table .dt-go { width: 28px; color: var(--muted-2); }
.dt-table .dt-go .ico { width: 16px; height: 16px; }
.dt-table .dt-first .t { font-weight: 550; color: var(--ink); }
.dt-table .sub { display: block; color: var(--muted); font-size: .78rem; margin-top: .1rem; }
.dt-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; padding: .7rem .9rem;
           border-top: 1px solid var(--line-soft); font-size: .84rem; }
.dt-foot select { width: auto; min-height: 34px; padding: .2rem 1.8rem .2rem .6rem; font-size: .82rem; margin: 0; }
.dt-foot .btn.small { min-height: 34px; }
.dt .pill { white-space: nowrap; }
.pill.grey  { background: var(--line-soft); color: var(--muted); }
.pill.blue  { background: var(--brand-soft); color: var(--brand-text); }

/* On a phone each row is a card: tick, the first column as its title, the
   rest as a line of small labelled facts. */
@media (max-width: 760px) {
  .dt-tools { padding: .7rem; }
  .dt-search { flex-basis: 100%; max-width: none; }
  .dt-tools select { flex: 1 1 140px; max-width: none !important; }
  .dt-export { flex: 1 1 100%; }
  .dt-export .btn { flex: 1 1 0; }
  .dt-table thead { display: none; }
  .dt-table, .dt-table tbody { display: block; }
  .dt-table tr { display: grid; grid-template-columns: 34px 1fr auto; gap: .1rem .5rem;
                 padding: .7rem .8rem; border-bottom: 1px solid var(--line-soft); align-items: start; }
  .dt-table td { display: block; padding: 0; border: 0; background: none !important; }
  .dt-table td.dt-chk { grid-row: 1 / span 9; padding-top: .15rem; width: auto; }
  .dt-table td.dt-first { grid-column: 2; }
  .dt-table td:not(.dt-chk):not(.dt-first):not(.dt-go) { grid-column: 2; font-size: .8rem; color: var(--muted);
                                                          text-align: left; }
  .dt-table td:not(.dt-chk):not(.dt-first):not(.dt-go):empty { display: none; }
  .dt-table td:not(.dt-chk):not(.dt-first):not(.dt-go)::before { content: attr(data-label) ': '; color: var(--muted-2); }
  .dt-table td.dt-go { grid-column: 3; grid-row: 1; }
  .dt-table tr.on { background: var(--brand-soft); }
  .dt-table .hide-sm { display: none !important; }
  .dt-bulk { top: 54px; }
}

/*
 * The toast floats.
 *
 * It was an ordinary block at the foot of the page, so "Saved" or "That
 * could not be sent" appeared below everything — on a long screen, somewhere
 * nobody was looking, and the person pressed the button again. It now sits at
 * the bottom of the window, above dialogs, wherever the page is scrolled to.
 */
#toast {
  position: fixed; left: 50%; bottom: max(1.1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 95; margin: 0;
  width: max-content; max-width: min(560px, calc(100vw - 2rem));
  box-shadow: var(--shadow-lg); font-weight: 500;
}
#toast.msg.good, #toast.msg.bad, #toast.msg.warn, #toast.msg.info { background-clip: padding-box; }
#toast.msg.info { background: var(--card); }
@media (min-width: 900px) { #toast { left: calc(50% + var(--nav-w) / 2); } }

/* "and 12 more" under a short list. */
details.more > summary { cursor: pointer; list-style: none; color: var(--brand-text); font-size: .85rem;
                         font-weight: 550; padding: .55rem 0 .2rem; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { display: none; }
.dt-search { max-width: 380px; }
.dt-tools select { flex: 0 0 auto; }

/* Giving: the guided setup's numbered steps. */
ol.setupsteps { padding-left: 1.3rem; margin: .8rem 0 0; }
ol.setupsteps > li { margin: 0 0 1rem; line-height: 1.5; }
ol.setupsteps > li::marker { font-weight: 700; color: var(--brand-text); }
ol.setupsteps label { margin-top: .55rem; }
.card.setup h2 .sub { margin-left: auto; }

/* Administration: sections and the set-up tiles. */
.sectabs { margin: 0 0 1rem; }
.tiles { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-content: start; }
.tiles .card { margin: 0; display: flex; flex-direction: column; }
.tiles .card .btns { margin-top: auto; padding-top: .8rem; }
.tiles .card .muted { font-size: .82rem; }

/* Ministries as cards. */
.mingrid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.mincard {
  display: flex; flex-direction: column; gap: .25rem; text-align: left; cursor: pointer; font: inherit;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.05rem; box-shadow: var(--shadow-sm); border-top: 3px solid var(--brand-text);
  transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.mincard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.mincard .nm { font-weight: 650; font-size: 1rem; }
.mincard .kind { color: var(--muted); font-size: .8rem; text-transform: capitalize; }
.mincard .nums { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .55rem; font-size: .82rem; color: var(--ink-2); }
.mincard .nums b { font-variant-numeric: tabular-nums; }

/* ==============================================================
   Version 22
   ============================================================== */

/* The menu in groups, each with a quiet heading. */
nav.side .navgroup {
  font-size: .66rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: rgba(255,255,255,.42); padding: .95rem .7rem .3rem;
}
nav.side .navgroup:first-child { padding-top: .3rem; }
nav.side .foot .role { text-transform: none; }
nav.side .foot .role::first-letter { text-transform: uppercase; }

/* Back to the top: bottom left, clear of the conversation button. */
.totop {
  position: fixed; left: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(16,24,34,.16));
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(14px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
.totop:hover { color: var(--brand-text); border-color: var(--brand-text); }
.totop .ico { width: 20px; height: 20px; }
@media (min-width: 900px) { .totop { left: calc(var(--nav-w) + 18px); } }
@media (prefers-reduced-motion: reduce) { .totop { transition: none; } }
@media print { .totop, #newsbar { display: none !important; } }

/* What's new: a band, never a box in the way. */
#newsbar { padding: .9rem .9rem 0; }
.newsband {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  background: var(--brand-soft); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: .6rem .7rem .6rem .9rem; font-size: .88rem; color: var(--ink);
}
.newsband > .ico { color: var(--accent); flex: 0 0 auto; }
.newsband .grow { flex: 1 1 260px; min-width: 0; }
.newsband .grow span { color: var(--ink-2); margin-left: .25rem; }
.newsband .btn.small { width: auto; }

/* Settings, grouped as tiles. */
.setfind { flex: 0 1 300px; }
.setgroup { margin-bottom: 1.2rem; }
.sethead { font-size: .74rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
           color: var(--muted); margin: .4rem 0 .55rem; }
.setgrid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.settile {
  display: flex; align-items: flex-start; gap: .8rem; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem .9rem .9rem 1rem; cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.settile:hover { border-color: var(--brand-text); box-shadow: 0 4px 14px rgba(16,24,34,.08); }
.settile:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.settile .setico { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  background: var(--brand-soft); color: var(--brand-text); display: flex; align-items: center; justify-content: center; }
.settile .settxt { flex: 1 1 auto; min-width: 0; }
.settile .t { display: block; font-weight: 600; font-size: .93rem; }
.settile .h { display: block; color: var(--muted); font-size: .8rem; margin-top: .15rem; line-height: 1.4; }
.settile .go { color: var(--muted-2); align-self: center; width: 16px; height: 16px; }

/* Several branches, a role in each. */
.places { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: .7rem .8rem; margin: .6rem 0 .4rem; }
.places .placeshead { display: flex; align-items: center; gap: .4rem; font-size: .88rem; flex-wrap: wrap; }
.places .placeshead .ico { color: var(--brand-text); }
.placerow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: .4rem; align-items: center; margin-top: .5rem; }
.placerow select { margin: 0; }
.places [data-addplace] { margin-top: .6rem; width: auto; }
.places .placesnote { font-size: .8rem; margin-top: .4rem; }
.placepills { margin: .3rem 0 .1rem; }
.placepills .pill { display: inline-flex; align-items: center; gap: .3rem; }
.placepills .ico { width: 13px; height: 13px; }
.placelist { display: grid; gap: .4rem; margin: .3rem 0 .4rem; }
.placelist .btn { justify-content: flex-start; width: 100%; }
#branchpick select#wplace { min-width: 0; }

/* The account panel and the audit entry. */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .9rem; margin: 0 0 .6rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.dlgsub { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .4rem; }
.difftable { width: 100%; border-collapse: collapse; font-size: .85rem; }
.difftable th { text-align: left; color: var(--muted); font-weight: 600; font-size: .75rem; padding: .35rem .4rem;
                border-bottom: 1px solid var(--line); }
.difftable td { padding: .4rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; overflow-wrap: anywhere; }
.difftable td:nth-child(2) { color: var(--bad); }
.difftable td:nth-child(3) { color: var(--good); }
.badtext { color: var(--bad) !important; }
.dt-table td.wrap { white-space: normal; max-width: 420px; color: var(--ink-2); font-size: .82rem; }
.dt-table code, .kv code { font-size: .76rem; background: var(--line-soft); padding: .05rem .3rem; border-radius: 4px; }
.auditkinds .btn { flex: 0 0 auto; min-width: 0; }

/* Insights. */
.kpis { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 1rem; }
@media (max-width: 420px) { .kpi { padding: .7rem .8rem; } .kpi .val { font-size: 1.3rem; } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.kpi .lbl { color: var(--muted); font-size: .76rem; font-weight: 550; }
.kpi .val { font-size: 1.55rem; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.kpi .val small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.kpi .meta { color: var(--muted); font-size: .76rem; margin-top: .15rem; }
.kpi.warn { border-left: 4px solid var(--warn); }
.kpi.bad { border-left: 4px solid var(--bad); }
.trend { font-weight: 600; }
.trend.up { color: var(--good); }
.trend.down { color: var(--bad); }
.hbars { display: grid; gap: .45rem; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: .6rem; align-items: center; font-size: .84rem; }
.hbar .hl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .ht { background: var(--line-soft); border-radius: 99px; height: 9px; overflow: hidden; }
.hbar .ht i { display: block; height: 100%; border-radius: 99px; }
.hbar .hv { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; min-width: 2.5rem; text-align: right; }
.heat { display: grid; gap: 3px; overflow-x: auto; padding-bottom: .3rem; }
.heatrow { display: grid; grid-template-columns: 2.6rem repeat(24, minmax(12px, 1fr)); gap: 3px; align-items: center; }
.heatrow i { display: block; height: 18px; border-radius: 3px; background: var(--brand-text); }
.heatrow .hd { font-size: .74rem; color: var(--muted); }
.heathead span { font-size: .66rem; color: var(--muted-2); text-align: left; }
.tablewrap { overflow-x: auto; }
.insights-people tr.faded td { opacity: .6; }

/* Updates. */
.newver { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
          padding: .7rem .9rem; margin: .4rem 0 .8rem; }
.newver .nv-head .ico { color: var(--accent); vertical-align: -3px; }
ul.notes { margin: .5rem 0 .3rem; padding-left: 1.1rem; line-height: 1.55; font-size: .9rem; }
ul.notes li { margin-bottom: .4rem; }
details.relnote { border-bottom: 1px solid var(--line-soft); padding: .55rem 0; }
details.relnote:last-child { border-bottom: 0; }
details.relnote summary { cursor: pointer; font-size: .92rem; }
label.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; margin: .5rem 0; flex-wrap: wrap; }
label.check input { width: auto; min-height: auto; margin-top: .25rem; }

/* Version 23: getting started */
.card.setup { border-left: 4px solid var(--accent); }
.setuphead { display: flex; align-items: flex-start; gap: .6rem; }
.setuphead .grow { flex: 1 1 auto; }
.setupbar { height: 6px; background: var(--line-soft); border-radius: 99px; overflow: hidden; margin: .2rem 0 .8rem; max-width: 420px; }
.setupbar i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.setupsteps { display: grid; gap: .45rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.setupstep { display: flex; gap: .7rem; align-items: flex-start; text-align: left; width: 100%; font: inherit;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .65rem .7rem; cursor: pointer; }
.setupstep:hover:not(:disabled) { border-color: var(--brand-text); }
.setupstep.done { opacity: .62; cursor: default; }
.setupstep .tick { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center;
  justify-content: center; font-size: .78rem; font-weight: 700; background: var(--brand-soft); color: var(--brand-text); }
.setupstep.done .tick { background: var(--good-soft); color: var(--good); }
.setupstep .tick .ico { width: 15px; height: 15px; }
.setupstep .txt { flex: 1 1 auto; min-width: 0; }
.setupstep .t { display: block; font-weight: 600; font-size: .88rem; }
.setupstep .h { display: block; color: var(--muted); font-size: .78rem; margin-top: .1rem; }
.setupstep .go { width: 15px; height: 15px; color: var(--muted-2); align-self: center; }
