/* =============================================================================
   ZEC Registry — design system  ·  "Quiet heritage" (Direction A)
   A parish-register aesthetic for creation care: parchment + fir + a gilt accent,
   Spectral for headings, IBM Plex Sans for UI, IBM Plex Mono for codes.
   Layered over Bootstrap 5.3 by overriding its CSS variables + a few components.
   ---------------------------------------------------------------------------
   Theme: light by default; follows the OS setting automatically (auto); a manual
   Auto/Light/Dark toggle sets html[data-theme] to override. See zec-theme.js.
============================================================================= */
@import url('/fonts/fonts.css');

/* ---------- tokens: LIGHT (base) ---------- */
:root {
    --parchment:#F4F0E6; --paper:#FBFAF5; --ink:#24312B; --muted:#6B7169;
    --fir:#1F4E3D; --fir-2:#2E6650; --moss:#6E8B5A; --gilt:#B8863B;
    --stone:#DED8CA; --stone-2:#E9E4D7; --field:#FFFFFF; --field-bd:#D3CCBB;
    --bar:#1F4E3D; --topbar-text:#EDE7D6; --topbar-mut:#C4CEC1;

    /* certificate status (map + legend). Awarded tiers kept for when data lands. */
    --st-none:#A9A597; --st-progress:#6E8B5A; --st-certified:#B8863B;
    --pin-gold:#D4A418; --pin-silver:#8D9BB0; --pin-bronze:#B07C4A;

    --shadow:0 1px 3px rgba(40,45,38,.08), 0 8px 24px rgba(40,45,38,.05);
    --sel-lockup:url('/img/sel-lockup-light.svg');
    color-scheme: light;

    /* map the palette onto Bootstrap so its components inherit the look */
    --bs-body-bg: var(--parchment);
    --bs-body-color: var(--ink);
    --bs-body-font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-bg: var(--stone-2);
    --bs-border-color: var(--stone);
    --bs-link-color: var(--fir);
    --bs-link-hover-color: var(--fir-2);
    --bs-primary: var(--fir);
    --bs-primary-rgb: 31,78,61;
}

/* ---------- tokens: DARK — applied automatically when the OS is dark and the
   user has NOT chosen a theme, OR explicitly when data-theme="dark". ---------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --parchment:#141E19; --paper:#1A2620; --ink:#E7E1D2; --muted:#9AA79C;
        --fir:#4E8F73; --fir-2:#5FA184; --moss:#82A46B; --gilt:#CDA054;
        --stone:#2C3A33; --stone-2:#243029; --field:#182320; --field-bd:#33443B;
        --bar:#16342A; --topbar-text:#E7E1D2; --topbar-mut:#9FB0A4;
        --st-none:#8E958A; --st-progress:#82A46B; --st-certified:#CDA054;
        --shadow:0 1px 3px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
        --sel-lockup:url('/img/sel-lockup-dark.svg');
        color-scheme: dark;
        --bs-tertiary-bg: var(--stone-2);
    }
}
:root[data-theme="dark"] {
    --parchment:#141E19; --paper:#1A2620; --ink:#E7E1D2; --muted:#9AA79C;
    --fir:#4E8F73; --fir-2:#5FA184; --moss:#82A46B; --gilt:#CDA054;
    --stone:#2C3A33; --stone-2:#243029; --field:#182320; --field-bd:#33443B;
    --bar:#16342A; --topbar-text:#E7E1D2; --topbar-mut:#9FB0A4;
    --st-none:#8E958A; --st-progress:#82A46B; --st-certified:#CDA054;
    --shadow:0 1px 3px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
    --sel-lockup:url('/img/sel-lockup-dark.svg');
    color-scheme: dark;
    --bs-tertiary-bg: var(--stone-2);
}

/* ---------- base ---------- */
body {
    background: var(--parchment);
    color: var(--ink);
    font-family: var(--bs-body-font-family);
}
h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6 { font-family:"Spectral", Georgia, serif; }
code, .zec-mono { font-family:"IBM Plex Mono", ui-monospace, monospace; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; }

/* ---------- app shell: top bar + left menu ----------
   Pages with navigation get <header class="zec-topbar"> + <aside class="zec-sidebar">
   as direct children of <body>; this grid places them without any per-page markup.
   The login pages have no sidebar, so :has() leaves them alone. */
:root { --topbar-h:56px; --sidebar-w:236px; }
html[data-sidebar="collapsed"] { --sidebar-w:64px; }

body:has(> .zec-sidebar) {
    display:grid; min-height:100vh;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
}
body:has(> .zec-sidebar) > .zec-topbar,
body:has(> .zec-sidebar) > footer { grid-column:1 / -1; }
body:has(> .zec-sidebar) > main { grid-column:2; }

