/* =====================================================================
   MPT Admin Panel — Moms & Pops & Tots
   Palette taken directly from the logo:
     slate  #586B95   coral #E57B85   sun #FED45C   sage #A9C980
   Type: Nunito (rounded, echoes the logo lettering) for headings and
   navigation; IBM Plex Sans for data and body copy.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  /* Brand */
  --slate:        #586B95;
  --slate-deep:   #3F4E71;
  --slate-dark:   #2E3A57;
  --slate-soft:   #EDF0F7;
  --coral:        #E57B85;
  --coral-soft:   #FDEEF0;
  --sun:          #FED45C;
  --sun-soft:     #FFF6DC;
  --sage:         #A9C980;
  --sage-soft:    #EFF6E6;

  /* Neutrals */
  --ink:          #232B3E;
  --ink-2:        #5A6480;
  --ink-3:        #8A93A9;
  --line:         #E3E7F0;
  --line-strong:  #CDD4E4;
  --canvas:       #F3F5FA;
  --surface:      #FFFFFF;

  /* Shape */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;
  --shadow-card: 0 1px 2px rgba(35, 43, 62, .05);
  --shadow-pop:  0 12px 32px rgba(46, 58, 87, .16);
  --rail: 268px;

  --font-display: 'Nunito', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.25; letter-spacing: -.01em; }
a { color: var(--slate); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--slate-dark); color: #fff; padding: 12px 18px; border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; }

/* =====================  Sign-in  ===================================== */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--surface);
}

