:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d8e0ea;
  --text: #152033;
  --muted: #66758a;
  --primary: #1464d2;
  --primary-strong: #0f4faa;
  --success: #16794c;
  --warning: #9a5b00;
  --danger: #b42318;
  --teal: #0f766e;
  --shadow: 0 10px 28px rgba(21, 32, 51, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-tabs {
  display: flex;
  gap: 8px;
  padding: 14px 18px 0;
  background: var(--bg);
}

.app-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  padding: 0 16px;
  background: #eaf0f7;
  color: #35465f;
  cursor: pointer;
  font-weight: 700;
}

.app-tab.active {
  border-bottom-color: var(--surface);
  background: var(--surface);
  color: var(--primary);
}

.app-view.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns:
    minmax(var(--workspace-left-min, 380px), var(--workspace-left-width, 430px))
    10px
    minmax(var(--workspace-right-min, 680px), 1fr);
  gap: 12px;
  min-height: calc(100vh - 52px);
  padding: 18px;
}

.app-shell.manual-mode {
  --workspace-left-min: 720px;
  --workspace-left-width: var(--manual-left-width, 60%);
}

.control-panel,
.result-panel {
  min-width: 0;
}

.layout-resizer {
  position: relative;
  display: block;
  min-width: 10px;
  cursor: col-resize;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.layout-resizer::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: var(--line);
  transition: 0.15s ease;
}

.layout-resizer:hover::before,
.layout-resizer:focus-visible::before,
.app-shell.resizing .layout-resizer::before {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(20, 100, 210, 0.12);
}

.layout-resizer:focus-visible {
  outline: 0;
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

.app-shell.stacked-layout {
  grid-template-columns: 1fr;
  gap: 18px;
}

.app-shell.stacked-layout .layout-resizer {
  display: none;
}

.app-shell.stacked-layout .result-panel,
.app-shell.stacked-layout .control-panel {
  min-height: auto;
}

.manual-mode .control-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 70px);
}

.topbar,
.input-panel,
.dropzone,
.manual-panel,
.status-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  gap: 16px;
  padding: 18px;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2,
h3 {
  font-size: 16px;
  line-height: 1.3;
}

.status-line {
  margin-top: 8px;
  font-size: 13px;
}

.status-line.ok {
  color: var(--success);
}

.status-line.warn,
.danger-text {
  color: var(--warning);
}

.top-actions,
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.button.secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.button.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.input-panel {
  display: grid;
  gap: 14px;
  margin: 16px 0;
  padding: 16px;
}

.mode-control {
  margin-bottom: 16px;
}

.manual-mode .input-panel {
  grid-template-columns: 160px minmax(120px, 1fr) minmax(120px, 1fr) minmax(220px, 1.2fr);
  align-items: stretch;
}

.manual-mode .input-panel .rank-readout {
  min-height: 0;
}

.manual-mode .candidate-strip,
.manual-mode .analysis-summary,
.manual-mode .issue-overview {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.segment.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(21, 32, 51, 0.09);
}

.score-field {
  display: grid;
  gap: 7px;
}

.score-field span,
.rank-readout span,
.metric span,
.candidate-strip span {
  color: var(--muted);
  font-size: 13px;
}

.score-field input,
.score-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: #fff;
}

.score-field input:focus,
.score-field select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(20, 100, 210, 0.12);
}

.rank-readout {
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.rank-readout strong {
  font-size: 28px;
  line-height: 1.1;
}

.rank-readout small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dropzone {
  position: relative;
  margin-bottom: 16px;
  border-style: dashed;
  background: #eef4f8;
  transition: 0.15s ease;
}

.dropzone.dragging {
  border-color: var(--primary);
  background: #eaf2ff;
}

.dropzone.has-file {
  border-style: solid;
  background: #f5fbf7;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 108px;
  padding: 20px;
}

.dropzone p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.drop-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 58px;
  height: 70px;
  border: 1px solid #8aa4bf;
  border-radius: 6px;
  background: #fff;
  color: var(--primary);
  font-weight: 800;
}

