/* ============ Google Fonts ============ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

/* ============ Design tokens ============ */
:root {
  --ink-900: #0F1115;
  --ink-700: #2A2F39;
  --ink-500: #5B6472;
  --ink-400: #858D9A;
  --ink-300: #B5BAC2;
  --ink-200: #E2E4E8;
  --ink-100: #EEF0F3;
  --paper:   #F7F6F2;
  --card:    #FFFFFF;

  --navy-950: #0B1220;
  --navy-900: #111827;
  --navy-800: #1B2434;
  --navy-700: #2A3547;
  --navy-500: #64748B;

  --accent:     #1E40AF;
  --accent-600: #1D4ED8;
  --accent-50:  #EEF2FF;

  --ok:    #117A4F;
  --ok-50: #E6F4EC;
  --warn:    #B45309;
  --warn-50: #FDF3E2;
  --bad:    #B42318;
  --bad-50: #FDECEA;

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: 'Inter', 'Noto Sans SC', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  overflow-y: scroll; /* always show scrollbar — prevents width jump on toggle */
  overflow-anchor: none; /* disable scroll anchoring globally — prevents viewport jump on collapse */
}

body {
  font-family: var(--sans);
  font-size: 14px;
  background: var(--paper);
  color: var(--ink-900);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ============ SIDEBAR ============ */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--navy-900);
  color: #E7EAF0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  border-right: 1px solid #000;
  overflow-y: auto;
}

#sidebar-header {
  padding: 18px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
#sidebar-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #F3F5F9;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
  white-space: nowrap;
}
#sidebar-header h2::before {
  content: 'BM';
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(135deg, #3B82F6, #1E40AF);
  color: white;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

#btn-new-client {
  width: 100%;
  padding: 9px 14px;
  background: linear-gradient(180deg, #2563EB, #1E40AF);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--sans);
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 1px 2px rgba(0,0,0,0.3);
  transition: filter 0.15s;
}
#btn-new-client:hover { filter: brightness(1.08); }

#client-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 20px;
}
#client-list::-webkit-scrollbar { width: 5px; }
#client-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* ---- Client row ---- */
.client-item {
  padding: 9px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s;
  position: relative;
}
.client-item:hover { background: rgba(255,255,255,0.03); }
.client-item.active {
  background: rgba(59,130,246,0.08);
  border-left-color: #3B82F6;
}
.client-item .client-name {
  font-size: 13px;
  font-weight: 500;
  color: #F3F5F9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 156px;
}
.client-item .client-meta {
  font-size: 10px;
  color: #64748B;
  margin-top: 2px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.client-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #475569;
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.12s;
  padding: 2px 4px;
}
.client-item:hover .client-delete { opacity: 1; }
.client-delete:hover { color: #ef4444; }

/* ---- Session sub-list ---- */
.session-sub-list {
  padding: 4px 0 8px 14px;
  border-left: 1px solid rgba(255,255,255,0.06);
  margin-left: 16px;
}
.session-sub-item {
  padding: 4px 10px;
  font-size: 11px;
  color: #94A3B8;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 4px;
  margin: 1px 8px 1px 0;
  cursor: pointer;
  white-space: nowrap;
  gap: 6px;
  border-left: 2px solid transparent;
}
.session-sub-item:hover { background: rgba(255,255,255,0.04); color: #CBD5E1; }
.session-sub-item.active { background: rgba(59,130,246,0.14); color: #BFDBFE; border-left-color: #60A5FA; }
.session-sub-date { font-size: 11px; }
.session-sub-delete {
  background: none;
  border: none;
  color: #475569;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  padding: 1px 4px;
  transition: opacity 0.12s;
  line-height: 1;
}
.session-sub-item:hover .session-sub-delete { opacity: 1; }
.session-sub-delete:hover { color: #ef4444; }

/* ============ MAIN AREA ============ */
#main {
  flex: 1;
  display: block;
  min-height: 0;
  background: var(--paper);
  min-width: 0;
}

/* ---- Topbar ---- */
#topbar {
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--ink-200);
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  gap: 0;
}
#topbar::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 0 18px;
  height: 52px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink-500);
  font-weight: 500;
  font-family: var(--sans);
  transition: color 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink-700); }
.tab-btn.active { color: var(--ink-900); border-bottom-color: var(--ink-900); font-weight: 600; }

#topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#client-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
  padding: 4px 10px;
  border: 1px solid var(--ink-200);
  border-radius: 5px;
  background: white;
}
#btn-new-session {
  padding: 6px 14px;
  background: var(--ok);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--sans);
  display: none;
  transition: filter 0.12s;
}
#btn-new-session:hover { filter: brightness(1.08); }

#save-msg {
  font-size: 12px;
  color: var(--ok);
  font-weight: 500;
  font-family: var(--mono);
  opacity: 0;
  transition: opacity 0.4s;
  white-space: nowrap;
}
#save-msg.saving { color: var(--ink-500); opacity: 1; }

/* ---- Session selector bar ---- */
#session-selector-bar {
  position: sticky;
  top: 52px;
  z-index: 99;
  background: var(--card);
  border-bottom: 1px solid var(--ink-200);
  padding: 7px 24px;
  display: none;
  align-items: center;
  gap: 10px;
}
#session-selector-bar label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--ink-400);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
#session-select {
  padding: 5px 24px 5px 10px;
  border: 1px solid var(--ink-200);
  border-radius: 5px;
  font-size: 12px;
  font-family: var(--mono);
  background: white;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%235B6472' stroke-width='1.2' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* ---- Tab content ---- */
#tab-content {
  display: block;
  min-height: 0;
}
#tab-content::-webkit-scrollbar { width: 6px; }
#tab-content::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 3px; }
#tab-content::-webkit-scrollbar-track { background: transparent; }

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  width: 100%;
  max-width: 1100px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 16px 24px 80px;
}

#no-client-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  flex-direction: column;
  gap: 10px;
  color: var(--ink-400);
}
#no-client-msg p {
  font-size: 14px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

/* ============ SECTION CARDS ============ */
.section-card {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}
.section-title {
  width: 100%;
  box-sizing: border-box;
  background: #1a1a1a;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.section-body {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  border: 1px solid #E8E8E8;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 16px 20px;
  overflow: hidden;
  max-height: 5000px;
}
.section-body.collapsed {
  max-height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  border-width: 0 !important;
}
.sub-title {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #F0F0F0;
}

/* ============ FORM PRIMITIVES ============ */
.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  align-items: flex-start;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
}
.form-group.wide { min-width: 220px; flex: 1; }
.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.04em;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group textarea {
  padding: 7px 10px;
  border: 1px solid var(--ink-200);
  border-radius: 5px;
  font-size: 13px;
  color: var(--ink-900);
  background: white;
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
  font-family: var(--sans);
}
.form-group input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--ink-700);
  box-shadow: 0 0 0 2px rgba(15,17,21,0.06);
}
.form-group textarea { resize: vertical; min-height: 60px; }