/* ---------- top bar / brand ---------- */
.zec-topbar {
    display:flex; align-items:center; gap:1rem;
    height:var(--topbar-h); padding:0 1.25rem;
    background: var(--bar);
    border-bottom: 2px solid var(--gilt);
    position:sticky; top:0; z-index:1040;
}
.zec-brand { display:flex; align-items:center; gap:.55rem; }
.zec-brand:hover { text-decoration:none; }
.zec-logo-mark {
    font-family:"Spectral", serif; font-weight:600; font-size:1.05rem; letter-spacing:.06em;
    color: var(--topbar-text); background: transparent;
    border:1px solid rgba(237,231,214,.42); padding:0 .5rem; border-radius:2px;
}
.zec-logo-text { font-family:"Spectral", serif; font-style:italic; color: var(--topbar-mut); font-weight:400; font-size:1.05rem; }
.zec-topbar-right { display:flex; align-items:center; gap:1rem; margin-left:auto; }
.zec-org-badge {
    align-items:center; color: var(--topbar-mut); font-size:.85rem;
    padding-left:1rem; border-left:1px solid rgba(237,231,214,.25);
}

/* hamburger — mobile only; the sidebar becomes a drawer below 992px */
.zec-menu-btn {
    display:none; background:transparent; border:0; color:var(--topbar-mut);
    padding:.25rem; margin-left:-.25rem; cursor:pointer; line-height:0;
}
.zec-menu-btn:hover { color:var(--topbar-text); }
.zec-menu-btn svg { width:22px; height:22px; }

/* ---------- user menu (avatar + dropdown) ---------- */
.zec-user { position:relative; }
.zec-avatar {
    width:34px; height:34px; border-radius:50%;
    display:inline-flex; align-items:center; justify-content:center;
    background:rgba(237,231,214,.08); color:var(--topbar-text);
    border:1px solid rgba(237,231,214,.42);
    font-size:.8rem; font-weight:600; letter-spacing:.04em; line-height:1; cursor:pointer;
}
.zec-avatar:hover, .zec-user.open .zec-avatar {
    background:rgba(237,231,214,.16); border-color:rgba(237,231,214,.6);
}
.zec-user-menu {
    position:absolute; right:0; top:calc(100% + 10px); min-width:230px; z-index:1050;
    background:var(--paper); color:var(--ink);
    border:1px solid var(--stone); border-radius:6px; box-shadow:var(--shadow);
    padding:.4rem;
}
.zec-user-menu-head { display:flex; flex-direction:column; gap:.1rem; padding:.5rem .6rem .6rem; border-bottom:1px solid var(--stone-2); }
.zec-user-menu-name { font-weight:600; font-size:.9rem; }
.zec-user-menu-mail { color:var(--muted); font-size:.78rem; }
.zec-user-menu-theme {
    display:flex; gap:.25rem; padding:.6rem .6rem; border-bottom:1px solid var(--stone-2);
}
.zec-user-menu-theme button {
    flex:1; font-size:.78rem; padding:.28rem 0; cursor:pointer;
    background:transparent; color:var(--muted);
    border:1px solid var(--field-bd); border-radius:20px; line-height:1.2;
}
.zec-user-menu-theme button:hover { color:var(--ink); border-color:var(--muted); }
.zec-user-menu-theme button.active {
    background:var(--fir); border-color:var(--fir); color:var(--topbar-text); font-weight:500;
}
.zec-user-menu-item {
    display:flex; align-items:center; gap:.55rem; width:100%;
    background:transparent; border:0; text-align:left; cursor:pointer;
    padding:.55rem .6rem; margin-top:.15rem; border-radius:4px;
    color:var(--ink); font-size:.9rem;
}
.zec-user-menu-item:hover { background:var(--stone-2); }
.zec-user-menu-item svg { width:16px; height:16px; color:var(--muted); }

/* ---------- left menu ---------- */
/* The aside stretches to its grid track (ending above the full-width footer);
   the inner wrapper is what sticks and scrolls. */
