.diagnosis-v3 {
  --v3-border: #d8dee8;
  --v3-muted: #5b6574;
  --v3-ink: #18212f;
  --v3-blue: #155eef;
  --v3-green: #137a4b;
  --v3-amber: #9a5b00;
  min-width: 0;
}

.v3-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.v3-mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  padding: 3px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #eef2f6;
}

.v3-mode-switch button {
  min-height: 34px;
  border-radius: 5px;
  background: transparent;
  color: #475569;
  padding: 6px 12px;
}

.v3-mode-switch button.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

.v3-case-context {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--v3-border);
  border-radius: 7px;
  background: #fff;
  margin-bottom: 12px;
  overflow: hidden;
}

.v3-context-item {
  min-width: 0;
  padding: 11px 14px;
  border-right: 1px solid #e7ebf0;
}

.v3-context-item:last-child { border-right: 0; }
.v3-context-item span { display: block; color: var(--v3-muted); font-size: 12px; margin-bottom: 5px; }
.v3-context-item strong { display: block; color: var(--v3-ink); font-size: 14px; overflow-wrap: anywhere; }

.v3-workbench-grid {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  min-height: 620px;
  border: 1px solid var(--v3-border);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}

.v3-side-panel {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--v3-border);
  background: #f8fafc;
  overflow-y: auto;
}

.v3-input-block { display: grid; gap: 9px; }
.v3-input-block label { color: var(--v3-ink); font-size: 14px; font-weight: 700; }
.v3-input-block textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border: 1px solid #b8c2d0;
  border-radius: 6px;
  padding: 10px;
  color: var(--v3-ink);
  background: #fff;
  font: inherit;
  line-height: 1.55;
}

.v3-direct-tools {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--v3-border);
}

.v3-direct-tools strong { font-size: 14px; }
.v3-direct-tools button { width: 100%; text-align: left; background: #475569; }

.v3-timeline-head {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--v3-border);
}

