/* Admin, SuperAdmin and auth screens. Rectangular everywhere; angles only on pills and primary buttons. */

.admin main { padding-block: var(--cst-s5) var(--cst-s8); }
.admin-header__name { margin: 0; padding-bottom: var(--cst-s2); color: var(--cst-text); font-weight: 700; overflow-wrap: anywhere; }
.site-header.is-compact .admin-header__name { padding-bottom: var(--cst-s1); font-size: 0.875rem; }

.banner { border: 1px solid var(--cst-warning); background: var(--cst-held-dim); color: var(--cst-text); padding: var(--cst-s3) var(--cst-s4); margin-bottom: var(--cst-s5); }
.banner strong { color: var(--cst-warning); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8125rem; display: block; }
.banner p { margin: 0; }
.flash { border-left: 3px solid var(--cst-success); background: var(--cst-surface); color: var(--cst-text); padding: var(--cst-s3) var(--cst-s4); margin-bottom: var(--cst-s4); }
.flash--error { border-left-color: var(--cst-danger); }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--cst-s4); margin-bottom: var(--cst-s5); }
.page-head h1 { overflow-wrap: anywhere; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: var(--cst-s2); }
.panel { background: var(--cst-surface); border: 1px solid var(--cst-border); padding: var(--cst-s5) var(--cst-s4); margin-bottom: var(--cst-s5); }
.panel h2 { margin-bottom: var(--cst-s4); }
@media (min-width: 768px) { .panel { padding: var(--cst-s5); } }
.stack { display: grid; gap: var(--cst-s4); }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--cst-s2); align-items: center; }
.empty { padding: var(--cst-s6) var(--cst-s4); text-align: center; border: 1px dashed var(--cst-border-strong); }

/* ---------- Tabs ---------- */
/* Folder tabs (CR-014, CR-024): every tab is a bordered tab sitting on a dark rule. The current tab is bold with a
   red top edge and opens into the page below (same background, no bottom rule). No underlines (CR-024).
   Not a scroll box: all five fit at 320px, and a scrollable bar let the current tab's 2px overlap be dragged up and down. */
.tabs {
  display: flex; gap: 3px; margin-bottom: var(--cst-s5); padding: var(--cst-s2) 0 0;
  border-bottom: 2px solid var(--cst-text);
}
.tabs a {
  flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; min-height: var(--cst-tap); padding: 0 var(--cst-s1);
  white-space: nowrap; color: var(--cst-text); font-weight: 600; font-size: 0.8125rem; text-decoration: none;
  background: var(--cst-tab); border: 1px solid var(--cst-border-strong); border-bottom: 0;
}
.tabs a:hover { background: var(--cst-surface); }
.tabs a[aria-current="page"] {
  position: relative; margin-bottom: -2px; background: var(--cst-bg); text-decoration: none; font-weight: 800;
  border: 2px solid var(--cst-text); border-top: 4px solid var(--cst-red); border-bottom: 0;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: var(--cst-s4); }
@media (min-width: 768px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid--3 { grid-template-columns: repeat(3, 1fr); } .span-all { grid-column: 1 / -1; } }
.field { display: grid; gap: var(--cst-s1); min-width: 0; }
.field > label, .field > .label { display: block; }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea {
  width: 100%; min-height: var(--cst-control-h); padding: var(--cst-s2) var(--cst-s3);
  background: var(--cst-surface-3); color: var(--cst-text); border: 1px solid var(--cst-border); border-radius: var(--cst-radius);
  transition: border-color var(--cst-dur-fast) var(--cst-ease), box-shadow var(--cst-dur-fast) var(--cst-ease);
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--cst-red); box-shadow: 0 0 0 3px var(--cst-red-dim); }
.field input[type="file"] { min-height: var(--cst-control-h); padding: var(--cst-s2) 0; color: var(--cst-text-2); }
.field .hint { font-size: 0.8125rem; color: var(--cst-text-2); }
.field-validation-error, .validation-summary-errors, .error { color: var(--cst-danger); font-size: 0.875rem; }
.validation-summary-errors ul { padding: 0; margin: 0; }
.validation-summary-valid { display: none; }
.input-validation-error { border-color: var(--cst-danger) !important; }
.check { display: flex; align-items: center; gap: var(--cst-s3); min-height: var(--cst-tap); color: var(--cst-text); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--cst-red); flex: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] { opacity: 0.6; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--cst-s2); margin-top: var(--cst-s5); }
.inline-form { display: inline; margin: 0; }

