:root {
  --navy: #123c76;
  --deep: #092f69;
  --gold: #c98b2d;
  --orange: #f06c00;
  --ink: #0f2d55;
  --muted: #657792;
  --line: #d7e2ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 18px;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #e8eef6;
}

button,
input,
textarea,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c9d8e9;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #f9fbfe;
}

.app-shell {
  max-width: 920px;
  margin: 0 auto;
}

.controls-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 10px;
  max-width: 792px;
  margin: 0 auto 12px;
}

.toolbar-panel,
.market-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(16, 45, 85, 0.06);
}

.toolbar-head,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-head {
  margin-bottom: 10px;
}

.toolbar-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.quote-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid #e3edf8;
}

.quote-toolbar span {
  margin-right: auto;
  color: #48617f;
  font-size: 12px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: #39506f;
  font-size: 13px;
  font-weight: 700;
}

.market-status {
  display: flex;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #f2f7fd;
}

.market-status span:last-child {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 50%;
  background: #b9c7d8;
}

.status-dot.ready {
  background: #13966f;
}

.icon-button,
.mini-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbff;
  color: var(--deep);
  cursor: pointer;
}

.icon-button {
  width: 36px;
  height: 36px;
}

.mini-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 6px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}

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

.secondary-button {
  color: var(--deep);
  background: #e8f0fa;
}

.preview-panel {
  overflow: auto;
}

.preview-toolbar {
  max-width: 792px;
  margin: 0 auto 12px;
  color: #415977;
}

.poster {
  width: 792px;
  min-height: 1173px;
  margin: 0 auto;
  padding: 20px 32px 0;
  overflow: hidden;
  background: linear-gradient(160deg, #f5f9fd 0%, #eef5fc 58%, #ddebf8 100%);
  box-shadow: 0 18px 45px rgba(16, 45, 85, 0.22);
}

.field-store {
  display: none;
}

.poster-hero {
  display: grid;
  grid-template-columns: 1fr 172px;
  gap: 16px;
  align-items: end;
}

.badge {
  display: inline-flex;
  max-width: 370px;
  padding: 7px 14px;
  margin-bottom: 18px;
  border: 1px solid #dfa650;
  border-radius: 999px;
  color: #bc7b23;
  background: #fff8ed;
  font-size: 14px;
  font-weight: 800;
}

.poster-hero h2 {
  margin-bottom: 8px;
  color: var(--deep);
  font-size: 34px;
  line-height: 1.1;
}

.poster-hero h2 span {
  white-space: nowrap;
}

.poster-hero h2 strong {
  display: block;
  color: var(--gold);
}

.poster-hero p {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--deep);
  font-size: 18px;
  font-weight: 800;
}

.inline-editable,
.table-editable {
  position: relative;
  cursor: text;
  transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

.inline-editable:hover,
.table-editable:hover {
  box-shadow: inset 0 0 0 1px rgba(18, 60, 118, 0.18);
}

.inline-editable::after,
.table-editable::after {
  content: "编辑";
  position: absolute;
  top: -18px;
  right: 0;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  background: rgba(18, 60, 118, 0.82);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.inline-editable:hover::after,
.inline-editable:focus::after,
.table-editable:hover::after,
.table-editable:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.inline-editable:focus,
.table-editable:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(18, 60, 118, 0.28);
  background: rgba(255, 255, 255, 0.94);
}

.block-editable {
  white-space: pre-wrap;
}

.coupon-card {
  display: grid;
  gap: 8px;
  min-height: 140px;
  padding: 22px 16px 12px;
  border-radius: 18px;
  color: #fff;
  text-align: center;
  background: var(--deep);
}

.coupon-card span {
  font-weight: 800;
}

.coupon-card strong {
  color: #ffd36e;
  font-family: Georgia, serif;
  font-size: 30px;
  line-height: 1.22;
}

.coupon-card em {
  justify-self: end;
  font-style: normal;
  font-weight: 800;
}

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 12px;
}

.feature-row div,
.block,
.basics-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.feature-row div {
  min-height: 72px;
  padding: 12px 12px 10px 42px;
  position: relative;
}

.feature-row b {
  position: absolute;
  left: 14px;
  top: 16px;
  width: 26px;
  height: 26px;
  border: 1px solid #d19535;
  border-radius: 50%;
  color: #c18124;
  text-align: center;
  line-height: 24px;
}

.feature-row strong,
.feature-row span {
  display: block;
}

.feature-row strong {
  margin-bottom: 5px;
  font-size: 15px;
}

.feature-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  align-items: stretch;
}

.block {
  padding: 16px 14px 12px;
  position: relative;
}

.block h3 {
  display: inline-block;
  padding: 8px 14px;
  margin: -16px 0 12px -14px;
  border-radius: 0 0 8px 0;
  color: #fff;
  background: var(--deep);
  font-size: 17px;
}

.quote-section {
  display: flex;
  flex-direction: column;
}

.block p {
  color: #27466e;
  font-size: 13px;
  line-height: 1.42;
}

