:root {
  font-size: 16px;
  --teal: #009688;
  --teal-2: #47af90;
  --bg: #ffffff;
  --text: #212121;
  --muted: #666;
  --border: #dcdfe6;
  --danger: #ef5350;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-question {
  max-width: 48.75rem;
  margin: 0 auto;
  position: relative;
  padding-bottom: 1.625rem;
}

.lang-bar {
  position: absolute;
  right: 1.25rem;
  top: 1.25rem;
  background: #fff;
  border-radius: .625rem;
  box-shadow: 0 0 .25rem rgba(0,0,0,.24);
  overflow: hidden;
  z-index: 3;
}

.lang-btn {
  border: none;
  background: #fff;
  min-width: 5rem;
  padding: .5rem .625rem;
  cursor: pointer;
  font-size: .75rem;
}

.page-header { padding: 20px; }
.page-header .title {
  text-align: center;
  font-size: 18px;
  margin-bottom: 20px;
  font-weight: 700;
}
.page-header .info {
  font-size: 14px;
  color: #333;
  line-height: 1.65;
}
.page-header .info p { margin: 0 0 8px; }

.form { padding-bottom: 30px; }
.form .item {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 8px 15px;
}
.mark { height: 15px; }
.question {
  display: flex;
  font-size: 16px;
  margin: 0 0 5px;
}
.question label {
  line-height: 1.5;
  font-weight: 700;
  font-size: 16px;
}
.question .red {
  line-height: 1.5;
  color: red;
  font-size: 20px;
  display: inline-block;
  margin-left: 10px;
}

.input {
  font-size: 16px;
  outline: none;
  width: 100%;
  line-height: 2;
  border-radius: 4px;
  border: 1px solid var(--border);
  padding: 5px 12px;
  background: #fafafa;
}

.option {
  border: 1px solid var(--border);
  padding: 9px 10px;
  align-items: center;
  color: #9e9e9e;
  border-radius: 6px;
  display: flex;
  flex-direction: row;
  margin-bottom: 8px;
  cursor: pointer;
}

.option .check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #e6e6e6;
  margin-right: 10px;
  flex-shrink: 0;
}

