﻿:root {
  --bg: #eef3ef;
  --panel: #ffffff;
  --sidebar: #17322c;
  --accent: #d16b2c;
  --accent-soft: #f6dfcf;
  --text: #1f2937;
  --muted: #5f6b7a;
  --border: #d9e0e6;
  --shadow: 0 22px 60px rgba(23, 50, 44, 0.14);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top left, #f7eadf 0, var(--bg) 42%, #dce9e5 100%);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  background: linear-gradient(180deg, #17322c 0%, #21453d 100%);
  color: #f8fafc;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand h1, .workspace-header h2, .panel-header h3 { margin: 0; }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; opacity: 0.78; }
.muted { color: var(--muted); line-height: 1.5; }
.sidebar .muted { color: rgba(248, 250, 252, 0.75); }
.tool-list { display: grid; gap: 10px; }
.tool-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  padding: 12px 14px;
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: 160ms ease;
}
.tool-button:hover, .tool-button.active {
  background: rgba(209, 107, 44, 0.22);
  border-color: rgba(209, 107, 44, 0.65);
  transform: translateY(-1px);
}
.workspace { padding: 28px; }
.workspace-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.header-actions, .panel-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.primary-button, .secondary-button, .link-button {
  border: none;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.primary-button { background: var(--accent); color: #fff; box-shadow: 0 12px 30px rgba(209, 107, 44, 0.28); }
.secondary-button { background: #eef3f5; color: var(--text); border: 1px solid #d7e0e4; }
.compact-button { padding: 9px 14px; }
.link-button { background: transparent; color: #b75b24; padding: 0; font-weight: 600; }
.panels { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 22px; }
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel-header { margin-bottom: 16px; }
.panel-header-actions { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field span, .result-sections h4, .subsection-title, .mapping-header h4 { font-size: 14px; font-weight: 600; }
.subsection-title { color: var(--text); margin-bottom: 8px; }
input, select, textarea, pre, table { border: 1px solid var(--border); background: #fbfcfd; }
input, select, textarea { width: 100%; padding: 12px 14px; border-radius: 14px; }
textarea, pre { font-family: "Cascadia Code", "Consolas", monospace; }
.helper-card { background: var(--accent-soft); border-radius: 16px; padding: 14px; }
.helper-card pre, .result-sections pre { margin: 0; padding: 12px; overflow: auto; white-space: pre-wrap; word-break: break-word; border-radius: 14px; }
.mapping-panel {
  border: 1px solid #d9e0e6;
  background: linear-gradient(180deg, #fcf7f2 0%, #fff 100%);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}
.mapping-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.mapping-content { display: grid; gap: 14px; }
.mapping-section { border: 1px solid #e6ecef; border-radius: 14px; padding: 12px; background: #fff; }
.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.mapping-sample { margin-top: 10px; font-size: 12px; color: var(--muted); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.summary-grid div, .map-summary-grid div { background: #f4f7f8; border-radius: 14px; padding: 12px; }
.summary-grid span, .map-summary-grid span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.summary-grid strong, .map-summary-grid strong { font-size: 24px; }
.result-sections { display: grid; gap: 14px; }
.result-sections section { display: grid; gap: 10px; }
.map-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; background: #fbfcfd; }
#result-table, #error-table, #map-preview-table { width: 100%; border-collapse: collapse; border: none; }
#result-table th, #result-table td, #error-table th, #error-table td, #map-preview-table th, #map-preview-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e7ecef;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}
#result-table th, #error-table th, #map-preview-table th { position: sticky; top: 0; background: #f2f6f7; font-weight: 700; }
#result-table tbody tr:nth-child(even), #error-table tbody tr:nth-child(even), #map-preview-table tbody tr:nth-child(even) { background: #f9fbfb; }
.result-expand-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.map-preview-panel { background: linear-gradient(180deg, #f7fafb 0%, #eff5f6 100%); border: 1px solid #dce5e8; border-radius: 16px; padding: 16px; }
.map-canvas { width: 100%; min-height: 460px; border-radius: 16px; border: 1px solid #dce5e8; background: linear-gradient(135deg, #eef4f6 0%, #dfe9ed 100%); overflow: hidden; }
.map-hint { margin: 0; }
.empty-cell { color: var(--muted); text-align: center; }
.debug-panel { border: 1px dashed #d8e1e5; border-radius: 14px; background: #fcfdfd; padding: 10px 12px; }
.debug-panel summary { cursor: pointer; color: var(--muted); font-size: 13px; }
[data-hidden="true"] { display: none !important; }

@media (max-width: 980px) {
  .app-shell, .panels, .mapping-grid { grid-template-columns: 1fr; }
  .workspace-header, .panel-header-actions, .mapping-header { flex-direction: column; }
  .header-actions, .panel-actions { width: 100%; }
  .map-summary-grid, .summary-grid { grid-template-columns: 1fr; }
  .map-canvas { min-height: 360px; }
}
.segmented-control { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compact-switch { margin-top: 10px; }
.active-pill { background: var(--accent); color: #fff; border-color: transparent; }
.imported-summary-card { gap: 10px; }
.summary-meta { font-size: 13px; color: var(--muted); }
.summary-list { margin: 0; padding-left: 18px; color: var(--text); }
.compact-header { margin-bottom: 12px; }
.dual-slot-card { gap: 12px; }
.excel-workflow-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.compact-panel {
  padding: 14px;
}

.mapping-content.compact-layout {
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mapping-sample-card {
  margin-top: 10px;
  border-top: 1px dashed #d8e1e5;
  padding-top: 10px;
}

.mapping-sample-toggle {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.mapping-sample pre {
  margin: 8px 0 0;
  max-height: 96px;
}

#excel-mode-panel {
  display: grid;
  gap: 12px;
}

#excel-summary-panel {
  order: 1;
}

#excel-mapping-panel {
  order: 2;
}

@media (max-width: 980px) {
  .compact-grid,
  .excel-workflow-actions {
    grid-template-columns: 1fr;
  }

  .excel-workflow-actions {
    display: grid;
  }

  .mapping-content.compact-layout {
    max-height: none;
  }
}
