/* =============================================================
   MMSx TEScanner v2.0 — Stylesheet
   TrainersEye Authority · MMSx Authority Institute · Powell, Ohio
   Mobile-first · Dark + Amber · Calibration-grade UI
   ============================================================= */

:root {
  /* Brand palette — TrainersEye dark with MMSx Authority refinements */
  --ink-0:        #050608;
  --ink-1:        #0A0C12;
  --ink-2:        #12151E;
  --ink-3:        #1B2032;
  --ink-4:        #252B40;
  --line:         #2A3045;
  --line-soft:    #1E2236;

  --gold:         #FFC107;
  --gold-bright:  #FFDA47;
  --gold-deep:    #E0A800;
  --gold-glow:    rgba(255, 193, 7, 0.45);

  --navy-deep:    #0F2341;
  --cream:        #F8F6F0;

  /* Status palette */
  --jade:         #4ADE80;
  --jade-deep:    #16A34A;
  --amber:        #FFAB00;
  --coral:        #FF4757;
  --coral-deep:   #DC2626;
  --teal:         #2DD4BF;
  --violet:       #A78BFA;
  --sky:          #38BDF8;

  /* Typography */
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Geometry */
  --radius-sm: 6px;
  --radius:    12px;
  --radius-lg: 18px;
  --safe-top:    env(safe-area-inset-top);
  --safe-bot:    env(safe-area-inset-bottom);

  /* Header / control heights */
  --topbar-h:    48px;
  --actionbar-h: 64px;
}

/* ─────────────────────────────────────────────────────────────
   RESET
   ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  height: 100%;
  background: var(--ink-0);
  color: var(--cream);
  font: 400 14px/1.45 var(--sans);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: var(--gold-glow); color: var(--gold-bright); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ─────────────────────────────────────────────────────────────
   APP LAYOUT — VIDEO TAKES MAXIMUM SCREEN ON MOBILE
   ───────────────────────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--ink-0);
}

/* ── TOP BAR ────────────────────────────────────────────────── */
.topbar {
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: linear-gradient(180deg, var(--ink-1), var(--ink-0));
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.topbar::after {
  content: "";
  position: absolute; inset-inline: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .45;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-weight: 700;
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--cream);
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-0); font-weight: 900; font-size: 14px;
  box-shadow: 0 0 12px var(--gold-glow);
  letter-spacing: -.02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { color: var(--gold); font-weight: 800; }
.brand-sub  { color: var(--cream); opacity: .55; font-size: 9px; font-weight: 500; letter-spacing: .14em; }

.topbar-status {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.10);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: var(--jade);
}
.topbar-status[data-state="standby"] {
  background: rgba(148, 163, 184, 0.10);
  border-color: rgba(148, 163, 184, 0.25);
  color: #94A3B8;
}
.topbar-status[data-state="scanning"] {
  background: rgba(255, 193, 7, 0.12);
  border-color: rgba(255, 193, 7, 0.35);
  color: var(--gold);
}
.topbar-status[data-state="error"] {
  background: rgba(255, 71, 87, 0.12);
  border-color: rgba(255, 71, 87, 0.35);
  color: var(--coral);
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: dotPulse 1.6s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(0.8); }
}

.topbar-actions {
  display: flex; align-items: center; gap: 4px;
}
.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--cream); opacity: .65;
  transition: all .15s ease;
}
.icon-btn:hover { opacity: 1; background: var(--ink-3); }
.icon-btn.active { opacity: 1; color: var(--gold); background: rgba(255, 193, 7, 0.10); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ── STAGE: VIDEO + OVERLAYS (MAX MOBILE REAL ESTATE) ──────── */
.stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: var(--ink-0);
  min-height: 0;
  /* Aspect-aware container */
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--ink-1), var(--ink-0));
}

#video, #skeleton-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--ink-0);
  display: block;
}
#video { transform: scaleX(-1); /* mirror front-camera */ }
#video.no-mirror { transform: none; }

#skeleton-canvas { pointer-events: none; z-index: 5; }

/* ── CALIBRATION GRID (overlays video) ────────────────────── */
#calibration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
}
#calibration.hidden { display: none; }

.calib-frame {
  width: min(90%, calc(100% - 24px));
  height: min(90%, calc(100% - 56px));
  position: relative;
  border: 1px solid rgba(255, 193, 7, 0.20);
}