.manual-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
}

.manual-mode .manual-panel {
  flex: 1;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
  min-height: 0;
}

.manual-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.manual-head strong {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.manual-message {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.manual-message.error {
  color: var(--danger);
}

.manual-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.manual-progress > div {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfe;
}

.manual-progress span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.manual-progress strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.manual-progress strong.ok {
  color: var(--success);
}

.manual-progress strong.warn {
  color: var(--warning);
}

.manual-progress strong.danger {
  color: var(--danger);
}

.manual-drafts {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.draft-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.draft-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.draft-list {
  display: grid;
  gap: 8px;
}

.draft-empty {
  color: var(--muted);
  font-size: 13px;
}

.draft-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #e6edf6;
  border-radius: 7px;
  padding: 9px;
  background: #fff;
}

.draft-item.active {
  border-color: #9fc3f3;
  background: #f4f8ff;
}

.draft-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.draft-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.draft-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.draft-button:hover {
  border-color: var(--primary);
}

.draft-button.danger {
  color: var(--danger);
}

.draft-button.danger:hover {
  border-color: var(--danger);
}

.draft-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 32, 51, 0.38);
}

.draft-dialog-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(21, 32, 51, 0.18);
}

.draft-dialog-card p {
  color: #35465f;
  line-height: 1.55;
}

.draft-name-field.hidden {
  display: none;
}

.draft-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.manual-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.manual-actions {
  display: flex;
  justify-content: flex-end;
}

.manual-table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.manual-mode .manual-table-scroll {
  min-height: 0;
}

.manual-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.manual-table th,
.manual-table td {
  border-top: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

.manual-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  border-top: 0;
  background: #fbfcfe;
  color: var(--muted);
  font-weight: 700;
}

.manual-table th:first-child,
.manual-table td:first-child {
  width: 46px;
  text-align: center;
}

.manual-table th:nth-child(2),
.manual-table td:nth-child(2) {
  width: 110px;
}

.manual-table th:nth-child(3),
.manual-table td:nth-child(3) {
  width: 92px;
}

.manual-table th:nth-child(5),
.manual-table td:nth-child(5) {
  width: 72px;
}

.manual-table th:nth-child(6),
.manual-table td:nth-child(6) {
  width: 94px;
}

.manual-table th:nth-child(7),
.manual-table td:nth-child(7) {
  width: 70px;
}

.manual-code-input,
.manual-major-code {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  text-transform: uppercase;
}

.manual-code-input:focus,
.manual-major-code:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(20, 100, 210, 0.12);
}

.manual-major-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(54px, 1fr));
  gap: 6px;
}

.manual-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  color: var(--success);
  font-weight: 700;
  white-space: nowrap;
}

.manual-check input {
  width: 16px;
  height: 16px;
}

.manual-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  min-width: 64px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.manual-status-pill.ok {
  color: var(--success);
  border-color: #a6d8ba;
  background: #f4fbf6;
}

.manual-status-pill.warn {
  color: var(--warning);
  border-color: #e2b76a;
  background: #fff8e6;
}

.manual-status-pill.danger {
  color: var(--danger);
  border-color: #efb5b0;
  background: #fff5f5;
}

.manual-status-pill.muted {
  color: var(--muted);
  background: var(--surface-soft);
}

.manual-row-remove {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}

.manual-row-remove:hover:not(:disabled) {
  border-color: var(--primary);
}

.manual-row-remove:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.status-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  overflow: hidden;
}

.metric {
  min-height: 68px;
  padding: 13px 15px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.metric:last-child {
  border-bottom: 0;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
}

.result-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 70px);
  overflow: hidden;
}

.panel-header {
  justify-content: space-between;
  min-height: 54px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.hidden {
  display: none !important;
}

.detail-content {
  min-height: 0;
  overflow: auto;
}

.candidate-strip {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1fr 1.5fr;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.candidate-strip strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 9px;
  padding: 16px;
}

.summary-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.summary-chip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-chip strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.issue-section {
  display: grid;
  gap: 10px;
  margin: 0 16px 18px;
}

.issue-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 9px;
}