/* ---------- Data tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--cst-border); background: var(--cst-surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th {
  text-align: left; padding: var(--cst-s3); border-bottom: 1px solid var(--cst-border-strong); white-space: nowrap;
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cst-text-2);
}
.table td { padding: var(--cst-s3); border-bottom: 1px solid var(--cst-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table a { font-weight: 600; }
.neg { color: var(--cst-held); }

/* Responsive list-tables: stack rows into labelled cards below 768px */
@media (max-width: 767.98px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { border-bottom: 1px solid var(--cst-border); padding: var(--cst-s2) 0; }
  .table--stack td { border: 0; padding: var(--cst-s1) var(--cst-s3); display: flex; justify-content: space-between; gap: var(--cst-s3); }
  .table--stack td[data-label]::before { content: attr(data-label); font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cst-text-2); }
  .table--stack td.r { text-align: right; }
}

/* ---------- Summary chips ---------- */
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--cst-s2); margin-bottom: var(--cst-s4); }
@media (min-width: 768px) { .chips { grid-template-columns: repeat(6, 1fr); } }
.chip {
  display: grid; gap: 2px; padding: var(--cst-s2) var(--cst-s3); background: var(--cst-surface); border: 1px solid var(--cst-border);
  text-decoration: none; min-height: 56px; border-top: 5px solid var(--cst-border-strong);
}
.chip b { font-size: 1.5rem; font-weight: 900; font-stretch: 62%; color: var(--cst-text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.chip--available { border-top-color: var(--cst-available); }
.chip--held { border-top-color: var(--cst-held); }
.chip--sold { border-top-color: var(--cst-sold); }
.chip--comped { border-top-color: var(--cst-comped); }
.chip--returned { border-top-color: var(--cst-text-3); }
.chip[aria-current="true"] { background: var(--cst-surface-2); }

/* ---------- Ticket inventory ---------- */
.filters { display: grid; gap: var(--cst-s2); grid-template-columns: 1fr 1fr; margin-bottom: var(--cst-s4); }
.filters .field--q { grid-column: 1 / -1; }
@media (min-width: 768px) { .filters { grid-template-columns: 1fr 1fr 2fr auto; align-items: end; } .filters .field--q { grid-column: auto; } }
.inv { width: 100%; border-collapse: collapse; background: var(--cst-surface); border: 1px solid var(--cst-border); }
.inv th { text-align: left; padding: var(--cst-s3); border-bottom: 1px solid var(--cst-border-strong); font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cst-text-2); }
.inv td { padding: var(--cst-s2) var(--cst-s3); border-bottom: 1px solid var(--cst-border); vertical-align: middle; }
.inv .r { text-align: right; font-variant-numeric: tabular-nums; }
.inv tbody { transition: opacity var(--cst-dur-fast) var(--cst-ease); }
.inv tbody.htmx-swapping, .inv tbody.htmx-added { opacity: 0; }
.inv tbody.htmx-request { opacity: 0.6; }
.inv .seat { color: var(--cst-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.inv .buyer { color: var(--cst-text); }
.inv .sel { width: 44px; }
.inv .sel input { width: 22px; height: 22px; accent-color: var(--cst-red); }
.status-btn {
  display: inline-flex; align-items: center; gap: var(--cst-s2); min-height: var(--cst-tap); padding: 0 var(--cst-s2);
  background: none; border: 1px solid var(--cst-border); cursor: pointer;
}
.status-btn:hover { border-color: var(--cst-border-strong); background: var(--cst-surface-2); }
.status-btn::after { content: "▾"; color: var(--cst-text-2); font-size: 0.75rem; }
.inv tr.panel-row td { background: var(--cst-surface-2); padding: var(--cst-s4); border-bottom: 2px solid var(--cst-border-strong); }
.status-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--cst-s2); margin-bottom: var(--cst-s4); }
.status-choices .btn { padding: 0 var(--cst-s2); font-size: 0.8125rem; }
.status-choices .btn[aria-pressed="true"] { border-color: var(--cst-text); background: var(--cst-surface-3); }
.history { margin-top: var(--cst-s4); font-size: 0.8125rem; }
.history li { padding: var(--cst-s1) 0; border-top: 1px solid var(--cst-border); }

@media (max-width: 767.98px) {
  .inv thead { display: none; }
  .inv, .inv tbody, .inv tr, .inv td { display: block; width: 100%; }
  .inv tr.item[data-pick] { cursor: pointer; }
.inv tr.item {
    display: grid; grid-template-columns: 44px 1fr auto; grid-template-areas: "sel seat price" "sel status status" "sel buyer buyer";
    gap: var(--cst-s1) var(--cst-s2); padding: var(--cst-s3) var(--cst-s2) var(--cst-s3) 0; border-bottom: 1px solid var(--cst-border);
  }
  .inv tr.item td { border: 0; padding: 0; }
  .inv .sel { grid-area: sel; display: grid; place-items: center; width: auto; }
  .inv .c-seat { grid-area: seat; }
  .inv .c-face { grid-area: price; }
  .inv .c-status { grid-area: status; }
  .inv .c-buyer { grid-area: buyer; }
  .inv .c-buyer:empty { display: none; }
  .inv .c-money { display: none; }
  .inv tr.panel-row td { padding: var(--cst-s4) var(--cst-s3); }
}
.bulkbar { background: var(--cst-surface); border: 1px solid var(--cst-border-strong); border-top: 2px solid var(--cst-red); padding: var(--cst-s4); margin-top: var(--cst-s4); }
.bulkbar .form-grid { align-items: end; }


/* ---------- Money ---------- */
.money { width: 100%; border-collapse: collapse; background: var(--cst-surface); border: 1px solid var(--cst-border); }
.money th, .money td { padding: var(--cst-s3) var(--cst-s4); border-bottom: 1px solid var(--cst-border); vertical-align: baseline; }
.money th { text-align: left; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cst-text-2); }
.money th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 0.8125rem; color: var(--cst-held); margin-top: 2px; }
.money td { text-align: right; color: var(--cst-text); font-weight: 500; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; white-space: nowrap; }
.money td.count { color: var(--cst-text-2); width: 4.5rem; }
.money tr.total th, .money tr.total td { border-top: 2px solid var(--cst-border-strong); }
.money tr.key th, .money tr.key td { background: var(--cst-surface-2); }
.money tr.key td { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 800; font-stretch: 70%; }
.money tr.key th { color: var(--cst-text); font-size: 0.8125rem; }
.money-key { display: grid; gap: var(--cst-s2); grid-template-columns: 1fr 1fr; margin-bottom: var(--cst-s5); }
/* Styled like the ticket count cards (CR-013): white, with a coloured bar on top. */
.money-key div { background: var(--cst-surface); border: 1px solid var(--cst-border); border-top: 5px solid var(--cst-border-strong); padding: var(--cst-s3) var(--cst-s4); box-shadow: var(--cst-shadow); }
.money-key .money-key__remit { border-top-color: var(--cst-red); }
.money-key .money-key__commission { border-top-color: var(--cst-available); }
.money-key b { display: block; font-size: clamp(1.5rem, 6vw, 2rem); font-weight: 800; font-stretch: 70%; color: var(--cst-text); font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: var(--cst-s1); overflow-wrap: anywhere; }