/* Corner brackets — large, prominent */
.calib-corner {
  position: absolute;
  width: 28px; height: 28px;
}
.calib-corner.tl { top: -2px; left: -2px;
  border-top: 3px solid var(--gold);
  border-left: 3px solid var(--gold);
  border-top-left-radius: 6px;
}
.calib-corner.tr { top: -2px; right: -2px;
  border-top: 3px solid var(--gold);
  border-right: 3px solid var(--gold);
  border-top-right-radius: 6px;
}
.calib-corner.bl { bottom: -2px; left: -2px;
  border-bottom: 3px solid var(--gold);
  border-left: 3px solid var(--gold);
  border-bottom-left-radius: 6px;
}
.calib-corner.br { bottom: -2px; right: -2px;
  border-bottom: 3px solid var(--gold);
  border-right: 3px solid var(--gold);
  border-bottom-right-radius: 6px;
}

/* Rule-of-thirds grid */
.calib-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 193, 7, 0.10) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 193, 7, 0.10) 1px, transparent 1px);
  background-size: 33.333% 33.333%;
  background-position: -1px -1px;
}

/* Plumb line (vertical center reference) */
.calib-plumb {
  position: absolute;
  top: 0; bottom: 0; left: 50%; width: 0;
  border-left: 1px dashed rgba(255, 193, 7, 0.35);
}

/* Horizontal anatomical reference levels */
.calib-level {
  position: absolute; left: 0; right: 0;
  height: 0; border-top: 1px dashed rgba(56, 189, 248, 0.35);
}
.calib-level[data-level="shoulder"] { top: 22%; }
.calib-level[data-level="hip"]      { top: 52%; }
.calib-level[data-level="knee"]     { top: 75%; }
.calib-level::after {
  content: attr(data-level);
  position: absolute;
  right: 6px; top: -8px;
  font-family: var(--mono);
  font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(56, 189, 248, 0.7);
  background: rgba(5, 6, 8, 0.75);
  padding: 1px 6px; border-radius: 3px;
  pointer-events: none;
}

/* CENTER ANCHOR — the focal point coach uses to position subject */
.calib-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
}
.calib-center::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--gold);
  border-radius: 50%;
  opacity: 0;
  animation: centerPulse 2.4s ease-out infinite;
}
.calib-center::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 16px var(--gold-glow), 0 0 32px var(--gold-glow);
}
@keyframes centerPulse {
  0%   { opacity: 0.6; transform: scale(0.55); }
  70%  { opacity: 0;   transform: scale(1.4);  }
  100% { opacity: 0;   transform: scale(1.55); }
}

/* Center crosshair extensions */
.calib-cross-h, .calib-cross-v {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 193, 7, 0.55);
}
.calib-cross-h { width: 24px; height: 1.5px; }
.calib-cross-v { width: 1.5px; height: 24px; }

/* Calibration status banner */
.calib-banner {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 6, 8, 0.85);
  border: 1px solid rgba(255, 193, 7, 0.35);
  border-radius: 999px;
  padding: 7px 18px;
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold);
  backdrop-filter: blur(8px);
}
.calib-banner[data-state="ok"] {
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--jade);
}
.calib-banner[data-state="warning"] {
  border-color: rgba(255, 171, 0, 0.4);
  color: var(--amber);
}

/* Calibration footer hint */
.calib-hint {
  position: absolute;
  bottom: 10px; left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 6, 8, 0.78);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--cream);
  opacity: 0.82;
  text-align: center;
  max-width: calc(100% - 24px);
  line-height: 1.3;
}

/* ── HUD READOUTS (top-right overlay on video) ─────────────── */
#hud {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.hud-card {
  background: rgba(5, 6, 8, 0.78);
  border: 1px solid rgba(255, 193, 7, 0.25);
  border-radius: 10px;
  padding: 6px 10px;
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 80px;
}
.hud-lbl {
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); opacity: .85;
}
.hud-val {
  font-family: var(--mono);
  font-size: 18px; font-weight: 800;
  color: var(--cream);
  line-height: 1;
  font-feature-settings: "tnum" 1;
}
.hud-val.sm { font-size: 14px; }
.hud-val[data-state="safe"]    { color: var(--jade); }
.hud-val[data-state="warning"] { color: var(--amber); }
.hud-val[data-state="risk"]    { color: var(--coral); }

