/* The Didactical operator's pages (2026-09-24): Organizations (board, one
 * organization, the New organization wizard), Mail, and System's health.
 * Owner: console/js/organizations.js, mail.js, system.js.
 *
 * Built on the design foundation in console.css: tokens only (--surface-*,
 * --text*, --ok/--warn/--danger/--info and their -soft fills, --space-*,
 * --radius-*, --shadow-*). No palette is defined here, so all four themes
 * (LORE Blue, Light, Dark, Easy reading) come for free. An organization's own
 * brand colour appears only as a band and a monogram fill, never as text,
 * because a school's colour is not chosen for contrast against our surfaces.
 *
 * Colour is never the only signal: every state has an icon and a word. */

/* --- the sentence at the top of a house page ----------------------------------- */

.house-hero {
  position: relative; overflow: hidden;
  padding: var(--space-6) var(--space-6) var(--space-5);
  background: var(--surface-1);   /* flat, like every card (2026-10-11) */
}
.house-hero .card-head { margin-bottom: var(--space-2); }
.house-hero h2.t-eyebrow { margin: 0; }
.house-headline {
  display: flex; align-items: center; gap: var(--space-3);
  margin: 0 0 var(--space-3);
  font-size: var(--fs-display); line-height: 1.15; font-weight: var(--fw-bold);
  letter-spacing: -.025em; color: var(--text); text-wrap: balance;
}
.house-why { margin: 0 0 var(--space-4); padding-left: 1.1rem; color: var(--text-dim); }
.house-why li + li { margin-top: 2px; }
.house-why strong { color: var(--text); font-weight: var(--fw-semibold); }
/* One ruled readout, as on the teacher's pages (cards.css .att-stats). */
.house-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: var(--space-4);
               border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.house-stats .stat { min-width: 0; border: 0; border-radius: 0; box-shadow: 0 0 0 1px var(--border); }
.stack > .house-stats { margin-top: .75rem; }

/* --- the board: one card per organization ---------------------------------------- */

.oc-grid {
  list-style: none; margin-inline: 0; margin-bottom: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--space-4);
}
.oc {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: calc(var(--space-5) + 4px) var(--space-5) var(--space-4);
  background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color var(--dur) var(--ease);
}
.oc:hover { border-color: var(--border-strong); }
.oc:has(.oc-open:focus-visible) { border-color: var(--focus); box-shadow: 0 0 0 2px var(--focus), var(--shadow-md); }
/* The organization's own colour, as a band along the top. Neutral when unbranded. */
.oc-band { position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--border-strong); }

.oc-head { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.oc-title { flex: 1 1 auto; min-width: 0; }
.oc-open {
  appearance: none; background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  font: inherit; font-size: var(--fs-h3, 1.1rem); font-weight: var(--fw-semibold); color: var(--text);
  text-align: left; line-height: 1.25; overflow-wrap: anywhere;
}
/* The name is the card's link; its ::after covers the card, controls sit above. */
.oc-open::after { content: ""; position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
.oc-open:hover span { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.oc-open:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.oc-sub { font-size: var(--fs-caption); color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The mark: a logo on white (brand guides specify it), or initials in the brand colour. */
.oc-mark {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  background: #fff; border-radius: var(--radius); border: 1px solid var(--border); padding: 4px;
}
.oc-mark img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.oc-mark.oc-mono { padding: 0; border-color: transparent; background: var(--brand-soft); color: var(--brand-ink);
                   font-weight: var(--fw-bold); letter-spacing: .02em; }
.oc-mark.oc-mono span { font-size: .95rem; }

.oc-owner { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; position: relative; z-index: 1; }
.oc-owner-name { font-size: var(--fs-small); color: var(--text); min-width: 0; overflow-wrap: anywhere; }

.oc-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2);
           padding: var(--space-3) 0; border-block: 1px solid var(--border); }
.oc-fig { display: flex; flex-direction: column; min-width: 0; }
.oc-fig-value { font-size: 1.4rem; font-weight: var(--fw-bold); letter-spacing: -.02em; line-height: 1.1;
                color: var(--text); font-variant-numeric: tabular-nums; }
.oc-fig-label { font-size: var(--fs-caption); color: var(--text-dim); line-height: 1.3; }

.oc-chips { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); align-items: center; position: relative; z-index: 1; }
.oc-chips select { max-width: 100%; font-size: var(--fs-caption); padding: .2rem .45rem; }
.oc-foot { display: flex; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap;
           font-size: var(--fs-caption); color: var(--text-dim); margin-top: auto; }

/* --- one organization ---------------------------------------------------------------- */

.org-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.org-nav select { max-width: 100%; min-width: 0; }
.org-hero { position: relative; overflow: hidden; padding-top: calc(var(--space-6) + 4px); box-shadow: var(--shadow-md); }
.org-hero-band { position: absolute; left: 0; right: 0; top: 0; height: 8px; background: var(--border-strong); }
.org-hero-main { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-3); }
.org-hero-text { flex: 1 1 16rem; min-width: 0; }
.org-hero-name { margin: 0 0 2px; font-size: var(--fs-display); line-height: 1.15; letter-spacing: -.025em; overflow-wrap: anywhere; }

