/* ==========================================================================
   CYD Club Members area (loaded after styles.css, reuses its color tokens)
   A working tool: calmer than the public site, same family.
   ========================================================================== */

:root {
  --panel: #ffffff;
  --canvas: #f6f5fa;
  --ok: #2f7d32;
  --ok-bg: #e9f5ea;
  --warn-bg: #fff6de;
  --warn: #8a5a00;
  --bad-bg: #fdecea;
  --muted: #6d6780;
}

body.members { background: var(--canvas); font-size: 1rem; }

/* ---------- Top bar ---------- */
.m-topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.m-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
}
.m-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--purple);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
}
.m-brand img { width: 46px; height: auto; }
.m-user { display: flex; align-items: center; gap: 14px; font-size: 0.92rem; }
.m-user a { color: var(--ink); font-weight: 700; }
.m-user form { margin: 0; }
.role-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--tint-lime);
  color: var(--green-text);
}
.role-chip.admin { background: #efe4f6; color: var(--purple); }

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Shell ---------- */
.m-shell {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 1200px;
  margin: 0 auto;
}
@media (min-width: 880px) {
  .m-shell { grid-template-columns: 220px 1fr; gap: 28px; padding: 24px 20px 48px; }
}

.m-nav { padding: 12px 16px; }
@media (min-width: 880px) { .m-nav { padding: 0; position: sticky; top: 24px; align-self: start; } }
.m-nav-group { margin-bottom: 18px; }
.m-nav-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px 10px;
}
.m-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
@media (max-width: 879px) {
  .m-nav { display: flex; gap: 18px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--panel); }
  .m-nav-group { margin: 0; display: flex; align-items: center; gap: 4px; }
  .m-nav-label { margin: 0 4px 0 0; }
  .m-nav ul { display: flex; }
}
.m-nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.m-nav a:hover { background: #ece9f3; }
.m-nav a[aria-current="page"] { background: var(--purple); color: #fff; }
.count-badge {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}
.count-badge.bad { background: var(--error); color: #fff; }

.m-main { padding: 20px 16px 48px; min-width: 0; }
@media (min-width: 880px) { .m-main { padding: 0; } }

.m-title { font-size: clamp(1.6rem, 3vw, 2rem); color: var(--purple); margin: 0 0 6px; }
.m-intro { color: var(--muted); margin: 0 0 22px; max-width: 70ch; }

/* ---------- Panels, flash, forms ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}
.panel h2 { font-size: 1.2rem; margin: 0 0 12px; color: var(--ink); }

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-weight: 700;
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid #cfe8d1;
}
.flash.error { background: var(--bad-bg); color: var(--error); border-color: #f5c6c1; }

.m-form { display: grid; gap: 14px; max-width: 560px; }
.m-form .field { margin: 0; }
.m-form .field-error { min-height: 0; margin: 4px 0 0; }
.inline-fields { display: grid; gap: 12px; }
@media (min-width: 640px) { .inline-fields { grid-template-columns: 1fr 1fr 180px auto; align-items: end; } }
.hint { font-size: 0.875rem; color: var(--muted); margin: 4px 0 0; }
.checkbox { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; }
.checkbox input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--purple); }

.btn-small { min-height: 36px; padding: 6px 14px; font-size: 0.875rem; box-shadow: none; }

/* Members area: tighter buttons than the public site's big, kid-friendly ones */
body.members .btn { min-height: 40px; padding: 7px 18px; font-size: 0.95rem; }
body.members .btn-purple { box-shadow: 0 3px 0 var(--purple-deep); }
body.members .btn-small { min-height: 32px; padding: 4px 12px; font-size: 0.85rem; }
.btn-plain { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn-plain:hover { border-color: var(--purple); }
.btn-danger { background: #fff; color: var(--error); border: 2px solid #f0b8b2; }
.btn-danger:hover { background: var(--bad-bg); }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions-row form { margin: 0; }

textarea.filters-box {
  width: 100%;
  min-height: 220px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ---------- Stats ---------- */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.stat-num { display: block; font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1.1; color: var(--purple); font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

/* ---------- Tabs + tables ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.9rem;
}
.tab[aria-current="page"] { border-color: var(--purple); background: var(--purple); color: #fff; }
.search { display: flex; gap: 8px; margin-left: auto; }
.search input { border: 2px solid var(--line); border-radius: 999px; padding: 7px 14px; font: inherit; min-width: 0; width: 220px; }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: #faf9fc; }
table.data tr:last-child td { border-bottom: none; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data select {
  font: inherit;
  font-size: 0.9rem;
  padding: 5px 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
table.data a.row-link { color: var(--ink); font-weight: 800; text-decoration: none; }
table.data a.row-link:hover { color: var(--purple); text-decoration: underline; }
.snippet { color: var(--muted); display: block; max-width: 48ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 800; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--error); }
.chip.muted { background: #eeecf3; color: var(--muted); }

.empty { padding: 28px; text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 0.9rem; color: var(--muted); }
.pager a { font-weight: 800; color: var(--blue); }

/* ---------- Message detail ---------- */
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 18px; }
.meta-list dt { font-weight: 800; color: var(--muted); }
.meta-list dd { margin: 0; overflow-wrap: anywhere; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; background: #faf9fc; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 18px; line-height: 1.6; }
.back-link { display: inline-block; margin-bottom: 12px; font-weight: 700; color: var(--blue); }

/* ---------- Auth pages (sign in, reset, invitation) ---------- */
body.auth { background: var(--canvas); min-height: 100vh; display: flex; flex-direction: column; }
.auth-wrap { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: 0 18px 40px -28px rgba(30, 22, 54, 0.35);
}
.auth-card .auth-logo { display: block; width: 110px; margin: 0 auto 10px; }
.auth-card h1 { text-align: center; color: var(--purple); font-size: 1.7rem; margin: 0 0 6px; }
.auth-card .auth-sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
.auth-card .m-form { max-width: none; }
.auth-card .btn { width: 100%; }
.auth-links { text-align: center; margin-top: 16px; font-size: 0.92rem; }
.auth-links a { color: var(--blue); font-weight: 700; }
.auth-foot { text-align: center; padding: 16px; font-size: 0.8rem; color: var(--muted); }
.auth-foot a { color: var(--muted); }

.m-foot { padding: 16px 20px 28px; text-align: center; font-size: 0.8rem; color: var(--muted); }

/* ---------- Events ---------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 14px 20px; margin-bottom: 24px; }
.page-head .m-intro { margin-bottom: 0; }
.section-title { font-size: 1.2rem; margin: 34px 0 12px; color: var(--ink); }
.req { color: var(--error); font-weight: 800; }
.delete-note { text-align: right; margin: -8px 0 16px; }

.event-form { max-width: 720px; gap: 18px; }
.event-form fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.event-form legend { font-weight: 800; font-size: 0.95rem; margin-bottom: 6px; padding: 0; }
.field-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .field-grid.three { grid-template-columns: 1.3fr 1fr 1fr; } }

.partner-list { display: grid; gap: 8px; margin-bottom: 8px; }
.partner-row { display: flex; gap: 8px; align-items: center; }
.partner-row input { flex: 1; min-width: 0; }
/* Round ✕ button, centered beside its partner box */
body.members .partner-row .btn-small { flex: 0 0 38px; width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%; font-size: 1rem; line-height: 1; }

.with-suffix { display: flex; align-items: center; gap: 10px; }
.with-suffix input { max-width: 140px; }
.with-suffix .suffix { font-weight: 700; color: var(--muted); }

.counter { display: block; text-align: right; font-size: 0.78rem; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.counter.near { color: var(--warn); font-weight: 800; }

.form-actions { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

.reg-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.reg-details summary { cursor: pointer; }
.reg-details[open] summary { margin-bottom: 8px; }
.meta-list.compact { gap: 3px 12px; margin: 0; font-size: 0.9rem; }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.history > li { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.history > li:last-child { border-bottom: none; padding-bottom: 0; }
.history .hint { display: block; margin: 0 0 2px; }
.history ul { margin: 6px 0 0; padding-left: 20px; font-size: 0.92rem; color: var(--ink-soft); }
.history del { color: var(--muted); }

.confirm-dialog {
  border: none;
  border-radius: 20px;
  padding: 24px;
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 60px -20px rgba(30, 22, 54, 0.5);
  color: var(--ink);
}
.confirm-dialog::backdrop { background: rgba(30, 22, 54, 0.45); }
.confirm-dialog h2 { margin: 0 0 10px; color: var(--error); font-size: 1.4rem; }
.confirm-dialog p { margin: 0 0 12px; }

.confirm-dialog.friendly h2 { color: var(--purple); }

/* Automatic reminders on the event form */
.reminders-field { display: grid; gap: 8px; }
.reminders-field .checkbox .hint { font-weight: 400; margin-left: 4px; }

/* Emails to families: panel on the event page, the "let families know?" page, and one send's recipients */
.email-result { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.email-note { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.email-preview { background: #faf9fd; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 0 0 16px; }
.email-preview .subject { font-weight: 800; margin: 0 0 8px; }
.email-preview pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 0.92rem; color: var(--ink-soft); }
.change-list { margin: 0 0 16px; padding-left: 20px; }
.change-list del { color: var(--muted); }
.budget-note { background: var(--warn-bg); color: var(--ink); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-size: 0.92rem; }
.family-emails { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.family-emails li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form { display: inline; margin: 0; }

.event-form [data-add-partner] { align-self: flex-start; }
.search.wide input { width: min(100%, 320px); }

.btn[disabled], .btn[disabled]:hover {
  opacity: 0.45;
  cursor: not-allowed;
  background: #fff;
  transform: none;
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .m-topbar-inner { padding: 8px 14px; }
  .m-brand { font-size: 1rem; gap: 8px; }
  .m-brand img { width: 36px; }
  .m-user { gap: 10px; font-size: 0.85rem; }
  .m-user .m-user-name, .m-user .role-chip { display: none; }   /* name and role are on the Account page */
  .m-brand, .m-user a, .m-user .link-button { white-space: nowrap; }

  .meta-list { grid-template-columns: 1fr; gap: 0; }
  .meta-list dt { margin-top: 10px; font-size: 0.85rem; }
  .meta-list dt:first-child { margin-top: 0; }

  .page-head .actions-row { width: 100%; }
  .delete-note { text-align: left; margin-top: 0; }

  /* Tables become one card per row, each value labeled */
  table.data.stack thead { display: none; }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data.stack tr:last-child { border-bottom: none; }
  /* Label sits in a fixed column on the left; the value flows normally beside it */
  table.data.stack td { border: none; padding: 3px 0 3px 106px; position: relative; text-align: left; white-space: normal; }
  table.data.stack td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 5px;
    width: 96px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--muted);
  }
  table.data.stack td.stack-head { padding: 0 0 6px; font-size: 1.02rem; }
  table.data.stack td.stack-head::before { content: none; }
  table.data.stack td.num { text-align: left; }
}

/* ---------- Flyers in the members area ---------- */
.with-thumb { display: flex; align-items: center; gap: 12px; }
.flyer-current { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 12px; }
.flyer-current a { margin-left: 8px; font-weight: 700; }
.details-grid { display: grid; gap: 18px; }
@media (min-width: 900px) { .details-grid.has-flyer { grid-template-columns: 1fr 240px; align-items: start; } }
@media (max-width: 899px) { .details-grid .flyer { max-width: 200px; } }

.upcoming-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.upcoming-list li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }

/* Read by screen readers, not shown on screen */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Website content screens (Leadership, Donation details, Partners & links) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.leader-table input { width: 100%; min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.add-row, .section-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.add-row input, .section-form input:not([type=checkbox]) { flex: 1 1 200px; min-width: 0; }
.section-edit { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.section-edit .section-form { flex: 1 1 520px; margin-top: 0; }
.section-name { font-weight: 800; font-size: 1.1rem; }
.link-admin-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; }
.link-admin { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 8px; }
.link-admin.broken { border-color: var(--error); background: #fffafa; }
.link-admin.hidden-link { opacity: 0.75; }
.link-admin .chip { justify-self: start; white-space: normal; }
.link-admin-form { display: grid; gap: 8px; }
.link-admin-form input:not([type=checkbox]), .link-admin-form textarea, .link-admin-form select { width: 100%; min-width: 0; }
.link-admin-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.link-admin-bar select { width: auto; }
.add-link summary { cursor: pointer; font-weight: 800; color: var(--purple); }
.add-link[open] summary { margin-bottom: 10px; }
.wide-form { max-width: 760px; }
.form-section { border: 0; padding: 0; margin: 0 0 10px; display: grid; gap: 10px; min-width: 0; }
.form-section legend { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; color: var(--purple); margin-bottom: 4px; padding: 0; }
.flash.warn-note { background: var(--warn-bg); color: var(--ink); border-color: #f1d9a0; }
.volunteer-answers { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }

/* Inline fields on the Leadership and Links screens: the site's input style, a bit more compact */
.leader-table input, .add-row input, .section-form input:not([type=checkbox]),
.link-admin-form input:not([type=checkbox]), .link-admin-form textarea, .link-admin-form select {
  font: inherit; font-size: 0.95rem; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; min-height: 40px;
}
.link-admin-form textarea { resize: vertical; min-height: 60px; }
.leader-table input:focus, .add-row input:focus, .section-form input:focus,
.link-admin-form input:focus, .link-admin-form textarea:focus, .link-admin-form select:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(107, 35, 148, 0.18);
}
.section-form .section-name { font-weight: 800; font-size: 1.05rem; }
.section-form .checkbox, .link-admin-bar .checkbox { flex: 0 1 auto; align-items: center; font-size: 0.92rem; }
.section-form .checkbox .hint { font-weight: 400; }
.leader-table td { vertical-align: middle; }

/* ---------- Error log ---------- */
.slack-hint { margin: -8px 0 16px; }
.error-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.error-filters select, .error-filters input[type=search] { font: inherit; font-size: 0.95rem; border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; min-height: 40px; background: #fff; }
.error-table td:first-child, .error-table th:first-child { width: 36px; }
.error-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--purple); }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.bulk-bar input { flex: 1 1 260px; min-width: 0; font: inherit; font-size: 0.95rem; border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; min-height: 40px; }
.error-message { font-weight: 800; font-size: 1.05rem; margin: 0 0 14px; overflow-wrap: anywhere; }
.error-context { margin-top: 12px; }
.error-context summary { cursor: pointer; font-weight: 800; color: var(--purple); }
.error-context pre { white-space: pre-wrap; word-break: break-word; background: #faf9fd; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 0.85rem; }
.wrap-anywhere { overflow-wrap: anywhere; }
.count-badge.alert { background: var(--error); color: #fff; }

/* ---------- Messages: unread, replies ---------- */
.message-table tr.unread td { background: #fbf8ff; }
.message-table tr.unread .row-link { font-weight: 900; }
.unread-dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--purple); vertical-align: middle; }
.tabs .count-badge { margin-left: 4px; }
.reply-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.reply-list > li { border-top: 1px solid var(--line); padding-top: 12px; }
.reply-list > li:first-child { border-top: 0; padding-top: 0; }
.reply-meta { margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.92rem; color: var(--ink-soft); }
.reply-subject { margin: 0 0 6px; font-weight: 800; }
.compose-meta { margin-bottom: 8px; }
/* Messages list: a two-line preview, so the Status and Delete columns fit */
.message-table .snippet { max-width: 34ch; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.message-table td { vertical-align: top; }
.message-table td.row-actions { display: table-cell; white-space: nowrap; text-align: right; }