/* ── ASYMMETRY METER (left-side overlay) ──────────────────── */
#asymmetry {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 10;
  background: rgba(5, 6, 8, 0.78);
  border: 1px solid rgba(255, 193, 7, 0.25);
  border-radius: 10px;
  padding: 8px 10px 10px;
  backdrop-filter: blur(8px);
  min-width: 110px;
  pointer-events: none;
}
.asym-lbl {
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.asym-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; font-size: 11px; }
.asym-name { font-family: var(--mono); font-size: 9px; width: 28px; color: var(--cream); opacity: .85; letter-spacing: .05em; }
.asym-bar { flex: 1; height: 6px; background: var(--ink-3); border-radius: 999px; position: relative; overflow: hidden; }
.asym-bar-fill {
  position: absolute; inset-block: 0; left: 50%;
  width: 0; height: 100%;
  background: var(--jade);
  transform-origin: left center;
  transition: width .15s ease, background .15s ease;
}
.asym-bar-fill[data-state="warning"] { background: var(--amber); }
.asym-bar-fill[data-state="risk"]    { background: var(--coral); }
.asym-val {
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 700;
  color: var(--cream);
  min-width: 26px;
  text-align: right;
  font-feature-settings: "tnum" 1;
}

/* ── ANGLE LABELS (drawn on canvas, but for portable list overlay) */
#angle-labels {
  position: absolute;
  bottom: 12px; left: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px;
  pointer-events: none;
}
.angle-pill {
  background: rgba(5, 6, 8, 0.82);
  border: 1px solid rgba(255, 193, 7, 0.25);
  border-radius: 6px;
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--cream);
  letter-spacing: .04em;
  font-feature-settings: "tnum" 1;
}
.angle-pill .deg { color: var(--gold); margin-left: 3px; }
.angle-pill[data-state="warning"] .deg { color: var(--amber); }
.angle-pill[data-state="risk"]    .deg { color: var(--coral); }

/* Hide left/bottom HUD when stage is small */
@media (max-height: 580px) {
  #asymmetry { display: none; }
  #angle-labels { display: none; }
}

/* ── REP COUNTER (big, prominent) ──────────────────────────── */
#rep-counter {
  position: absolute;
  bottom: 12px; right: 12px;
  z-index: 10;
  background: rgba(5, 6, 8, 0.85);
  border: 1px solid rgba(74, 222, 128, 0.4);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  backdrop-filter: blur(8px);
}
.rep-lbl {
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--jade);
}
.rep-val {
  font-family: var(--mono);
  font-size: 28px; font-weight: 800;
  color: var(--cream);
  line-height: 1;
  font-feature-settings: "tnum" 1;
}
.rep-val.flash { animation: repFlash .4s ease; }
@keyframes repFlash {
  0% { transform: scale(1); color: var(--cream); }
  35% { transform: scale(1.18); color: var(--jade); }
  100% { transform: scale(1); color: var(--cream); }
}

/* ── MOVEMENT BADGE (top-center, indicates active movement) ─── */
#movement-badge {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(5, 6, 8, 0.85);
  border: 1px solid rgba(255, 193, 7, 0.35);
  border-radius: 999px;
  padding: 6px 14px;
  display: flex; align-items: center; gap: 8px;
  backdrop-filter: blur(8px);
  max-width: calc(100% - 240px);
}
.mvmt-icon { width: 16px; height: 16px; color: var(--gold); }
.mvmt-name {
  font-family: var(--sans);
  font-size: 12px; font-weight: 700;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mvmt-form-score {
  font-family: var(--mono);
  font-size: 11px; font-weight: 700;
  color: var(--gold);
  padding-left: 8px;
  border-left: 1px solid rgba(255, 193, 7, 0.25);
  margin-left: 4px;
  font-feature-settings: "tnum" 1;
}

/* ── ACTION BAR (sticky bottom) ─────────────────────────────── */
.actionbar {
  flex: 0 0 var(--actionbar-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-bot));
  background: linear-gradient(180deg, var(--ink-1), var(--ink-0));
  border-top: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.actionbar::before {
  content: "";
  position: absolute; inset-inline: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .35;
}
.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 10px;
  padding: 4px 6px;
  color: var(--cream); opacity: .7;
  transition: all .15s ease;
  position: relative;
}
.action svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; }
.action-label {
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.action:active { transform: scale(0.94); }
.action.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--ink-0);
  opacity: 1;
  box-shadow: 0 0 16px var(--gold-glow);
}
.action.primary svg { stroke-width: 2.5; }
.action.recording {
  background: var(--coral);
  color: white;
  opacity: 1;
  animation: recPulse 1.4s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 71, 87, 0.5); }
  50% { box-shadow: 0 0 20px rgba(255, 71, 87, 0.8); }
}
.action.active { color: var(--gold); opacity: 1; background: rgba(255, 193, 7, 0.10); }

