/* Graham Fitness — Trainer App + Client Portal. Shared stylesheet. */
:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --ink: #14181a;
  --muted: #5d6b73;
  --line: #dde3e6;
  --brand: #111827;
  --accent: #c8f04a;          /* lime — Graham Fitness energy */
  --accent-ink: #1a2305;
  --accent-soft: #eef7d2;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --info-bg: #dbeafe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
p { margin: 0 0 .75rem; }
a { color: #0b5fff; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: #9dbb2e; }
label { display: block; font-size: .85rem; font-weight: 600; margin: .6rem 0 .25rem; color: #374151; }
textarea { min-height: 74px; resize: vertical; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem; position: sticky; top: 0; z-index: 20;
}
.topbar .logo { font-weight: 800; letter-spacing: .02em; font-size: 1.05rem; white-space: nowrap; }
.topbar .logo span { color: var(--accent); }
.topbar .who { margin-left: auto; font-size: .85rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who b { color: var(--accent); }
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 8px;
  padding: .5rem .9rem; font-weight: 600; background: var(--accent); color: var(--accent-ink);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(.95); }
.btn.secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.tabs {
  display: flex; gap: .35rem; overflow-x: auto; padding: .6rem 1rem .2rem;
  background: var(--brand); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none; background: transparent; color: #cbd5e1; font-weight: 600;
  padding: .55rem .8rem; border-radius: 8px 8px 0 0; white-space: nowrap;
}
.tab.active { background: var(--bg); color: var(--ink); }
.tab .badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: var(--danger); color: #fff; border-radius: 9px; font-size: .72rem; line-height: 18px; text-align: center;
}
main { max-width: 1080px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.view h2 { font-size: 1.35rem; margin-bottom: .25rem; }
.view .sub { color: var(--muted); margin-bottom: 1rem; }

/* ---------- cards / grids ---------- */
.grid { display: grid; gap: .9rem; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.card h3 { font-size: 1rem; }
.kpi .label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi .value { font-size: 1.9rem; font-weight: 800; line-height: 1.15; margin-top: .15rem; }
.kpi .note { font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.flag { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.flag.warn { background: var(--warn-bg); color: var(--warn); }
.flag.ok { background: var(--ok-bg); color: var(--ok); }
.flag.bad { background: var(--danger-bg); color: var(--danger); }
.flag.info { background: var(--info-bg); color: #1d4ed8; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- forms / modal ---------- */
.formrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 1rem 1rem; z-index: 50; overflow-y: auto;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; padding: 1.25rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal h3 { font-size: 1.15rem; }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .9rem; }
.toolbar input[type="search"], .toolbar select { width: auto; flex: 1 1 180px; }
.toolbar .spacer { flex: 1; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--brand); }
.login-card { background: #fff; border-radius: 16px; padding: 1.6rem; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card h1 { font-size: 1.4rem; }
.login-card h1 span { color: #65a30d; }
.login-card .err { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: .6rem .75rem; font-size: .9rem; margin: .6rem 0; }
.setup-note { background: var(--warn-bg); color: #78350f; border-radius: 8px; padding: .7rem .8rem; font-size: .88rem; margin-top: .8rem; }
.setup-note code { background: rgba(0,0,0,.07); padding: .05rem .3rem; border-radius: 4px; }

/* ---------- misc ---------- */
.alert { border-radius: 10px; padding: .7rem .85rem; margin-bottom: .9rem; font-size: .92rem; }
.alert.warn { background: var(--warn-bg); color: #78350f; }
.alert.info { background: var(--info-bg); color: #1e3a8a; }
.alert.ok { background: var(--ok-bg); color: #14532d; }
.progressbar { height: 9px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-top: .35rem; }
.progressbar > div { height: 100%; background: #65a30d; }
.progressbar.low > div { background: var(--danger); }
.checkline { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .25rem; border-bottom: 1px solid var(--line); }
.checkline input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: #65a30d; }
.checkline.done .ex-name { text-decoration: line-through; color: var(--muted); }
.ex-name { font-weight: 600; }
.ex-meta { font-size: .85rem; color: var(--muted); }
.msg { max-width: 78%; padding: .55rem .75rem; border-radius: 12px; margin-bottom: .5rem; }
.msg.mine { background: var(--accent-soft); margin-left: auto; }
.msg.theirs { background: #eef2f7; }
.msg .who { font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: .15rem; }
.msg .when { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.photogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.photogrid img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.pillnav { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pillnav button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .8rem; font-weight: 600; font-size: .88rem; }
.pillnav button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
#toast-root { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; align-items: center; width: min(92vw, 480px); pointer-events: none; }
.toast { background: var(--brand); color: #fff; border-radius: 10px; padding: .65rem .95rem; font-size: .92rem; box-shadow: 0 8px 24px rgba(0,0,0,.3); width: 100%; text-align: center; }
.install-hint { background: var(--accent-soft); border: 1px solid #bef264; border-radius: 10px; padding: .7rem .9rem; margin-bottom: .9rem; font-size: .92rem; }
.install-hint b { color: #3f6212; }
.empty { color: var(--muted); padding: 1rem .25rem; }
canvas.chart { max-height: 260px; }
@media (max-width: 640px) {
  .topbar .who { display: none; }
  .kpi .value { font-size: 1.6rem; }
}