/* ---------- Reorderable lists (fight card, FAQ, template bouts) ---------- */
.ordered { display: grid; gap: var(--cst-s3); }
.ordered__item { background: var(--cst-surface); border: 1px solid var(--cst-border); padding: var(--cst-s4); }
.ordered__item--own { border-left: 3px solid var(--cst-red); }
.ordered__tools { display: flex; flex-wrap: wrap; gap: var(--cst-s2); margin-top: var(--cst-s3); }
.ordered__tools .btn { padding: 0 var(--cst-s4); }

/* ---------- Images tab ---------- */
.img-preview { width: 100%; max-width: 480px; aspect-ratio: 16 / 9; object-fit: cover; background: var(--cst-surface-2); border: 1px solid var(--cst-border); }
.img-preview--square { max-width: 200px; aspect-ratio: 1; }

/* ---------- Templates picker ---------- */
.picker { display: grid; gap: var(--cst-s3); }
@media (min-width: 768px) { .picker { grid-template-columns: repeat(2, 1fr); } }
.picker .card { padding: var(--cst-s4); }

/* ---------- One-time password ---------- */
.secret { display: flex; flex-wrap: wrap; gap: var(--cst-s2); align-items: stretch; }
.secret code {
  flex: 1 1 14rem; display: flex; align-items: center; min-height: var(--cst-control-h); padding: 0 var(--cst-s4);
  background: var(--cst-surface-3); border: 1px solid var(--cst-gold); color: var(--cst-text);
  font-size: 1.25rem; font-weight: 700; letter-spacing: 0.04em; user-select: all; -webkit-user-select: all; overflow-wrap: anywhere;
}