.org-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.org-col { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.org-col > .card + .card { margin-top: 0; }
.org-panel h3 { font-size: var(--fs-body); }

.staff-list, .class-list, .plain-list, .mail-list { list-style: none; margin: 0; padding: 0; }
.staff-row, .class-row, .plain-list > li {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
  padding: var(--space-3) 0; border-top: 1px solid var(--border);
}
.staff-row:first-child, .class-row:first-child, .plain-list > li:first-child { border-top: 0; padding-top: 0; }
.plain-list > li { justify-content: space-between; }
.staff-row > .person { flex: 1 1 14rem; min-width: 0; }
.staff-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.staff-actions { display: flex; gap: var(--space-2); margin-left: auto; }

.class-row { flex-direction: column; align-items: stretch; }
.class-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); }
.class-join { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
              padding: var(--space-2) var(--space-3); background: var(--surface-2); border-radius: var(--radius); }
.class-code { font-size: 1.05rem; font-weight: var(--fw-bold); letter-spacing: .14em; color: var(--text); }
.class-url { color: var(--text-dim); flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }

.link-btn { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--brand-ink);
            cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: transparent;
            text-underline-offset: 3px; min-width: 0; overflow-wrap: anywhere; }
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* Fourteen days of "how many students did something". */
.act-bars { display: flex; align-items: flex-end; gap: 4px; height: 96px; padding: var(--space-2) 0 0;
            border-bottom: 1px solid var(--border); }
.act-bar { flex: 1 1 0; min-width: 3px; background: var(--chart-1); border-radius: 4px 4px 0 0; }
.act-bar.act-zero { background: var(--surface-3); }
.act-axis { display: flex; justify-content: space-between; font-size: var(--fs-caption); color: var(--text-dim); }

.use-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: var(--space-3); }
.use-fig { display: flex; flex-direction: column; padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius); min-width: 0; }
.use-value { font-size: 1.35rem; font-weight: var(--fw-bold); letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.use-label { font-size: var(--fs-small); color: var(--text); }
.use-sub { font-size: var(--fs-caption); color: var(--text-dim); overflow-wrap: anywhere; }

/* --- choices (send or hold, owner or admin, library courses) ------------------------- */

fieldset.choice { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3) var(--space-3);
                  margin: 0 0 var(--space-4); min-width: 0; }
fieldset.choice legend { padding: 0 .35rem; font-weight: var(--fw-semibold); font-size: var(--fs-small); }
.choice-opt { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2);
              border-radius: var(--radius-sm); cursor: pointer; }
.choice-opt:hover { background: var(--surface-2); }
.choice-opt input { margin-top: .25rem; flex: 0 0 auto; accent-color: var(--brand-fill); }
.choice-opt > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.choice-opt:has(input:checked) { background: var(--brand-soft); }
.choice-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }

/* --- the wizard -------------------------------------------------------------------- */

.wiz-steps { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: flex; gap: var(--space-2); flex-wrap: wrap; counter-reset: none; }
.wiz-step { display: flex; align-items: center; gap: var(--space-2); flex: 1 1 0; min-width: 7rem;
            padding-bottom: var(--space-2); border-bottom: 3px solid var(--border); color: var(--text-dim);
            font-size: var(--fs-small); font-weight: var(--fw-medium); }