.chart-section {
  padding-bottom: 14px;
}

.chart-section p {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid #dce8f5;
  border-radius: 8px;
  background: #f8fbff;
}

#rateChart {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 205px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbff;
}

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

.threshold-cards div {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  background: #f8fbff;
}

.threshold-cards strong,
.quote-section td:last-child,
.scenario-product strong:last-child {
  color: var(--orange);
}

.threshold-cards strong {
  font-size: 15px;
  white-space: nowrap;
}

.threshold-cards span,
.threshold-cards em {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.threshold-cards span {
  color: var(--deep);
}

.threshold-cards em {
  color: var(--muted);
  font-style: normal;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  font-size: 12px;
}

th,
td {
  padding: 7px 5px;
  border: 1px solid var(--line);
  text-align: center;
}

th {
  color: var(--deep);
  background: #e7f0fa;
}

td {
  background: #fbfdff;
}

td:first-child {
  font-weight: 800;
}

.quote-section table {
  font-size: 11px;
  table-layout: fixed;
}

.quote-tenor {
  width: 24%;
}

.quote-condition {
  width: 36%;
}

.quote-coupon {
  width: 40%;
}

.quote-section td:last-child {
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.quote-section th {
  line-height: 1.25;
  vertical-align: middle;
}

.table-head-editable {
  display: inline-block;
  min-width: 48px;
}

.note {
  margin: 8px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f9fe;
  font-size: 11px !important;
}

.basics,
.scenario,
.poster-footer {
  margin-top: 10px;
}

.basics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.basics-grid div {
  display: grid;
  min-height: 58px;
  align-content: center;
  justify-items: center;
  padding: 8px 10px;
  text-align: center;
}

.basics-grid strong,
.basics-grid span {
  display: block;
}

.basics-grid strong {
  margin-bottom: 4px;
  color: var(--deep);
  font-size: 13px;
}

.basics-grid span {
  font-size: 12px;
}

.scenario-grid {
  display: grid;
  gap: 8px;
}

.scenario-note {
  margin: -6px 0 10px;
  color: var(--muted);
  font-size: 11px !important;
}

.scenario-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
  align-items: stretch;
}

.scenario-period,
.scenario-product {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.scenario-period {
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 8px;
  text-align: center;
}

.scenario-period strong {
  color: var(--deep);
  font-size: 13px;
}

.scenario-period span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.scenario-products {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.scenario-product {
  overflow: hidden;
}

.scenario-product h4 {
  margin: 0;
  padding: 7px 8px;
  color: var(--deep);
  background: #e7f0fa;
  font-size: 12px;
  text-align: center;
}

.scenario-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line);
}

.scenario-metrics div {
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  text-align: center;
}

.scenario-metrics div + div {
  border-left: 1px solid var(--line);
}

.scenario-product span {
  color: var(--muted);
  font-size: 11px;
}

.scenario-product strong {
  color: var(--deep);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.poster-footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.poster-footer > div {
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff;
}

.poster-footer h3 {
  margin-bottom: 7px;
  color: var(--deep);
  font-size: 17px;
}

.investor-editable {
  min-height: 92px;
  padding-left: 2px;
  font-size: 12px;
  line-height: 1.55;
}

.risk-box {
  border: 1px solid #e5ad5a;
  background: #fff9f0 !important;
}

.risk-box h3 {
  color: #c66300;
}

.risk-box p {
  margin-bottom: 0;
  color: #72420d;
  font-size: 11px;
}

.poster-footer small {
  grid-column: 1 / -1;
  display: block;
  margin: 6px -32px 0;
  padding: 10px 32px;
  color: #fff;
  background: var(--deep);
  font-size: 10px;
  text-align: center;
}

@media (max-width: 860px) {
  body {
    padding: 14px;
  }

  .controls-strip,
  .market-controls,
  .toolbar-actions,
  .feature-row,
  .main-grid,
  .basics-grid,
  .poster-footer,
  .scenario-products,
  .scenario-metrics {
    grid-template-columns: 1fr;
  }

  .poster {
    width: 100%;
    padding: 18px 18px 0;
  }

  .preview-toolbar {
    max-width: none;
  }

  .poster-hero {
    grid-template-columns: 1fr;
  }

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

  .scenario-row {
    grid-template-columns: 1fr;
  }
}

@page {
  size: A4 portrait;
  margin: 8mm;
}

@media print {
  html,
  body {
    width: 100%;
    height: auto;
    padding: 0;
    background: #fff;
  }

  .controls-strip,
  .preview-toolbar {
    display: none;
  }

  .preview-panel {
    overflow: visible;
  }

  .poster {
    width: 190mm;
    min-height: 281mm;
    max-height: 281mm;
    margin: 0 auto;
    overflow: hidden;
    transform: none;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .inline-editable::after,
  .table-editable::after {
    display: none !important;
  }

  .inline-editable:hover,
  .table-editable:hover,
  .inline-editable:focus,
  .table-editable:focus {
    box-shadow: none;
    background: transparent;
  }
}
