:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6ea;
  --text: #1c2024;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-bg: #e8f0fe;
  --success: #16915b;
  --warning: #b5730a;
  --danger: #c0392b;
  --radius: 12px;
  --pad: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 72px;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 600; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 13px; }

.container { max-width: 720px; margin: 0 auto; padding: var(--pad); }

.grid { display: grid; gap: 12px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }

.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.tile .label { color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.tile .value { font-size: 24px; font-weight: 600; margin: 0; }
.tile .value.small { font-size: 18px; }
.tile .delta { font-size: 13px; margin: 4px 0 0; }

.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.ok > span { background: var(--success); }
.bar.warn > span { background: var(--warning); }
.row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 14px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(0.95); }
.btn.block { width: 100%; justify-content: center; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.badge.on { background: #e7f6ee; color: var(--success); }
.badge.off { background: #f5e9e7; color: var(--danger); }

input, select {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.field { margin-bottom: 14px; }

/* Coach chat */
.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; }

.coach-card { background: var(--accent-bg); border: none; }
.coach-card h2 { color: var(--accent); }

.notice { background: #fff8e6; border: 1px solid #f2e2b3; color: #7a5a04; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a {
  flex: 1; text-align: center; padding: 10px 0; font-size: 12px; color: var(--muted);
}
.bottomnav a.active { color: var(--accent); }
.bottomnav a .ico { display: block; font-size: 20px; line-height: 1.2; }

.login-wrap { max-width: 380px; margin: 12vh auto; padding: var(--pad); }
.login-wrap .card { padding: 24px; }
h1.brand { font-size: 22px; margin: 0 0 4px; }