.v3-timeline-head h3 { margin: 0; font-size: 14px; }
.v3-timeline { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.v3-timeline li { position: relative; padding-left: 18px; color: #334155; font-size: 13px; line-height: 1.45; }
.v3-timeline li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.v3-timeline li[data-status="completed"]::before { background: var(--v3-green); }
.v3-timeline li[data-status="running"]::before { background: var(--v3-blue); }
.v3-timeline li[data-status="failed"]::before,
.v3-timeline li[data-status="insufficient"]::before { background: #c2410c; }
.v3-timeline time { display: block; margin-top: 2px; color: #7b8493; font-size: 11px; }

.v3-result-panel { min-width: 0; padding: 22px 24px; overflow-y: auto; }
.v3-empty-state { min-height: 500px; display: grid; place-content: center; gap: 7px; text-align: center; color: var(--v3-muted); }
.v3-empty-state strong { color: var(--v3-ink); font-size: 18px; }

.v3-result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 2px solid #e5eaf0;
}
.v3-result-head h3 { margin: 7px 0 0; color: var(--v3-ink); font-size: 23px; line-height: 1.35; letter-spacing: 0; }
.v3-status-label {
  display: inline-block;
  color: #0f5132;
  font-size: 13px;
  font-weight: 700;
}
.v3-status-label[data-tone="warning"] { color: var(--v3-amber); }
.v3-status-label[data-tone="danger"] { color: #b42318; }
.v3-case-id { color: #7b8493; font-size: 12px; white-space: nowrap; }

.v3-focus-business {
  margin: 16px 0 2px;
  padding: 0;
  border: 1px solid #d8dee8;
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  background: #fff;
  color: var(--v3-ink);
}
.v3-business-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid #e7ebf0; }
.v3-business-panel-head > strong { font-size: 15px; }
.v3-business-panel-head > span { color: var(--v3-muted); font-size: 12px; }
.v3-business-scope { padding: 13px 16px 14px; border-bottom: 1px solid #e7ebf0; background: #f8fafc; }
.v3-business-scope[data-coverage="partial"] { background: #fffaf0; }
.v3-business-scope-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.v3-business-scope-head strong { color: #1e293b; font-size: 14px; }
.v3-business-scope-head span { color: #526173; font-size: 12px; }
.v3-business-scope[data-coverage="partial"] .v3-business-scope-head span { color: #9a3412; font-weight: 700; }
.v3-business-scope-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
  border-top: 1px solid #dce3eb;
  border-bottom: 1px solid #dce3eb;
}
.v3-business-scope-metrics > div { display: grid; gap: 3px; min-width: 0; padding: 9px 12px; border-right: 1px solid #dce3eb; }
.v3-business-scope-metrics > div:first-child { padding-left: 0; }
.v3-business-scope-metrics > div:last-child { padding-right: 0; border-right: 0; }
.v3-business-scope-metrics span { color: #64748b; font-size: 12px; }
.v3-business-scope-metrics strong { color: #1e293b; font-size: 15px; overflow-wrap: anywhere; }
.v3-business-scope-metrics [data-tone="warning"] strong { color: #b42318; }
.v3-business-scope > p { margin: 10px 0 4px; color: #334155; font-size: 13px; line-height: 1.65; }
.v3-business-scope > small { display: block; color: #64748b; font-size: 12px; line-height: 1.55; }
.v3-business-group { padding: 0 16px 10px; }
.v3-business-group + .v3-business-group { border-top: 1px solid #e7ebf0; }
.v3-business-group > h4 { margin: 0; padding: 12px 0 8px; color: #334155; font-size: 13px; }
.v3-business-group[data-kind="abnormal"] > h4 { color: #b42318; }
.v3-business-group[data-kind="observation"] > h4 { color: #475569; }
.v3-business-item { padding: 11px 12px; border-left: 3px solid #dc2626; background: #fff8f7; }
.v3-business-item + .v3-business-item { margin-top: 8px; }
.v3-business-item[data-kind="observation"] { border-left-color: #64748b; background: #f8fafc; }
.v3-business-compact { display: grid; grid-template-columns: minmax(240px, auto) minmax(0, 1fr); gap: 14px; align-items: center; padding: 9px 12px; border-left: 3px solid #dc2626; background: #fff8f7; }
.v3-business-compact + .v3-business-compact, .v3-business-item + .v3-business-compact { margin-top: 8px; }
.v3-business-compact[data-kind="observation"] { border-left-color: #64748b; background: #f8fafc; }
.v3-business-compact > div { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.v3-business-compact > div > span { padding: 2px 6px; border-radius: 4px; background: #fee2e2; color: #991b1b; font-size: 11px; font-weight: 700; }
.v3-business-compact[data-kind="observation"] > div > span { background: #e2e8f0; color: #334155; }
.v3-business-compact small { color: var(--v3-muted); }
.v3-business-compact p { margin: 0; color: #475569; font-size: 13px; line-height: 1.5; }
.v3-business-compact p > small { display: block; margin-top: 2px; color: #64748b; font-size: 12px; }
.v3-business-empty { display: grid; gap: 4px; padding: 11px 12px; border-left: 3px solid #d97706; background: #fffaf0; }
.v3-business-empty strong { color: #92400e; font-size: 13px; }
.v3-business-empty span { color: #6b4f24; font-size: 13px; line-height: 1.55; }
.v3-focus-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 12px; }
.v3-focus-head > strong { font-size: 18px; }
.v3-focus-head small { color: var(--v3-muted); }
.v3-focus-badges { display: flex; gap: 6px; }
.v3-focus-badges span {
  padding: 2px 7px;
  border-radius: 4px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 12px;
  font-weight: 700;
}
.v3-focus-badges span[data-tone="observation"] { background: #e2e8f0; color: #334155; }
.v3-focus-badges span[data-tone="cross-border"] { background: #ffedd5; color: #9a3412; }
.v3-business-item > p { margin: 9px 0; font-weight: 700; line-height: 1.6; }
.v3-business-item dl { margin: 0; }
.v3-business-item dl > div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 5px 0; }
.v3-focus-business dt { color: #475569; font-size: 13px; font-weight: 700; }
.v3-focus-business dd { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }

.v3-case-pattern {
  margin: 12px 0 2px;
  padding: 14px 16px;
  border-left: 4px solid #2563eb;
  background: #f7faff;
  color: var(--v3-ink);
}
.v3-pattern-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.v3-pattern-head > span { color: #1d4ed8; font-size: 13px; font-weight: 700; }
.v3-pattern-head > strong { font-size: 13px; }
.v3-case-pattern > p { margin: 10px 0; font-weight: 700; line-height: 1.6; }
.v3-case-pattern ul { margin: 8px 0; padding: 0; list-style: none; }
.v3-case-pattern li { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-top: 1px solid #dbe7f7; }
.v3-case-pattern li span { color: #475569; font-size: 13px; line-height: 1.55; }
.v3-case-pattern dl { margin: 5px 0 0; }
.v3-case-pattern dl > div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 5px 0; }
.v3-case-pattern dt { color: #475569; font-size: 13px; font-weight: 700; }
.v3-case-pattern dd { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }

.v3-summary-list { margin: 0; }
.v3-summary-list > div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  padding: 17px 0;
  border-bottom: 1px solid #e7ebf0;
}
.v3-summary-list dt { color: #475569; font-size: 13px; font-weight: 700; }
.v3-summary-list dd { margin: 0; color: var(--v3-ink); line-height: 1.65; overflow-wrap: anywhere; }
.v3-summary-list .v3-next-row { border-left: 3px solid var(--v3-blue); padding-left: 14px; background: #f7faff; }
.v3-summary-list .v3-next-row dd { font-weight: 700; }

.v3-primary-action { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.v3-action-choice { display: flex; flex-wrap: wrap; gap: 8px; }
.v3-primary-action button { min-width: 180px; min-height: 42px; }
.v3-primary-action span { color: var(--v3-muted); font-size: 13px; }

.v3-action-confirm {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #e0b86b;
  border-radius: 6px;
  background: #fffaf0;
}
.v3-action-confirm label { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; color: #3f3422; line-height: 1.45; }
.v3-action-confirm select { width: min(100%, 420px); margin-bottom: 12px; }
.v3-action-confirm .v3-confirm-buttons { display: flex; gap: 8px; }
.v3-auto-wan-check { margin-bottom: 12px; color: #3f3422; }
.v3-auto-wan-check p { margin: 7px 0; line-height: 1.6; }
.v3-auto-wan-check ul { margin: 6px 0 8px; padding-left: 20px; }
.v3-auto-wan-check li { margin: 4px 0; }
.v3-auto-wan-check small { color: #7c5b25; }

.v3-details { border-top: 1px solid var(--v3-border); margin-top: 18px; padding-top: 4px; }
.v3-details summary { cursor: pointer; padding: 13px 0; color: #334155; font-weight: 700; }
.v3-evidence-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; padding: 9px 0; border-top: 1px solid #edf0f4; font-size: 13px; }
.v3-evidence-row span { color: var(--v3-muted); }
.v3-evidence-row strong { color: var(--v3-ink); font-weight: 500; overflow-wrap: anywhere; }
.v3-metadata { color: #475569; font-size: 13px; line-height: 1.7; }

@media (max-width: 1080px) {
  .v3-case-context { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .v3-context-item:nth-child(3) { border-right: 0; }
  .v3-context-item:nth-child(-n+3) { border-bottom: 1px solid #e7ebf0; }
  .v3-workbench-grid { grid-template-columns: 260px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .diagnosis-v3 { margin: 0; }
  .v3-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 8px;
  }
  .v3-mode-switch { width: 100%; min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v3-mode-switch button { min-width: 0; padding-inline: 8px; }
  #v3NewCaseBtn { white-space: nowrap; padding-inline: 10px; }
  .v3-case-context { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v3-context-item { border-bottom: 1px solid #e7ebf0; }
  .v3-context-item:nth-child(2n) { border-right: 0; }
  .v3-workbench-grid { display: block; min-height: 0; }
  .v3-side-panel { border-right: 0; border-bottom: 1px solid var(--v3-border); max-height: none; }
  .v3-result-panel { padding: 18px 16px; }
  .v3-empty-state { min-height: 260px; }
  .v3-result-head { display: block; }
  .v3-case-id { display: block; margin-top: 10px; white-space: normal; }
  .v3-result-head h3 { font-size: 20px; }
  .v3-focus-head { display: grid; gap: 7px; }
  .v3-business-panel-head { align-items: flex-start; }
  .v3-business-scope-head { display: grid; gap: 4px; }
  .v3-business-scope-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v3-business-scope-metrics > div:nth-child(2n) { border-right: 0; }
  .v3-business-scope-metrics > div:nth-child(n+3) { border-top: 1px solid #dce3eb; }
  .v3-business-scope-metrics > div:first-child,
  .v3-business-scope-metrics > div:last-child { padding-inline: 10px; }
  .v3-business-compact { grid-template-columns: 1fr; gap: 5px; }
  .v3-business-item dl > div { grid-template-columns: 1fr; gap: 2px; padding: 7px 0; }
  .v3-pattern-head { display: grid; gap: 4px; }
  .v3-case-pattern li, .v3-case-pattern dl > div { grid-template-columns: 1fr; gap: 3px; }
  .v3-summary-list > div { grid-template-columns: 1fr; gap: 6px; padding: 14px 0; }
  .v3-primary-action { display: grid; }
  .v3-action-choice { display: grid; }
  .v3-primary-action button { width: 100%; }
  .v3-evidence-row { grid-template-columns: 1fr; gap: 4px; }
}