.zec-sidebar {
    background:var(--paper); border-right:1px solid var(--stone);
}
.zec-sidebar-inner {
    position:sticky; top:var(--topbar-h);
    height:calc(100vh - var(--topbar-h)); max-height:100%;
    display:flex; flex-direction:column;
    overflow-y:auto; overflow-x:hidden;
}
.zec-view-block { padding:.9rem .9rem .7rem; border-bottom:1px solid var(--stone-2); }
.zec-view-label {
    display:block; font-size:.68rem; letter-spacing:.11em; text-transform:uppercase;
    color:var(--muted); margin-bottom:.35rem;
}
.zec-view-switcher { font-size:.85rem; }
.zec-nav { display:flex; flex-direction:column; padding:.6rem 0; }
.zec-nav-link {
    display:flex; align-items:center; gap:.65rem;
    padding:.55rem .95rem; color:var(--muted); font-size:.92rem; white-space:nowrap;
}
.zec-nav-link:hover { color:var(--ink); background:var(--stone-2); text-decoration:none; }
.zec-nav-link.active {
    color:var(--fir); background:var(--stone-2); font-weight:500;
    box-shadow: inset 3px 0 0 var(--gilt);
}
.zec-nav-link svg { width:18px; height:18px; flex:0 0 auto; }
.zec-collapse {
    display:flex; align-items:center; gap:.65rem; margin-top:auto;
    padding:.6rem .95rem; background:transparent; border:0; border-top:1px solid var(--stone-2);
    color:var(--muted); font-size:.85rem; cursor:pointer; white-space:nowrap; text-align:left;
}
.zec-collapse:hover { color:var(--ink); background:var(--stone-2); }
.zec-collapse svg { width:16px; height:16px; flex:0 0 auto; transition:transform .15s ease; }
html[data-sidebar="collapsed"] .zec-collapse svg { transform:rotate(180deg); }

/* collapsed rail (desktop): icons only */
@media (min-width: 992px) {
    html[data-sidebar="collapsed"] .zec-nav-link span,
    html[data-sidebar="collapsed"] .zec-collapse span,
    html[data-sidebar="collapsed"] .zec-view-block { display:none; }
    html[data-sidebar="collapsed"] .zec-nav-link,
    html[data-sidebar="collapsed"] .zec-collapse { justify-content:center; padding-left:0; padding-right:0; }
}

/* drawer (mobile): the sidebar slides over the content */
@media (max-width: 991.98px) {
    body:has(> .zec-sidebar) { grid-template-columns: minmax(0, 1fr); }
    body:has(> .zec-sidebar) > main,
    body:has(> .zec-sidebar) > footer { grid-column:1; }
    .zec-menu-btn { display:inline-flex; }
    .zec-sidebar {
        position:fixed; top:var(--topbar-h); left:0; bottom:0; height:auto;
        width:min(280px, 84vw); z-index:1045;
        transform:translateX(-100%); transition:transform .18s ease;
        box-shadow:none;
    }
    .zec-sidebar-inner { position:static; height:100%; max-height:none; }
    .zec-sidebar.open { transform:none; box-shadow:var(--shadow); }
    .zec-backdrop {
        position:fixed; inset:var(--topbar-h) 0 0 0; z-index:1044;
        background:rgba(20,30,25,.45);
    }
    /* the collapsed rail is a desktop idea only */
    html[data-sidebar="collapsed"] .zec-sidebar { width:min(280px, 84vw); }
}
@media (prefers-reduced-motion: reduce) {
    .zec-sidebar { transition:none; }
}

/* ---------- masthead (dashboard) ---------- */
.zec-masthead {
    display:flex; justify-content:space-between; align-items:flex-start; gap:1.25rem;
    padding-bottom:1rem; border-bottom:1px solid var(--stone); margin-bottom:1.1rem;
}
.zec-eyebrow { font-size:.72rem; letter-spacing:.13em; text-transform:uppercase; color:var(--muted); margin:0 0 .25rem; }
.zec-masthead h1 { font-size:1.55rem; font-weight:600; margin:0; display:flex; align-items:center; gap:.6rem; }
.zec-masthead .zec-sub { margin:.3rem 0 0; color:var(--muted); font-size:.9rem; }
.zec-leaf { color:var(--moss); flex:0 0 auto; }

/* ---------- mission strip ---------- */
.zec-mission {
    background:var(--paper); border:1px solid var(--stone); border-radius:4px;
    padding:.9rem 1.1rem; margin-bottom:1.25rem;
}
.zec-mission-label { font-size:.72rem; letter-spacing:.11em; text-transform:uppercase; color:var(--muted); }
.zec-mission-row { display:flex; align-items:center; gap:1.1rem; margin-top:.55rem; flex-wrap:wrap; }
.zec-bar { flex:1; min-width:180px; height:12px; border-radius:6px; background:var(--stone-2); overflow:hidden; display:flex; }
.zec-bar-fill { background:var(--st-certified); }
.zec-mission-counts { display:flex; gap:1.15rem; font-size:.85rem; white-space:nowrap; flex-wrap:wrap; }
.zec-mission-counts b { font-family:"Spectral", serif; font-weight:600; font-size:1rem; }