.auth__brand {
  background: var(--slate-dark);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

/* Three overlapping rings, the way the logo's O's overlap */
.auth__rings { position: absolute; inset: auto -90px -120px auto; opacity: .5; }
.auth__rings span {
  position: absolute; border-radius: 50%; border: 22px solid;
  width: 260px; height: 260px;
}
.auth__rings span:nth-child(1) { border-color: var(--coral); right: 120px; bottom: 60px; }
.auth__rings span:nth-child(2) { border-color: var(--slate); right: 0; bottom: 0; }
.auth__rings span:nth-child(3) { border-color: var(--sun); right: 190px; bottom: -80px; }

.auth__logo { width: 148px; height: auto; background: #fff; padding: 14px; border-radius: var(--r-md); }
.auth__brand h1 { font-size: 2.1rem; margin-top: 32px; max-width: 15ch; }
.auth__brand p { color: rgba(255,255,255,.78); max-width: 42ch; margin: 12px 0 0; }
.auth__meta { position: relative; font-size: .85rem; color: rgba(255,255,255,.6); }

.auth__panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth__card { width: 100%; max-width: 380px; }
.auth__card h2 { font-size: 1.6rem; }
.auth__card > p { color: var(--ink-2); margin: 6px 0 28px; }
.auth__footnote { margin-top: 26px; font-size: .82rem; color: var(--ink-3); }

/* =====================  Shell  ======================================= */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--slate-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail__head {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.rail__logo { width: 46px; height: 46px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.rail__title { font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; line-height: 1.1; }
.rail__sub { font-size: .72rem; color: rgba(255,255,255,.55); }

.rail__nav { flex: 1; overflow-y: auto; padding: 14px 12px 24px; }
.rail__group + .rail__group { margin-top: 18px; }
.rail__label {
  font-size: .72rem; font-weight: 600; color: rgba(255,255,255,.45);
  padding: 0 10px 8px; letter-spacing: .02em;
}

.rail__link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.82);
  font-family: var(--font-display); font-weight: 600; font-size: .94rem;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.rail__link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.rail__link svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.rail__link.is-active { background: rgba(255,255,255,.12); color: #fff; }
/* the accent keyline tells you which family of screens you are in */
.rail__group--overview .rail__link.is-active { border-left-color: var(--slate); }
.rail__group--programmes .rail__link.is-active { border-left-color: var(--coral); }
.rail__group--master .rail__link.is-active { border-left-color: #8FA3CC; }
.rail__group--access .rail__link.is-active { border-left-color: var(--sage); }
.rail__group--system .rail__link.is-active { border-left-color: var(--sun); }

.rail__foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1); font-size: .74rem; color: rgba(255,255,255,.45); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 16px;
}
.topbar h1 { font-size: 1.32rem; }
.topbar__crumb { font-size: .78rem; color: var(--ink-3); }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }

.burger {
  display: none; border: 1px solid var(--line-strong); background: #fff;
  border-radius: var(--r-sm); width: 40px; height: 40px; cursor: pointer; padding: 0;
}
.burger span, .burger span::before, .burger span::after {
  display: block; width: 17px; height: 2px; background: var(--slate-dark); border-radius: 2px; margin: 0 auto; position: relative;
}
.burger span::before, .burger span::after { content: ''; position: absolute; }
.burger span::before { top: -5px; }
.burger span::after { top: 5px; }

.account { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--slate); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: .82rem;
}
.account__name { font-weight: 600; font-size: .88rem; line-height: 1.2; }
.account__role { font-size: .74rem; color: var(--ink-3); }

.content { padding: 26px 28px 60px; max-width: 1440px; width: 100%; }

/* =====================  Buttons  ===================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
  padding: 10px 18px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  background: var(--slate); color: #fff;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--slate-deep); text-decoration: none; }
.btn--ghost { background: #fff; color: var(--slate-dark); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--slate-soft); border-color: var(--slate); }
.btn--danger { background: var(--coral); }
.btn--danger:hover { background: #D3626D; }
.btn--sun { background: var(--sun); color: var(--slate-dark); }
.btn--sun:hover { background: #F5C544; }
.btn--sm { padding: 7px 12px; font-size: .82rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--slate); text-decoration: underline;
}
.btn-link--danger { color: var(--coral); }

/* Small round icon actions inside table rows */
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; padding: 0;
}
.icon-btn:hover { border-color: var(--slate); color: var(--slate); background: var(--slate-soft); }
.icon-btn--danger:hover { border-color: var(--coral); color: var(--coral); background: var(--coral-soft); }
.icon-btn svg { width: 16px; height: 16px; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.row-actions form { display: inline-flex; margin: 0; }
/* The actions column keeps its own width so the buttons never sit on top
   of the text in the cell beside them. */
table.data th.right, table.data td.right { white-space: nowrap; width: 1%; }
table.data td.right { padding-left: 20px; }

/* =====================  Cards and panels  ============================ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.panel__head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.panel__head h2 { font-size: 1.02rem; }
.panel__head p { margin: 2px 0 0; font-size: .82rem; color: var(--ink-3); }
.panel__body { padding: 20px; }
.panel__foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }

/* Stat tiles: each keyed to its module colour rather than all identical */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 18px 20px; border-top: 4px solid var(--slate);
}
.stat--events { border-top-color: var(--coral); }
.stat--cities { border-top-color: var(--sage); }
.stat--users { border-top-color: var(--slate); }
.stat--roles { border-top-color: var(--sun); }
.stat__label { font-size: .82rem; color: var(--ink-2); font-weight: 500; }
.stat__value { font-family: var(--font-display); font-weight: 800; font-size: 2.1rem; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: .78rem; color: var(--ink-3); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.grid-halves { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* =====================  Filters  ===================================== */

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.filters .field { margin: 0; }
.filters__grow { flex: 1 1 240px; min-width: 180px; }

/* =====================  Forms  ======================================= */

.field { margin-bottom: 18px; }
.field > label, .label {
  display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; color: var(--ink);
}
.field .hint { display: block; font-weight: 400; font-size: .78rem; color: var(--ink-3); margin-top: 4px; }
.required { color: var(--coral); }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=search], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font: inherit; font-size: .92rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--slate); box-shadow: 0 0 0 3px rgba(88,107,149,.16);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%235A6480' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
  padding-right: 34px;
}
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--coral); }
.field-error { color: #C4515C; font-size: .8rem; margin: 6px 0 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }

/* ---- Status switch -------------------------------------------------
   Built so the knob can never land on the text next to it:
   the track is a fixed-size inline-block (not reliant on flex sizing),
   it clips its own knob with overflow:hidden, and the hidden input is
   positioned against the label rather than the page.                  */
.switch {
  position: relative;
  display: inline-flex; align-items: center; gap: 12px;
  cursor: pointer; padding: 4px 0; max-width: 100%;
  line-height: 1.4;
}
.switch input.switch__input {
  position: absolute; top: 0; left: 0;
  width: 1px; height: 1px; opacity: 0; margin: 0; padding: 0;
  border: 0; pointer-events: none; appearance: none;
}
.switch .switch__track {
  display: inline-block;          /* sized even outside a flex container */
  box-sizing: border-box;
  width: 52px; min-width: 52px; max-width: 52px;
  height: 28px; min-height: 28px;
  flex: 0 0 52px;                 /* never shrinks inside a flex row */
  position: relative; overflow: hidden;   /* the knob is clipped to the track */
  vertical-align: middle;
  border-radius: var(--r-pill);
  background: #C3CAD9;            /* OFF: clearly grey, never white */
  border: 1px solid #AEB7CA;
  transition: background .18s ease, border-color .18s ease;
}
.switch .switch__track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  transition: transform .18s ease;
  box-shadow: 0 1px 3px rgba(35,43,62,.35);
}
.switch .switch__input:checked + .switch__track {
  background: var(--sage);        /* ON: sage green */
  border-color: #8FB566;
}
.switch .switch__input:checked + .switch__track::after { transform: translateX(24px); }
.switch .switch__input:focus-visible + .switch__track { outline: 3px solid var(--sun); outline-offset: 2px; }
.switch .switch__input:disabled + .switch__track { opacity: .55; cursor: not-allowed; }
.switch__text { font-size: .88rem; min-width: 0; overflow-wrap: anywhere; }
/* A word next to the switch so the state is readable, not just colour-coded */
.switch__state {
  font-family: var(--font-display); font-weight: 700; font-size: .78rem;
  color: var(--ink-3); min-width: 54px;
}
.switch .switch__input:checked ~ .switch__state { color: #5C7A38; }
.switch .switch__input:checked ~ .switch__state .switch__state-off { display: none; }
.switch .switch__input:not(:checked) ~ .switch__state .switch__state-on { display: none; }
.switch:hover .switch__track { border-color: var(--slate); }

.checkbox { display: flex; align-items: flex-start; gap: 10px; font-size: .88rem; cursor: pointer; }
.checkbox input { margin-top: 3px; accent-color: var(--slate); width: 16px; height: 16px; }

/* =====================  Tabs  ======================================== */

.tabs {
  display: flex; gap: 4px; padding: 0 20px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: thin;
}
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 16px; border: 0; background: none; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: .92rem;
  color: var(--ink-2); white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--slate-deep); }
