/* ==========================================================================
   BSC dashboard: the pieces the website doesn't have.
   Reads every colour from the tokens in brand.css, so light and dark both work.
   Mobile first.
   ========================================================================== */

/* ---------- App shell ---------- */
body.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.app-main {
  flex: 1 0 auto;
  padding-block: clamp(20px, 4vw, 40px) 72px;
}
/* Page kickers are small text: Club Red fails AA on the dark grounds, so use the accent text token
   (#ff6b57 at night, still Club Red by day). */
.app .kicker.accent {
  color: var(--accent-text);
}
.app-foot {
  padding-block: 8px 28px;
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.app-header {
  position: relative;
  z-index: 40;
  background: var(--header-bg);
  color: var(--text);
  border-bottom: 2px solid var(--line);
}
@media (min-width: 900px) {
  .app-header {
    position: sticky;
    top: 0;
    -webkit-backdrop-filter: saturate(1.3) blur(10px);
    backdrop-filter: saturate(1.3) blur(10px);
  }
}
.app-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding-block: 10px;
}
.app-brand {
  flex: none;
  display: block;
  width: clamp(118px, 30vw, 168px);
  line-height: 0;
  border-radius: 8px;
}
.app-brand .logo {
  width: 100%;
  height: auto;
}
.logo .lg-l {
  fill: var(--logo-fg);
}
.logo .lg-d1 {
  fill: var(--logo-d1);
}
.logo .lg-d2 {
  fill: var(--logo-d2);
}
.app-tag {
  flex: none;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: var(--sun);
  color: var(--ink);
  font: 800 0.7rem / 1 var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: rotate(-3deg);
}

/* nav pills: a second row on phones (scrolls inside itself, never the page), inline on desktop */
.app-nav {
  order: 3;
  flex: 1 1 100%;
  min-width: 0;
}
.nav-pills {
  list-style: none;
  margin: -6px;
  padding: 6px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.nav-pills::-webkit-scrollbar {
  display: none;
}
.nav-pills li {
  flex: none;
}
.nav-pills li:last-child {
  padding-inline-end: 22px;
}
.nav-pills a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font: 800 0.8rem / 1 var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px var(--line);
}
.nav-pills a:hover {
  box-shadow: inset 0 0 0 2px var(--text);
}
.nav-pills a[aria-current="page"] {
  background: var(--text);
  color: var(--surface);
  box-shadow: none;
}
@media (min-width: 900px) {
  .app-nav {
    order: 1;
    flex: 1 1 auto;
  }
  .nav-pills {
    -webkit-mask: none;
    mask: none;
    flex-wrap: wrap;
    overflow: visible;
  }
  .nav-pills li:last-child {
    padding-inline-end: 0;
  }
}

.app-user {
  order: 1;
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 240px;
  padding: 3px 12px 3px 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 2px var(--line);
  font-weight: 700;
  font-size: 0.9rem;
}
.user-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.user-initial {
  display: grid;
  place-items: center;
  background: var(--club-red);
  color: var(--sand);
  font: 800 0.95rem / 1 var(--font-display);
}
.user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role {
  flex: none;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--surface);
  font: 800 0.62rem / 1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
@media (min-width: 900px) {
  .app-user {
    order: 2;
  }
}
.logout-form {
  margin: 0;
}
.btn-logout .icon {
  width: 16px;
  height: 16px;
}
@media (max-width: 560px) {
  .user-name,
  .user-role {
    display: none;
  }
  .user-chip {
    padding: 3px;
  }
  .btn-logout span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .btn-logout {
    width: 40px;
    padding: 0;
  }
}
@media (max-width: 340px) {
  .app-tag {
    display: none;
  }
}