/* energy page: the year's GHG headline inside the mission strip */
.zec-ghg-figure { font-family:"Spectral", serif; font-weight:600; font-size:1.45rem; line-height:1.1; white-space:nowrap; }
.zec-ghg-unit { font-size:.9rem; color:var(--muted); font-weight:400; }

/* status dots */
.zec-dot { width:9px; height:9px; border-radius:50%; display:inline-block; margin-right:.4rem; vertical-align:middle; }
.zec-dot--none { background:var(--st-none); }
.zec-dot--progress { background:var(--st-progress); }
.zec-dot--certified { background:var(--st-certified); }

/* ---------- cards / panels ---------- */
.card {
    --bs-card-bg: var(--paper);
    --bs-card-border-color: var(--stone);
    --bs-card-border-radius: 4px;
    --bs-card-color: var(--ink);
    box-shadow: none;
}
/* Fixed-height flex column so the map / list body fills the space below its
   header. The map's slim head and the list's taller search block differ in
   height, so pinning both bodies to 68vh made the list overrun the map; letting
   the body flex keeps both panels the same height, tops and bottoms aligned. */
.zec-panel { background:var(--paper); border:1px solid var(--stone); border-radius:4px; overflow:hidden; display:flex; flex-direction:column; height:68vh; min-height:480px; }
.zec-panel-head {
    display:flex; align-items:center; justify-content:space-between; gap:.75rem;
    padding:.65rem .9rem; border-bottom:1px solid var(--stone); font-size:.78rem; color:var(--muted);
}
.zec-legend { display:flex; gap:.9rem; align-items:center; flex-wrap:wrap; }
.zec-legend span { display:flex; align-items:center; }

/* ---------- map ---------- */
.zec-map {
    height:68vh; min-height:480px; border-radius:0; overflow:hidden; background:var(--stone-2);
}
.zec-panel .zec-map { border-radius:0; height:auto; flex:1 1 auto; min-height:0; }
/* Congregation detail: the map matches the info card beside it — its column is
   d-flex, so the map stretches to the row height the card defines (no percentage
   heights, which some browsers won't resolve against a stretched column), with
   the card's corner radius. The doubled selector outranks .zec-map's 68vh/480px. */
.zec-map.zec-map--detail { height:auto; min-height:320px; flex:1 1 auto; border-radius:4px; }

/* ---------- congregation list ---------- */
/* Match the map's height and scroll internally, so the list doesn't run the page down. */
.zec-list { border-radius:0; flex:1 1 auto; min-height:0; overflow-y:auto; }
.zec-list-item {
    --bs-list-group-bg: var(--paper);
    --bs-list-group-color: var(--ink);
    --bs-list-group-border-color: var(--stone-2);
    --bs-list-group-action-hover-bg: var(--stone-2);
    --bs-list-group-action-hover-color: var(--ink);
    display:flex; align-items:center; gap:.7rem; padding:.7rem .9rem;
}
.zec-list-item .zec-list-name { font-family:"Spectral", serif; font-weight:500; font-size:1rem; line-height:1.2; display:block; }
.zec-list-item .fw-semibold { font-family:"Spectral", serif; font-weight:500; }

/* ---------- detail: chips + rows ---------- */
.zec-chip {
    display:inline-flex; align-items:center; font-size:.78rem; padding:.22rem .7rem;
    border-radius:20px; background:var(--stone-2); color:var(--ink); border:1px solid var(--stone);
}
.zec-chip--org { background:transparent; border-color:var(--fir); color:var(--fir); }
/* Tame Bootstrap's loud contextual badges into the parchment palette */
.badge.text-bg-success { background:transparent !important; color:var(--fir) !important; border:1px solid var(--fir); font-weight:500; }
.badge.text-bg-secondary,
.badge.text-bg-light,
.badge.text-bg-info { background:var(--stone-2) !important; color:var(--ink) !important; border:1px solid var(--stone); font-weight:500; }
.badge.text-bg-warning { background:transparent !important; color:var(--gilt) !important; border:1px solid var(--gilt); font-weight:500; }
.badge { border-radius:20px; padding:.28rem .7rem; }

dl.row dt { color:var(--muted); font-weight:400; }
dl.row dd code, code { color:var(--fir-2); background:transparent; }

.zec-status-pill {
    display:inline-flex; align-items:center; font-size:.8rem; padding:.15rem .6rem;
    border-radius:20px; background:var(--stone-2); color:var(--muted);
}

