/* ============================================================
   VIA METHOD PORTAL — app styles
   Loads after ../css/styles.css and reuses its tokens.
   ============================================================ */

body.portal-body {
  min-height: 100dvh;
  background: var(--bg);
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); /* room for tab bar */
}

/* ---------- Header ---------- */
.p-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 32px);
  background: rgba(14, 14, 16, 0.88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.p-header img { height: 30px; width: auto; }

.p-header-right { display: flex; align-items: center; gap: 14px; }

.p-header-right a,
.p-header-right button {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 4px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--dur-fast) ease-out;
}
.p-header-right a:hover,
.p-header-right button:hover { color: var(--text); }
.p-header-right svg { width: 18px; height: 18px; }

/* ---------- Shell ---------- */
.p-shell {
  width: 100%;
  max-width: 780px;
  margin-inline: auto;
  padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 32px) 40px;
}

.p-greeting { margin-bottom: 6px; }
.p-greeting h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  line-height: 1.05;
}
.p-greeting .text-red { color: var(--red); }

.p-phase {
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: var(--yellow);
  margin-bottom: 26px;
}

.p-view h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 30px 0 14px;
}
.p-view h2:first-child { margin-top: 0; }

/* ---------- Cards ---------- */
.p-card {
  background: var(--charcoal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 26px);
  margin-bottom: 14px;
}

.p-card h3 { font-size: 1.15rem; margin-bottom: 10px; }
.p-card p { color: var(--text-muted); font-size: 0.97rem; }

.p-note {
  border-left: 3px solid var(--red);
  background: var(--charcoal-2);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 18px;
}

