/* JoeGym admin panel. Served same-origin so the CSP needs no
   'unsafe-inline' for styles; keep it that way (no style="" attributes,
   no <style> blocks, no setAttribute('style')). */
:root {
  --bg: #111315;
  --surface: #1b1e21;
  --surface-2: #24282c;
  --border: #33383d;
  --text: #e7eaed;
  --muted: #9aa1a8;
  --accent: #e0a23c;
  --danger: #e5534b;
  --ok: #59a14f;
  --info: #6ea8d8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
header.top h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.header-right { display: flex; align-items: center; gap: 12px; }
header .who { font-size: 13px; color: var(--muted); }
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }
h2, h3, h4 { font-weight: 700; }
.mt-0 { margin-top: 0; }
.section-head { margin: 0 0 4px; }
.section-head.spaced { margin-top: 28px; }
.section-intro { margin: 0 0 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px;
}
.card-narrow { text-align: center; max-width: 400px; }
.card-table { padding: 8px 12px; }
.center { display: flex; min-height: 70vh; align-items: center; justify-content: center; }

/* ---- controls ---- */
button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); padding: 8px 14px; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--muted); padding: 6px 8px; }
button.link:hover { color: var(--text); }
button.danger { background: none; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: rgba(229, 83, 75, .12); }
button.small-btn { padding: 4px 9px; }
button:disabled { opacity: .5; cursor: default; }
.g-btn { display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; font-weight: 600; }
a.link-a { color: var(--accent); }