.tab.is-active { color: var(--slate-deep); border-bottom-color: var(--slate); }
.tab__badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-pill); background: var(--coral); color: #fff;
  font-size: .72rem; font-weight: 700;
}

.tab-panel { display: none; }
.tab-panel.is-open { display: block; }

.section-heading {
  font-size: 1rem; margin: 26px 0 14px;
  padding-top: 18px; border-top: 1px dashed var(--line);
}

.is-hidden { display: none !important; }

.foot-note { font-size: .8rem; color: var(--ink-3); align-self: center; }

/* =====================  Segmented control  =========================== */

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.segmented__option { position: relative; }
.segmented__option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented__option span {
  display: block; padding: 9px 22px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: .88rem;
  color: var(--ink-2); background: #fff;
  border-right: 1px solid var(--line-strong);
}
.segmented__option:last-child span { border-right: 0; }
.segmented__option input:checked + span { background: var(--slate); color: #fff; }
.segmented__option input:focus-visible + span { outline: 3px solid var(--sun); outline-offset: -3px; }

/* =====================  Repeatable rows  ============================= */

.repeat-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 12px;
}
.repeat-head .hint { display: block; margin-top: 2px; }
.repeat-head--nested {
  margin: 18px 0 10px; padding-top: 14px; border-top: 1px dashed var(--line);
  align-items: center;
}