.issue-stat {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.issue-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.issue-stat strong {
  display: block;
  margin-top: 7px;
  font-size: 18px;
}

.issue-stat.danger {
  border-color: #efb5b0;
  background: #fff5f5;
  color: var(--danger);
}

.issue-stat.warn {
  border-color: #e2b76a;
  background: #fff8e6;
  color: var(--warning);
}

.issue-stat.ok {
  border-color: #a6d8ba;
  background: #f4fbf6;
  color: var(--success);
}

.issue-list,
.issue-entries {
  display: grid;
  gap: 8px;
}

.issue-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.issue-group > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
}

.issue-group > header strong,
.issue-entry b {
  display: block;
  margin-bottom: 4px;
}

.issue-group > header span,
.issue-entry span {
  color: #35465f;
  line-height: 1.55;
}

.issue-group > header > b {
  min-width: 52px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  text-align: center;
  background: #fff;
  font-size: 12px;
}

.issue-entries {
  padding: 8px;
}

.issue-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #e8eef7;
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
}

.issue-group.danger {
  border-color: #efb5b0;
}

.issue-group.danger > header {
  background: #fff5f5;
}

.issue-group.warn {
  border-color: #e2b76a;
}

.issue-group.warn > header {
  background: #fffaf0;
}

.issue-group.info {
  border-color: #c9d7e8;
}

.issue-group.info > header {
  background: #f8fafc;
}

.issue-link {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}

.issue-link:hover {
  border-color: var(--primary);
}

.issue-empty {
  border: 1px solid #a6d8ba;
  border-radius: 8px;
  background: #f4fbf6;
  color: var(--success);
  line-height: 1.6;
  padding: 11px 12px;
}

.preference-section {
  padding: 0 16px 18px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title p {
  color: var(--muted);
  font-size: 13px;
}

.preference-list {
  display: grid;
  gap: 18px;
}

.preference-batch-group,
.preference-batch-list {
  display: grid;
  gap: 12px;
}

.preference-batch-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
  border-top: 1px solid var(--line);
}

.preference-batch-group:first-child .preference-batch-head {
  border-top: 0;
}

.preference-batch-head strong {
  display: block;
  font-size: 15px;
}

.preference-batch-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.preference-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preference-card.risk-reach {
  box-shadow: inset 4px 0 0 var(--danger);
}

.preference-card.risk-target {
  box-shadow: inset 4px 0 0 var(--teal);
}

.preference-card.risk-safe {
  box-shadow: inset 4px 0 0 var(--success);
}

.preference-card.risk-unknown {
  box-shadow: inset 4px 0 0 #8792a2;
}

.group-card {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  background: #f8fafc;
}

.group-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.group-top strong {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
}

.group-top span {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.group-compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 180px);
  gap: 10px;
  align-items: stretch;
}

.group-rank-block {
  display: grid;
  gap: 8px;
}

.group-quick-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.group-quick-stat {
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.group-quick-stat span,
.adjustment-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.group-quick-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.group-quick-stat small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.group-quick-stat.good {
  border-color: #a6d8ba;
  background: #f4fbf6;
}

.group-quick-stat.risk {
  border-color: #efb5b0;
  background: #fff5f5;
}

.group-quick-stat.close {
  border-color: #9fcfcc;
  background: #f2fbfa;
}

.group-trend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.group-trend span {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  border: 1px solid #dce6f2;
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff;
  color: #35465f;
  line-height: 1.2;
}

.group-trend.empty {
  color: var(--muted);
}

.adjustment-status {
  display: grid;
  align-content: center;
  min-height: 100%;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
}

.adjustment-status strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

.adjustment-status small {
  display: block;
  margin-top: 5px;
}

.adjustment-status.ok {
  border-color: #65c38d;
  background: #eefaf2;
  color: var(--success);
}

.adjustment-status.warn {
  border-color: #e2b76a;
  background: #fff8e6;
  color: var(--warning);
}

.adjustment-status.danger {
  border-color: #ef8d86;
  background: #fff5f5;
  color: var(--danger);
}

.group-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.group-foot p {
  flex: 1 1 360px;
  min-width: 0;
  margin: 0;
  color: #35465f;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.group-toggle {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.group-toggle:hover {
  border-color: var(--primary);
}

.group-history-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
}