/* ---- ISA specific ---- */
.isa-interp {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 5px;
  margin-top: 4px;
  font-weight: 500;
  border-left: 3px solid;
  line-height: 1.6;
}
.isa-interp.narrow   { background: var(--accent-50); color: #1d4ed8; border-color: var(--accent); }
.isa-interp.wide     { background: var(--warn-50); color: var(--warn); border-color: var(--warn); }
.isa-interp.neutral  { background: var(--ok-50); color: var(--ok); border-color: var(--ok); }
.isa-interp.good     { background: var(--ok-50); color: var(--ok); border-color: var(--ok); }
.isa-interp.restricted { background: var(--warn-50); color: var(--warn); border-color: var(--warn); }
.isa-interp.rigid    { background: var(--bad-50); color: var(--bad); border-color: var(--bad); }
.isa-input-row { display: flex; gap: 24px; align-items: flex-start; }
.isa-input-col { flex: 1 1 0; min-width: 0; }
.isa-input-col label { font-size: 11px; color: var(--ink-500); display: block; margin-bottom: 3px; font-weight: 600; white-space: nowrap; }
@media (max-width: 768px) { .isa-input-row { flex-direction: column; gap: 12px; } .isa-input-col { flex: none; width: 100%; } }

/* ---- Bounded angle / numeric input ---- */
.bounded-input { min-width: 210px; width: 100%; }
.bounded-controls { display: flex; align-items: center; gap: 7px; }
.bounded-track { position: relative; flex: 1; min-width: 96px; height: 22px; display: flex; align-items: center; }
.bounded-reference-zone {
  position: absolute; z-index: 0; height: 6px; border-radius: 4px;
  background: rgba(5, 150, 105, 0.24); pointer-events: none;
}
.bounded-range {
  position: relative; z-index: 1; width: 100%; margin: 0; padding: 0;
  background: transparent; accent-color: var(--ink-900); cursor: pointer;
}
.bounded-number { width: 58px !important; min-width: 58px; box-sizing: border-box; padding: 6px 5px !important; text-align: center; }
.bounded-clear {
  padding: 4px 5px; border: 0; background: transparent; color: var(--ink-400);
  font: 11px var(--sans); cursor: pointer; white-space: nowrap;
}
.bounded-clear:hover:not(:disabled) { color: var(--bad); text-decoration: underline; }
.bounded-clear:disabled { opacity: 0.35; cursor: default; }
.bounded-scale { position: relative; height: 16px; margin: -1px 75px 0 0; color: var(--ink-400); font-size: 9px; }
.bounded-mark { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.bounded-mark-min { transform: none; }
.bounded-mark-max { transform: translateX(-100%); }
.bounded-input.is-unmeasured .bounded-range { opacity: 0.28; filter: grayscale(1); }
.bounded-input.is-unmeasured .bounded-range::-webkit-slider-thumb { opacity: 0; }
.bounded-input.is-unmeasured .bounded-range::-moz-range-thumb { opacity: 0; }
.bounded-input.is-unmeasured .bounded-reference-zone { opacity: 0.45; }
.rom-table td:has(.bounded-input) { min-width: 230px; }
.supine-shoulder-row td:has(.bounded-input) { min-width: 205px; }
.supine-shoulder-row .bounded-scale { margin-right: 76px; font-size: 10px; }

/* ---- Centered bilateral rotation input ---- */
.centered-list { border-top: 1px solid var(--ink-100); }
.centered-bilateral {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) minmax(300px, 2.8fr) 88px 88px minmax(78px, .8fr) 64px;
  gap: 12px;
  align-items: center;
  padding: 11px 10px;
  border-bottom: 1px solid var(--ink-100);
  font-size: 13px;
}
.centered-title { font-weight: 500; color: var(--ink-700); }
.centered-axis-wrap { min-width: 0; }
.centered-axis-labels {
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--ink-400);
  font-size: 9px;
  margin-bottom: 1px;
}
.centered-axis-labels span:last-child { text-align: right; }
.centered-axis-labels strong { color: var(--ink-700); font-weight: 600; }
.centered-axis { position: relative; height: 24px; }
.centered-axis::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 11px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink-200);
}
.centered-zero {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 5px;
  width: 2px;
  height: 14px;
  background: var(--ink-700);
  transform: translateX(-50%);
  pointer-events: none;
}
.centered-half { position: absolute; top: 0; width: 50%; height: 24px; }
.centered-half-left { left: 0; }
.centered-half-right { right: 0; }
.centered-reference-zone {
  position: absolute;
  z-index: 0;
  top: 9px;
  height: 6px;
  border-radius: 4px;
  background: rgba(5, 150, 105, 0.24);
  pointer-events: none;
}
.centered-range {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  background: transparent;
  accent-color: var(--ink-900);
  cursor: pointer;
}
.centered-half-left .centered-range { direction: rtl; }
.centered-half-left::after,
.centered-half-right::after {
  position: absolute;
  top: 3px;
  color: var(--ink-300);
  font-size: 10px;
  pointer-events: none;
}
.centered-half-left::after { content: '←'; left: 0; }
.centered-half-right::after { content: '→'; right: 0; }
.centered-half.is-unmeasured .centered-range { opacity: .28; filter: grayscale(1); }
.centered-half.is-unmeasured .centered-range::-webkit-slider-thumb { opacity: 0; }
.centered-half.is-unmeasured .centered-range::-moz-range-thumb { opacity: 0; }
.centered-side { min-width: 0; }
.centered-side-label { display: none; font-size: 11px; color: var(--ink-500); }
.centered-side-input { display: flex; align-items: center; gap: 3px; }
.centered-side .bounded-number { width: 52px !important; min-width: 52px; }
.centered-side .bounded-clear { padding-inline: 2px; }
.centered-reference-label { color: var(--ink-400); font-size: 11px; }
.centered-delta { min-height: 16px; }

@media (max-width: 768px) {
  .rom-table { display: block; overflow-x: auto; }
  .bounded-input { min-width: 190px; }
  .bounded-scale { margin-right: 72px; }
  .centered-bilateral {
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    padding: 12px 0;
  }
  .centered-title { grid-column: 1; grid-row: 1; }
  .centered-reference-label { grid-column: 2; grid-row: 1; text-align: right; }
  .centered-axis-wrap { grid-column: 1 / -1; grid-row: 2; }
  .centered-side-left { grid-column: 1; grid-row: 3; }
  .centered-side-right { grid-column: 2; grid-row: 3; }
  .centered-side-label { display: block; margin-bottom: 3px; }
  .centered-side-input { justify-content: center; }
  .centered-delta { grid-column: 1 / -1; grid-row: 4; text-align: center; }
}

/* ---- Button groups (option pills) ---- */
.btn-group { display: flex; flex-wrap: wrap; gap: 5px; }
.btn-option {
  padding: 5px 13px;
  border: 1px solid var(--ink-200);
  border-radius: 100px;
  background: white;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-500);
  font-family: var(--sans);
  font-weight: 500;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.btn-option:hover { border-color: var(--ink-300); color: var(--ink-700); }
.btn-option.selected { background: var(--ink-900); border-color: var(--ink-900); color: white; }
.btn-option.selected-green { background: var(--ok); border-color: var(--ok); color: white; }

/* ---- ROM table ---- */
.rom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rom-table th {
  text-align: left;
  padding: 8px 10px;
  background: #FAFAF8;
  color: var(--ink-400);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--ink-200);
}
.rom-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
.rom-table tr:last-child td { border-bottom: none; }
.rom-table td:first-child { font-weight: 500; color: var(--ink-700); }
.rom-num-input {
  width: 70px;
  padding: 5px 8px;
  border: 1px solid var(--ink-200);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
  background: white;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.rom-num-input:focus { border-color: var(--ink-700); box-shadow: 0 0 0 2px rgba(15,17,21,0.06); }
.rom-num-input.flag-red { border-color: var(--bad); background: var(--bad-50); color: var(--bad); }
.rom-ref { color: var(--ink-400); font-size: 11px; font-family: var(--mono); }
.rom-delta {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
  margin-left: 4px;
}
.rom-delta.big { color: var(--bad); }
.rom-delta.med { color: var(--warn); }
.rom-delta.ok  { color: var(--ok); }

/* ---- Foot bilateral groups ---- */
.bilateral-group { margin-bottom: 12px; }
.bilateral-group .bilateral-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
}
.bilateral-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.bilateral-side { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.bilateral-side-label {
  font-size: 11px;
  color: var(--ink-400);
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.06em;
}

/* ---- Gait checkbox ---- */
.check-group { display: flex; gap: 8px; flex-wrap: wrap; }
.check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  padding: 5px 11px;
  border: 1px solid var(--ink-200);
  border-radius: 5px;
  background: white;
  transition: border-color 0.12s;
  font-family: var(--sans);
}
.check-label:hover { border-color: var(--ink-300); }
.check-label input[type="checkbox"] { accent-color: var(--ink-900); }
.check-label.checked { border-color: var(--ink-700); background: var(--ink-100); }