/* ---------- buttons ---------- */
.btn-success, .btn-primary {
    --bs-btn-bg: var(--fir); --bs-btn-border-color: var(--fir); --bs-btn-color: var(--topbar-text);
    --bs-btn-hover-bg: var(--fir-2); --bs-btn-hover-border-color: var(--fir-2); --bs-btn-hover-color:#fff;
    --bs-btn-active-bg: var(--fir-2); --bs-btn-active-border-color: var(--fir-2);
    --bs-btn-disabled-bg: var(--fir); --bs-btn-disabled-border-color: var(--fir);
}
.btn-outline-secondary, .btn-outline-success {
    --bs-btn-color: var(--fir); --bs-btn-border-color: var(--field-bd);
    --bs-btn-hover-bg: var(--stone-2); --bs-btn-hover-border-color: var(--fir); --bs-btn-hover-color: var(--fir);
    --bs-btn-active-bg: var(--stone-2); --bs-btn-active-color: var(--fir);
}

/* ---------- forms ---------- */
.form-control, .form-select {
    --bs-body-bg: var(--field);
    background-color: var(--field);
    border-color: var(--field-bd);
    color: var(--ink);
    border-radius:3px;
}
.form-control:focus, .form-select:focus {
    background-color: var(--field); color: var(--ink);
    border-color: var(--gilt); box-shadow: 0 0 0 .2rem rgba(184,134,59,.18);
}
.form-control::placeholder { color: var(--muted); opacity:.7; }
.form-label { font-size:.72rem; letter-spacing:.05em; text-transform:uppercase; color:var(--muted); margin-bottom:.3rem; }
.form-check-input:checked { background-color: var(--fir); border-color: var(--fir); }

