:root {
  --bg: #f4f7fb;
  --bg-alt: #edf2f8;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #d7e0ea;
  --line-strong: #c4d2e1;
  --title: #0f2233;
  --text: #1d3448;
  --muted: #5f7284;
  --muted-soft: #7c8b99;
  --accent: #1d6fd8;
  --accent-strong: #195fb8;
  --success: #0e9f6e;
  --danger: #d64545;
  --warning: #b87814;
  --shadow-soft: 0 8px 20px rgba(15, 34, 51, 0.06);
  --shadow-card: 0 12px 24px rgba(15, 34, 51, 0.08);
  --ui-font: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--ui-font);
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(62rem 40rem at 90% -12%, rgba(29, 111, 216, 0.1), transparent 72%),
    radial-gradient(54rem 34rem at -10% 120%, rgba(94, 119, 146, 0.1), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
}

button,
select,
input {
  font: inherit;
}

button,
a {
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.page {
  width: min(1480px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero,
.controls,
.chart-zone {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.hero {
  border-radius: 22px;
  padding: 22px 28px;
  background:
    linear-gradient(180deg, #ffffff, #f7fbff),
    var(--panel);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted-soft);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

.hero h1,
.chart-head h2,
.controls h2 {
  margin: 0;
  color: var(--title);
}

.hero h1 {
  font-size: clamp(30px, 4vw, 46px);
  letter-spacing: 0.01em;
}

.subtitle {
  max-width: 1000px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: 348px minmax(0, 1fr);
  gap: 18px;
  margin-top: 16px;
}

.controls,
.chart-zone {
  border-radius: 18px;
}

.controls {
  position: sticky;
  top: 14px;
  align-self: start;
  padding: 20px 18px 18px;
}

.controls h2 {
  margin-bottom: 14px;
  font-size: 22px;
  font-weight: 700;
}

.control-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
}

.control-block + .control-block {
  margin-top: 10px;
}

.control-block h3 {
  margin: 0 0 10px;
  color: var(--title);
  font-size: 14px;
  font-weight: 700;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(29, 111, 216, 0.28);
  background: rgba(29, 111, 216, 0.09);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
}

.asset-search,
select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--title);
  outline: none;
}

.asset-search:focus,
select:focus {
  border-color: rgba(29, 111, 216, 0.8);
  box-shadow: 0 0 0 3px rgba(29, 111, 216, 0.15);
}

.company-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  margin-top: 10px;
  overflow-y: auto;
  padding: 2px 2px 0 0;
}

.company-list::-webkit-scrollbar {
  width: 8px;
}

.company-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(95, 114, 132, 0.45);
}

.company-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.company-card:hover {
  transform: translateY(-1px);
  border-color: #b9cbdf;
}

.company-card.is-active {
  border-color: rgba(29, 111, 216, 0.72);
  background: #f3f8ff;
  box-shadow: 0 8px 16px rgba(29, 111, 216, 0.12);
}

.company-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-soft);
  font-size: 11px;
}

.company-title {
  color: var(--title);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.company-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.company-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid #d4e2f1;
  background: #f2f8ff;
  color: #2b5f94;
  font-size: 10px;
  font-weight: 700;
}

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