/* ============ TAB 1: FUNCTIONAL ============ */
.quadrant-banner {
  padding: 11px 16px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid;
}
.quadrant-banner.q-pending { background: var(--ink-100); color: var(--ink-500); border-color: var(--ink-200); }
.quadrant-banner.q-result  { background: var(--accent-50); color: var(--accent); border-color: #BFDBFE; }

.functional-card {
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}
.func-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 100px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--mono);
}
.func-tag.central { background: #E0E7FF; color: #4338CA; }
.func-tag.upper   { background: #FCE7F3; color: #9D174D; }
.func-tag.lower   { background: var(--ok-50); color: var(--ok); }
.func-tag.isa     { background: var(--warn-50); color: var(--warn); }

.pmp-signal {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 5px;
  margin-top: 6px;
  border-left: 3px solid;
  line-height: 1.6;
}
.pmp-signal.warn { background: var(--warn-50); color: var(--warn); border-color: var(--warn); }
.pmp-signal.info { background: var(--accent-50); color: var(--accent); border-color: var(--accent); }

/* ============ TAB 2: REPORT ============ */
.rl-item { display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; }
.rl-item-text { flex: 1; color: var(--bad); font-size: 14px; font-weight: 600; white-space: pre-wrap; }
.rl-reason-btn {
  flex-shrink: 0; width: 18px; height: 18px;
  background: var(--bad-50); border: 1px solid #FCA5A5; border-radius: 50%;
  color: #991B1B; font-size: 10px; font-weight: 700; cursor: default;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 2px; line-height: 1;
}
.rl-reason-btn:hover { background: #FECACA; }

#reason-tooltip {
  display: none; position: fixed; z-index: 9999;
  background: var(--ink-900); color: #F9FAFB; font-size: 12px;
  padding: 10px 14px; border-radius: 8px; max-width: 300px;
  white-space: pre-wrap; line-height: 1.6; box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  pointer-events: none; font-family: var(--sans);
}

.exec-block {
  border-radius: 8px; padding: 15px 18px; margin-bottom: 12px;
  border: 1px solid var(--ink-200); background: var(--card);
}
.exec-block h3 {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ink-400); margin-bottom: 10px;
  font-family: var(--mono);
}

.exec-notice {
  font-size: 12px; color: var(--ink-400); margin-bottom: 14px;
  padding: 7px 12px; background: var(--ink-100); border-radius: 5px;
  border: 1px solid var(--ink-200);
}

.report-placeholder { text-align: center; padding: 16px 20px; color: var(--ink-400); font-size: 14px; }

.report-card {
  border-radius: 8px; padding: 15px 18px; margin-bottom: 12px;
  border: 1px solid var(--ink-200); background: var(--card);
}
.report-card.conflict { border-color: var(--bad); border-left: 3px solid var(--bad); }
.report-card.warning  { border-color: var(--warn); border-left: 3px solid var(--warn); }
.report-card.caution  { border-color: #EAB308; border-left: 3px solid #EAB308; }
.report-card.ok       { border-color: var(--ok); border-left: 3px solid var(--ok); }
.report-card.info     { border-color: var(--accent); border-left: 3px solid var(--accent); }
.report-card h3 {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-400); margin-bottom: 8px; font-family: var(--mono);
}
.report-card .report-main { font-size: 14px; font-weight: 600; color: var(--ink-900); }
.report-card .report-sub  { font-size: 13px; color: var(--ink-700); margin-top: 5px; line-height: 1.5; }

.confidence-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 100px; margin-left: 8px;
  text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--mono);
}
.confidence-badge.high   { background: var(--ok-50); color: var(--ok); }
.confidence-badge.medium { background: var(--warn-50); color: var(--warn); }
.confidence-badge.low    { background: var(--bad-50); color: var(--bad); }

.risk-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 5px;
}
.risk-badge.high-risk   { background: var(--bad-50); color: var(--bad); }
.risk-badge.normal-risk { background: var(--ok-50); color: var(--ok); }

/* ============ TAB 3: TREND ============ */
canvas { display: block; max-width: 100%; }
.trend-placeholder { text-align: center; padding: 16px 20px; color: var(--ink-400); font-size: 14px; }

.trend-tab-bar { display: flex; gap: 5px; margin-bottom: 14px; flex-wrap: wrap; }
.trend-tab-btn {
  padding: 5px 14px; border: 1px solid var(--ink-200); border-radius: 100px;
  background: white; font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--ink-500); font-family: var(--sans); transition: all 0.12s;
}
.trend-tab-btn:hover { border-color: var(--ink-300); color: var(--ink-700); }
.trend-tab-btn.active { background: var(--ink-900); border-color: var(--ink-900); color: white; }

.sm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.sm-card { background: var(--card); border-radius: 8px; border: 1px solid var(--ink-200); overflow: hidden; }
.sm-card.sm-wide { grid-column: 1 / -1; }
.sm-card-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; }
.sm-card-title { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.sm-card-ref   { font-size: 11px; color: var(--ink-400); font-family: var(--mono); }
.sm-canvas { display: block; }
.sm-data-bar { padding: 8px 14px 10px; border-top: 1px solid var(--ink-100); display: flex; flex-direction: column; gap: 5px; }
.sm-data-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.sm-side-lbl { color: var(--ink-400); font-weight: 600; font-size: 11px; width: 14px; font-family: var(--mono); }
.sm-val      { font-weight: 700; font-size: 13px; min-width: 44px; font-family: var(--mono); }
.sm-delta    { font-size: 11px; font-weight: 600; color: var(--ink-400); font-family: var(--mono); }

.sm-toggle {
  width: 100%; background: var(--ink-100); border: 1px solid var(--ink-200);
  border-radius: 8px; padding: 10px 14px; text-align: left; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink-700); font-family: var(--sans);
  display: flex; align-items: center; justify-content: space-between; transition: background 0.12s;
}
.sm-toggle:hover { background: var(--ink-200); }
.sm-toggle .sm-arrow { font-size: 11px; color: var(--ink-400); transition: transform 0.2s; }
.sm-toggle.open .sm-arrow { transform: rotate(180deg); }
.sm-summary {
  display: none; background: var(--card); border: 1px solid var(--ink-200);
  border-top: none; border-radius: 0 0 8px 8px; overflow-x: auto; margin-bottom: 14px;
}
.sm-summary.open { display: block; }
.sm-tbl { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.sm-tbl th {
  text-align: center; padding: 7px 10px; background: #FAFAF8;
  color: var(--ink-400); font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--ink-200); white-space: nowrap; text-transform: uppercase;
}
.sm-tbl th:first-child, .sm-tbl th:nth-child(2) { text-align: left; }
.sm-tbl td { padding: 5px 10px; border-bottom: 1px solid var(--ink-100); text-align: center; white-space: nowrap; color: var(--ink-700); }
.sm-tbl td:first-child { font-weight: 600; color: var(--ink-900); }
.sm-tbl td:nth-child(2) { text-align: left; }
.sm-tbl tr:last-child td { border-bottom: none; }
.sm-tbl .sm-vbelow { color: var(--bad); font-weight: 700; }
.sm-tbl .sm-vabove { color: var(--warn); font-weight: 700; }
.sm-tbl .sm-vok    { color: var(--ok); font-weight: 700; }
.sm-tbl .sm-vref   { color: var(--ink-400); font-size: 11px; font-family: var(--mono); }

/* ============ UTILITIES ============ */
.text-red    { color: var(--bad); }
.text-orange { color: var(--warn); }
.text-green  { color: var(--ok); }
.mt-8 { margin-top: 8px; }
.gap-indicator { display: inline-block; margin-left: 4px; font-size: 11px; color: var(--bad); font-weight: 600; }
.suspect-value { text-decoration: line-through; color: var(--ink-400); font-style: italic; }
.suspect-tag {
  display: inline-block; font-size: 11px; padding: 1px 6px;
  background: var(--warn-50); color: var(--warn); border-radius: 3px;
  margin-left: 4px; font-weight: 600;
}

/* ============ COLLAPSIBLE ============ */
.collapsible-header {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none; padding: 8px 0;
}
.collapsible-header:hover { opacity: 0.75; }
.collapsible-arrow { font-size: 10px; color: var(--ink-400); }
.collapsible-hint  { font-size: 12px; color: var(--ink-300); }
.collapsible-body  { width: 100%; box-sizing: border-box; overflow: hidden; max-height: 2000px; padding: 8px 0 4px 16px; }
.collapsible-body.collapsed { max-height: 0 !important; overflow: hidden !important; padding: 0 !important; }

