:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #2e3534;          /* logo charcoal */
  --muted: #6b7271;
  --line: #e7e4e0;
  --orange: #eb5b04;       /* logo orange: accents, logo, focus */
  --brand: #c84c00;        /* deeper orange: buttons (white text passes contrast) */
  --brand-dark: #a84000;   /* hover + link text */
  --brand-tint: #fdeee4;
  --ok: #0e8a4a;
  --ok-bg: #e3f5ea;
  --bad: #c0182f;
  --bad-bg: #fde8eb;
  --warn: #9a5b00;
  --warn-bg: #fff3d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 6px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 24px; }

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 14px; font-weight: 700; color: var(--ink); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-wordmark { height: 34px; width: auto; display: block; }
.brand-gym { padding-left: 14px; border-left: 1px solid var(--line); line-height: 1.2; }
.topbar { border-top: 3px solid var(--orange); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--brand-tint); color: var(--brand-dark); }
.logout { display: flex; align-items: center; gap: 12px; margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- Cards & stats ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 4px; }
.stat { border-top: 3px solid var(--orange); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 36px; font-weight: 800; font-style: italic; letter-spacing: -.03em; line-height: 1.2; margin-top: 4px; }
.stat-value.ok { color: var(--ok); }
.stat-value.bad { color: var(--bad); }
.stat-of { font-size: 20px; color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; margin: 0; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table-foot { margin: 12px 12px 0; }
.pager { display: flex; justify-content: space-between; padding: 14px 12px 0; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-muted { background: #eef0f3; color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 16px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-weight: 400;
  border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(235, 91, 4, .18); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 4px; }
.error { display: block; font-weight: 500; color: var(--bad); font-size: 13px; margin-top: 4px; }
.optional { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form { max-width: 760px; }
.card-field { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 4px; margin: 0 0 18px; }
.card-field legend { font-weight: 700; padding: 0 6px; }
.picker { margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { border: 1px dashed var(--orange); background: var(--brand-tint); color: var(--brand-dark); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.chip:hover { border-style: solid; }
label.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; }
label.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--orange); }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.toolbar input { margin: 0; flex: 1; }
.toolbar select { margin: 0; width: auto; }
.inline-form { display: flex; align-items: flex-end; gap: 12px; max-width: 560px; }
.inline-form label { flex: 1; margin: 0; }
.danger-zone { max-width: 760px; text-align: right; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border-color: #d0d5dd; }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f1b5bf; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-block { width: 100%; padding: 11px; }
.btn-lg { padding: 13px 24px; font-size: 16px; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-dark); cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--bad); }

/* ---------- Flash messages ---------- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; font-size: 14px; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Device key ---------- */
.copy-row { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 14px; }
.codebox { flex: 1; display: block; margin: 0; background: var(--ink); color: #e6edf3; padding: 12px 14px; border-radius: 8px; font-size: 13px; overflow-x: auto; white-space: pre; }
.tabs { display: flex; gap: 4px; background: #e9ecf0; padding: 4px; border-radius: 10px; }
.tabs a { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; font-size: 14px; }
.tabs a.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px;
  background: radial-gradient(circle at 50% 0%, var(--brand-tint), transparent 60%); }
.auth-logo img { height: 86px; width: auto; display: block; }
.auth-card { border-top: 3px solid var(--orange); }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card h1 { font-size: 22px; margin-bottom: 20px; }

/* ---------- Landing page ---------- */
.landing { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.landing-nav { display: flex; justify-content: space-between; align-items: center; height: 84px; }
.landing-logo img { height: 48px; width: auto; display: block; }
.landing-nav nav { display: flex; align-items: center; gap: 20px; font-weight: 500; }
.hero { display: grid; grid-template-columns: 1fr 1.1fr; align-items: center; gap: 40px; padding: 50px 0 70px; }
/* Heavy italic caps echo the wordmark */
.display { font-size: clamp(48px, 7.5vw, 88px); font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: -.035em; line-height: .95; }
.accent { color: var(--orange); }
.lead { font-size: 19px; color: var(--muted); max-width: 480px; margin: 22px 0 32px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-art { position: relative; }
.hero-art::before {
  content: ""; position: absolute; inset: 8% 6% 0; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-tint) 0%, var(--brand-tint) 55%, transparent 72%);
}
.hero-art img { position: relative; width: 100%; height: auto; display: block; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding-bottom: 60px; }
.feature { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.feature-num { display: block; color: var(--orange); font-weight: 900; font-style: italic; font-size: 22px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); }
.landing-foot { text-align: center; padding: 30px 0; border-top: 1px solid var(--line); }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 8px 16px; }
  .nav { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .logout { margin-left: auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .features, .hero { grid-template-columns: 1fr; }
  .hero { padding-top: 20px; text-align: center; }
  .hero-art { order: -1; max-width: 420px; margin: 0 auto; }
  .lead { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
  .brand-gym { display: none; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .toolbar { flex-wrap: wrap; }
  .inline-form { flex-direction: column; align-items: stretch; }
}
