/* Brand tokens: change these to match the logo. */
:root {
  --bg: #f3f6f5;
  --card: #ffffff;
  --text: #16302d;
  --muted: #64748b;
  --line: #e2e8e6;
  --primary: #0f766e;
  --primary-dark: #0f5f5a;
  --primary-soft: #d5f0eb;
  --accent: #c89b5c;
  --accent-soft: #f6ecdc;
  --shadow: 0 1px 2px rgba(16, 48, 45, .05), 0 4px 16px rgba(16, 48, 45, .06);
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --orange: #b45309;
  --orange-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
main { max-width: 860px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.35rem; margin: 4px 0 14px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.mt0 { margin-top: 0; }
a { color: var(--primary-dark); text-decoration: none; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.right { text-align: right; }
.pre { white-space: pre-wrap; margin-top: 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; margin-top: 14px; }
.wrap-gap { margin: 12px 0 4px; }
.grow { flex: 1; min-width: 0; }
.hidden, [hidden] { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
a.card { color: inherit; }
a.card:not(.row):not(.lesson-card) { display: block; }
a.card:active { background: #f7faf9; }
.card.warn { background: var(--orange-soft); border-color: #fcd34d; }
.card.okbox { background: var(--green-soft); border-color: #86efac; color: var(--green); }

button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.danger { color: var(--red); border-color: #fecaca; }
button.small { min-height: 34px; padding: 5px 10px; font-size: .9rem; }
button.block { width: 100%; }
button:disabled { opacity: .55; cursor: default; }

label { display: block; font-size: .9rem; color: var(--muted); margin: 10px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); margin: 10px 0; }
label.check input { width: auto; }
input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 10px; }
@media (max-width: 560px) { .grid4 { grid-template-columns: 1fr 1fr; } }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #eef2f1; color: var(--muted); }
.owe { color: var(--red); font-weight: 600; }
.ok { color: var(--green); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat .v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Calendar */
.day { margin-bottom: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.day-head strong.today { color: var(--primary-dark); }
.lesson-card { display: flex; gap: 12px; align-items: center; }
.lesson-time { font-weight: 700; min-width: 50px; font-variant-numeric: tabular-nums; }
.empty-day { color: var(--muted); font-size: .9rem; padding: 2px 2px 8px; }

/* Rows inside a card */
.att { border-top: 1px solid var(--line); padding: 10px 0; display: block; }
.att.row { display: flex; }
.att:first-child { border-top: 0; padding-top: 0; }
.att:last-child { padding-bottom: 0; }

/* Session status picker */
.seg5 { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 6px; margin-bottom: 8px; }
.seg5 button { min-height: 44px; font-size: .9rem; }
.seg5 button[aria-pressed="true"] { border-width: 2px; font-weight: 700; }
.seg5 button[aria-pressed="true"][data-s="done"] { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.seg5 button[aria-pressed="true"][data-s="late_cancel"] { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }
.seg5 button[aria-pressed="true"][data-s="scheduled"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.seg5 button[aria-pressed="true"][data-s="cancelled"],
.seg5 button[aria-pressed="true"][data-s="coach_cancelled"] { background: #eef2f1; border-color: var(--muted); }

/* Workout editor */
.ex { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; display: grid; gap: 6px; }
.ex-nums { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; align-items: end; }
label.mini { margin: 0; font-size: .75rem; }
label.mini input { margin-top: 2px; }

/* Packages */
.pkg .bar { height: 8px; background: var(--primary-soft); border-radius: 99px; margin: 8px 0 6px; overflow: hidden; }
.pkg .bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.compact th, table.compact td { padding: 6px 8px; }
th { background: #f7faf9; font-weight: 600; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: #f7faf9; }

details.card summary { cursor: pointer; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card[open] summary { margin-bottom: 8px; }

h3 { font-size: 1rem; margin: 0 0 6px; }

/* Nutrition */
.targets { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.target { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.target .bar { height: 7px; background: #eef2f1; border-radius: 99px; margin: 6px 0 2px; overflow: hidden; }
.target .bar span { display: block; height: 100%; background: var(--muted); }
.target.good .bar span { background: var(--green); }
.target.low .bar span { background: var(--orange); }
.target.high .bar span { background: var(--red); }
.target.good strong { color: var(--green); }
.target.high strong { color: var(--red); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.food-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px auto; gap: 6px; align-items: center; margin-bottom: 4px; }
.food-row .macros { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); margin: -2px 0 6px; }
.food-row input.invalid { border-color: var(--red); background: var(--red-soft); }
.meal-total { font-size: .85rem; font-weight: 600; margin-top: 4px; }

/* Training plan */
.plan-day.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.plan-day.rest { padding: 10px 14px; }
.day-editor { border-left: 4px solid var(--primary-soft); }

/* Bar chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 18px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-fill { width: 100%; max-width: 34px; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-val { font-size: .75rem; font-weight: 700; }
.bar-label { font-size: .68rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }

.chart { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 13px; fill: var(--muted); }

/* Navigation */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(var(--tabs, 4), 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.nav a { display: flex; flex-direction: column; align-items: center; padding: 7px 0 8px; font-size: .74rem; color: var(--muted); }
.nav a span { font-size: 1.25rem; line-height: 1.2; }
.nav a.active { color: var(--primary-dark); font-weight: 700; }

.fab-row {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom));
  display: flex; justify-content: flex-end; gap: 8px;
  margin: 10px -16px 0; padding: 10px 16px;
  background: rgba(243, 246, 245, .96); border-top: 1px solid var(--line);
}

dialog {
  border: 0; border-radius: 16px; padding: 18px;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(16, 48, 45, .45); }
dialog h2 { margin-top: 0; }
.notice-text { min-height: 240px; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #16302d; color: #fff; padding: 10px 16px; border-radius: 10px;
  z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.error { background: var(--red); }

.auth { max-width: 400px; margin: 10vh auto 0; }
.auth h1 { text-align: center; margin-bottom: 4px; }

@media (max-width: 420px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-top: 58px; }
  .nav { top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); grid-template-columns: repeat(var(--tabs, 4), 130px); justify-content: center; }
  .nav a { flex-direction: row; gap: 6px; font-size: .95rem; padding: 14px 0; }
  .toast { bottom: 24px; }
  .fab-row { bottom: 0; }
}