.analysis-btn,
.primary-btn {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.analysis-btn:hover,
.primary-btn:hover {
  transform: translateY(-1px);
  border-color: #9db7d1;
}

.analysis-btn {
  flex: 1 1 120px;
}

.primary-btn {
  width: 100%;
  border-color: rgba(29, 111, 216, 0.85);
  background: linear-gradient(180deg, #2a7ce4, #1b68cb);
  color: #fff;
  box-shadow: 0 8px 16px rgba(29, 111, 216, 0.26);
}

.primary-btn:hover {
  border-color: rgba(29, 111, 216, 0.95);
  box-shadow: 0 10px 20px rgba(29, 111, 216, 0.3);
}

.analysis-hint,
.status,
.footnote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.chart-zone {
  padding: 20px;
}

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

.chart-head-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.chart-head h2 {
  font-size: clamp(24px, 2.6vw, 34px);
  letter-spacing: 0.01em;
}

.chart-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.chart-edit-group {
  display: grid;
  gap: 6px;
}

.chart-edit-group[hidden] {
  display: none !important;
}

.chart-mode-btn,
.chart-edit-btn,
.chart-reset-btn,
.chart-download-btn {
  flex: 0 0 auto;
  min-width: 132px;
}

.chart-mode-btn.is-bars {
  border-color: rgba(29, 111, 216, 0.88);
  background: linear-gradient(180deg, #2a7ce4, #1b68cb);
  color: #fff;
}

.chart-edit-btn.is-active {
  border-color: rgba(14, 159, 110, 0.84);
  background: linear-gradient(180deg, #14b17c, #0a8f61);
  color: #fff;
}

.chart-reset-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--title);
}

.language-switch span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.language-switch select {
  min-width: 106px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 8px;
}

.preview-toolbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.toolbar-item {
  display: grid;
  gap: 2px;
  padding: 10px 11px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
}

.toolbar-item span {
  color: var(--muted-soft);
  font-size: 11px;
}

.toolbar-item strong {
  color: var(--title);
  font-size: 13px;
  font-weight: 700;
}

.quality-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid #dbe5f2;
  background: #f5f8fc;
  color: #4f5f70;
  font-size: 11px;
  font-weight: 700;
}

.quality-pill.is-good {
  border-color: rgba(14, 159, 110, 0.42);
  background: rgba(14, 159, 110, 0.12);
  color: #0a8159;
}

.quality-pill.is-medium {
  border-color: rgba(184, 120, 20, 0.38);
  background: rgba(184, 120, 20, 0.12);
  color: #8b5d10;
}

.quality-pill.is-low {
  border-color: rgba(214, 69, 69, 0.38);
  background: rgba(214, 69, 69, 0.12);
  color: #b23232;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.kpi-card {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.kpi-label {
  display: block;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 600;
}

.kpi-value {
  display: block;
  margin-top: 6px;
  color: var(--title);
  font-size: 22px;
  line-height: 1.15;
}

.kpi-delta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  min-height: 17px;
}

.kpi-delta.is-positive {
  color: var(--success);
}

.kpi-delta.is-negative {
  color: var(--danger);
}

.kpi-delta.is-neutral {
  color: var(--muted-soft);
}

.preview-stage {
  margin-top: 12px;
}

.preview-canvas {
  position: relative;
  overflow: hidden;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  border: 0;
}

.chart-output {
  display: flex;
  align-items: stretch;
  aspect-ratio: 16 / 9;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #f6f5f2;
  box-shadow: var(--shadow-card);
}

.chart-output svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-output.is-editing {
  outline: 2px dashed rgba(29, 111, 216, 0.42);
  outline-offset: -8px;
}

.chart-output.is-editing svg {
  cursor: grab;
}

.chart-output.is-editing svg.is-dragging {
  cursor: grabbing;
}

.chart-output [data-edit-hit="true"] {
  pointer-events: none;
}

.chart-output.is-editing [data-edit-hit="true"] {
  pointer-events: all;
  cursor: grab;
}

.reference-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.reference-overlay.is-visible {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.detail-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.detail-card span {
  color: var(--muted-soft);
  font-size: 11px;
}

.detail-card strong {
  display: block;
  margin-top: 7px;
  color: var(--title);
  font-size: 20px;
  line-height: 1.2;
}

.detail-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.footnote {
  margin-top: 10px;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

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

@media (max-width: 960px) {
  .page {
    width: min(100vw - 22px, 100%);
    padding-top: 14px;
  }

  .hero,
  .controls,
  .chart-zone {
    border-radius: 14px;
  }

  .hero {
    padding: 18px 16px;
  }

  .controls,
  .chart-zone {
    padding: 14px;
  }

  .preview-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .chart-head,
  .chart-head-actions,
  .chart-tools {
    justify-items: stretch;
    justify-content: stretch;
  }

  .language-switch {
    justify-content: space-between;
  }
}