.group-history-table th,
.group-history-table td {
  border-top: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
}

.group-history-table th {
  border-top: 0;
  background: #fbfcfe;
  color: var(--muted);
  font-weight: 700;
}

.group-risk-note,
.group-history-empty,
.group-empty {
  border: 1px solid #dce6f2;
  border-radius: 8px;
  background: #fff;
  color: #35465f;
  line-height: 1.65;
  padding: 10px 12px;
}

.group-history-empty,
.group-empty {
  color: var(--muted);
}

.risk-badge,
.issue-count-badge,
.batch-badge,
.risk-pill,
.restriction-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: #fff;
  white-space: normal;
  font-size: 12px;
  font-weight: 700;
}

.group-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.batch-badge {
  border-color: #c9d7e8;
  background: #f7fbff;
  color: #25405f;
}

.risk-badge {
  flex: 0 0 auto;
}

.risk-badge.risk-reach {
  color: var(--danger);
  border-color: #efb5b0;
  background: #fff5f5;
}

.risk-badge.risk-target {
  color: var(--teal);
  border-color: #9fcfcc;
  background: #f2fbfa;
}

.risk-badge.risk-safe {
  color: var(--success);
  border-color: #a6d8ba;
  background: #f4fbf6;
}

.risk-badge.risk-unknown {
  color: var(--muted);
  background: var(--surface-soft);
}

.issue-count-badge.ok {
  color: var(--success);
  border-color: #a6d8ba;
  background: #f4fbf6;
}

.issue-count-badge {
  color: var(--warning);
  border-color: #e2b76a;
  background: #fff8e6;
}

.risk-pill.risk-reach {
  color: var(--danger);
  border-color: #efb5b0;
  background: #fff5f5;
}

.risk-pill.risk-target {
  color: var(--teal);
  border-color: #9fcfcc;
  background: #f2fbfa;
}

.risk-pill.risk-safe {
  color: var(--success);
  border-color: #a6d8ba;
  background: #f4fbf6;
}

.risk-pill.risk-unknown {
  color: var(--muted);
  background: var(--surface-soft);
}

.restriction-chip {
  display: inline-flex;
  margin: 0 5px 5px 0;
  max-width: 260px;
  white-space: normal;
}

.restriction-chip.conflict {
  color: var(--danger);
  border-color: #efb5b0;
  background: #fff5f5;
}

.restriction-chip.ok {
  color: var(--success);
  border-color: #a6d8ba;
  background: #f4fbf6;
}

.restriction-chip.attention {
  color: var(--warning);
  border-color: #e2b76a;
  background: #fff8e6;
}

.attention-conflict td {
  background: #fffafa;
}

.major-detail-panel {
  border-top: 1px solid var(--line);
  background: #fff;
}

.major-table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.major-detail-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.major-detail-table th,
.major-detail-table td {
  border-top: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.major-detail-table tr:first-child th {
  border-top: 0;
}

.major-detail-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfe;
  color: var(--muted);
  font-weight: 700;
}

.major-detail-table small {
  color: var(--muted);
  line-height: 1.6;
}

.major-detail-table th:nth-child(1) {
  width: 34%;
}

.major-detail-table th:nth-child(2) {
  width: 15%;
}

.major-detail-table th:nth-child(3) {
  width: 18%;
}

.major-detail-table th:nth-child(4) {
  width: 23%;
}

.major-detail-table th:nth-child(5) {
  width: 10%;
}

.major-row.attention-conflict td {
  background: #fffafa;
}