/* ---------- Day picker ---------- */
.daypick {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.daypick button {
  flex: none;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: var(--text-muted);
  background: var(--charcoal);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
  transition: all var(--dur-fast) ease-out;
}

.daypick button.on {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

/* ---------- Exercises ---------- */
.exercise {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.exercise:last-child { border-bottom: none; padding-bottom: 4px; }

.exercise input[type="checkbox"] {
  appearance: none;
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: all var(--dur-fast) ease-out;
}
.exercise input[type="checkbox"]:checked {
  background: var(--red);
  border-color: var(--red);
}
.exercise input[type="checkbox"]:checked::before {
  content: "";
  width: 12px;
  height: 7px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.exercise .ex-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.exercise.done .ex-name { color: var(--text-faint); text-decoration: line-through; }

.ex-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.ex-meta span {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--charcoal-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}
.ex-meta .rir { color: var(--yellow); border-color: rgba(255, 219, 47, 0.3); }

.ex-note { margin-top: 8px; font-size: 0.9rem; color: var(--text-muted); }
.ex-sub { margin-top: 4px; font-size: 0.85rem; color: var(--text-faint); }

/* ---------- Nutrition ---------- */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.macro {
  background: var(--charcoal);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.macro b {
  display: block;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  color: var(--red);
  font-variant-numeric: tabular-nums;
}
.macro span {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meal-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meal-row:last-child { border-bottom: none; }
.meal-row b {
  flex: none;
  width: 92px;
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.9rem;
  color: var(--yellow);
}
.meal-row p { font-size: 0.95rem; color: var(--text-muted); }

.p-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.p-list li { display: flex; gap: 10px; color: var(--text-muted); font-size: 0.95rem; }
.p-list li::before { content: "—"; color: var(--red); flex: none; }

/* ---------- Forms (portal-wide) ---------- */
.p-form { display: flex; flex-direction: column; gap: 16px; }

.p-form label {
  display: block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.p-form input,
.p-form select,
.p-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 48px;
  color: var(--text);
  width: 100%;
  transition: border-color var(--dur-fast) ease-out, box-shadow var(--dur-fast) ease-out;
}
.p-form textarea { resize: vertical; min-height: 90px; }
.p-form input:focus, .p-form select:focus, .p-form textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(229, 36, 36, 0.22);
}
.p-form select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A6A6A3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 44px;
}

.p-form .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.p-form .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.p-status { min-height: 1.3em; font-size: 0.92rem; color: var(--text-muted); }
.p-status.error { color: var(--red-bright); }
.p-status.success { color: var(--yellow); }

/* ---------- Check-in history ---------- */
.ci-item { border-top: 3px solid var(--red); }
.ci-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ci-head time { color: var(--text-faint); font-size: 0.85rem; }
.ci-nums { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ci-nums span {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--charcoal-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}
.ci-reply {
  margin-top: 10px;
  background: rgba(229, 36, 36, 0.07);
  border: 1px solid rgba(229, 36, 36, 0.25);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.ci-reply b {
  display: block;
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  color: var(--red-bright);
  margin-bottom: 4px;
}
.ci-reply p { font-size: 0.93rem; }

/* ---------- Progress chart ---------- */
.chart-wrap { padding: 10px 0 0; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--text-faint); font-size: 0.95rem; padding: 18px 0; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(14, 14, 16, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 60px;
  color: var(--text-faint);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  transition: color var(--dur-fast) ease-out;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--red-bright); }
.tabbar a:hover { color: var(--text); }

@media (min-width: 900px) {
  body.portal-body { padding-bottom: 40px; }
  .tabbar {
    position: sticky;
    top: 55px;
    bottom: auto;
    max-width: 780px;
    margin: 0 auto;
    grid-template-columns: repeat(5, auto);
    justify-content: center;
    gap: 6px;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-top: none;
    padding: 14px 0 4px;
  }
  .tabbar a {
    flex-direction: row;
    gap: 8px;
    min-height: 44px;
    padding: 8px 18px;
    font-size: 0.85rem;
    border: 1px solid transparent;
    border-radius: 999px;
  }
  .tabbar a.on {
    background: var(--charcoal);
    border-color: var(--border);
  }
}

/* ---------- Auth / gate screens ---------- */
.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--charcoal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(26px, 5vw, 38px);
}
.gate-card > img { height: 44px; width: auto; margin: 0 auto 22px; }
.gate-card h1 { font-size: 1.7rem; text-align: center; margin-bottom: 6px; }
.gate-card .gate-sub { text-align: center; color: var(--text-muted); font-size: 0.95rem; margin-bottom: 22px; }
.gate-links { margin-top: 18px; text-align: center; font-size: 0.92rem; color: var(--text-muted); }
.gate-links a { color: var(--yellow); }

/* ---------- Demo banner ---------- */
.demo-banner {
  background: var(--yellow);
  color: #1a1a1a;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.85rem;
  text-align: center;
  padding: 8px 14px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 12px;
}
.badge-founding { color: var(--yellow); border: 1px solid rgba(255, 219, 47, 0.4); }
.badge-active { color: #6ee76e; border: 1px solid rgba(110, 231, 110, 0.35); }
.badge-inactive { color: var(--text-faint); border: 1px solid var(--border); }

/* ---------- Wizard (join) ---------- */
.wizard-steps {
  display: flex;
  gap: 6px;
  margin: 18px 0 26px;
}
.wizard-steps span {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.wizard-steps span.done { background: var(--red); }

.wizard-title { font-size: clamp(1.6rem, 5vw, 2.2rem); margin-bottom: 6px; }
.wizard-sub { color: var(--text-muted); font-size: 0.97rem; margin-bottom: 22px; }

.waiver-box {
  height: 320px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.waiver-box h3 { font-size: 1rem; color: var(--text); margin: 14px 0 6px; }
.waiver-box h3:first-child { margin-top: 0; }
.waiver-box p, .waiver-box li { margin-bottom: 8px; line-height: 1.55; }

.agree-row { display: flex; align-items: flex-start; gap: 12px; margin: 14px 0; }
.agree-row input[type="checkbox"] { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--red); flex: none; }
.agree-row span { font-size: 0.92rem; color: var(--text-muted); }

.price-pick { display: grid; gap: 14px; }
.price-pick .p-card { margin-bottom: 0; text-align: center; }
.price-pick .amount {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 2.6rem;
  line-height: 1;
  margin: 8px 0 2px;
  font-variant-numeric: tabular-nums;
}
.price-pick .amount small { font-size: 0.4em; color: var(--text-muted); }

/* ---------- Admin ---------- */
.admin-shell { max-width: 1080px; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.93rem;
}
.admin-table th {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  color: var(--text-faint);
}
.admin-table tr { cursor: pointer; }
.admin-table tbody tr:hover { background: var(--charcoal-2); }

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  background: var(--charcoal-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur-fast) ease-out;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--dur-fast) ease-out, background var(--dur-fast) ease-out;
}
.switch.on { background: rgba(229, 36, 36, 0.5); border-color: var(--red); }
.switch.on::after { transform: translateX(20px); background: #fff; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 0.93rem; }
.kv dt { color: var(--text-faint); }
.kv dd { color: var(--text); margin: 0; overflow-wrap: anywhere; }

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 340px;
  overflow-y: auto;
}

.admin-back { margin-bottom: 16px; display: inline-flex; }

@media (max-width: 640px) {
  .macro-grid { grid-template-columns: repeat(2, 1fr); }
  .p-form .grid-3 { grid-template-columns: 1fr; }
  .p-form .grid-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  .admin-table .hide-sm { display: none; }
}