.repeat { display: grid; gap: 10px; }
.repeat-row {
  display: flex; align-items: flex-end; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #FCFDFF;
}
.repeat-row__fields { flex: 1; display: grid; gap: 0 14px; min-width: 0; }
.repeat-row__fields--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.repeat-row .field { margin-bottom: 0; }
.repeat-row__remove { flex: none; margin-bottom: 1px; }
.repeat--nested .repeat-row { background: #fff; }

.activity-card {
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 18px; background: #fff;
}
.activity-card + .activity-card { margin-top: 4px; }
.activity-card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.activity-card__index {
  font-family: var(--font-display); font-weight: 800; font-size: .82rem;
  color: var(--slate-deep); background: var(--slate-soft);
  padding: 4px 12px; border-radius: var(--r-pill);
}

/* =====================  Banner doodles  ============================== */

.doodle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.doodle-slot {
  padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: #FCFDFF;
  min-width: 0;
}
.doodle-slot .label { margin-bottom: 10px; }
.doodle-slot__preview {
  display: grid; gap: 6px; justify-items: start; margin-bottom: 10px;
}
.doodle-slot__preview img {
  max-width: 100%; height: 110px; object-fit: contain;
  /* checkerboard, so transparency is visible */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, var(--slate-soft) 25%, transparent 25%),
    linear-gradient(-45deg, var(--slate-soft) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--slate-soft) 75%),
    linear-gradient(-45deg, transparent 75%, var(--slate-soft) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  border-radius: var(--r-sm); border: 1px solid var(--line);
}
.doodle-slot__empty {
  height: 110px; margin-bottom: 10px; display: grid; place-items: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm); color: var(--ink-3);
}
.doodle-slot__empty svg { width: 28px; height: 28px; }

/* =====================  API token reveal  ============================ */

.token-reveal { border-color: var(--sage); border-top: 4px solid var(--sage); margin-bottom: 18px; }
.token-reveal h2 { font-size: 1.05rem; margin-bottom: 6px; }
.token-reveal > .panel__body > p { color: var(--ink-2); margin: 0 0 14px; }

.token-value {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--slate-dark);
}
.token-value code {
  flex: 1; min-width: 0; overflow-wrap: anywhere;
  color: #fff; font-size: .92rem; letter-spacing: .02em;
}

.code-block {
  margin: 0; padding: 14px 16px; border-radius: var(--r-sm);
  background: var(--slate-soft); color: var(--slate-deep);
  font-size: .84rem; line-height: 1.6; overflow-x: auto; white-space: pre;
}

/* =====================  Images  ====================================== */

.image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px; margin-top: 12px;
}
.image-card {
  display: block; position: relative; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  overflow: hidden; background: #fff;
}
.image-card img { display: block; width: 100%; height: 140px; object-fit: cover; background: var(--slate-soft); }
.image-card__bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-top: 1px solid var(--line); font-size: .84rem;
}
.image-card__bar input { accent-color: var(--coral); width: 16px; height: 16px; }
.image-card__meta { display: block; padding: 0 12px 10px; font-size: .74rem; color: var(--ink-3); }
.image-card:has(input:checked) { border-color: var(--coral); }
.image-card:has(input:checked) img { opacity: .4; }
.image-card:has(input:checked) .image-card__label { color: #B2545E; font-weight: 700; }

input[type=file] {
  width: 100%; padding: 10px 12px; font: inherit; font-size: .9rem;
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: #fff;
}
input[type=file]:hover { border-color: var(--slate); }
input[type=file]::file-selector-button {
  margin-right: 12px; padding: 7px 14px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: .84rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--slate-soft); color: var(--slate-deep);
}

