/*
 * 账号诊断真实界面切换 V2。
 * 三种布局由 html[data-diagnose-layout] 控制当前真实页面；不使用 iframe、弹窗或新页面。
 * 现有颜色、字体、圆角、阴影、动画和业务状态保持不变。
 */

html[data-diagnose-layout] body.diagnose-layout-v2-ready {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-x: hidden;
}

#diagnoseLayoutStage {
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
}

#diagnoseLayoutShell {
  width: var(--diagnose-logical-width, 100%);
  min-height: var(--diagnose-logical-min-height, 100vh);
  transform: scale(var(--diagnose-layout-scale, 1));
  transform-origin: top left;
  background: var(--bg);
}

/* ===== PC / Pad 公共宽屏结构 ===== */
html[data-diagnose-layout="pc"] #diagnoseLayoutShell,
html[data-diagnose-layout="pad"] #diagnoseLayoutShell {
  max-width: none;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  box-shadow: none;
}

html[data-diagnose-layout="pc"] .topbar-inner,
html[data-diagnose-layout="pc"] .wrap,
html[data-diagnose-layout="pad"] .topbar-inner,
html[data-diagnose-layout="pad"] .wrap {
  margin-right: auto;
  margin-left: auto;
}

html[data-diagnose-layout="pc"] .stage,
html[data-diagnose-layout="pc"] .stage > *,
html[data-diagnose-layout="pad"] .stage,
html[data-diagnose-layout="pad"] .stage > * {
  min-width: 0;
}

html[data-diagnose-layout="pc"] .steps,
html[data-diagnose-layout="pad"] .steps {
  max-width: 520px;
}

html[data-diagnose-layout="pc"] #stageGate,
html[data-diagnose-layout="pc"] #stagePreflight,
html[data-diagnose-layout="pc"] #stageLoading,
html[data-diagnose-layout="pc"] #stageError,
html[data-diagnose-layout="pad"] #stageGate,
html[data-diagnose-layout="pad"] #stagePreflight,
html[data-diagnose-layout="pad"] #stageLoading,
html[data-diagnose-layout="pad"] #stageError {
  max-width: 760px;
  margin-right: auto;
  margin-left: auto;
}

html[data-diagnose-layout="pc"] #stagePreflight .preflight-box,
html[data-diagnose-layout="pad"] #stagePreflight .preflight-box {
  max-width: none;
  margin: 40px 0;
}

html[data-diagnose-layout="pc"] #stageCollect .upload-grid,
html[data-diagnose-layout="pad"] #stageCollect .upload-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

html[data-diagnose-layout="pc"] #stageCollect .capture-period .radios,
html[data-diagnose-layout="pc"] #stageCollect #routeCChoice,
html[data-diagnose-layout="pc"] #stageCollect #FA03_timeframe,
html[data-diagnose-layout="pc"] #stageCollect #FA07_weekly_output,
html[data-diagnose-layout="pc"] #stageCollect #FA08_long_term,
html[data-diagnose-layout="pc"] #stageCollect #FA10_recent_status,
html[data-diagnose-layout="pc"] #stageCollect #preflight_note_count_band,
html[data-diagnose-layout="pc"] #stageCollect #FA06_weekly_time,
html[data-diagnose-layout="pad"] #stageCollect .capture-period .radios,
html[data-diagnose-layout="pad"] #stageCollect #routeCChoice,
html[data-diagnose-layout="pad"] #stageCollect #FA03_timeframe,
html[data-diagnose-layout="pad"] #stageCollect #FA07_weekly_output,
html[data-diagnose-layout="pad"] #stageCollect #FA08_long_term,
html[data-diagnose-layout="pad"] #stageCollect #FA10_recent_status,
html[data-diagnose-layout="pad"] #stageCollect #preflight_note_count_band,
html[data-diagnose-layout="pad"] #stageCollect #FA06_weekly_time,
html[data-diagnose-layout="pc"] #stageCollect .checks,
html[data-diagnose-layout="pad"] #stageCollect .checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-diagnose-layout="pc"] #stageCollect .optional-card-content,
html[data-diagnose-layout="pad"] #stageCollect .optional-card-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-diagnose-layout="pc"] #stageHistory .history-list,
html[data-diagnose-layout="pad"] #stageHistory .history-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

html[data-diagnose-layout="pc"] #stageHistory .hist-item,
html[data-diagnose-layout="pad"] #stageHistory .hist-item {
  height: 100%;
}

html[data-diagnose-layout="pc"] #stageReport .report,
html[data-diagnose-layout="pc"] #stageReport .report-table-scroll,
html[data-diagnose-layout="pad"] #stageReport .report,
html[data-diagnose-layout="pad"] #stageReport .report-table-scroll {
  width: 100%;
  max-width: 100%;
}

html[data-diagnose-layout="pc"] .route-c-choice,
html[data-diagnose-layout="pad"] .route-c-choice {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-diagnose-layout="pc"] .route-c-note-head,
html[data-diagnose-layout="pad"] .route-c-note-head {
  display: flex;
}