/* ---------- alerts ---------- */
.alert-success { --bs-alert-bg: var(--stone-2); --bs-alert-border-color: var(--fir); --bs-alert-color: var(--fir); }
.alert-danger  { --bs-alert-color:#8a2e2e; }

/* ---------- login ---------- */
.zec-login-card {
    background: var(--paper); border:1px solid var(--stone); border-top:3px solid var(--gilt);
    border-radius:5px; box-shadow: var(--shadow);
}
.zec-login-card h1 { display:flex; align-items:center; gap:.5rem; font-weight:600; }

/* ---------- map pins (ready for status colouring once certificates exist) ---------- */
.zec-pin { width:14px; height:14px; border-radius:50%; border:2px solid var(--paper);
    box-shadow:0 0 0 1px rgba(0,0,0,.25); cursor:pointer; transition:transform .1s ease; }
.zec-pin:hover { transform:scale(1.35); }
.zec-pin--none { background:var(--st-none); }
.zec-pin--progress { background:var(--st-progress); }
.zec-pin--certified { background:var(--st-certified); }
.mapboxgl-popup-content { font-family:inherit; border-radius:6px; padding:12px 14px; min-width:220px;
    background:var(--paper); color:var(--ink); }
.mapboxgl-popup-content strong { color:var(--fir-2); }

/* ---------- ZE certificate badge (#35): the gilt certified colour, both themes ---------- */
.zec-cert-badge { background:var(--st-certified); color:var(--paper); font-weight:500; }

/* ---------- footer (SEL branding: logo, copyright, contact) ---------- */
.zec-footer {
    display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap;
    border-top:1px solid var(--stone); padding:.9rem 1.5rem;
    background:var(--paper); color:var(--muted); font-size:.82rem;
}
/* On plain pages (login) the footer is inline in the card, but if ever included
   standalone it should not cling to the content above. */
body:not(:has(> .zec-sidebar)) .zec-footer { margin-top:2rem; }
.zec-footer a { color:var(--muted); }
.zec-footer a:hover { color:var(--ink); }
/* The lockup is an SVG pair (dark text / light text) swapped with the theme,
   because currentColor cannot reach into an <img>/background document. */
.zec-sel-logo {
    display:block; width:148px; aspect-ratio:324/88; flex:0 0 auto;
    background:var(--sel-lockup) center/contain no-repeat;
}

/* ---------- user-form role editor (zec-user-form.js) ---------- */
.zec-add-role { display:none; }   /* revealed by JS when a spare row is hidden */
.zec-combobox { position:relative; }
.zec-combobox-list {
    position:absolute; z-index:1050; top:100%; left:0; right:0; margin:2px 0 0; padding:.25rem 0;
    list-style:none; max-height:14rem; overflow-y:auto; background:var(--paper); color:var(--ink);
    border:1px solid var(--field-bd); border-radius:5px; box-shadow:var(--shadow);
}
.zec-combobox-list li { padding:.3rem .75rem; cursor:pointer; }
.zec-combobox-list li.selected { font-weight:600; }
.zec-combobox-list li:hover, .zec-combobox-list li.active { background:var(--fir-2); color:var(--paper); }
.zec-combobox-empty { color:var(--muted); cursor:default; }
.zec-combobox-list li.zec-combobox-empty:hover { background:none; color:var(--muted); }

/* ---------- congregations table (#54) ----------
   ag-grid's Theming API exposes every theme parameter as an --ag-* custom
   property, so the Quiet-heritage palette maps straight on and follows the
   light/dark toggle with no per-theme grid config. */
.zec-grid { flex:1 1 auto; min-height:0; }
.zec-grid {
    --ag-background-color: var(--paper);
    --ag-foreground-color: var(--ink);
    --ag-border-color: var(--stone);
    --ag-header-background-color: var(--stone-2);
    --ag-header-text-color: var(--ink);
    --ag-odd-row-background-color: var(--paper);
    --ag-row-hover-color: var(--stone-2);
    --ag-accent-color: var(--fir);
    --ag-font-family: var(--bs-body-font-family);
    --ag-font-size: .82rem;
    --ag-wrapper-border-radius: 0;
    --ag-wrapper-border: none;
}
.zec-grid .ag-row { cursor:pointer; }
.zec-grid-toolbar #gridQuickFilter { max-width:260px; }

/* Print: the roll as a formatted document — page chrome off, print heading on,
   the grid in its full-height print layout (set by zec-congregations.js). */
.zec-print-head { display:none; }
@media print {
    .zec-topbar, .zec-sidebar, .zec-backdrop, .zec-footer,
    .zec-masthead, .zec-grid-toolbar { display:none !important; }
    body { display:block !important; background:#fff; }
    main { padding:0 !important; }
    .zec-print-head { display:block; margin-bottom:.75rem; }
    .zec-print-head h1 { font-size:1.3rem; margin:0; }
    .zec-print-head p { color:#555; margin:0; font-size:.8rem; }
    .zec-panel { height:auto; min-height:0; border:none; }
}

/* ---------- missing-data pills (#56) ----------
   Tinted, bordered chips so they still read when a printer drops the fill.
   Terracotta = no contacts (the urgent one), slate blue = no buildings
   (Mark's suggestion), gilt = imported address needs checking (#65). */
:root {
    --pill-contacts-fg:#8C3B2E; --pill-contacts-bg:#F6E3DE;
    --pill-buildings-fg:#3E5A75; --pill-buildings-bg:#E1E8F0;
    --pill-address-fg:#7A5A1F; --pill-address-bg:#F3E9D2;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --pill-contacts-fg:#E5A196; --pill-contacts-bg:#3A2420;
        --pill-buildings-fg:#A9C1D9; --pill-buildings-bg:#20303F;
        --pill-address-fg:#DBBB77; --pill-address-bg:#352B17;
    }
}
:root[data-theme="dark"] {
    --pill-contacts-fg:#E5A196; --pill-contacts-bg:#3A2420;
    --pill-buildings-fg:#A9C1D9; --pill-buildings-bg:#20303F;
    --pill-address-fg:#DBBB77; --pill-address-bg:#352B17;
}
.zec-pill {
    display:inline-block; padding:.05rem .5rem; margin:0 .25rem 0 0;
    border-radius:99px; font-size:.68rem; font-weight:600; line-height:1.5;
    border:1px solid currentColor; white-space:nowrap;
}
.zec-pill--contacts { color:var(--pill-contacts-fg); background:var(--pill-contacts-bg); }
.zec-pill--buildings { color:var(--pill-buildings-fg); background:var(--pill-buildings-bg); }
.zec-pill--address { color:var(--pill-address-fg); background:var(--pill-address-bg); }
.zec-pill-filter { display:flex; flex-direction:column; gap:.35rem; padding:.6rem .75rem; }
.zec-pill-filter-option { margin:0; display:flex; align-items:center; gap:.45rem; cursor:pointer; }

/* Dashboard missing-data notice: present but polite — dismissible for a week
   or a month (the snooze proposal from the 31 Jul call). */
.zec-missing-notice {
    display:flex; align-items:center; gap:.9rem; flex-wrap:wrap;
    background:var(--paper); border:1px solid var(--gilt); border-left:4px solid var(--gilt);
    border-radius:4px; padding:.6rem .9rem; margin-bottom:1rem; font-size:.86rem;
}
.zec-missing-notice .zec-snooze { margin-left:auto; display:flex; gap:.75rem; align-items:center;
    font-size:.78rem; color:var(--muted); white-space:nowrap; }

/* Stage dot (#13): each stage's light/dark colour pair travels inline as custom
   properties from the lookup row, so a colour tweak in the CRUD needs no CSS. */
.zec-stage-dot {
    width:11px; height:11px; border-radius:50%; display:inline-block;
    margin-right:.4rem; vertical-align:middle;
    background:var(--zec-stage-light);
    border:1px solid rgba(0,0,0,.2);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .zec-stage-dot { background:var(--zec-stage-dark); border-color:rgba(255,255,255,.25); }
}
:root[data-theme="dark"] .zec-stage-dot { background:var(--zec-stage-dark); border-color:rgba(255,255,255,.25); }

/* Keep the grid's action button clear of the row cursor and out of print. */
.zec-grid-actions { cursor:default; }
@media print { .zec-grid-actions { display:none; } }

/* Map legend (#13): the stage journey under the dashboard map. */
.zec-map-legend { display:flex; flex-wrap:wrap; gap:.3rem 1rem; padding:.45rem .2rem 0;
    font-size:.78rem; color:var(--muted); }
.zec-map-legend-item { white-space:nowrap; }

/* ---------- dialog (#52) ----------
   The project popup, used by zec-dialog.js for confirms and HTML-content
   popups. A native <dialog> styled as a small registry card — paper panel with
   the gilt top rule, like the login card — so it inherits the light/dark theme
   from the tokens. Fade only; Esc, focus trapping and the backdrop are native. */
dialog.zec-dialog {
    background:var(--paper); color:var(--ink);
    border:1px solid var(--stone); border-top:3px solid var(--gilt);
    border-radius:5px; box-shadow:var(--shadow);
    padding:0; width:min(var(--zec-dialog-w, 26rem), calc(100vw - 2rem));
    opacity:0;
    transition:opacity .15s ease, display .15s allow-discrete, overlay .15s allow-discrete;
}
dialog.zec-dialog[open] { opacity:1; }
dialog.zec-dialog::backdrop {
    background:rgba(20,30,25,.45); opacity:0;
    transition:opacity .15s ease, display .15s allow-discrete, overlay .15s allow-discrete;
}
dialog.zec-dialog[open]::backdrop { opacity:1; }
@starting-style {
    dialog.zec-dialog[open] { opacity:0; }
    dialog.zec-dialog[open]::backdrop { opacity:0; }
}
@media (prefers-reduced-motion: reduce) {
    dialog.zec-dialog, dialog.zec-dialog::backdrop { transition:none; }
}
/* The padding lives on the inner wrapper so a click on the dialog element
   itself can only mean the backdrop (zec-dialog.js closes on it). */
.zec-dialog-inner { padding:1.1rem 1.25rem 1.2rem; }
.zec-dialog-title { font-size:1.15rem; font-weight:600; margin:0 0 .5rem; }
.zec-dialog-body { font-size:.92rem; }
.zec-dialog-body p { margin:0 0 .5rem; }
.zec-dialog-body p:last-child { margin-bottom:0; }
/* Primary first, then Cancel — the same order as every Save/Cancel form. */
.zec-dialog-actions { display:flex; gap:.5rem; margin-top:1.1rem; }

/* Destructive confirm button: Bootstrap's red is too loud for the parchment
   palette, so tone it to the alert-danger brick (lighter, not darker, on hover
   in dark mode — the same direction fir/fir-2 take). */
:root { --brick:#8A2E2E; --brick-2:#762727; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) { --brick:#A5544A; --brick-2:#B4655B; }
}
:root[data-theme="dark"] { --brick:#A5544A; --brick-2:#B4655B; }
.btn-danger {
    --bs-btn-bg: var(--brick); --bs-btn-border-color: var(--brick);
    --bs-btn-color:#F6EFE9;
    --bs-btn-hover-bg: var(--brick-2); --bs-btn-hover-border-color: var(--brick-2);
    --bs-btn-hover-color:#fff;
    --bs-btn-active-bg: var(--brick-2); --bs-btn-active-border-color: var(--brick-2);
    --bs-btn-disabled-bg: var(--brick); --bs-btn-disabled-border-color: var(--brick);
}

/* =============================================================================
   Building screen — the heating panel
   The panel is a description of how a building is heated, not a control board:
   the status states itself and says why, every row is its own hit area, and the
   destructive actions live inside the dialog of the thing they destroy. One
   button and one link in the resting state, and no red at all.
============================================================================= */

/* A button that reads as a link — used where the action is quiet by design. */
.zec-linkish {
    background:none; border:0; padding:0; color:var(--fir);
    font:inherit; text-align:left;
}
.zec-linkish:hover { text-decoration:underline; }
.zec-linkish--danger { color:var(--brick); }

/* ---- a block that states something and opens its editor when clicked ---- */
.zec-openable {
    display:flex; flex-wrap:wrap; align-items:center; gap:.35rem .5rem;
    padding:.5rem .55rem; margin:0 -.55rem; border-radius:4px;
}
.zec-openable--clickable { cursor:pointer; }
.zec-openable--clickable:hover { background:var(--stone-2); }
.zec-openable-change {
    background:none; border:0; padding:0; margin-left:auto;
    font-size:.82rem; color:var(--fir); white-space:nowrap;
}
.zec-openable--clickable:hover .zec-openable-change { text-decoration:underline; }

/* ---- status ---- */
.zec-status-why { flex:1 1 100%; font-size:.85rem; color:var(--muted); }

/* ---- the heating note ---- */
.zec-note { margin-top:.9rem; border-top:1px solid var(--stone); padding-top:.6rem; }
.zec-note-body { flex:1 1 12rem; font-size:.85rem; color:var(--muted); }
.zec-note-label {
    display:block; font-size:.72rem; letter-spacing:.11em;
    text-transform:uppercase; color:var(--muted);
}
/* With no note yet there is nothing to push the offer away from, so it sits left. */
.zec-note--empty .zec-openable-change { margin-left:0; }

.zec-status-manual { margin:.4rem 0 0 1.6rem; }
.zec-status-manual .form-text { margin-top:.35rem; }
.zec-dialog-lede { font-size:.88rem; color:var(--muted); margin:0 0 .9rem; }

/* ---- parts of the building, and the heating in each ---- */
.zec-heat-groups { margin-top:.35rem; }

.zec-heat-part {
    display:flex; align-items:flex-start; justify-content:space-between; gap:.5rem;
    width:calc(100% + 1.1rem); margin:.65rem -.55rem 0; padding:.5rem .55rem .15rem;
    background:none; border:0; border-top:1px solid var(--stone);
    border-radius:0; text-align:left; color:inherit;
}
button.zec-heat-part { cursor:pointer; }
button.zec-heat-part:hover { background:var(--stone-2); }
.zec-heat-part-name { font-weight:600; font-size:.88rem; }
.zec-heat-part-notes { display:block; font-size:.82rem; color:var(--muted); }
/* The building-at-large heading is a label, not a thing you can open. */
.zec-heat-part--fixed .zec-heat-part-name {
    font-weight:500; font-size:.72rem; letter-spacing:.11em;
    text-transform:uppercase; color:var(--muted);
}

.zec-heat-list { list-style:none; margin:.15rem 0 0; padding:0; }
.zec-heat-row {
    display:flex; align-items:baseline; gap:.55rem;
    padding:.4rem .55rem; margin:0 -.55rem; border-radius:4px;
    color:var(--ink); text-decoration:none;
}
.zec-heat-row:hover { background:var(--stone-2); color:var(--ink); text-decoration:none; }
.zec-heat-role {
    flex:0 0 4rem; font-size:.72rem; letter-spacing:.09em;
    text-transform:uppercase; color:var(--muted);
}
.zec-heat-what { flex:1; font-size:.9rem; }
.zec-heat-detail { display:block; font-size:.82rem; color:var(--muted); }
.zec-heat-none {
    font-size:.85rem; color:var(--muted); padding:.3rem 0 .3rem 4.55rem;
}
.zec-heat-none.ps-0 { padding-left:0; }

.zec-chev { width:14px; height:14px; flex:0 0 auto; color:var(--muted); align-self:center; }
.zec-heat-row:hover .zec-chev, button.zec-heat-part:hover .zec-chev { color:var(--fir); }

.zec-heat-foot {
    margin:1rem 0 0; padding-top:.75rem; border-top:1px solid var(--stone);
    font-size:.85rem; color:var(--muted);
}

/* Removal sits at the far end of the dialog's action row, away from Save. */
.zec-dialog-destroy { margin-left:auto; font-size:.85rem; color:var(--muted); align-self:center; }
.zec-dialog-destroy [data-zec-remove-confirm] { display:inline-flex; align-items:center; gap:.4rem; }

/* An offer where something is missing, in the same column as the rows it joins. */
.zec-heat-add { font-size:.85rem; padding:.3rem 0 .3rem 4.55rem; }
/* With no rows above it there is no column to line up with. */
.zec-heat-add--alone { padding-left:0; }
.zec-heat-add a { color:var(--fir); }
/* The imported-fuel hint renders empty unless there is one to give. */
.form-text:empty { display:none; }

/* ---- the diocese logo dropzone (#23) ---- */
.zec-dropzone {
    border: 1px dashed var(--bs-border-color, currentColor);
    border-radius: .375rem;
    padding: .6rem .8rem;
    cursor: pointer;
    text-align: center;
    font-size: .85rem;
}
.zec-dropzone--over {
    border-style: solid;
    background: color-mix(in srgb, currentColor 8%, transparent);
}