input[type=number], input.num-input {
  width: 110px; font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
input.text-input, select.select, textarea.textarea {
  width: 100%; min-width: 150px; font: inherit;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
textarea.textarea { resize: vertical; }
select.select { min-width: 180px; }
input[type=file] { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---- messages & helpers ---- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.row-msg { font-size: 12px; margin-top: 6px; min-height: 0; }
.row-msg:empty { margin-top: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hidden { display: none !important; }
.saved { color: var(--ok); }
.err { color: var(--danger); }
.spinner { color: var(--muted); padding: 32px; text-align: center; }
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 12px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
}

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
td .name { font-weight: 600; }
td .email { color: var(--muted); font-size: 13px; }
.table-wrap { width: 100%; }
tr.row-error > td { background: rgba(229, 83, 75, .06); }
tr.row-editing > td { background: rgba(224, 162, 60, .08); }
.count-pill {
  display: inline-block; min-width: 28px; text-align: center; padding: 2px 8px;
  border-radius: 999px; background: var(--surface-2); font-variant-numeric: tabular-nums;
}
.count-pill.full { color: var(--accent); border: 1px solid var(--accent); }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap;
}
.chip-ok { color: var(--ok); border-color: var(--ok); }
.chip-info { color: var(--info); border-color: var(--info); }
.chip-err { color: var(--danger); border-color: var(--danger); }
/* Clients tab trainer chips (× removes) and the Sessions tab's Cover tag. */
.trainer-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.trainer-chip { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
button.chip-x {
  background: none; border: none; color: var(--muted); padding: 0 2px 0 4px;
  border-radius: 999px; line-height: 1;
}
button.chip-x:hover { color: var(--danger); }
.cover-tag { color: var(--info); border-color: var(--info); margin-left: 6px; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] {
  flex: 1; font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}

/* ---- gym page ---- */
.back-link { padding-left: 0; margin-bottom: 6px; }
.page-title { margin: 0 0 4px; }
.page-sub { margin-bottom: 16px; font-size: 13px; }
.tabbar {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; flex-wrap: wrap;
}
.tabbar .tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 10px 14px; color: var(--muted);
}
.tabbar .tab:hover { color: var(--text); }
.tabbar .tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.pane { display: flex; flex-direction: column; gap: 20px; }
.pane-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px;
}
.pane-section h3 { margin: 0 0 6px; font-size: 16px; }
.pane-section h4 { margin: 18px 0 8px; font-size: 14px; }
.pane-section .intro { margin: 0 0 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 6px; }
.inline-form .field { min-width: 220px; }
.form-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); font-weight: 600;
}
.field-hint { font-size: 12px; color: var(--muted); }
.field-hint:empty { display: none; }
.readonly { padding: 8px 0; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.intake-built { columns: 2 340px; column-gap: 28px; }
.intake-built .check-group { break-inside: avoid; }
.editor-box { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.editor-box h4 { margin: 0; }
.brand-swatch {
  width: 44px; height: 36px; padding: 2px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
}
.brand-link { color: var(--muted); word-break: break-all; }
.svc-archived { opacity: .55; }
.svc-section > td {
  border-bottom: none; padding: 16px 10px 2px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); font-weight: 600;
}
.logo-box { min-height: 40px; display: flex; align-items: center; }
.logo-preview { max-width: 200px; max-height: 80px; border-radius: 8px; background: var(--surface-2); }
.link-box {
  margin: 14px 0; padding: 14px; border-radius: 10px;
  border: 1px solid var(--accent); background: rgba(224, 162, 60, .08);
  display: flex; flex-direction: column; gap: 8px;
}
.link-code {
  display: block; padding: 8px 10px; border-radius: 8px; background: var(--bg);
  border: 1px solid var(--border); word-break: break-all; user-select: all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px;
}
.summary { margin-bottom: 10px; }
.warnings { margin: 0 0 12px; padding-left: 20px; color: var(--accent); }
.import-inputs { margin: 12px 0; }
.sticky-actions { position: sticky; bottom: 0; z-index: 1; }

/* ---- reports tab (gym_reports.js) ---- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; }
.seg .seg-btn { border-radius: 0; margin-left: -1px; }
.seg .seg-btn:first-child { border-radius: 10px 0 0 10px; margin-left: 0; }
.seg .seg-btn:last-child { border-radius: 0 10px 10px 0; }
.seg .seg-btn.active { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
input.date-input {
  font: inherit; padding: 8px 10px; border-radius: 8px; color-scheme: dark;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.range-heading { font-weight: 700; }
.report-note { margin: 0; }
.report-wrap { width: 100%; overflow-x: auto; }
table.report th, table.report td { padding: 7px 10px; }
table.report td { font-variant-numeric: tabular-nums; }
table.report .num { text-align: right; white-space: nowrap; }
table.report tbody tr:nth-child(even) > td { background: rgba(255, 255, 255, .02); }
table.report tr.total-row > td { font-weight: 700; border-top: 2px solid var(--border); background: none; }
table.report tr.grand-row > td { border-top-color: var(--muted); }
table.report tr.section-bar > td { background: var(--surface-2); font-weight: 600; }
button.client-link { color: var(--accent); padding: 0; font-weight: 600; text-align: left; white-space: normal; }
.kpi-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kpi { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 20px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.report-details > summary { cursor: pointer; padding: 6px 0; font-weight: 600; }

/* ---- table editing (gym_pay_rates.js, Packages → Who can sell) ---- */
.edit-bar {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--accent); background: rgba(224, 162, 60, .06);
}
.bar-row { justify-content: flex-start; }
.bar-spacer { flex: 1; }
.cell-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
table.report th.center, table.report td.center { text-align: center; }
tr.click-row { cursor: pointer; }
table.report tbody tr.click-row:hover > td { background: rgba(255, 255, 255, .05); }
input.rate-input {
  width: 84px; font: inherit; text-align: right; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
table.report tbody tr > td.cell-changed,
table.report tbody tr:nth-child(even) > td.cell-changed { background: rgba(224, 162, 60, .16); }
td.cell-changed input.rate-input { border-color: var(--accent); }
table.report tbody tr > td.cell-invalid,
table.report tbody tr:nth-child(even) > td.cell-invalid { background: rgba(229, 83, 75, .12); }
td.cell-invalid input.rate-input { border-color: var(--danger); }
/* The first column (trainer / package name) stays put while the rest scrolls. */
table.report .sticky-first {
  position: sticky; left: 0; z-index: 1; min-width: 180px; background: var(--surface);
}
table.report tbody tr:nth-child(even) > td.sticky-first { background: var(--surface); }
/* The single-row editing tint wins over the zebra stripes on every row
   (the sticky name cell stays opaque, tinted). */
table.report tbody tr.row-editing > td,
table.report tbody tr.row-editing:nth-child(even) > td { background: rgba(224, 162, 60, .08); }
table.report tbody tr.row-editing > td.sticky-first,
table.report tbody tr.row-editing:nth-child(even) > td.sticky-first {
  background: linear-gradient(rgba(224, 162, 60, .08), rgba(224, 162, 60, .08)), var(--surface);
}
table.report tbody tr.row-editing > td.cell-changed,
table.report tbody tr.row-editing:nth-child(even) > td.cell-changed { background: rgba(224, 162, 60, .16); }
table.report tbody tr.row-editing > td.cell-invalid,
table.report tbody tr.row-editing:nth-child(even) > td.cell-invalid { background: rgba(229, 83, 75, .12); }
tr.history-row > td { background: var(--surface-2); }
table.report tbody tr.history-row > td { background: var(--surface-2); }
.history-box { gap: 8px; }
.history-group { display: flex; flex-direction: column; gap: 4px; }
.history-line { padding-left: 12px; }
.history-service { min-width: 180px; }

/* Report table headings with their "Download CSV" button on the right. */
.report-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 10px; }
.report-head.first { margin-top: 0; }
.pane-section .report-head h4 { margin: 0; }
.csv-action { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