html[data-diagnose-layout="pc"] .route-c-note-actions,
html[data-diagnose-layout="pad"] .route-c-note-actions {
  justify-content: flex-start;
  margin-top: 0;
}

html[data-diagnose-layout="pc"] .preflight-actions,
html[data-diagnose-layout="pad"] .preflight-actions,
html[data-diagnose-layout="pc"] .loading-actions,
html[data-diagnose-layout="pad"] .loading-actions {
  flex-direction: row;
}

html[data-diagnose-layout="pc"] .preflight-actions .btn,
html[data-diagnose-layout="pad"] .preflight-actions .btn,
html[data-diagnose-layout="pc"] .loading-actions .btn,
html[data-diagnose-layout="pad"] .loading-actions .btn {
  width: auto;
}

html[data-diagnose-layout="pc"] .candidate-panel,
html[data-diagnose-layout="pad"] .candidate-panel {
  padding: 18px;
}

html[data-diagnose-layout="pc"] .role-row,
html[data-diagnose-layout="pad"] .role-row {
  grid-template-columns: minmax(0, 1fr) 150px;
}

html[data-diagnose-layout="pc"] .loading-box,
html[data-diagnose-layout="pad"] .loading-box {
  padding: 48px 20px;
}

html[data-diagnose-layout="pc"] .report h1,
html[data-diagnose-layout="pad"] .report h1 {
  font-size: 24px;
}

html[data-diagnose-layout="pc"] .report h2,
html[data-diagnose-layout="pad"] .report h2 {
  margin-top: 30px;
  font-size: 19px;
}

html[data-diagnose-layout="pc"] .report h3,
html[data-diagnose-layout="pad"] .report h3 {
  font-size: 16px;
}

html[data-diagnose-layout="pc"] .report-table-scroll,
html[data-diagnose-layout="pad"] .report-table-scroll {
  margin: 16px 0;
}

html[data-diagnose-layout="pc"] .topbar-inner,
html[data-diagnose-layout="pad"] .topbar-inner {
  height: 56px;
  padding: 12px 16px;
  gap: 0;
}

html[data-diagnose-layout="pc"] .count-chip,
html[data-diagnose-layout="pad"] .count-chip {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  margin-right: 8px;
}

html[data-diagnose-layout="pc"] .route-c-add-meta,
html[data-diagnose-layout="pad"] .route-c-add-meta {
  display: flex;
}

/* ===== PC版 ===== */
html[data-diagnose-layout="pc"] .topbar-inner {
  width: calc(100% - 48px);
  max-width: 1200px;
}

html[data-diagnose-layout="pc"] .wrap {
  width: calc(100% - 48px);
  max-width: 1080px;
  padding: 36px 28px 64px;
}

html[data-diagnose-layout="pc"] body.report-screen .wrap {
  max-width: 1160px;
}

html[data-diagnose-layout="pc"] #stageCollect .card {
  padding: 22px;
}

html[data-diagnose-layout="pc"] #stageCollect .upload-grid {
  gap: 18px 20px;
}

html[data-diagnose-layout="pc"] #stageCollect .optional-card-content {
  column-gap: 24px;
}

html[data-diagnose-layout="pc"] #stageCollect .route-c-note .uploader {
  min-height: 150px;
}

html[data-diagnose-layout="pc"] #stageReport .report {
  padding: 42px 48px;
}

html[data-diagnose-layout="pc"] #stageReport .report-outline-links {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

html[data-diagnose-layout="pc"] #stageReport .chart-radar-wrap {
  width: 100%;
  max-width: 520px;
  height: 380px;
}

html[data-diagnose-layout="pc"] #stageReport .report-actions {
  max-width: 720px;
  margin-right: auto;
  margin-left: auto;
}

html[data-diagnose-layout="pc"] .module-hub {
  right: 24px;
}

/* ===== Pad版 ===== */
html[data-diagnose-layout="pad"] .topbar-inner,
html[data-diagnose-layout="pad"] .wrap {
  width: calc(100% - 32px);
}

html[data-diagnose-layout="pad"] .topbar-inner {
  max-width: 900px;
}

html[data-diagnose-layout="pad"] .wrap {
  max-width: 820px;
  padding: 28px 20px 48px;
}

html[data-diagnose-layout="pad"] body.report-screen .wrap {
  max-width: 900px;
}

html[data-diagnose-layout="pad"] #stageCollect .card {
  padding: 18px;
}

html[data-diagnose-layout="pad"] #stageCollect .upload-grid {
  gap: 16px;
}

html[data-diagnose-layout="pad"] #stageCollect .optional-card-content {
  column-gap: 18px;
}

html[data-diagnose-layout="pad"] #stageCollect .route-c-note .uploader {
  min-height: 0;
}

html[data-diagnose-layout="pad"] #stageReport .report {
  padding: 30px 28px;
}

html[data-diagnose-layout="pad"] #stageReport .report-outline-links {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-diagnose-layout="pad"] #stageReport .chart-radar-wrap {
  max-width: 420px;
  height: 320px;
}