.option.active { color: #212121; }
.option.active .check {
  border-color: #409eff;
  background: radial-gradient(circle at center, #409eff 0 45%, transparent 46%);
}

.submit-wrap {
  padding: .875rem .9375rem .5rem;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, #fff 70%, rgba(255,255,255,.75));
}

.btn {
  width: 100%;
  border: none;
  border-radius: 1.875rem;
  color: #fff;
  font-size: 1.125rem;
  line-height: 1;
  padding: .875rem;
  box-shadow: 0 .375rem .875rem rgba(59, 130, 246, .26);
  background: linear-gradient(95deg, #2563eb, #7c3aed);
  cursor: pointer;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.disabled {
  opacity: .6;
  box-shadow: none;
}

.btn.secondary {
  background: linear-gradient(95deg, #0ea5e9, #2563eb);
  border-radius: 8px;
  box-shadow: none;
  font-size: 16px;
}

.blink { animation: blink 1s ease-in-out infinite; }
@keyframes blink {
  0% { background-color: #b3e5fc; }
  50% { background-color: #03a9f4; }
  100% { background-color: #b3e5fc; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.82);
  color: #fff;
  font-size: 14px;
  border-radius: 8px;
  padding: 9px 12px;
  z-index: 6;
}

.alert-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}

.alert-dialog {
  width: min(320px, 100%);
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}

.alert-title {
  padding: 14px 16px 8px;
  text-align: center;
  font-weight: 700;
  font-size: 17px;
}

.alert-message {
  padding: 8px 18px 14px;
  text-align: center;
  color: #333;
  font-size: 15px;
  line-height: 1.6;
}

.alert-ok {
  width: 100%;
  border: none;
  border-top: 1px solid #ececec;
  background: #fff;
  color: #409eff;
  font-size: 16px;
  padding: 12px 0;
  cursor: pointer;
}

.offline-banner {
  background: #fff3cd;
  color: #856404;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  border-bottom: 1px solid #ffc107;
}

.page-report {
  max-width: 48.75rem;
  margin: 0 auto;
  padding: 8px 4px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.report-card {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, .1);
  overflow: hidden;
}

.report-card img {
  width: 100%;
  height: auto;
  display: block;
}

.report-bottom {
  width: 100%;
  padding: 10px 0 0;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, #fff 70%, rgba(255,255,255,.75));
}

.report-save-btn {
  width: 100%;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  padding: 12px;
  background: linear-gradient(95deg, #2563eb, #0ea5e9);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

/* ====================== Report Card ====================== */
.rpt-card {
  background: #fff;
  padding: 10px 8px 4px;
  font-size: 12px;
  color: #333;
  line-height: 1.4;
}

.rpt-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  margin-bottom: 6px;
  overflow: hidden;
}

.rpt-logo-area { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rpt-logo-icon { font-size: 28px; color: #7c3aed; }
.rpt-logo-text { font-size: 14px; font-weight: 700; color: #333; line-height: 1.3; }
.rpt-brand { font-size: 18px; }
.rpt-badge-tag {
  display: inline-block;
  background: #ff9800;
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  font-weight: 700;
}

.rpt-meta {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 10px;
  font-size: 10px;
  color: #555;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

/* Grid: 2 columns */
.rpt-grid { display: grid; grid-template-columns: 2fr 3fr; gap: 8px; }
.rpt-col { display: flex; flex-direction: column; gap: 8px; }

/* Sections */
.rpt-section {
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
}
/* sections are content-sized, no stretching */
.rpt-bdr-red { border-color: #e57373; }
.rpt-bdr-brown { border-color: #a1887f; }
.rpt-bdr-blue { border-color: #64b5f6; flex: 1; }
.rpt-bdr-green { border-color: #81c784; padding: 8px 10px 13px; flex: 1; }

.rpt-sec-title {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}
.rpt-clr-red { color: #c62828; }
.rpt-clr-brown { color: #795548; }
.rpt-clr-blue { color: #1565c0; }
.rpt-clr-green { color: #2e7d32; }

/* Sub-sections */
.rpt-sub {
  margin-bottom: 8px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 6px 8px;
}
.rpt-sub:last-child { margin-bottom: 0; }
.rpt-sub-hd { font-size: 11px; font-weight: 700; margin-bottom: 4px; }

.rpt-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  color: #fff;
  font-size: 10px;
  margin-right: 4px;
  font-weight: 700;
}
.tag-orange { background: #ff9800; }
.tag-red { background: #e53935; }

/* Chart SVGs */
.rpt-chart-svg { width: 100%; display: block; margin: 0 auto; }

/* ---- Bipolar Bars ---- */
.bp-row {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 4px;
}
.bp-scale-row { margin-bottom: 0; }
.bp-label-l, .bp-label-r {
  font-size: 10px;
  color: #555;
  width: 26px;
  flex-shrink: 0;
  text-align: center;
}
.bp-label-l { text-align: right; }
.bp-label-r { text-align: left; }

.bp-track {
  flex: 1;
  height: 14px;
  background: #f5f5f5;
  border-radius: 2px;
  position: relative;
  border: 1px solid #e0e0e0;
}
.bp-scale-row .bp-track {
  background: transparent;
  border: none;
  height: 12px;
}

.bp-scale-nums {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: #999;
  padding: 0 2px;
}

.bp-grid-lines {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.bp-grid-lines::before,
.bp-grid-lines::after {
  content: '';
  width: 0;
}

.bp-fill {
  position: absolute;
  top: 1px;
  bottom: 1px;
  border-radius: 1px;
}
.bp-blue { background: #42a5f5; }
.bp-orange { background: #ff7043; }

.bp-dot-mark {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: #bbb;
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

/* ---- Energy Section (III) ---- */
.energy-content { margin-bottom: 4px; }
.energy-scale-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 0;
}
.energy-scale-row .energy-label { width: 28px; }
.energy-track-wrap { flex: 1; }
.energy-track-wrap .bp-scale-nums { padding: 0 1px; }

.energy-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 1px;
}
.energy-label {
  width: 28px;
  font-size: 10px;
  color: #555;
  flex-shrink: 0;
  text-align: right;
}
.energy-track {
  flex: 1;
  height: 11px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
}
.energy-fill { height: 100%; border-radius: 2px; }

.energy-fig-area {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-top: 2px;
}
.energy-figure { width: 40px; flex-shrink: 0; }
.energy-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 8px;
  color: #555;
}
.energy-leg-item { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.energy-leg-line {
  width: 14px;
  height: 2px;
  flex-shrink: 0;
  border-radius: 1px;
}
.energy-leg-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

/* ---- Diagnosis Section (IV) ---- */
.diagnosis-grid { display: flex; gap: 0; align-items: center; margin-top: 6px; }
.diagnosis-left { flex: 0 0 42%; }
.diagnosis-right { flex: 0 0 58%; }
.rpt-pyramid-svg, .rpt-tree-svg { width: 100%; display: block; }
.rpt-arr-up { color: #c62828; font-weight: 700; }
.rpt-arr-down { color: #c62828; font-weight: 700; }

/* Footer */
.rpt-footer {
  text-align: center;
  font-size: 10px;
  color: #999;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #eee;
}

/* Number badge for section titles (e.g. IV circle) */
.rpt-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  margin-right: 4px;
}
.rpt-num-green { background: #4caf50; }