/* ---------- Auth ---------- */
.auth { max-width: 26rem; margin: 0 auto; padding: var(--cst-s7) 0; }
.auth h1 { margin-bottom: var(--cst-s5); }

/* ---------- Reply to buyer ---------- */
.reply-row td, section.reply-row { border-left: 3px solid var(--cst-available); }
.reply-text { margin: var(--cst-s2) 0 var(--cst-s3); padding: var(--cst-s3); background: var(--cst-surface-2); border: 1px solid var(--cst-border); color: var(--cst-text); white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.reply-link { display: inline-flex; align-items: center; min-height: var(--cst-tap); font-size: 0.8125rem; font-weight: 600; color: var(--cst-text); text-decoration: none; }
/* One straight 2px line under the words and the ↗ alike (CR-028). A border, not text-decoration: the arrow comes
   from a fallback font whose underline sits at a different height and weight. */
.reply-link__label { border-bottom: 2px solid var(--cst-available); padding-bottom: 1px; line-height: 1.2; }
.field select:disabled, .field input:disabled { opacity: 0.5; cursor: not-allowed; }
.inv-top { display: flex; justify-content: flex-start; margin-bottom: var(--cst-s4); }
.dialog {
  width: min(32rem, calc(100vw - 2 * var(--cst-gutter))); max-height: calc(100dvh - 2 * var(--cst-gutter)); overflow: auto;
  padding: var(--cst-s5); border: 1px solid var(--cst-border-strong); border-top: 3px solid var(--cst-available); border-radius: var(--cst-radius);
  background: var(--cst-surface); color: var(--cst-text-2); box-shadow: var(--cst-shadow-lg);
}
.dialog:not([open]) { display: none; }
.dialog::backdrop { background: var(--cst-backdrop); }
.dialog h2 { margin-bottom: var(--cst-s3); }

/* ---------- Header menu (CR-006) ---------- */
.menu { position: relative; }
.menu__button {
  display: inline-flex; align-items: center; gap: var(--cst-s2); min-height: var(--cst-tap); padding: 0 var(--cst-s3);
  background: var(--cst-button-2); border: 1px solid var(--cst-button-2); color: var(--cst-on-button-2); cursor: pointer; list-style: none;
  font-weight: 700; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em;
}
.menu__button::-webkit-details-marker { display: none; }
.menu__button::before { content: "☰"; font-size: 1rem; letter-spacing: 0; }
.menu__button:hover, .menu[open] .menu__button { background: var(--cst-button-2-hover); }
.menu[open] .menu__button::before { content: "✕"; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + var(--cst-s2)); z-index: 70; min-width: 15rem;
  display: grid; background: var(--cst-surface); border: 1px solid var(--cst-border-strong); border-top: 2px solid var(--cst-red); box-shadow: var(--cst-shadow-lg);
}
.menu__panel a, .menu__signout button {
  display: flex; align-items: center; min-height: var(--cst-control-h); padding: 0 var(--cst-s4);
  color: var(--cst-text); text-decoration: none; font-weight: 600; font-size: 1rem; text-align: left;
}
.menu__panel a:hover, .menu__signout button:hover { background: var(--cst-surface-2); }
.menu__panel a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--cst-red); background: var(--cst-surface-2); }
.menu__signout { margin: 0; border-top: 1px solid var(--cst-border); }
.menu__signout button { width: 100%; border: 0; background: none; color: var(--cst-text-2); cursor: pointer; }
.back-link { display: inline-flex; align-items: center; min-height: var(--cst-tap); margin-bottom: var(--cst-s1); color: var(--cst-text-2); font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--cst-text); }