.wiz-dot { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: 0 0 auto;
           border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-caption);
           font-weight: var(--fw-bold); color: var(--text-dim); }
.wiz-step.is-current { color: var(--text); border-bottom-color: var(--brand-fill); }
.wiz-step.is-current .wiz-dot { background: var(--brand-fill); color: var(--brand-fill-ink); border-color: transparent; }
.wiz-step.is-done { color: var(--text); border-bottom-color: color-mix(in srgb, var(--ok) 60%, var(--border)); }
.wiz-step.is-done .wiz-dot { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.wiz-body { min-height: 16rem; }
.wiz-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); }
.wiz-two input[type=color] { width: 3rem; height: 2.3rem; padding: 2px; }
.wiz-foot { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4);
            padding-top: var(--space-4); border-top: 1px solid var(--border); }
.wiz .form-error { margin: var(--space-2) 0 0; }

.wiz-brand-preview { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius);
                     padding: calc(var(--space-4) + 4px) var(--space-4) var(--space-4); background: var(--surface-2); }
.wiz-brand-band { position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--border-strong); }
.wiz-brand-row { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.wiz-brand-row strong { overflow-wrap: anywhere; }

.wiz-review { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2) var(--space-5); margin: 0; }
.wiz-review dt { color: var(--text-dim); font-size: var(--fs-small); }
.wiz-review dd { margin: 0; overflow-wrap: anywhere; }

.wiz-result { display: flex; flex-direction: column; gap: var(--space-4); }
.wiz-result-head { display: flex; align-items: center; gap: var(--space-3); }
.wiz-result-head h3 { margin: 0; font-size: var(--fs-h2, 1.3rem); }
.wiz-result-head p { margin: 0; }
.wiz-result-icon { color: var(--ok); display: inline-flex; }
.wiz-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.wiz-checks li { display: flex; align-items: flex-start; gap: var(--space-2); }
.wiz-checks li.ok .icon { color: var(--ok); margin-top: 2px; }
.wiz-checks li.warn .icon { color: var(--warn); margin-top: 2px; }
.wiz-result-block { padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.wiz-result-block h4 { margin: 0 0 var(--space-1); }
.wiz-result-block .secret { background: var(--surface-1); }

/* --- mail ---------------------------------------------------------------------------- */

.mail-filters { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; }
.mail-filters select { max-width: 100%; min-width: 0; }
/* ONE TAB SYSTEM (2026-10-16, the console's theme): a filter of a house list is drawn as every row of tabs is (the
   console's own, the course page's views): words, the one in force in --text with a bar under it in the accent, on a
   hairline. It was a segmented box of its own. */
.hseg { display: inline-flex; flex-wrap: wrap; gap: 0 1.25rem; padding: 0; background: none;
        border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.hseg-btn { appearance: none; border: 0; border-bottom: 3px solid transparent; background: none; font: inherit; font-size: var(--fs-small); cursor: pointer;
            color: var(--text-dim); padding: .45rem 0 .4rem; margin-bottom: -1px; border-radius: 0; display: inline-flex; align-items: center; gap: .4rem; }
.hseg-btn:hover { color: var(--text); }
.hseg-btn[aria-pressed="true"] { color: var(--text); font-weight: var(--fw-semibold); border-bottom-color: var(--accent); }
.hseg-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hseg-count { font-size: var(--fs-caption); font-weight: var(--fw-bold); background: var(--surface-3); color: var(--text);
              border-radius: var(--radius-pill); padding: 0 .45rem; min-width: 1.4rem; text-align: center; }

.mail-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) 0; border-top: 1px solid var(--border); }
.mail-row:first-child { border-top: 0; padding-top: var(--space-1); }
.mail-icon { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
             border-radius: var(--radius); background: var(--surface-2); color: var(--text-dim); }