/* ── SHEETS (bottom modals — client info, movement select, report) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 80;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.sheet-backdrop.open { display: flex; animation: sheetFadeIn .25s ease; }
@keyframes sheetFadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: sheetSlideUp .3s cubic-bezier(.2,.85,.3,1.1);
}
@keyframes sheetSlideUp { from { transform: translateY(20%); } to { transform: translateY(0); } }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 8px auto 4px;
  flex: 0 0 auto;
}
.sheet-head {
  padding: 6px 18px 14px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sheet-title {
  font-family: var(--sans);
  font-size: 16px; font-weight: 700;
  color: var(--cream);
  letter-spacing: -.01em;
}
.sheet-eyebrow {
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 2px;
}
.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 18px calc(18px + var(--safe-bot));
  -webkit-overflow-scrolling: touch;
}
.sheet-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--cream); opacity: .65;
}
.sheet-close:hover { opacity: 1; background: var(--ink-3); }

/* Form fields */
.field { margin-bottom: 14px; }
.field-label {
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); opacity: .85;
  margin-bottom: 5px;
  display: block;
}
.field-input, .field-select, .field-textarea {
  width: 100%;
  min-height: 42px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--cream);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.field-textarea { min-height: 70px; resize: vertical; font-family: var(--sans); }

.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Movement selection grid */
.movement-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.movement-card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  text-align: start;
  transition: all .15s;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 78px;
  color: var(--cream);
  cursor: pointer;
}
.movement-card:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 193, 7, 0.12);
}
.movement-card.selected {
  border-color: var(--gold);
  background: rgba(255, 193, 7, 0.06);
  box-shadow: 0 0 0 1px var(--gold), 0 0 16px rgba(255, 193, 7, 0.25);
}
.movement-card-name {
  font-family: var(--sans);
  font-size: 13px; font-weight: 700;
  color: var(--cream);
  line-height: 1.2;
}
.movement-card-cat {
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: .04em;
  color: var(--gold); opacity: .8;
}
.movement-card-plane {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--cream); opacity: .55;
  margin-top: auto;
}

/* Category groups in sheet */
.cat-group { margin-bottom: 16px; }
.cat-head {
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
}

/* Button row */
.sheet-actions {
  display: flex; gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.btn {
  flex: 1;
  min-height: 46px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px; font-weight: 700;
  letter-spacing: .02em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--ink-0);
  box-shadow: 0 4px 16px var(--gold-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--gold-glow); }
.btn-ghost {
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--cream);
}
.btn-ghost:hover { border-color: var(--gold); }
.btn-danger {
  background: var(--coral-deep);
  color: white;
}

/* ── REPORT (full-screen takeover) ────────────────────────── */
.report-bg {
  position: fixed;
  inset: 0;
  background: var(--cream);
  color: var(--navy-deep);
  z-index: 90;
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--sans);
}
.report-bg.open { display: block; }
.report {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 18px 60px;
  padding-top: calc(24px + var(--safe-top));
}
.report-head {
  display: flex; align-items: flex-start; gap: 14px;
  border-bottom: 2px solid var(--navy-deep);
  padding-bottom: 16px; margin-bottom: 22px;
}
.report-logo {
  width: 54px; height: 54px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--navy-deep), #1a3050);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-weight: 900; font-size: 22px;
  letter-spacing: -.03em;
}
.report-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 26px; font-weight: 500;
  letter-spacing: -.02em;
  color: var(--navy-deep);
  margin: 0;
}
.report-eyebrow {
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 4px;
}
.report-sub {
  color: #555;
  font-size: 13px;
  margin-top: 4px;
}