/* ---------- Date and time fields fit their box on iPhone (CR-006) ---------- */
.field input[type="date"], .field input[type="time"], .field input[type="datetime-local"] {
  -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; text-align: left;
}
.field input::-webkit-date-and-time-value { text-align: left; min-height: 1.5em; }
.dialog:focus { outline: none; } /* the dialog itself takes focus on open so no button looks pre-selected; buttons keep their focus rings */
.btn-close { border-color: transparent; color: var(--cst-text-2); padding: 0 var(--cst-s3); }
.btn-close:hover { color: var(--cst-text); background: var(--cst-surface-2); }
.record { display: grid; gap: var(--cst-s1); }
.record legend { padding: 0; margin-bottom: var(--cst-s1); }
.record__row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--cst-s2); }
/* Share: one compact strip above the event tabs (CR-013). */
/* Share (CR-026): a compact light-red callout under the event name; Copy link and View are text links, not buttons. */
.share {
  margin-top: var(--cst-s3); padding: var(--cst-s2) var(--cst-s3); background: var(--cst-red-dim); border-left: 3px solid var(--cst-red);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--cst-s1) var(--cst-s4);
}
.share__text { margin: 0; font-size: 0.875rem; font-weight: 600; color: var(--cst-text); }
.share__links { display: inline-flex; gap: var(--cst-s4); }
.share__link {
  display: inline-flex; align-items: center; min-height: var(--cst-tap); padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 0.875rem; font-weight: 700; color: var(--cst-red-hover);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px;
}
.share__link:hover { color: var(--cst-text); }

/* ---------- Contact us inbox (CR-019) ---------- */
.messages { display: grid; gap: var(--cst-s3); }
.message { padding: var(--cst-s4); display: grid; gap: var(--cst-s2); }
.message__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--cst-s2); }
.message__name { margin: 0; font-size: 1.0625rem; display: flex; align-items: center; gap: var(--cst-s2); }
.message__contact, .message__body { margin: 0; }
.message__body { white-space: pre-line; color: var(--cst-text); }

/* CR-032: a ticket the promotion issued to the athlete */
.pill--issued { background: var(--cst-surface-2); color: var(--cst-text); box-shadow: inset 0 0 0 1px var(--cst-border-strong); }

/* CR-032: unread messages on the menu button */
.menu__badge { display: inline-block; min-width: 1.25rem; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: var(--cst-red); color: #fff; font-size: 0.6875rem; font-weight: 800; line-height: 1.25rem; text-align: center; }