.mail-held .mail-icon { background: var(--info-soft); color: var(--info); }
.mail-failed .mail-icon { background: var(--danger-soft); color: var(--danger); }
.mail-sent .mail-icon { background: var(--ok-soft); color: var(--ok); }
.mail-never { opacity: .78; }
.mail-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mail-to { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.mail-name { font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.mail-addr { font-size: var(--fs-small); color: var(--text-dim); overflow-wrap: anywhere; }
.mail-subject { font-size: var(--fs-small); color: var(--text); overflow-wrap: anywhere; }
.mail-chips { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
.mail-meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: var(--fs-caption); color: var(--text-dim); }
.mail-error { font-size: var(--fs-caption); color: var(--danger); font-family: var(--font-mono); overflow-wrap: anywhere; }
.mail-actions { flex: 0 0 auto; display: flex; gap: var(--space-2); align-items: center; }

/* --- system health ------------------------------------------------------------------ */

.health-icon { display: inline-flex; flex: 0 0 auto; }
.health-ok .health-icon { color: var(--ok); }
.health-warn .health-icon { color: var(--warn); }
.health-bad .health-icon { color: var(--danger); }
.health-grid { list-style: none; margin: var(--space-4) 0 0; padding: 0;
               display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: var(--space-3); }
.hc { padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-1); min-width: 0; }
.hc-top { display: flex; align-items: center; gap: var(--space-2); }
.hc-icon { display: inline-flex; }
.hc-label { font-size: var(--fs-small); color: var(--text-dim); font-weight: var(--fw-medium); }
.hc-value { font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--text); margin-top: 4px; overflow-wrap: anywhere; }
.hc-detail { font-size: var(--fs-caption); color: var(--text-dim); margin-top: 2px; overflow-wrap: anywhere; }
.hc-ok .hc-icon { color: var(--ok); }
.hc-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.hc-warn .hc-icon, .hc-warn .hc-label { color: var(--warn); }
.hc-bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.hc-bad .hc-icon, .hc-bad .hc-label { color: var(--danger); }
.hc-unknown .hc-icon { color: var(--text-dim); }
.health-findings { margin-top: var(--space-5); }
.health-findings h3 { font-size: var(--fs-body); margin: 0 0 var(--space-2); }
.health-findings .plain-list > li > div { flex: 1 1 20rem; min-width: 0; }

/* House tabs carry their own figures; the header's course/student tiles
   (a tenant's view of the world) are noise above them. app.js sets data-tab. */
body[data-tab="organizations"] #stats, body[data-tab="mail"] #stats,
body[data-tab="system"] #stats, body[data-tab="agent"] #stats { display: none; }

/* --- phones ---------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .org-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .house-hero { padding: var(--space-5) var(--space-4) var(--space-4); }
  .house-headline, .org-hero-name { font-size: 1.5rem; }
  .house-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .oc-grid { grid-template-columns: minmax(0, 1fr); }
  .oc-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-3); }
  .wiz-two { grid-template-columns: minmax(0, 1fr); }
  .wiz-step { min-width: 0; flex-basis: calc(50% - var(--space-2)); }
  .wiz-review { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .wiz-review dd { margin-bottom: var(--space-2); }
  .mail-row { flex-wrap: wrap; }
  .mail-actions { width: 100%; padding-left: calc(36px + var(--space-3)); }
  .staff-actions { margin-left: 0; }
  .hseg { width: 100%; }
  /* (Fix round 1, L5) One row that scrolls inside itself, as every row of tabs on a phone: wrapped onto two or three
     lines, the bar under the filter in force floated off the hairline. Its end fades, and the keyboard stops clear of
     the fade. */
  .hseg { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; padding-right: 40px; box-sizing: border-box;
          scroll-padding: 0 40px 0 0;
          -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
  .hseg-btn { flex: none; margin-bottom: 0; white-space: nowrap; }
}

/* The Wording setting (organizations.js wordingControl, 2026-09-28): inside the
   Staff card an owner uses, set apart from the staff table above it. */
.wording-in-staff { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.wording-control select { max-width: 26rem; }

/* The filters' bars in forced colours: an edge that is transparent is drawn in full there, so every filter would carry one. */
@media (forced-colors: active) {
  .hseg-btn { border-bottom-color: Canvas; }
  .hseg-btn[aria-pressed="true"] { border-bottom-color: Highlight; }
}