.image-queue { display: grid; gap: 6px; margin-top: 10px; }
.image-queue__item {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--slate-soft); font-size: .84rem;
}
.image-queue__size { color: var(--ink-3); }
.image-queue__item.is-bad { background: var(--coral-soft); color: #A8454F; }
.image-queue__item.is-bad .image-queue__size { color: #A8454F; }

.thumb {
  width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: cover;
  border: 1px solid var(--line); background: var(--slate-soft); flex: none;
}
.cell-with-thumb { display: flex; align-items: center; gap: 10px; }

/* Unread marker on the contact list */
.dot-new {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--coral); margin-right: 6px; vertical-align: middle;
}

.message-body {
  font-size: .95rem; line-height: 1.7; white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 18px; border-radius: var(--r-md);
  background: #FCFDFF; border: 1px solid var(--line);
}
.thumb--video { display: grid; place-items: center; color: var(--slate-deep); background: var(--slate-soft); }
.thumb--video svg { width: 18px; height: 18px; }
.thumb--round { border-radius: 50%; }
/* Stands in for a missing photo or cover, rather than a broken image box. */
.thumb--empty { display: grid; place-items: center; color: var(--slate-deep); background: var(--slate-soft); }
.thumb--empty svg { width: 18px; height: 18px; }

.media-preview {
  display: grid; grid-template-columns: minmax(0, 220px) 1fr; gap: 16px;
  align-items: start; padding: 14px; margin-bottom: 18px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: #FCFDFF;
}
.media-preview img, .media-preview video {
  width: 100%; border-radius: var(--r-sm); background: var(--slate-soft); display: block;
}
.media-preview img { height: 140px; object-fit: cover; }
.media-preview__meta { display: grid; gap: 8px; font-size: .84rem; color: var(--ink-2); }
.media-preview__meta strong { font-size: .9rem; color: var(--ink); overflow-wrap: anywhere; }

/* A session row stacks its times above its description. */
.repeat-row--stacked { flex-wrap: wrap; }
.session-row__description { width: 100%; margin: 8px 0 0; }
.session-row__description textarea { min-height: 54px; }
.session-row .booked-badge { align-self: flex-start; margin-top: 26px; }

/* =====================  Registrations  =============================== */

.filters--wrap { flex-wrap: wrap; }
.filters__actions { display: flex; align-items: center; gap: 12px; }
.data--compact td, .data--compact th { padding-top: 9px; padding-bottom: 9px; }
.grid-2--even { grid-template-columns: 1fr 1fr; }
.people-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.people-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-sm); background: #FCFDFF; border: 1px solid var(--line);
}
@media (max-width: 720px) { .grid-2--even { grid-template-columns: 1fr; } }

/* =====================  Activity dates  ============================== */