/* ---------- Page furniture ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: clamp(18px, 3vw, 30px);
}
.page-head-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 820px;
}
.page-title {
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}
.page-head .lead {
  color: var(--text-muted);
}

.section-title {
  font-size: clamp(1.35rem, 3.4vw, 1.9rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}
.panel {
  background: var(--surface-raised);
  color: var(--text);
  border: 2.5px solid var(--text);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 3.4vw, 28px);
  min-width: 0;
}
.panel + .panel,
.stat-grid + .panel,
.panel + .save-bar,
.save-bar + .panel,
form + .panel,
.alert + .panel,
.search-wrap + .panel {
  margin-top: clamp(16px, 2.6vw, 24px);
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 18px;
}
.panel-head-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 70ch;
}
.flash {
  margin-bottom: 20px;
}
.hint code,
.audit-target code,
.health-foot code,
.alert-body code {
  font: 600 0.85em / 1 var(--font-mono);
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 2.5px solid var(--text);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  font: 800 0.85rem / 1 var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover {
  background: var(--text);
  color: var(--surface);
}
.btn .icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.76rem;
}
.btn-solid {
  background: var(--club-red);
  border-color: var(--club-red);
  color: var(--sand);
}
.btn-solid:hover {
  background: var(--club-red-dark);
  border-color: var(--club-red-dark);
  color: var(--sand);
}
.btn:disabled,
.btn.is-disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.is-disabled:hover,
.btn:disabled:hover {
  background: transparent;
  color: var(--text);
}
.btn.is-busy {
  cursor: progress;
  opacity: 0.7;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
svg.icon {
  max-width: none;
}
.icon {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Inputs the website doesn't use ---------- */
.search-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 2.5px solid var(--text);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 500 1rem / 1.4 var(--font-text);
}
.panel .form input[type="text"],
.panel .form select,
.panel .form textarea {
  background: var(--surface);
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 18px 22px;
  margin-bottom: 18px;
}
.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}
@media (min-width: 640px) {
  .add-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .add-row .btn {
    margin-bottom: 0;
  }
}
.add-row .field .hint {
  order: 3;
}
.staff-list + .form {
  margin-top: 18px;
}

/* pick several */
.check-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 12px 14px;
  border: 2.5px solid var(--text);
  border-radius: 12px;
  background: var(--surface);
}
.check[hidden] {
  display: none;
}