.report-section {
  margin: 26px 0;
}
.report-section-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 20px; font-weight: 500;
  color: var(--navy-deep);
  border-bottom: 1px solid #ccc;
  padding-bottom: 6px;
  margin: 0 0 14px;
}
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.report-kv {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px 14px;
}
.report-kv-lbl {
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: #8a6a18;
  margin-bottom: 4px;
}
.report-kv-val {
  font-size: 18px; font-weight: 700;
  color: var(--navy-deep);
  font-feature-settings: "tnum" 1;
}
.report-kv-val.big { font-size: 28px; }
.report-kv-val.safe    { color: var(--jade-deep); }
.report-kv-val.warning { color: #B45309; }
.report-kv-val.risk    { color: var(--coral-deep); }
.report-kv-meta {
  font-size: 11px; color: #777;
  margin-top: 2px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.report-table th {
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--navy-deep);
  background: #f1ede2;
  border: 1px solid #ddd;
  padding: 8px 10px;
  text-align: start;
}
.report-table td {
  border: 1px solid #ddd;
  padding: 8px 10px;
  color: #333;
}
.report-table td:first-child { background: #faf8f3; font-weight: 600; }

.risk-card {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 8px 0;
  display: flex; gap: 12px;
  align-items: flex-start;
}
.risk-card.high     { background: #FEF2F2; border-left: 4px solid var(--coral-deep); }
.risk-card.medium   { background: #FFF7ED; border-left: 4px solid #B45309; }
.risk-card.low      { background: #F0FDF4; border-left: 4px solid var(--jade-deep); }
.risk-card.critical { background: #FEE2E2; border-left: 4px solid #991B1B; }
.risk-card-icon {
  width: 22px; height: 22px;
  flex: 0 0 auto;
}
.risk-card-body { flex: 1; }
.risk-card-title {
  font-size: 14px; font-weight: 700;
  color: var(--navy-deep);
  margin-bottom: 4px;
}
.risk-card-msg {
  font-size: 13px; color: #555; margin-bottom: 8px;
}
.risk-card-correctives {
  font-size: 12px;
  color: #444;
  background: rgba(255,255,255,.7);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px dashed #ccc;
}
.risk-card-correctives strong { color: var(--navy-deep); display: block; margin-bottom: 4px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }

.report-footer {
  border-top: 2px solid var(--navy-deep);
  padding-top: 16px;
  margin-top: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #555;
}
.report-footer .meta {
  font-family: var(--mono);
  letter-spacing: .04em;
}

.report-close {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  z-index: 91;
  width: 40px; height: 40px;
  border-radius: 999px;
  background: var(--navy-deep);
  color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.report-actions-fixed {
  position: fixed;
  bottom: calc(12px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%);
  z-index: 91;
  display: flex; gap: 8px;
}
.report-actions-fixed .btn { min-width: 120px; min-height: 44px; }

/* Print rules — report becomes the page */
@media print {
  @page { size: A4; margin: 18mm 14mm 18mm; }
  html, body { background: white; color: black; overflow: visible; height: auto; }
  body { padding: 0; }
  #app, .topbar, .stage, .actionbar, .sheet-backdrop, .report-close, .report-actions-fixed { display: none !important; }
  .report-bg { position: static; display: block; background: white; height: auto; overflow: visible; }
  .report { padding: 0; max-width: none; }
  .risk-card { break-inside: avoid; }
  .report-section { break-inside: avoid-page; }
  a { color: inherit; text-decoration: none; }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — TABLET / DESKTOP
   ───────────────────────────────────────────────────────────── */
@media (min-width: 720px) {
  :root { --topbar-h: 56px; --actionbar-h: 72px; }
  .topbar-brand { font-size: 12px; }
  .brand-mark { width: 36px; height: 36px; font-size: 16px; }
  .action svg { width: 24px; height: 24px; }
  .action-label { font-size: 10px; }
  .movement-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .actionbar { grid-template-columns: repeat(7, 1fr); }
  .movement-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ─────────────────────────────────────────────────────────────
   ACCESSIBILITY
   ───────────────────────────────────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