html[data-diagnose-layout="pad"] #stageReport .report-actions {
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}

html[data-diagnose-layout="pad"] .module-hub {
  right: max(18px, calc((100vw - 768px) / 2 + 18px));
}

/* ===== 手机版：恢复并保持原手机画板 ===== */
html[data-diagnose-layout="mobile"] #diagnoseLayoutShell {
  max-width: 480px;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
}

html[data-diagnose-layout="mobile"] .topbar-inner {
  width: 100%;
  max-width: 480px;
  height: 56px;
  margin: 0 auto;
  padding: 12px 16px;
  gap: 8px;
}

html[data-diagnose-layout="mobile"] .wrap {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}

html[data-diagnose-layout="mobile"] .steps {
  max-width: none;
}

html[data-diagnose-layout="mobile"] #stageGate,
html[data-diagnose-layout="mobile"] #stagePreflight,
html[data-diagnose-layout="mobile"] #stageLoading,
html[data-diagnose-layout="mobile"] #stageError {
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}

html[data-diagnose-layout="mobile"] #stagePreflight .preflight-box {
  max-width: 680px;
  margin: 36px auto;
}

html[data-diagnose-layout="mobile"] #stageCollect .card {
  padding: 18px;
}

html[data-diagnose-layout="mobile"] #stageCollect .upload-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

html[data-diagnose-layout="mobile"] #stageCollect .optional-card-content {
  display: block;
}

html[data-diagnose-layout="mobile"] #stageHistory .history-list {
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
  gap: 12px;
}

html[data-diagnose-layout="mobile"] #stageHistory .hist-item {
  height: auto;
}

html[data-diagnose-layout="mobile"] #stageReport .report {
  width: 100%;
  max-width: 100%;
  padding: 24px 20px;
}

html[data-diagnose-layout="mobile"] #stageReport .report-outline-links {
  grid-template-columns: minmax(0, 1fr);
}

html[data-diagnose-layout="mobile"] #stageReport .chart-radar-wrap {
  max-width: 420px;
  height: 320px;
}

html[data-diagnose-layout="mobile"] #stageReport .report-actions {
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}

html[data-diagnose-layout="mobile"] .route-c-choice {
  grid-template-columns: minmax(0, 1fr);
}

html[data-diagnose-layout="mobile"] .route-c-note-head {
  display: block;
}

html[data-diagnose-layout="mobile"] .route-c-note-actions {
  justify-content: space-between;
  margin-top: 7px;
}

html[data-diagnose-layout="mobile"] .preflight-actions,
html[data-diagnose-layout="mobile"] .loading-actions {
  flex-direction: column;
}

html[data-diagnose-layout="mobile"] .preflight-actions .btn,
html[data-diagnose-layout="mobile"] .loading-actions .btn {
  width: 100%;
}

html[data-diagnose-layout="mobile"] .candidate-panel {
  padding: 14px;
}

html[data-diagnose-layout="mobile"] .role-row {
  grid-template-columns: minmax(0, 1fr);
}

html[data-diagnose-layout="mobile"] .loading-box {
  padding: 36px 16px;
}

html[data-diagnose-layout="mobile"] .report h1 {
  font-size: 21px;
}

html[data-diagnose-layout="mobile"] .report h2 {
  margin-top: 26px;
  font-size: 17px;
}

html[data-diagnose-layout="mobile"] .report h3 {
  font-size: 15px;
}

html[data-diagnose-layout="mobile"] .report-table-scroll {
  margin-right: 0;
  margin-left: 0;
}

html[data-diagnose-layout="mobile"] .count-chip {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 5px;
  padding: 5px 8px;
}

html[data-diagnose-layout="mobile"] .user-chip {
  padding: 5px 8px;
  white-space: nowrap;
}

html[data-diagnose-layout="mobile"] .btn {
  min-height: 44px;
}

html[data-diagnose-layout="mobile"] .route-c-add-meta {
  display: block;
}

html[data-diagnose-layout="mobile"] .route-c-add-meta span {
  display: block;
  margin-top: 4px;
}

html[data-diagnose-layout="mobile"] .img-lightbox img {
  max-height: 60vh;
}

html[data-diagnose-layout="mobile"] .module-hub {
  right: max(14px, calc((100vw - 480px) / 2 + 14px));
}

/* ===== 悬浮面板中的界面切换 ===== */
.diagnose-layout-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
}

.diagnose-layout-option {
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #666;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.diagnose-layout-option:active {
  transform: translateY(1px);
}

.diagnose-layout-option.is-active {
  border-color: #ffd4dc;
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: 0 2px 8px rgba(230, 57, 80, 0.12);
}

.diagnose-layout-option:focus-visible {
  outline: 3px solid rgba(230, 57, 80, 0.24);
  outline-offset: 2px;
}

@media print {
  #diagnoseLayoutStage,
  #diagnoseLayoutShell {
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    transform: none !important;
  }
}