/* template preview */
.preview {
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview .mention {
  color: var(--teal-text);
  font-weight: 700;
}
.preview-wrap {
  display: grid;
  gap: 8px;
}
.preview-wrap[hidden] {
  display: none;
}

/* a table of rows to add to and take away from */
.rows-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.rows-table th {
  text-align: start;
  font-weight: 800;
  padding-bottom: 6px;
}
.rows-table td {
  padding: 4px 8px 4px 0;
}
.rows-table td:last-child {
  padding-inline-end: 0;
  width: 1%;
}
.rows-table + template + .btn-row {
  margin-bottom: 18px;
}
.panel .form input.emoji-box,
.panel .form input.level-box {
  width: 5.5rem;
}

/* the public leaderboard */
.board-number {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rows-table th.board-number {
  text-align: end;
}
.board-who {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-wrap: anywhere;
}

/* the time picker, which the website doesn't use */
.form input[type="time"] {
  min-height: 52px;
  padding: 8px 12px;
  border: 2.5px solid var(--text);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 500 1.0625rem / 1.4 var(--font-text);
}

/* the embed editor's fields */
.embed-rows {
  display: grid;
  gap: 14px;
}
.embed-rows:empty {
  display: none;
}
.embed-row {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
}
.form .embed-row textarea {
  min-height: 84px;
}
.embed-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* the embed preview. The colour comes from the form, and the page only ever shows text here. */
.embed-preview {
  display: grid;
  gap: 8px;
  overflow-wrap: anywhere;
}
.embed-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-inline-start-width: 6px;
  border-radius: 12px;
  background: var(--surface);
}
.embed-content,
.embed-text {
  white-space: pre-wrap;
}
.embed-author,
.embed-field-name {
  font-weight: 800;
  font-size: 0.875rem;
}
.embed-title {
  font-weight: 800;
}
.embed-picture,
.embed-footer {
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.embed-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.embed-fields:empty {
  display: none;
}
.embed-field {
  grid-column: 1 / -1;
}
.embed-field.is-inline {
  grid-column: auto;
}

/* logs */
.log-tabs {
  margin-bottom: 18px;
}
.log-lines {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
}
.log-label {
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}
.log-value {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.log-pager {
  margin-top: 16px;
}

/* search */
search.search-wrap {
  display: block;
}
.search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.search-box {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
}
.search-box .icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-box .search-input {
  padding-inline-start: 42px;
}
.search-input::-webkit-search-cancel-button {
  cursor: pointer;
}
.search-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* sticky save bar at the bottom of long forms */
.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 18px;
  margin-inline: calc(var(--gutter) * -1);
  padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--header-bg);
  border-top: 2px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.save-hint {
  font-weight: 700;
  color: var(--text);
}

/* ---------- Stat tiles ---------- */
.stat-grid {
  list-style: none;
  margin: 0 0 clamp(18px, 3vw, 28px);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 820px) {
  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
  }
}
.stat-grid > li {
  display: flex;
  min-width: 0;
}
.stat {
  --st: var(--club-red);
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 26px 14px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  border: 2.5px solid var(--text);
  box-shadow: 5px 6px 0 var(--st);
  text-decoration: none;
  overflow: hidden;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 11px;
  background: var(--st);
  border-bottom: 2.5px solid var(--text);
}
.stat-label {
  font: 800 0.78rem / 1.15 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat-hint {
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--text-muted);
}
.stat-value {
  font: 800 clamp(1.15rem, 3.6vw, 1.5rem) / 1.05 var(--font-display);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.stat-status.is-ok {
  --st: var(--gulf-teal);
}
.stat-status.is-warn {
  --st: var(--sun);
}
.stat-status.is-error {
  --st: var(--club-red);
}
.stat-status.is-info {
  --st: var(--line);
}
@media (max-width: 360px) {
  .stat {
    padding-inline: 10px;
  }
  .stat-hint {
    font-size: 0.8rem;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 2px solid currentColor;
  background: transparent;
  color: var(--text);
  font: 800 0.7rem / 1.1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid;
  color: var(--text);
  line-height: 1.45;
}
.alert + .alert {
  margin-top: 12px;
}
.alert-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.alert-title {
  font: 800 1rem / 1.2 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.alert-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin-top: -1px;
}
.alert-icon .icon {
  width: 16px;
  height: 16px;
  stroke-width: 3;
}
.alert-ok {
  background: rgba(14, 116, 112, 0.1);
  border-color: var(--gulf-teal);
}
.alert-ok .alert-icon {
  background: var(--gulf-teal);
  color: var(--sand);
}
.alert-warn {
  background: rgba(255, 200, 61, 0.2);
  border-color: var(--sun);
}
.alert-warn .alert-icon {
  background: var(--sun);
  color: var(--ink);
}
.alert-error {
  background: rgba(210, 38, 25, 0.09);
  border-color: var(--accent-text);
}
.alert-error .alert-icon {
  background: var(--accent-text);
  color: var(--surface);
}
.alert-info {
  background: var(--surface);
  border-color: var(--line);
}
.alert-info .alert-icon {
  background: var(--text);
  color: var(--surface);
}
.panel > .alert {
  margin-bottom: 16px;
}
.page-head + .alert,
.alert + .stat-grid {
  margin-bottom: 18px;
}

/* ---------- Pager ---------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--line);
}
.pager-info {
  font-weight: 700;
}
.pager-links {
  display: flex;
  gap: 8px;
}

/* ---------- Health and audit ---------- */
.health-grid .stat {
  padding-top: 24px;
}
.code {
  margin: 6px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  max-width: 100%;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--line);
  font: 500 0.82rem / 1.45 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dead-list .staff-who {
  flex: 1 1 320px;
}
.health-foot {
  margin-top: 18px;
}
.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.audit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 20px;
  padding: 12px 0;
  border-top: 2px solid var(--line);
}
.audit-row:first-child {
  border-top: 0;
  padding-top: 0;
}
.audit-when {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.audit-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.audit-what strong {
  font-weight: 800;
}
.audit-code {
  font-family: var(--font-mono);
  font-size: 0.8em;
}
.audit-extra {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
@media (min-width: 720px) {
  .audit-row {
    grid-template-columns: 200px minmax(0, 1fr);
  }
}

/* ---------- Login and error ---------- */
body.is-login .app-main,
body.is-error .app-main {
  display: grid;
  place-items: center;
}
.login-card,
.error-card {
  width: 100%;
  max-width: 560px;
  display: grid;
  gap: 18px;
  justify-items: start;
}
.login-card .page-title {
  font-size: clamp(2.2rem, 9vw, 3.6rem);
}
.login-note {
  color: var(--accent-text);
  font-size: 1.15rem;
  transform: rotate(-2deg);
}
.error-card {
  padding-block: clamp(20px, 6vw, 60px);
}
.error-code {
  font: 400 clamp(4.5rem, 20vw, 8rem) / 0.8 var(--font-scribble);
  color: var(--accent-text);
}

/* ---------- Dialogs ---------- */
.modal-confirm {
  width: min(460px, calc(100% - 32px));
}
.confirm-body {
  display: grid;
  gap: 14px;
}
.confirm-title {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}
.confirm-text {
  overflow-wrap: anywhere;
}
.confirm-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

/* keep toasts clear of the sticky save bar */
body:has(.save-bar) .toast {
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

/* the Identity page's two saved pictures */
.identity-pictures {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-block-end: 14px;
}
.identity-pictures img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

/* the Forget a member page */
.forget-heading {
  margin-block: 18px 8px;
  font-size: 1.1rem;
}
.forget-list {
  display: grid;
  gap: 8px;
  padding-inline-start: 20px;
  list-style: disc;
}
.panel .forget-list + .btn-row,
.panel .empty-state + .btn-row {
  margin-top: 18px;
}
.panel > .hint + .form {
  margin-top: 12px;
}