/* ============ SPORTS BUTTONS ============ */
.sports-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sport-btn {
  padding: 4px 12px; border-radius: 100px;
  border: 1px solid var(--ink-200); background: white;
  color: var(--ink-500); font-size: 12px; cursor: pointer;
  font-family: var(--sans); font-weight: 500; transition: all 0.12s;
}
.sport-btn:hover { border-color: var(--ink-300); color: var(--ink-700); }
.sport-btn.selected { background: var(--accent-50); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.movement-btn {
  padding: 3px 10px; border-radius: 100px;
  border: 1px solid var(--ink-200); background: white;
  color: var(--ink-500); font-size: 12px; cursor: pointer;
  font-family: var(--sans); font-weight: 500; transition: all 0.12s;
}
.movement-btn:hover { border-color: var(--ink-300); color: var(--ink-700); }
.movement-btn.selected { background: var(--accent-50); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ============ TENNIS MODULE ============ */
.tennis-module { width: 100%; box-sizing: border-box; border: 1px solid #BFDBFE; border-radius: 8px; padding: 16px; margin-bottom: 16px; background: var(--accent-50); }
.tennis-title    { font-size: 15px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.tennis-subtitle { font-size: 12px; color: var(--ink-500); margin-bottom: 12px; }
.tennis-aic-tag  { font-size: 12px; background: #FEF9C3; border: 1px solid #FDE047; border-radius: 5px; padding: 6px 10px; margin-bottom: 10px; color: #713F12; }
.aic-signals { display: block; margin-top: 2px; color: #92400E; }
.tennis-section { margin-bottom: 12px; }
.tennis-section-title { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.tennis-risk { padding: 8px 10px; border-radius: 5px; margin-bottom: 6px; }
.tennis-risk.red    { background: var(--bad-50); border-left: 3px solid var(--bad); }
.tennis-risk.orange { background: var(--warn-50); border-left: 3px solid var(--warn); }
.risk-label  { font-size: 13px; font-weight: 600; display: block; margin-bottom: 2px; }
.risk-desc   { font-size: 12px; color: var(--ink-500); }
.tennis-foot-finding { padding: 8px 10px; border-radius: 5px; background: var(--ok-50); border-left: 3px solid var(--ok); margin-bottom: 8px; }
.foot-pattern  { font-size: 13px; font-weight: 600; color: var(--ok); }
.foot-desc     { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.foot-strategy { font-size: 12px; color: var(--ok); margin-top: 4px; }
.tennis-collapsible { width: 100%; box-sizing: border-box; margin-bottom: 8px; }
.tennis-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: #DBEAFE; border-radius: 5px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); user-select: none;
}
.tennis-col-header:hover { opacity: 0.85; }
.strength-col-header {
  width: 100%; box-sizing: border-box;
  padding: 8px 10px; background: #DBEAFE; border-radius: 5px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); user-select: none;
}
.strength-col-header:hover { opacity: 0.85; }
.finding-count { font-size: 11px; font-weight: 400; color: var(--ink-500); }
.tennis-col-body { padding: 8px 0 2px; }
.tennis-finding { padding: 8px 10px; border-radius: 5px; margin-bottom: 6px; }
.tennis-finding.red    { background: var(--bad-50); border-left: 3px solid var(--bad); }
.tennis-finding.orange { background: var(--warn-50); border-left: 3px solid var(--warn); }
.finding-rule { font-size: 13px; font-weight: 600; color: var(--ink-900); margin-bottom: 2px; }
.finding-desc { font-size: 12px; color: var(--ink-500); }
.tennis-adductor { padding: 8px 10px; background: #F5F3FF; border-left: 3px solid #7C3AED; border-radius: 5px; margin-bottom: 10px; }
.adductor-title { font-size: 13px; font-weight: 600; color: #6D28D9; margin-bottom: 4px; }
.adductor-item  { font-size: 12px; color: var(--ink-500); margin-bottom: 2px; }
.adductor-note  { font-size: 11px; color: var(--ink-400); margin-top: 4px; }
.tennis-strategy { padding: 8px 10px; background: var(--ok-50); border-left: 3px solid var(--ok); border-radius: 5px; margin-bottom: 6px; }
.strategy-label { font-size: 13px; font-weight: 600; color: var(--ok); margin-bottom: 2px; }
.strategy-desc  { font-size: 12px; color: var(--ink-500); }

/* ============ INJURY CHECKBOXES ============ */
.injury-site-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; cursor: pointer; padding: 3px 8px;
  border: 1px solid var(--ink-200); border-radius: 100px;
  background: white; user-select: none; transition: border-color 0.12s;
}
.injury-site-label:hover { border-color: var(--ink-300); }
.injury-site-label input[type=checkbox] { cursor: pointer; accent-color: var(--ink-900); }

/* ============ PDF EXPORT ============ */
#btn-export-pdf {
  padding: 5px 12px; border-radius: 5px;
  border: 1px solid var(--ink-200); background: white;
  color: var(--ink-700); font-size: 12px; cursor: pointer; font-weight: 500;
  font-family: var(--sans); transition: background 0.12s;
}
#btn-export-pdf:hover { background: var(--ink-100); }

#pdf-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
#pdf-panel {
  background: white; border-radius: 10px; padding: 24px;
  min-width: 340px; max-width: 420px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.pdf-panel-title { font-size: 16px; font-weight: 700; color: var(--ink-900); margin-bottom: 12px; }
.pdf-client-info {
  font-size: 12px; color: var(--ink-500); margin-bottom: 16px;
  padding: 8px 10px; background: var(--ink-100); border-radius: 5px;
  font-family: var(--mono);
}
.pdf-checks { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.pdf-check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.pdf-check-row input[type=checkbox] { cursor: pointer; width: 15px; height: 15px; accent-color: var(--ink-900); }
.pdf-panel-btns { display: flex; gap: 10px; justify-content: flex-end; }
.pdf-btn-cancel {
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--ink-200);
  background: white; color: var(--ink-700); font-size: 13px; cursor: pointer; font-family: var(--sans);
}
.pdf-btn-cancel:hover { background: var(--ink-100); }
.pdf-btn-confirm {
  padding: 8px 20px; border-radius: 6px; border: none;
  background: var(--accent); color: white; font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: var(--sans);
}
.pdf-btn-confirm:hover { background: var(--accent-600); }

/* ============ DATA QUALITY ============ */
.dq-injury-banner {
  display: none; background: var(--warn-50); border: 1px solid #FDBA74;
  border-radius: 6px; padding: 10px 14px; margin-bottom: 12px;
  font-size: 13px; color: var(--warn); line-height: 1.6;
}
.dq-injury-banner strong { font-weight: 700; }

.dq-tension-badge {
  display: inline-block; font-size: 11px; color: var(--warn);
  background: var(--warn-50); border: 1px solid #FDBA74;
  border-radius: 3px; padding: 0 5px; margin-left: 6px;
  vertical-align: middle; font-weight: 600;
}
.dq-struct-note {
  display: inline-block; font-size: 11px; color: var(--ink-500);
  background: var(--ink-100); border: 1px solid var(--ink-200);
  border-radius: 3px; padding: 0 5px; margin-left: 6px; vertical-align: middle;
}
.dq-stale-badge {
  display: inline-block; font-size: 11px; color: var(--accent);
  background: var(--accent-50); border: 1px solid #BFDBFE;
  border-radius: 3px; padding: 0 5px; margin-left: 6px; vertical-align: middle;
}

.dq-completeness {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--ink-100); border: 1px solid var(--ink-200); border-radius: 6px;
  margin-bottom: 12px; cursor: pointer; user-select: none;
}
.dq-completeness:hover { background: var(--ink-200); }
.dq-comp-label { font-size: 11px; color: var(--ink-500); font-weight: 600; white-space: nowrap; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.dq-comp-bar { flex: 1; height: 5px; background: var(--ink-200); border-radius: 3px; overflow: hidden; min-width: 60px; }
.dq-comp-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.dq-comp-fill.green  { background: var(--ok); }
.dq-comp-fill.yellow { background: #D97706; }
.dq-comp-fill.orange { background: var(--warn); }
.dq-comp-fill.red    { background: var(--bad); }
.dq-comp-pct { font-size: 12px; font-weight: 700; white-space: nowrap; font-family: var(--mono); }
.dq-comp-pct.green  { color: var(--ok); }
.dq-comp-pct.yellow { color: #D97706; }
.dq-comp-pct.orange { color: var(--warn); }
.dq-comp-pct.red    { color: var(--bad); }
.dq-comp-text { font-size: 12px; color: var(--ink-500); }

.dq-comp-popup { display: none; background: var(--card); border: 1px solid var(--ink-200); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; font-size: 12px; }
.dq-comp-popup.open { display: block; }
.dq-comp-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.dq-comp-row .dq-field-name    { flex: 1; color: var(--ink-700); }
.dq-comp-row .dq-field-filled  { color: var(--ok); font-weight: 700; }
.dq-comp-row .dq-field-empty   { color: var(--ink-400); }
.dq-comp-row .dq-field-partial { color: var(--warn); font-weight: 600; }

.dq-interrupt { background: var(--bad-50); border: 1px solid #FCA5A5; border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; }
.dq-interrupt-title { font-size: 14px; font-weight: 700; color: var(--bad); margin-bottom: 6px; }
.dq-interrupt-row { font-size: 13px; color: #7F1D1D; line-height: 1.6; margin-top: 2px; }
.dq-interrupt-row strong { color: var(--bad); }

.dq-pending { margin-top: 6px; }
.dq-pending-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--warn); background: var(--warn-50);
  border: 1px solid #FDE68A; border-radius: 4px; padding: 3px 9px;
  cursor: pointer; font-weight: 600;
}
.dq-pending-toggle:hover { background: #FEF3C7; }
.dq-pending-body { display: none; background: var(--warn-50); border: 1px solid #FDE68A; border-top: none; border-radius: 0 0 4px 4px; padding: 8px 10px; font-size: 12px; color: #78350F; line-height: 1.6; }
.dq-pending-body.open { display: block; }

.dq-contradiction-notice { background: var(--bad-50); border: 1px solid #FCA5A5; border-radius: 5px; padding: 8px 12px; margin-bottom: 10px; font-size: 12.5px; color: #991B1B; font-weight: 600; }
.dq-contradiction-inline { display: block; font-size: 11.5px; color: var(--bad); background: var(--bad-50); border-left: 2px solid #FCA5A5; padding: 3px 7px; margin-top: 4px; border-radius: 0 3px 3px 0; line-height: 1.5; }

#dq-panel0 { padding: 0 0 2px 0; }

.dq-suggestions-block { background: #F0F9FF; border: 1px solid #BAE6FD; border-radius: 6px; padding: 12px 14px; margin-top: 12px; }
.dq-suggestions-block h4 { font-size: 13px; font-weight: 700; color: #0369A1; margin: 0 0 8px 0; }
.dq-suggestion-row { font-size: 12px; color: var(--ink-700); padding: 3px 0; display: flex; gap: 6px; }
.dq-suggestion-row .dq-sug-field { color: #0369A1; font-weight: 600; min-width: 120px; }
.dq-suggestion-row .dq-sug-desc  { color: var(--ink-500); }

/* ============ REASONING LOG ============ */
.reasoning-toggle {
  width: 100%; background: var(--ink-100); border: 1px solid var(--ink-200);
  border-radius: 8px; padding: 11px 14px; margin-top: 14px; text-align: left;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-700);
  font-family: var(--sans); display: flex; align-items: center; justify-content: space-between;
  transition: background 0.12s;
}
.reasoning-toggle:hover { background: var(--ink-200); }
.reasoning-toggle .toggle-arrow { font-size: 11px; color: var(--ink-400); transition: transform 0.2s; }
.reasoning-toggle.open .toggle-arrow { transform: rotate(180deg); }
.reasoning-log { display: none; background: var(--card); border: 1px solid var(--ink-200); border-top: none; border-radius: 0 0 8px 8px; padding: 14px 16px; font-size: 12.5px; line-height: 1.8; }
.reasoning-log.open { display: block; }
.log-ok   { color: var(--ok); }
.log-warn { color: var(--bad); font-weight: 600; }
.log-skip { color: var(--ink-400); }

/* ============ EXEC PLAN COLLAPSIBLE ============ */
.report-section-body { width: 100%; box-sizing: border-box; overflow: hidden; max-height: 5000px; overflow-anchor: none; }
.report-section-body.collapsed { max-height: 0 !important; overflow: hidden !important; padding: 0 !important; }
.report-collapsible-section { width: 100%; box-sizing: border-box; overflow-anchor: none; }
.specialty-subsection { width: 100%; box-sizing: border-box; }
#exec-container { width: 100%; box-sizing: border-box; overflow-anchor: none; }

/* ============ FEEDBACK FLAG BUTTONS ============ */
.feedback-flag-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
  transition: opacity 0.15s;
  color: #ccc;
}
.feedback-flag-btn.has-note { opacity: 1 !important; color: orange; }
.report-section-header:hover .feedback-flag-btn:not(.has-note),
.strength-col-header:hover .feedback-flag-btn:not(.has-note) { opacity: 0.4; }

/* ===== 移动端侧栏折叠按钮 ===== */
#sidebarToggle { display: none; }

@media (max-width: 768px) {
  #sidebarToggle {
    display: block;
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 1000;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 0 6px 6px 0;
    padding: 12px 6px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 1px 1px 4px rgba(0,0,0,0.15);
  }
  #sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }
  #sidebar.collapsed > * { display: none !important; }
}

/* ── 初始筛查 section heading ───────────────────────── */
.screening-section { margin: 12px 0 24px 0; }
.screening-title-bar { border-bottom: 2px solid #2563eb; padding: 4px 0 10px 0; margin-bottom: 18px; }
.screening-title { font-size: 18px; font-weight: 700; color: #1a1a1a; margin: 0; }
.screening-subtitle { font-size: 13px; color: #6b7280; margin: 4px 0 0 0; font-weight: 400; }

/* ── 足部结论 3-tier hierarchy + warning severity ───── */
.foot-conclusion { padding: 12px 0; }
.foot-side-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.foot-card { padding: 12px 16px; border-radius: 8px; border-left: 4px solid; background: #fff; }
.foot-card.severity-high   { border-left-color: #E85454; background: #FEF2F2; }
.foot-card.severity-medium { border-left-color: #F5A623; background: #FFF8EC; }
.foot-card.severity-low    { border-left-color: #5CB85C; background: #F0FAF1; }
.foot-label { font-size: 11px; color: #888; letter-spacing: 0.06em; text-transform: uppercase; }
.foot-verdict { font-size: 16px; font-weight: 700; color: #1a1a1a; margin: 4px 0 0 0; line-height: 1.4; }
.foot-comparison { display: flex; gap: 12px; align-items: baseline; padding: 10px 14px; background: #f3f4f6; border-radius: 6px; margin-bottom: 14px; }
.foot-comparison .label { font-size: 13px; color: #6b7280; }
.foot-comparison .value { font-weight: 600; color: #1a1a1a; }
.foot-warnings { display: flex; flex-direction: column; gap: 8px; }
.foot-warning { display: flex; gap: 10px; padding: 10px 14px; border-radius: 6px; border-left: 4px solid; font-size: 14px; line-height: 1.55; }
.foot-warning.sev-high   { border-left-color: #E85454; background: #FEF2F2; color: #991B1B; font-weight: 500; }
.foot-warning.sev-medium { border-left-color: #F5A623; background: #FFF8EC; color: #92400E; }
.foot-warning.sev-info   { border-left-color: #4A90D9; background: #EFF6FF; color: #1E40AF; }
.foot-warning .icon { flex-shrink: 0; }

/* ============ Priority tag system ============ */
.priority-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 8px;
  letter-spacing: 0.03em;
  vertical-align: middle;
  line-height: 1.4;
}
.priority-tag.t1 { background: #01847F; color: #fff; }
.priority-tag.t2 { background: #3B6CB7; color: #fff; }
.priority-tag.t3 { background: #E5E7EB; color: #374151; }
.priority-tag.t4 { background: #fff; color: #92400E; border: 1px solid #FCD9A8; }

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #F3F4F6;
  color: #6B7280;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  cursor: help;
  vertical-align: middle;
  user-select: none;
  border: none;
  transition: background 0.15s;
}
.info-tip:hover { background: #E5E7EB; color: #374151; }
.info-tip:active { background: #D1D5DB; }

.global-tooltip {
  position: fixed;
  background: #1F2937;
  color: #F9FAFB;
  font-size: 12px;
  font-weight: 400;
  padding: 8px 12px;
  border-radius: 6px;
  max-width: 280px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 9999;
  pointer-events: none;
  white-space: normal;
}

/* ============ Unified test heading ============ */
.test-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 16px 0 12px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.test-title .title-en {
  font-size: 12px;
  font-weight: 400;
  color: #9CA3AF;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* ============ Collapsible compensation blocks ============ */
.compensation-block { margin-top: 12px; }
.compensation-header {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: #374151;
  padding: 8px 0;
  list-style: none;
}
.compensation-header::-webkit-details-marker { display: none; }
.compensation-header::before {
  content: '▶';
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  transition: transform 0.2s;
}
details[open] .compensation-header::before { transform: rotate(90deg); }
.compensation-header .hint {
  font-weight: 400;
  font-size: 12px;
  color: #9CA3AF;
  margin-left: 6px;
}
.compensation-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-left: 16px;
}

.tier-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 0 8px 0;
  margin-top: 24px;
  border-bottom: 1px solid #E5E7EB;
  margin-bottom: 16px;
}
.tier-header:first-child { margin-top: 0; }
.tier-label {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.tier-1 .tier-label { background: #01847F; color: #fff; }
.tier-2 .tier-label { background: #3B6CB7; color: #fff; }
.tier-3 .tier-label { background: #E5E7EB; color: #374151; }
.tier-name { font-size: 15px; font-weight: 700; color: #1a1a1a; }
.tier-hint { font-size: 12px; color: #6B7280; font-weight: 400; }

/* ============ Unified engine warnings ============ */
.engine-warning {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  border-left: 4px solid;
  font-size: 14px;
  line-height: 1.55;
  margin: 8px 0;
}
.engine-warning .icon { flex-shrink: 0; font-size: 14px; }
.engine-warning .body { flex: 1; }
.engine-warning .body b { font-weight: 600; }
.engine-warning.sev-high   { border-left-color: #E85454; background: #FEF2F2; color: #991B1B; font-weight: 500; }
.engine-warning.sev-medium { border-left-color: #F5A623; background: #FFF8EC; color: #92400E; }
.engine-warning.sev-info   { border-left-color: #4A90D9; background: #EFF6FF; color: #1E40AF; }
.engine-warning.sev-good   { border-left-color: #5CB85C; background: #F0FAF1; color: #166534; }

/* ============ Unified module headers ============ */
.module-header {
  background: #1a1a1a;
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  min-height: 44px;
}
.module-header .module-title-cn { font-size: 16px; font-weight: 600; color: #fff; }
.module-header .module-title-en { font-size: 12px; font-weight: 400; color: rgba(255,255,255,0.6); letter-spacing: 0.02em; }
.module-header .info-tip { background: rgba(255,255,255,0.15); color: #fff; }
.module-header .info-tip:hover { background: rgba(255,255,255,0.25); }
.module-header .module-tag { font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 3px; letter-spacing: 0.03em; margin-left: auto; }
.module-header .module-tag.central { background: #8B5CF6; color: #fff; }
.module-header .module-tag.lower-limb { background: #D1FAE5; color: #065F46; }
.module-header .module-tag.upper-limb { background: #DBEAFE; color: #1E40AF; }

/* ===== Client list groups ===== */
.group { margin-bottom: 4px; }
.group-header {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; cursor: pointer; user-select: none;
  border-radius: 4px; font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.7);
}
.group-header:hover { background: rgba(255,255,255,0.05); }
.group-toggle {
  font-size: 10px; color: rgba(255,255,255,0.5);
  transition: transform 0.15s; cursor: pointer; padding: 2px;
}
.group.collapsed .group-toggle { transform: rotate(-90deg); }
.group.collapsed .group-clients { display: none; }
.group-color-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; cursor: pointer;
}
.group-name { flex: 1; outline: none; }
.group-name[contenteditable="true"] {
  background: rgba(255,255,255,0.08);
  border-radius: 3px; padding: 0 4px;
}
.group-count { font-size: 11px; color: rgba(255,255,255,0.4); }
.group-menu {
  opacity: 0; font-size: 14px; padding: 0 4px;
  cursor: pointer; transition: opacity 0.1s;
}
.group-header:hover .group-menu { opacity: 0.6; }
.group-menu:hover { opacity: 1 !important; }
.group-clients { padding-left: 8px; min-height: 28px; }
.group-clients.drag-over { background: rgba(59,130,246,0.08); border-radius: 4px; }

.client-item.dragging { opacity: 0.4; }
.client-item.drag-over-top { border-top: 2px solid #3B82F6; }
.client-item.drag-over-bottom { border-bottom: 2px solid #3B82F6; }

.btn-add-group {
  width: calc(100% - 16px); margin: 8px; padding: 8px;
  background: transparent; border: 1px dashed rgba(255,255,255,0.2);
  border-radius: 4px; color: rgba(255,255,255,0.5);
  cursor: pointer; font-size: 12px;
}
.btn-add-group:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.4);
}

.color-picker, .group-context-menu {
  position: absolute; background: #1f2937;
  border-radius: 6px; padding: 4px; z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.color-picker { display: flex; gap: 4px; padding: 8px; }
.color-picker .color-option {
  width: 20px; height: 20px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
}
.color-picker .color-option:hover { border-color: rgba(255,255,255,0.5); }
.group-context-menu { min-width: 120px; }
.group-context-menu button {
  display: block; width: 100%; padding: 6px 12px;
  background: transparent; border: none; color: #fff;
  font-size: 13px; text-align: left; cursor: pointer;
  border-radius: 3px;
}
.group-context-menu button:hover { background: rgba(255,255,255,0.08); }
.group-context-menu button.danger { color: #f87171; }
.group-context-menu button:disabled {
  color: rgba(255,255,255,0.3); cursor: not-allowed;
}

/* Group drag-and-drop */
.group.group-dragging { opacity: 0.4; }
.group-header.group-drag-over-top { border-top: 2px solid #3B82F6; }
.group-header.group-drag-over-bottom { border-bottom: 2px solid #3B82F6; }

/* ===== Mobile responsive: list/detail switch ===== */
.btn-back-to-list {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  color: #3B82F6;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
  width: 100%;
  text-align: left;
}

@media (max-width: 768px) {
  .btn-back-to-list { display: block; }

  body { display: block; }

  #sidebar, #main {
    position: fixed;
    top: 0; left: 0;
    width: 100% !important;
    height: 100vh;
    transition: transform 0.25s ease;
  }
  #sidebar { z-index: 30; max-width: 100%; min-width: 0; }
  #main { z-index: 20; overflow-y: auto; }

  body.mobile-view-list #sidebar { transform: translateX(0); }
  body.mobile-view-list #main { transform: translateX(100%); }

  body.mobile-view-detail #sidebar { transform: translateX(-100%); }
  body.mobile-view-detail #main { transform: translateX(0); }

  #sidebarToggle { display: none; }
}

/* ===== Mobile action sheet ===== */
.client-action-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 12px 12px 0 0;
  padding: 8px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
  z-index: 100;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.client-action-sheet.open { transform: translateY(0); }
.client-action-sheet .cas-title {
  padding: 10px 14px 8px;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
  border-bottom: 1px solid #f0f0f0;
}
.client-action-sheet button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: transparent;
  border: none;
  font-size: 16px;
  color: #1a1a1a;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.client-action-sheet button.danger { color: #ef4444; }
.client-action-sheet button.cancel {
  margin-top: 8px;
  font-weight: 600;
  border-bottom: none;
}
.client-action-sheet .cas-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.client-action-sheet-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.client-action-sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ===== User menu (top-right) ===== */
.user-menu { position: relative; display: inline-block; margin-left: 8px; }
.user-menu-trigger {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.04);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.user-menu-trigger:hover { background: rgba(0,0,0,0.08); }
.user-menu-arrow { font-size: 10px; opacity: 0.6; transition: transform 0.15s; }
.user-menu.open .user-menu-arrow { transform: rotate(180deg); }
.user-menu-dropdown {
  position: fixed;
  min-width: 200px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 8px;
  display: none;
  z-index: 9999;
}
.user-menu-dropdown.open { display: block; }
.user-menu-info { padding: 8px 12px; }
.user-menu-display-name { font-size: 14px; font-weight: 600; color: #1f2937; }
.user-menu-username { font-size: 12px; color: #6b7280; margin-top: 2px; font-family: var(--mono); }
.user-menu-divider { height: 1px; background: #e5e7eb; margin: 8px 0; }
.user-menu-item {
  display: block; width: 100%;
  padding: 8px 12px;
  background: transparent; border: none;
  color: #1f2937;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
}
.user-menu-item:hover { background: #f3f4f6; }
.user-menu-item-danger { color: #ef4444; }
.user-menu-item-danger:hover { background: #fef2f2; }
@media (max-width: 768px) {
  .user-menu-dropdown { min-width: 220px; }
}

/* ===== Modal (generic) ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.modal-card {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; color: #1f2937; }
.modal-close {
  background: transparent; border: none;
  font-size: 18px; color: #6b7280;
  cursor: pointer; padding: 4px 8px;
}
.modal-close:hover { color: #1f2937; }
.modal-body { padding: 20px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: #374151; margin-bottom: 6px;
}
.modal-body .form-group input {
  width: 100%; padding: 8px 12px;
  border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 14px; box-sizing: border-box;
  font-family: inherit;
}
.modal-body .form-group input:focus {
  outline: none; border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-hint { font-size: 12px; color: #6b7280; margin-top: 4px; }
.form-error {
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  font-size: 13px;
  margin-top: 8px;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}
.btn-secondary, .btn-primary {
  padding: 8px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
}
.btn-secondary { background: #fff; border-color: #d1d5db; color: #374151; }
.btn-secondary:hover { background: #f3f4f6; }
.btn-primary { background: #3B82F6; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2563EB; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 3000;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { background: #10B981; }
.toast-error { background: #EF4444; }

/* ============ R-43 Mobile / WeChat H5 shell ============ */
#mobile-header,
#mobile-actionbar,
#mobile-drawer-backdrop,
#mobile-drawer-close {
  display: none;
}

.sidebar-title-row h2 { margin-bottom: 12px; }

@media (max-width: 768px) {
  :root {
    --mobile-header-height: 56px;
    --mobile-tabs-height: 48px;
  }

  html {
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-text-size-adjust: 100%;
  }

  body {
    display: block;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
  }

  body.mobile-drawer-open { overflow: hidden; }

  #loginOverlay {
    height: 100vh !important;
    height: 100dvh !important;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  }

  #loginOverlay > div {
    max-width: 360px !important;
    padding: 28px 22px !important;
  }

  #loginOverlay input {
    min-height: 44px;
    font-size: 16px !important;
  }

  #mobile-header {
    position: sticky;
    z-index: 115;
    top: 0;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 58px;
    align-items: center;
    gap: 10px;
    min-height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    color: #f8fafc;
    background: var(--navy-900);
    border-bottom: 1px solid rgba(255,255,255,.08);
  }

  .mobile-brand {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: #fff;
    background: #1d4ed8;
    font: 700 12px var(--mono);
  }

  .mobile-context { min-width: 0; }
  .mobile-context strong,
  .mobile-context span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-context strong { font-size: 14px; font-weight: 600; }
  .mobile-context span { margin-top: 2px; color: #94a3b8; font: 10px var(--mono); }

  #mobile-client-button,
  #mobile-drawer-close {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 6px;
    color: #f8fafc;
    background: rgba(255,255,255,.06);
    font: 500 13px var(--sans);
    touch-action: manipulation;
  }

  #mobile-drawer-backdrop {
    position: fixed;
    z-index: 1190;
    inset: 0;
    display: block;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    border: 0;
    background: rgba(3, 7, 18, .52);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  body.mobile-drawer-open #mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  #sidebar,
  #sidebar.collapsed {
    position: fixed;
    z-index: 1200;
    inset: 0 auto 0 0;
    display: flex;
    width: min(88vw, 360px) !important;
    min-width: 0 !important;
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) !important;
    overflow: hidden;
    border-right: 1px solid #000 !important;
    transform: translate3d(-102%, 0, 0);
    transition: transform .22s ease;
    will-change: transform;
  }

  #sidebar.collapsed > * { display: block !important; }
  #sidebar.collapsed #client-list { display: block !important; flex: 1; }
  body.mobile-drawer-open #sidebar { transform: translate3d(0, 0, 0); }
  #sidebar-header { flex: 0 0 auto; }
  #client-list { min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .sidebar-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .sidebar-title-row h2 { margin: 0; }
  #mobile-drawer-close { display: block; font-size: 24px; line-height: 1; }

  .client-item,
  .session-sub-item,
  .group-header,
  #btn-new-client,
  .btn-add-group { min-height: 44px; }
  .client-delete,
  .session-sub-delete { min-width: 44px; min-height: 44px; opacity: 1; }
  .client-item .client-name { max-width: calc(100% - 50px); }

  #sidebarToggle,
  .btn-back-to-list { display: none !important; }

  #main {
    position: static;
    z-index: auto;
    width: 100%;
    min-height: 0;
    overflow: visible;
    transform: none !important;
  }

  #topbar {
    top: calc(var(--mobile-header-height) + env(safe-area-inset-top));
    z-index: 110;
    height: var(--mobile-tabs-height);
    padding: 0 8px;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    min-width: 58px;
    height: var(--mobile-tabs-height);
    min-height: 44px;
    padding: 0 13px;
    font-size: 0;
    scroll-snap-align: center;
    touch-action: manipulation;
  }
  .tab-btn::after { content: attr(data-mobile-label); font-size: 13px; }
  #topbar-right { display: none; }

  #mobile-actionbar {
    position: relative;
    z-index: 105;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 52px;
    padding: 6px 10px;
    background: var(--paper);
    border-bottom: 1px solid var(--ink-200);
  }

  #mobile-new-session,
  #mobile-more-button,
  #mobile-more-menu button {
    min-height: 44px;
    border-radius: 6px;
    font: 500 14px var(--sans);
    touch-action: manipulation;
  }
  #mobile-new-session {
    flex: 1;
    max-width: 240px;
    border: 0;
    color: #fff;
    background: var(--ok);
  }
  #mobile-new-session:disabled { opacity: .42; }
  #mobile-more-button {
    min-width: 64px;
    padding: 0 13px;
    color: var(--ink-700);
    background: #fff;
    border: 1px solid var(--ink-200);
  }
  .mobile-more-wrap { position: relative; }
  #mobile-more-menu {
    position: absolute;
    z-index: 1300;
    top: calc(100% + 6px);
    right: 0;
    display: none;
    width: 180px;
    padding: 6px;
    border: 1px solid var(--ink-200);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .16);
  }
  body.mobile-more-open #mobile-more-menu { display: grid; }
  #mobile-more-menu button { padding: 0 12px; border: 0; text-align: left; color: var(--ink-700); background: transparent; }
  #mobile-more-menu button.danger { color: var(--bad); }

  #session-selector-bar {
    top: calc(var(--mobile-header-height) + var(--mobile-tabs-height) + env(safe-area-inset-top));
    z-index: 108;
    min-height: 48px;
    padding: 5px 10px;
  }
  #session-select { min-width: 0; min-height: 38px; flex: 1; font-size: 14px; }

  .tab-panel.active {
    max-width: 100%;
    padding: 12px 10px calc(72px + env(safe-area-inset-bottom));
  }
  .section-card { margin-bottom: 12px; min-width: 0; }
  .section-title,
  .module-header { padding-right: 12px; padding-left: 12px; }
  .section-body { min-width: 0; padding: 13px 12px; overflow-x: auto; }

  .form-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .form-group,
  .form-group.wide { width: 100%; min-width: 0; }
  .form-group input[type="text"],
  .form-group input[type="number"],
  .form-group input[type="date"],
  .form-group textarea,
  .modal-body input,
  .modal-body select,
  .modal-body textarea {
    min-height: 44px;
    font-size: 16px;
  }
  .form-group textarea { min-height: 88px; }
  .btn-option,
  .check-label { min-height: 44px; display: inline-flex; align-items: center; }
  .bilateral-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

  .rom-table {
    display: block;
    width: 100%;
    overflow: visible;
  }
  .rom-table thead { display: none; }
  .rom-table tbody { display: block; }
  .rom-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ink-100);
  }
  .rom-table td,
  .rom-table td:has(.bounded-input),
  .supine-shoulder-row td:has(.bounded-input) {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
  }
  .rom-table td:first-child { grid-column: 1 / -1; font-size: 14px; }
  .rom-table td:nth-child(2)::before,
  .rom-table td:nth-child(3)::before,
  .rom-table td:nth-child(4)::before,
  .rom-table td:nth-child(5)::before {
    display: block;
    margin-bottom: 5px;
    color: var(--ink-400);
    font: 600 10px var(--mono);
  }
  .rom-table td:nth-child(2)::before { content: '左'; }
  .rom-table td:nth-child(3)::before { content: '右'; }
  .rom-table td:nth-child(4)::before { content: '参考'; }
  .rom-table td:nth-child(5)::before { content: '左右差'; }
  .rom-table td:nth-child(4) { align-self: end; }
  .rom-table td:nth-child(5) { align-self: end; text-align: right; }
  #hipflex-boundary-hint[style*="table-row"] { display: grid !important; grid-template-columns: 1fr; }
  #hipflex-boundary-hint td { grid-column: 1 / -1; }
  #hipflex-boundary-hint td::before { display: none; }

  .bounded-input { width: 100%; min-width: 0; }
  .bounded-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 5px 8px;
    width: 100%;
  }
  .bounded-track {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    height: 34px;
  }
  .bounded-number {
    grid-column: 1;
    width: 78px !important;
    min-width: 78px;
    min-height: 44px;
    padding: 8px 6px !important;
    font-size: 16px;
  }
  .bounded-clear {
    grid-column: 2;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 12px;
    touch-action: manipulation;
  }
  .bounded-scale { margin: 0; height: 17px; font-size: 10px; }

  .bounded-range,
  .centered-range {
    height: 32px;
    touch-action: pan-y;
  }
  .bounded-range::-webkit-slider-thumb,
  .centered-range::-webkit-slider-thumb { min-width: 24px; min-height: 24px; }
  .bounded-range::-moz-range-thumb,
  .centered-range::-moz-range-thumb { width: 24px; height: 24px; }

  .isa-input-row { gap: 16px; }
  .isa-input-col { width: 100%; }

  .centered-bilateral {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 9px 12px;
    padding: 14px 0;
  }
  .centered-axis { height: 36px; }
  .centered-axis::before { top: 17px; }
  .centered-zero { top: 9px; height: 18px; }
  .centered-half { height: 36px; }
  .centered-side-input { justify-content: flex-start; gap: 6px; }
  .centered-side .bounded-number {
    width: 76px !important;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }
  .centered-side .bounded-clear { min-width: 44px; min-height: 44px; padding: 0; }
  .centered-delta { text-align: left; }

  #pdf-overlay { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
  #pdf-panel { width: min(100%, 420px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
  .pdf-check-row,
  .pdf-panel-btns button { min-height: 44px; }

  .modal-overlay {
    align-items: flex-start;
    padding: calc(12px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .modal-card { width: 100%; max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
  .modal-close,
  .btn-secondary,
  .btn-primary { min-height: 44px; }
  .modal-body,
  .modal-footer { padding-right: 14px; padding-left: 14px; }

  .client-action-sheet { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 24px); text-align: center; }
}

/* ============ R-43A Mobile assessment density refinement ============ */
@media (max-width: 768px) {
  :root { --mobile-header-height: 50px; }

  html,
  body { overflow-x: clip; }
  body { overflow-y: visible; }

  #mobile-header {
    grid-template-columns: 34px minmax(0, 1fr) 58px;
    gap: 8px;
    padding-right: 10px;
    padding-left: 10px;
  }
  .mobile-brand {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    font-size: 11px;
  }
  .mobile-context strong { font-size: 13.5px; }
  .mobile-context span { margin-top: 1px; font-size: 9px; }

  .tab-panel.active { padding-top: 9px; }
  .section-card { margin-bottom: 10px; }
  .section-body { padding-top: 10px; padding-bottom: 10px; }
  .module-header {
    min-height: 40px;
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .module-header .module-title-cn { font-size: 15px; }
  .module-header .module-title-en { font-size: 10px; color: rgba(255,255,255,.48); }
  .module-header .module-tag { padding: 2px 7px; font-size: 10px; }

  .tier-header {
    gap: 7px;
    margin-top: 18px;
    margin-bottom: 10px;
    padding: 10px 0 6px;
  }
  .tier-label { padding: 2px 6px; font-size: 10px; }
  .tier-name { font-size: 14px; }
  .tier-hint { font-size: 11px; color: var(--ink-400); }
  .test-title {
    gap: 4px;
    margin: 12px 0 8px;
    font-size: 14px;
  }
  .test-title .title-en { font-size: 10px; color: var(--ink-400); }
  .priority-tag {
    margin-left: 4px;
    padding: 1px 4px;
    font-size: 8px;
    opacity: .72;
  }
  .info-tip {
    width: 16px;
    height: 16px;
    margin-left: 4px;
    font-size: 9px;
    opacity: .62;
  }

  .rom-table tr {
    position: relative;
    gap: 6px 10px;
    padding: 10px 0;
  }
  .rom-table td:first-child {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 20px;
    padding-right: 94px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
  }
  .rom-table td:first-child > span[style*="font-size:11px"] {
    font-size: 9.5px !important;
    color: var(--ink-400) !important;
    font-weight: 400;
  }
  .rom-table td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .rom-table td:nth-child(3) { grid-column: 2; grid-row: 2; }
  .rom-table td:nth-child(4) {
    position: absolute;
    top: 11px;
    right: 0;
    max-width: 92px;
    color: var(--ink-400);
    font-size: 10px;
    line-height: 1.3;
    text-align: right;
    white-space: nowrap;
  }
  .rom-table td:nth-child(5) {
    grid-column: 1 / -1;
    grid-row: 3;
    min-height: 14px;
    color: var(--ink-400);
    font-size: 10px;
    line-height: 1.3;
    text-align: right;
  }
  .rom-table td:nth-child(2)::before,
  .rom-table td:nth-child(3)::before {
    margin-bottom: 2px;
    font-size: 10px;
  }
  .rom-table td:nth-child(4)::before,
  .rom-table td:nth-child(5)::before {
    display: inline;
    margin: 0;
    font-size: inherit;
    font-weight: 500;
  }
  .rom-table td:nth-child(4)::before { content: '参考 '; }
  .rom-table td:nth-child(5)::before { content: '左右差 '; }
  .rom-table td:nth-child(5):has(.rom-delta:empty)::after { content: '—'; }
  #hipflex-boundary-hint td:first-child { min-height: 0; padding-right: 0; }

  .bounded-controls {
    grid-template-columns: 72px minmax(44px, 1fr);
    grid-template-rows: 44px 32px;
    gap: 2px 6px;
  }
  .bounded-number {
    grid-column: 1;
    grid-row: 1;
    width: 72px !important;
    min-width: 72px;
    font-weight: 600;
  }
  .bounded-clear {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    width: auto;
    min-width: 44px;
    color: var(--ink-400);
    font-size: 10px;
    opacity: .62;
  }
  .bounded-clear:disabled { visibility: hidden; }
  .bounded-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .bounded-scale {
    height: 13px;
    margin-top: -1px;
    font-size: 9px;
  }
  .bounded-mark:not(.bounded-mark-min):not(.bounded-mark-max) { display: none; }

  .isa-input-row { gap: 10px; }
  .isa-input-col label { margin-bottom: 2px; color: var(--ink-500); }

  .centered-bilateral {
    gap: 6px 10px;
    padding: 10px 0;
  }
  .centered-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
  }
  .centered-reference-label { color: var(--ink-400); font-size: 10px; }
  .centered-axis-labels {
    grid-template-columns: 1fr auto 1fr;
    gap: 4px;
    margin-bottom: -2px;
    font-size: 8px;
  }
  .centered-axis-labels span:nth-child(2),
  .centered-axis-labels span:nth-child(4) { display: none; }
  .centered-axis-labels strong { color: var(--ink-400); font-weight: 500; }
  .centered-axis { height: 32px; }
  .centered-axis::before { top: 15px; }
  .centered-zero { top: 9px; height: 14px; background: var(--ink-400); }
  .centered-half { height: 32px; }
  .centered-side-label { margin-bottom: 2px; font-size: 10px; }
  .centered-side-input { gap: 4px; }
  .centered-side .bounded-number {
    width: 68px !important;
    min-width: 68px;
    font-weight: 600;
  }
  .centered-side .bounded-clear {
    width: auto;
    min-width: 44px;
    color: var(--ink-400);
    font-size: 10px;
    opacity: .62;
  }
  .centered-delta {
    min-height: 14px;
    color: var(--ink-400);
    font-size: 10px;
    line-height: 1.3;
    text-align: right;
  }
  .centered-delta::before { content: '左右差 '; font-weight: 500; }
  .centered-delta:has(.rom-delta:empty)::after { content: '—'; }
}

@media (max-width: 430px) {
  .tab-panel.active { padding-right: 8px; padding-left: 8px; }
  .section-body { padding-right: 10px; padding-left: 10px; }
  .rom-table tr { gap: 8px; }
  .centered-reference-label { font-size: 10px; }
}