.major-detail-panel.is-hidden {
  display: none;
}

.flash-row > td,
.flash-row {
  animation: flash-row 1.3s ease;
}

@keyframes flash-row {
  0% {
    outline: 3px solid rgba(20, 100, 210, 0.45);
    outline-offset: -3px;
  }
  100% {
    outline: 3px solid transparent;
    outline-offset: -3px;
  }
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.json-details {
  margin: 0 16px 18px;
}

.json-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
}

.json-view {
  min-height: 300px;
  margin: 10px 0 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101828;
  color: #ecf3ff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.search-view {
  display: grid;
  gap: 14px;
  min-height: calc(100vh - 52px);
  padding: 18px;
}

.search-header,
.search-panel,
.search-results,
.search-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
}

.search-header p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1.8fr) repeat(4, minmax(120px, 0.7fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.search-input-field input {
  min-width: 0;
}

.search-status {
  align-self: center;
  min-width: 128px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.search-status.warn {
  color: var(--warning);
}

.search-status.danger {
  color: var(--danger);
}

.search-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(620px, 1.7fr);
  gap: 14px;
  min-height: 0;
}

.search-results,
.search-detail {
  min-width: 0;
  overflow: auto;
}

.search-results {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: calc(100vh - 230px);
  padding: 10px;
}

.search-result-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.search-result-card:hover,
.search-result-card.active {
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.search-result-card strong,
.search-result-card span,
.search-result-card small {
  display: block;
}

.search-result-card strong {
  margin-bottom: 6px;
  font-size: 15px;
}

.search-result-card span {
  color: #35465f;
  line-height: 1.45;
}

.search-result-card small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.search-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
  padding: 22px;
}

.search-detail {
  max-height: calc(100vh - 230px);
  padding: 14px;
}

.search-detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.search-detail-head strong {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
}

.search-detail-head span {
  color: var(--muted);
  line-height: 1.5;
}

.search-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-meta-grid,
.search-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.search-meta-item,
.search-stat-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.search-meta-item span,
.search-stat-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.search-meta-item strong,
.search-stat-item strong {
  display: block;
  margin-top: 5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.search-major-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.search-major-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-major-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.search-major-table th,
.search-major-table td {
  border-top: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.search-major-table th {
  border-top: 0;
  background: #fbfcfe;
  color: var(--muted);
}

.search-major-table tr.match td {
  background: #fff8e6;
}

.search-major-table small {
  color: var(--muted);
  line-height: 1.6;
}

.search-major-table .draft-button {
  white-space: nowrap;
}

@media (max-width: 1160px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .layout-resizer {
    display: none;
  }

  .result-panel {
    min-height: auto;
  }

  .status-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .metric:last-child {
    border-right: 0;
  }
}

@media (max-width: 1500px) {
  .manual-mode .manual-table-scroll {
    max-height: 62vh;
  }

  .search-panel,
  .search-layout {
    grid-template-columns: 1fr;
  }

  .search-results,
  .search-detail {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .app-tabs {
    padding: 10px 12px 0;
  }

  .app-tab {
    flex: 1 1 0;
    padding: 0 8px;
  }

  .search-view {
    padding: 12px;
  }

  .top-actions,
  .panel-header,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .dropzone-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .status-panel,
  .candidate-strip,
  .analysis-summary,
  .issue-overview,
  .manual-progress,
  .manual-settings,
  .group-quick-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manual-mode .input-panel {
    grid-template-columns: 1fr;
  }

  .manual-major-grid {
    grid-template-columns: repeat(3, minmax(54px, 1fr));
  }

  .draft-item {
    grid-template-columns: 1fr;
  }

  .draft-actions {
    justify-content: flex-start;
  }

  .draft-dialog-actions {
    flex-direction: column-reverse;
  }

  .draft-dialog-actions .button {
    width: 100%;
  }

  .issue-entry,
  .group-foot,
  .group-compact {
    grid-template-columns: 1fr;
  }

  .candidate-strip strong {
    white-space: normal;
  }
}
