/* Gym session tracker — built mobile-first, because coaches book from a phone
   between sessions and the owner reads the dashboard on a laptop. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e3e8ef;
  --text: #131a24;
  --muted: #667085;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --good: #0f7b53;
  --good-soft: #e8f6f0;
  --warn: #a35b06;
  --warn-soft: #fdf4e6;
  --alert: #b42318;
  --alert-soft: #fdeceb;
  --grey-soft: #eef1f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1219;
    --surface: #161c26;
    --surface-2: #1b222e;
    --line: #28313f;
    --text: #e8edf4;
    --muted: #93a0b4;
    --accent: #5b8dfb;
    --accent-soft: #1a2540;
    --good: #4ac795;
    --good-soft: #142b23;
    --warn: #e0a54a;
    --warn-soft: #2c2314;
    --alert: #f2867c;
    --alert-soft: #331b1a;
    --grey-soft: #222a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

/* ---------------------------------------------------------------- chrome */

.topbar {
  background: #10151d;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 650; letter-spacing: -.01em; font-size: 1.02rem; }
.brand:hover { text-decoration: none; opacity: .85; }
.nav { display: flex; gap: .15rem; flex: 1; flex-wrap: wrap; }
.nav a {
  color: #b8c2d1;
  padding: .38rem .7rem;
  border-radius: 8px;
  font-size: .92rem;
  white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav a.on { background: rgba(255, 255, 255, .14); color: #fff; }
.who { display: flex; align-items: center; gap: .6rem; color: #8b97a8; font-size: .86rem; }

/* On a phone the bar becomes two tidy rows: name and account on top, the
   sections underneath on one swipeable line. */
@media (max-width: 700px) {
  .topbar-inner { padding: .5rem .75rem; gap: .4rem; }
  .brand { order: 1; flex: 1; }
  .who { order: 2; }
  .nav {
    order: 3; flex-basis: 100%; flex-wrap: nowrap;
    overflow-x: auto; scrollbar-width: none; gap: .1rem;
    margin: 0 -.75rem; padding: 0 .75rem;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: .34rem .6rem; }
}
.linkish {
  background: none; border: 0; color: #8b97a8; cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}
.linkish:hover { color: #fff; }

.shell { max-width: 900px; margin: 0 auto; padding: 1.1rem 1rem 4rem; }
.shell.wide { max-width: 1180px; }
.page-title { font-size: 1.5rem; margin-bottom: .8rem; letter-spacing: -.02em; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card.alert { border-color: color-mix(in srgb, var(--alert) 35%, var(--line)); }
.card.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.card-head h2 { font-size: 1.02rem; letter-spacing: -.01em; }
.card-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.lead { color: var(--muted); margin: 0 0 .8rem; font-size: .92rem; }
.warn-text { color: var(--warn); }
.empty { color: var(--muted); margin: .3rem 0; font-style: italic; }
.foot-note { color: var(--muted); font-size: .88rem; margin-top: 1rem; }

/* ---------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .7rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem .9rem;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 1.7rem; font-weight: 660; letter-spacing: -.03em; }
.stat-label { color: var(--muted); font-size: .82rem; margin-top: .1rem; }
.stat.alert .stat-value { color: var(--alert); }
.stat.warn .stat-value { color: var(--warn); }
.stat.good .stat-value { color: var(--good); }

/* ---------------------------------------------------------------- pips */

.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pip {
  width: 13px; height: 8px; border-radius: 2px;
  background: var(--grey-soft);
  border: 1px solid var(--line);
  display: inline-block;
}
.pip.on { background: var(--accent); border-color: var(--accent); }
.pip.last { border-radius: 2px 5px 5px 2px; width: 15px; }
.pip.on.last { background: var(--alert); border-color: var(--alert); }

.progress-cell { white-space: nowrap; display: inline-flex; align-items: center; }
.counter { font-variant-numeric: tabular-nums; font-weight: 640; margin-left: .35rem; }
.counter .of { color: var(--muted); font-weight: 500; }

.num {
  font-size: .74rem; font-weight: 650; color: var(--accent);
  background: var(--accent-soft); border-radius: 5px; padding: .05rem .3rem;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.num.final { color: var(--alert); background: var(--alert-soft); }
.num.none { color: var(--alert); background: var(--alert-soft); }

.session-count {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.session-count .pips { transform: scale(1.4); transform-origin: left center; margin-right: .8rem; }
.count-text { display: flex; flex-direction: column; }
.count-text strong { font-size: 1.15rem; letter-spacing: -.02em; }
.count-text span { color: var(--muted); font-size: .88rem; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block; font-size: .74rem; font-weight: 600;
  padding: .13rem .45rem; border-radius: 999px;
  background: var(--grey-soft); color: var(--muted); white-space: nowrap;
}
.badge.green { background: var(--good-soft); color: var(--good); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--alert-soft); color: var(--alert); }
.badge.grey { background: var(--grey-soft); color: var(--muted); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .3rem; padding: .48rem .85rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); font: inherit; font-weight: 550; font-size: .9rem;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--line); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.good { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.btn.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.btn.danger { background: var(--alert-soft); border-color: var(--alert); color: var(--alert); }
.btn.small { padding: .3rem .58rem; font-size: .82rem; }
.btn.block { width: 100%; margin-top: .4rem; }
.btn-row { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .9rem; }
.inline { display: inline; }
.row-actions { display: inline-flex; gap: .3rem; }

/* ---------------------------------------------------------------- forms */

.field { margin-bottom: .85rem; }
.field label { display: block; font-weight: 560; font-size: .88rem; margin-bottom: .28rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: .52rem .65rem; font: inherit;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.field.check label { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.field.check input { width: auto; }
.hint { display: block; color: var(--muted); font-size: .8rem; margin-top: .22rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
.grid2 .full, .grid2 > .field:has(textarea) { grid-column: 1 / -1; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

.flash {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text); padding: .65rem .85rem; border-radius: 10px; margin-bottom: 1rem;
  font-size: .92rem;
}
.flash.error { background: var(--alert-soft); border-color: var(--alert); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn); }
.flash.good { background: var(--good-soft); border-color: var(--good); }
.flash ul { margin: .4rem 0; padding-left: 1.1rem; }

/* ---------------------------------------------------------------- login */

.login { max-width: 380px; margin: 8vh auto; }
.login h1 { font-size: 1.6rem; letter-spacing: -.02em; }
.login .sub { color: var(--muted); margin: .2rem 0 1.4rem; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th {
  text-align: left; font-size: .76rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); font-weight: 600;
  padding: .35rem .5rem; border-bottom: 1px solid var(--line);
}
td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
/* Keep a row's buttons on one line; the wrapper scrolls if the table is wider
   than the screen. */
td:last-child { white-space: nowrap; }
td .btn + .btn, td form + form, td form + .btn, td .btn + form { margin-left: .25rem; }
tr:last-child td { border-bottom: 0; }
table.meta td { border: 0; padding: .28rem .5rem .28rem 0; }
table.meta td:first-child { width: 120px; color: var(--muted); }

/* ---------------------------------------------------------------- calendar */

.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem;
}
.cal-head h2 { font-size: 1.05rem; letter-spacing: -.01em; }
.cal-nav, .cal-tools { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.filter select {
  padding: .3rem .5rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: .85rem;
}

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; }
@media (max-width: 900px) { .week { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .week { grid-template-columns: 1fr; } }

.day {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; min-height: 90px;
}
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-head {
  display: flex; align-items: baseline; gap: .35rem;
  padding: .45rem .55rem; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.day-head .dow { font-weight: 660; font-size: .8rem; }
.day-head .dom { color: var(--muted); font-size: .78rem; flex: 1; }
.day-head .add {
  color: var(--muted); font-weight: 700; font-size: 1rem; line-height: 1;
  padding: 0 .2rem; border-radius: 5px;
}
.day-head .add:hover { background: var(--accent); color: #fff; text-decoration: none; }
.day-body { padding: .4rem; display: flex; flex-direction: column; gap: .35rem; }
.day-body .none { color: var(--line); text-align: center; margin: .5rem 0; }

.entry {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: .35rem .45rem; color: var(--text);
  font-size: .82rem; line-height: 1.3;
}
.entry:hover { text-decoration: none; filter: brightness(.97); }
.entry .time { font-weight: 660; font-variant-numeric: tabular-nums; }
.entry .client { flex-basis: 100%; font-weight: 550; }
.entry .coach { flex-basis: 100%; color: var(--muted); font-size: .76rem; }
.entry.completed { background: var(--good-soft); border-left-color: var(--good); }
.entry.cancelled_early { background: var(--grey-soft); border-left-color: var(--muted); opacity: .65; }
.entry.cancelled_early .client { text-decoration: line-through; }
.entry.cancelled_late, .entry.no_show {
  background: var(--warn-soft); border-left-color: var(--warn);
}

/* ---------------------------------------------------------------- lists */

.slist { display: flex; flex-direction: column; }
.srow {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .55rem 0; border-bottom: 1px solid var(--line);
}
.srow:last-child { border-bottom: 0; }
.srow-main {
  display: flex; align-items: center; gap: .6rem; flex: 1;
  color: var(--text); flex-wrap: wrap; min-width: 0;
}
.srow-main:hover { text-decoration: none; color: var(--accent); }
.srow .when {
  font-weight: 660; font-variant-numeric: tabular-nums;
  min-width: 3.2rem;
}
.srow .client { font-weight: 550; }
.srow .meta { color: var(--muted); font-size: .86rem; }
.day-sep {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 620; padding: .7rem 0 .2rem;
}

.pkg-head {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding-bottom: .7rem; margin-bottom: .3rem; border-bottom: 1px solid var(--line);
}
.pkg-meta { color: var(--muted); font-size: .86rem; }

.pkg-edit { margin-top: .9rem; border-top: 1px solid var(--line); padding-top: .7rem; }
.pkg-edit summary {
  cursor: pointer; color: var(--muted); font-size: .86rem;
  font-weight: 550; list-style: none;
}
.pkg-edit summary::-webkit-details-marker { display: none; }
.pkg-edit summary::before { content: "+ "; font-weight: 700; }
.pkg-edit[open] summary::before { content: "- "; }
.pkg-edit summary:hover { color: var(--accent); }
.pkg-edit form { margin-top: .7rem; }

.client-note {
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--text); border-radius: 8px; padding: .55rem .7rem;
  margin-top: .5rem; font-size: .9rem; line-height: 1.5;
}
.client-note[hidden] { display: none; }

.bar {
  background: var(--grey-soft); border-radius: 999px; height: 8px;
  min-width: 60px; overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.grab {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .8rem .9rem; margin-bottom: 1.1rem;
}
.grab p { margin: 0 0 .6rem; font-size: .92rem; }
.grab .btn-row { margin-top: 0; }

.sub-head {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 620; margin: 1.2rem 0 .5rem;
}

.feed-url {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: .6rem .7rem; word-break: break-all;
}
