:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1c1f26;
  --text-dim: #6b7280;
  --accent: #2f6f4f;
  --accent-dim: #eaf3ee;
  --danger: #b3413a;
  --radius: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell { display: flex; min-height: 100vh; }

nav.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
}

nav.sidebar h1 {
  font-size: 17px;
  margin: 0 0 24px 4px;
}

nav.sidebar a {
  display: block;
  padding: 9px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
}

nav.sidebar a:hover { background: var(--accent-dim); color: var(--text); }
nav.sidebar a.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }

main {
  flex: 1;
  padding: 32px 40px;
  max-width: 980px;
}

h2 { margin-top: 0; font-size: 22px; }
h3 { font-size: 16px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  margin-top: 10px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; min-height: 50px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  margin-top: 14px;
}

button.secondary {
  background: var(--accent-dim);
  color: var(--accent);
}

button.danger { background: #fbe9e7; color: var(--danger); }
button.link {
  background: none;
  color: var(--accent);
  padding: 4px 6px;
  margin: 0;
  font-weight: 500;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fff;
}

.card-title { font-weight: 600; font-size: 15px; }
.card-meta { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.card-actions { margin-top: 8px; display: flex; gap: 8px; }
.card-actions button { margin-top: 0; padding: 6px 12px; font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.cancelled { background: #fbe9e7; color: var(--danger); }
.badge.completed { background: #e7f0fb; color: #2e5a8f; }

.empty { color: var(--text-dim); font-size: 14px; padding: 12px 0; }

.exercise-row {
  display: grid;
  grid-template-columns: 2fr 0.8fr 1fr 1fr 1fr 1.5fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.exercise-row label { margin-top: 0; }

.exercise-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fafbfc;
}
.exercise-block-head {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.exercise-block-head label { margin-top: 0; }
.scheme-fields { margin-top: 4px; }
.scheme-line {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 6px;
}
.scheme-line label { margin-top: 0; font-size: 11px; }

.date-group { margin-bottom: 22px; }
.date-group h3 { margin-bottom: 8px; color: var(--text-dim); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

a.plain { color: var(--accent); text-decoration: none; }
a.plain:hover { text-decoration: underline; }

/* Program builder: Days > Blocks > Exercises nesting */
.day-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #fafbfc;
}
.block-group {
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 10px 0 10px 8px;
  background: #fff;
}
.block-exercise-row { margin-bottom: 8px; }
.block-exercise-row:last-child { margin-bottom: 0; }

.day-tab-btn.active-day { background: var(--accent); color: #fff; }

/* Client log inputs: reps / load / rest side by side, even on a phone */
.log-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.log-fields label { margin-top: 4px; }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 760px) {
  .app-shell { flex-direction: column; }

  /* Sidebar becomes a sticky, horizontally scrollable top bar */
  nav.sidebar {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  nav.sidebar h1 { font-size: 15px; margin: 0 8px 0 0; white-space: nowrap; }
  nav.sidebar a { margin: 0; padding: 8px 10px; white-space: nowrap; flex-shrink: 0; }

  main { padding: 16px; max-width: none; }
  h2 { font-size: 20px; }
  .panel { padding: 14px; }
  .card { padding: 12px; }

  /* 16px inputs stop iPhones from zooming in when a field is tapped */
  input, select, textarea { font-size: 16px; }
  button { min-height: 42px; }
  .card-actions { flex-wrap: wrap; }
  .card-actions button { min-height: 38px; }

  .row > * { min-width: 140px; }

  /* Wide tables scroll sideways inside their card instead of the page */
  table { display: block; overflow-x: auto; white-space: nowrap; }

  .toast { left: 16px; right: 16px; bottom: 16px; text-align: center; }
}

/* ---------- Public pages (home, privacy, terms) ---------- */
.public-body { display: flex; flex-direction: column; min-height: 100vh; }
.public-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.public-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none;
}
.public-brand img { border-radius: 8px; }
.public-signin { color: var(--accent); font-weight: 600; text-decoration: none; }
.public-main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 32px 20px; }
.public-hero { padding: 24px 0 8px; }
.public-hero h1 { font-size: 32px; line-height: 1.2; margin: 0 0 12px; }
.public-lead { font-size: 17px; color: var(--text-dim); line-height: 1.5; margin: 0 0 8px; }
.public-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.public-features .panel { margin-bottom: 0; }
.public-features h3 { margin-top: 0; }
.public-features p { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 0; }
.public-doc h1 { font-size: 28px; margin-bottom: 4px; }
.public-doc h2 { font-size: 18px; margin-top: 28px; }
.public-doc p, .public-doc li { line-height: 1.6; }
.public-doc ul { padding-left: 20px; }
.public-footer {
  text-align: center; font-size: 13px; color: var(--text-dim);
  padding: 20px; border-top: 1px solid var(--border); background: var(--panel);
}
.public-footer p { margin: 6px 0 0; }
@media (max-width: 760px) {
  .public-features { grid-template-columns: 1fr; }
  .public-hero h1 { font-size: 26px; }
  .public-header { padding: 12px 16px; }
}