.repeat--dates { display: grid; gap: 12px; }
.date-block {
  padding: 14px; border-radius: var(--r-md);
  background: var(--slate-soft); border: 1px solid #D6DDEC;
}
.date-block__head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 10px;
}
.date-block__head .field { margin: 0; max-width: 220px; flex: 1; }
.date-block .repeat--nested { gap: 8px; }
.date-block .repeat-row { background: #fff; }
.date-block__add { margin-top: 10px; font-size: .86rem; }

.session-row { position: relative; }
.booked-badge {
  flex: none; align-self: center;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--sun-soft); color: #8A6A0B;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}

/* =====================  Map preview  ================================= */

.map-preview { display: grid; gap: 10px; justify-items: start; margin-top: 4px; }
.map-preview iframe {
  width: 100%; height: 280px; border: 1px solid var(--line-strong);
  border-radius: var(--r-md); background: var(--slate-soft);
}

/* =====================  Multi-choice sets  =========================== */

.choice-set { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.choice-set legend { padding: 0; }
.choice-set__bar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.choice-set__bar .hint { margin: 0; }
.choice-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px;
  max-height: 280px; overflow-y: auto; padding: 2px;
}
.choice {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: .88rem; cursor: pointer; background: #fff;
  transition: border-color .15s ease, background .15s ease;
}
.choice input { accent-color: var(--slate); width: 16px; height: 16px; flex: none; margin: 0; }
.choice span { min-width: 0; overflow-wrap: anywhere; }
.choice:hover { border-color: var(--slate); }
.choice:has(input:checked) { background: var(--slate-soft); border-color: var(--slate); font-weight: 600; }
.choice-set[aria-invalid=true] .choice-grid { outline: 1px solid var(--coral); outline-offset: 4px; border-radius: var(--r-sm); }

.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag--more { background: var(--slate-soft); color: var(--slate-deep); }
.tag--lang { background: var(--sun-soft); color: #8A6A0B; }
.tag--type { background: var(--sage-soft); color: #5C7A38; }
.tag--code { background: var(--slate-soft); color: var(--slate-deep); font-family: var(--font-body); text-transform: uppercase; letter-spacing: .03em; }
.choice__code {
  display: inline-block; margin-left: 4px; padding: 1px 6px;
  border-radius: var(--r-pill); background: var(--slate-soft);
  color: var(--slate-deep); font-size: .72rem; text-transform: uppercase;
}
.choice:has(input:checked) .choice__code { background: #fff; }

/* =====================  Permission matrix  =========================== */

.perm-group { border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 16px; overflow: hidden; }
.perm-group__head {
  background: var(--slate-soft); padding: 11px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.perm-group__head h3 { font-size: .95rem; }
.perm-module { padding: 14px 16px; border-top: 1px solid var(--line); }
.perm-module:first-of-type { border-top: 0; }
.perm-module__name { font-family: var(--font-display); font-weight: 700; font-size: .88rem; margin-bottom: 8px; }
.perm-list { display: flex; flex-wrap: wrap; gap: 8px; }
.perm-item {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  padding: 7px 14px 7px 11px; font-size: .84rem; cursor: pointer; background: #fff;
  transition: border-color .15s ease, background .15s ease;
}
.perm-item input { accent-color: var(--slate); width: 15px; height: 15px; }
.perm-item:hover { border-color: var(--slate); }
.perm-item:has(input:checked) { background: var(--slate-soft); border-color: var(--slate); font-weight: 600; }

/* =====================  Tables  ====================================== */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 13px 16px; text-align: left; vertical-align: middle; }
table.data thead th {
  font-family: var(--font-display); font-weight: 700; font-size: .82rem;
  color: var(--ink-2); background: #FAFBFD; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr { border-bottom: 1px solid var(--line); }
table.data tbody tr:last-child { border-bottom: 0; }
table.data tbody tr:hover { background: #FAFBFE; }
table.data td.num { font-variant-numeric: tabular-nums; color: var(--ink-3); }
table.data td.right, table.data th.right { text-align: right; }
.th-sort { color: inherit; display: inline-flex; gap: 5px; align-items: center; }
.th-sort.is-sorted { color: var(--slate); }

.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: .8rem; color: var(--ink-3); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: var(--r-pill);
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--live { background: var(--sage-soft); color: #5C7A38; }
.pill--paused { background: #F0F2F7; color: var(--ink-2); }
.pill--role { background: var(--slate-soft); color: var(--slate-deep); }
.pill--role::before { display: none; }
.pill--system { background: var(--sun-soft); color: #8A6A0B; }
.pill--paid { background: var(--sun-soft); color: #8A6A0B; }
.pill--paid::before { display: none; }
.pill--free { background: var(--slate-soft); color: var(--slate-deep); }
.pill--free::before { display: none; }
/* Published, but held back until its publish date. */
.pill--draft { background: var(--sun-soft); color: #8A6A0B; }
.pill--system::before { display: none; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--coral-soft); color: #B2545E; font-size: .74rem; font-weight: 600;
}

.empty { padding: 56px 24px; text-align: center; }
.empty__ring {
  width: 64px; height: 64px; border-radius: 50%; border: 10px solid var(--slate-soft);
  margin: 0 auto 16px;
}
.empty h3 { font-size: 1.05rem; }
.empty p { color: var(--ink-2); margin: 6px auto 18px; max-width: 44ch; }

/* =====================  Pagination  ================================== */

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.pager__count {
  font-size: .84rem; color: var(--ink-2);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.pager__sizes { display: inline-flex; align-items: center; gap: 2px; }
.pager__sizes a, .pager__sizes .is-current {
  min-width: 30px; height: 28px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-sm); font-size: .8rem; color: var(--ink-2);
}
.pager__sizes a:hover { background: var(--slate-soft); color: var(--slate-deep); text-decoration: none; }
.pager__sizes .is-current { background: var(--slate-soft); color: var(--slate-deep); font-weight: 700; }
.pager__sizes-label { margin-left: 4px; color: var(--ink-3); font-size: .78rem; }
.pager__links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager__links a, .pager__links span {
  min-width: 36px; height: 36px; padding: 0 10px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: .86rem; color: var(--ink-2); background: #fff;
}
.pager__links a:hover { border-color: var(--slate); color: var(--slate); text-decoration: none; }
.pager__links .is-current { background: var(--slate); border-color: var(--slate); color: #fff; font-weight: 700; }
.pager__links .is-disabled { opacity: .45; }

/* =====================  Flash messages  ============================== */

.flash-stack { display: grid; gap: 10px; margin-bottom: 20px; }
.flash {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; border-radius: var(--r-md);
  border: 1px solid; font-size: .9rem;
}
.flash__close { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; font-size: 1.1rem; line-height: 1; padding: 0 2px; }
.flash--success { background: var(--sage-soft); border-color: #C6DFA6; color: #4E6B2E; }
.flash--danger  { background: var(--coral-soft); border-color: #F3C4C9; color: #A8454F; }
.flash--warning { background: var(--sun-soft); border-color: #F6DE9A; color: #856512; }
.flash--info    { background: var(--slate-soft); border-color: #C9D3EA; color: var(--slate-deep); }

/* =====================  Activity feed / meta  ======================== */

.feed { display: grid; gap: 2px; }
.feed__item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.feed__item:last-child { border-bottom: 0; }
.feed__dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--slate); }
.feed__dot--create { background: var(--sage); }
.feed__dot--update { background: var(--slate); }
.feed__dot--delete { background: var(--coral); }
.feed__dot--login  { background: var(--sun); }
.feed__text { font-size: .88rem; }
.feed__meta { font-size: .76rem; color: var(--ink-3); }

.meta-list { display: grid; gap: 10px; font-size: .85rem; }
.meta-list div { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.meta-list dt, .meta-list .k { color: var(--ink-3); }
.meta-list dd, .meta-list .v { margin: 0; font-weight: 600; text-align: right; }

.bar-row { display: grid; gap: 6px; margin-bottom: 14px; }
.bar-row__top { display: flex; justify-content: space-between; font-size: .85rem; }
.bar-track { height: 9px; border-radius: var(--r-pill); background: var(--slate-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-pill); background: var(--coral); }

/* =====================  Error pages  ================================= */

.state-page { max-width: 480px; margin: 8vh auto; text-align: center; padding: 0 20px; }
.state-page__code { font-family: var(--font-display); font-weight: 800; font-size: 4.5rem; color: var(--slate); line-height: 1; }
.state-page h1 { font-size: 1.5rem; margin: 8px 0 10px; }
.state-page p { color: var(--ink-2); }

/* =====================  Responsive  ================================== */

.rail__scrim { display: none; }

/* =====================================================================
   Rich text editor (e-magazine description)
   The toolbar ships hidden and the plain textarea visible; editor.js
   swaps them, so the form still works with JavaScript off.
   ===================================================================== */
.editor {
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden; margin-bottom: 6px;
}
.editor__bar {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px;
  background: #FCFDFF; border-bottom: 1px solid var(--line);
}
.editor__group {
  display: flex; gap: 2px; padding-right: 6px;
  border-right: 1px solid var(--line);
}
.editor__group:last-child { border-right: 0; padding-right: 0; }

.editor__btn {
  min-width: 32px; height: 32px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2);
  font-family: var(--font-body); font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.editor__btn:hover { background: var(--slate-soft); color: var(--slate-deep); }
.editor__btn:focus-visible { outline: 2px solid var(--slate); outline-offset: 1px; }
.editor__btn.is-on { background: var(--slate); color: #fff; border-color: var(--slate-deep); }
.editor__btn svg { width: 15px; height: 15px; }

/* The native colour input is the swatch: the letter sits on top of it. */
.editor__colour {
  position: relative; width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 700; font-size: .82rem; cursor: pointer;
}
.editor__colour:hover { background: var(--slate-soft); }
.editor__colour span { pointer-events: none; }
.editor__colour input {
  position: absolute; inset: auto 0 2px 0; height: 4px; width: 22px;
  margin: 0 auto; padding: 0; border: 0; background: none; cursor: pointer;
}
.editor__colour--fill span { font-size: .7rem; }

.editor__area {
  min-height: 300px; max-height: 60vh; overflow-y: auto;
  padding: 18px 20px; font-size: .95rem; line-height: 1.75; color: var(--ink);
}
.editor__area:focus { outline: 0; box-shadow: inset 0 0 0 2px var(--slate-soft); }
.editor__area > :first-child { margin-top: 0; }
.editor__area p, .editor__area ul, .editor__area ol, .editor__area blockquote { margin: 0 0 1em; }
.editor__area h1, .editor__area h2, .editor__area h3,
.editor__area h4, .editor__area h5, .editor__area h6 {
  font-family: var(--font-display); line-height: 1.3; margin: 1.4em 0 .5em;
}
.editor__area h2 { font-size: 1.25rem; }
.editor__area h3 { font-size: 1.08rem; }
.editor__area ul, .editor__area ol { padding-left: 1.4em; }
.editor__area blockquote {
  padding: 2px 0 2px 16px; border-left: 3px solid var(--sun);
  color: var(--ink-2); font-style: italic;
}
.editor__area img { max-width: 100%; height: auto; border-radius: var(--r-sm); margin: 6px 0; }
.editor__area a { color: var(--slate); text-decoration: underline; }
.editor__area table { border-collapse: collapse; width: 100%; margin: 0 0 1em; }
.editor__area th, .editor__area td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.editor__area pre {
  background: var(--slate-soft); padding: 12px 14px; border-radius: var(--r-sm);
  overflow-x: auto; font-size: .86rem;
}

.editor__foot {
  padding: 8px 12px; border-top: 1px solid var(--line); background: #FCFDFF;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.editor__foot .hint.is-error { color: #A8454F; }
/* Opened by the toolbar's image button; never shown. */
.editor__file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.editor__store { font-family: var(--font-body); font-size: .88rem; }
.editor__store--hidden { display: none; }

@media (max-width: 720px) {
  .editor__group { border-right: 0; padding-right: 0; }
  .editor__area { min-height: 220px; padding: 14px; }
}

@media (max-width: 1080px) {
  .grid-2, .grid-halves { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-pop);
  }
  body.nav-open .rail { transform: translateX(0); }
  body.nav-open .rail__scrim {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(35,43,62,.45);
  }
  .burger { display: block; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .account__text { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth__brand { display: none; }
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .date-block__head { flex-direction: column; align-items: stretch; }
  .date-block__head .field { max-width: none; }
  .doodle-grid { grid-template-columns: 1fr; }
  .media-preview { grid-template-columns: 1fr; }
  .repeat-row { flex-direction: column; align-items: stretch; }
  .repeat-row__fields--three { grid-template-columns: 1fr; gap: 0; }
  .repeat-row .field { margin-bottom: 12px; }
  .repeat-row__remove { align-self: flex-end; }
  .tabs { padding: 0 8px; }
  .tab { padding: 12px 10px; font-size: .86rem; }
  .segmented { width: 100%; }
  .segmented__option { flex: 1; }
  .segmented__option span { text-align: center; padding: 10px 8px; }
  .topbar h1 { font-size: 1.1rem; }
  .stat__value { font-size: 1.8rem; }

  /* Tables restack as labelled rows */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    border: 1px solid var(--line); border-radius: var(--r-md);
    margin-bottom: 12px; padding: 6px 4px; background: #fff;
  }
  table.data td {
    padding: 8px 14px; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; text-align: right; flex-wrap: wrap;
  }
  table.data td.right { width: auto; padding-left: 14px; }
  table.data .tag-row { justify-content: flex-end; }
  table.data td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--ink-3); font-size: .8rem; text-align: left; flex: none;
  }
  table.data td.right { text-align: right; }
  .row-actions { justify-content: flex-end; }
  .pager { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .rail, .topbar__actions, .filters, .row-actions, .pager__links, .burger { display: none !important; }
  body { background: #fff; }
  .panel { border: 0; box-shadow: none; }
}
