/* Global layout */
:root {
  color-scheme: light;
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-alt: #f8f6f1;
  --line: #d8d2c8;
  --line-strong: #bdb6a8;
  --text: #1f242d;
  --muted: #5b6676;
  --accent: #1f6f78;
  --accent-dark: #184e54;
  --accent-soft: #d9efef;
  --warm: #9c6b2f;
  --warm-soft: #f5e6cf;
  --green: #2e8b57;
  --green-soft: #e6f5ec;
  --danger: #a23d3d;
  --shadow: 0 10px 24px rgba(29, 39, 52, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", PingFang SC,
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* ========== Header ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 242, 237, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(216, 210, 200, 0.9);
}

.header-inner,
.app-shell,
.site-footer {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand span:last-child {
  display: grid;
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand small,
.eyebrow,
.section-heading p,
.preview-toolbar p,
.document-head p,
.site-footer span,
.dialog-note,
.status-pill {
  color: var(--muted);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 700;
  flex: none;
  font-size: 16px;
}

.top-actions,
.form-actions,
.preview-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ========== Free badge ========== */
.free-badge-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.free-badge-footer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ========== Buttons ========== */
.ghost-button,
.primary-button,
.ghost-link {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.primary-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

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

.ghost-button:hover,
.ghost-link:hover {
  border-color: var(--line-strong);
  background: #fbfaf7;
}

.compact {
  min-height: 38px;
  padding: 0 14px;
}


/* ========== Intro band ========== */
.intro-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
  gap: 24px;
  align-items: center;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.intro-copy {
  display: grid;
  gap: 10px;
}

.free-badge-hero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  width: fit-content;
}

.eyebrow {
  font-size: 13px;
  font-weight: 500;
}

.intro-copy h1 {
  font-size: 22px;
  margin: 0;
  line-height: 1.2;
}

.intro-copy > p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.intro-visual img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

/* ========== App shell ========== */
.app-shell {
  padding: 24px 0 36px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 18px;
  align-items: start;
}

.quote-form,
.quote-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.section-heading,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-heading h2,
.preview-toolbar h2 {
  font-size: 20px;
  margin: 0;
  line-height: 1.2;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* ========== Form ========== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.full-field {
  grid-column: 1 / -1;
}

label > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

/* ========== Addon panel ========== */
.addon-panel {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--surface-alt);
}

.addon-panel legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 6px;
}

.addon-panel label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  margin-right: 14px;
  margin-top: 8px;
}

.addon-panel input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* ========== Quote panel (sticky) ========== */
.quote-panel {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.quote-document {
  background: #fff;
  padding: 18px;
}

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

.document-head strong {
  font-size: 26px;
  line-height: 1;
  color: var(--accent-dark);
  white-space: nowrap;
}

.client-summary {
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.client-summary div {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  min-width: 0;
}

.client-summary dt {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.client-summary dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 14px;
}

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

.quote-table th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.quote-table td:last-child,
.quote-table th:last-child {
  text-align: right;
  white-space: nowrap;
}

.quote-table td:nth-child(2) {
  color: var(--muted);
}

.needs-box,
.terms-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.needs-box h4,
.terms-box h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.needs-box p,
.terms-box ol {
  margin: 8px 0 0;
  font-size: 14px;
}

.terms-box ol {
  padding-left: 20px;
}

.terms-box li + li {
  margin-top: 6px;
}

/* ========== Preview actions ========== */
.preview-actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ========== Contact strip (唯一微信入口) ========== */
.contact-strip {
  margin-top: 18px;
  padding: 16px 22px;
  background: var(--warm-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.contact-inner span {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.wechat-number {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--warm);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

/* ========== WeChat dialog ========== */
.wechat-dialog {
  position: relative;
  width: min(480px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.wechat-dialog::backdrop {
  background: rgba(31, 36, 45, 0.42);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.dialog-content {
  display: grid;
  gap: 12px;
}

.dialog-content h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.wechat-qr {
  width: min(100%, 280px);
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.wechat-id-row {
  margin: 0;
  font-size: 15px;
}

.dialog-note {
  margin: 0;
  font-size: 13px;
}

/* ========== Footer ========== */
.site-footer {
  padding: 10px 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(216, 210, 200, 0.8);
}

.site-footer div,
.site-footer nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-footer strong {
  font-weight: 600;
}

.site-footer span {
  font-size: 13px;
}

.site-footer a {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* ========== Responsive ========== */
@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .quote-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .header-inner,
  .site-footer {
    align-items: flex-start;
  }

  .top-actions,
  .site-footer div,
  .site-footer nav {
    width: 100%;
  }

  .quote-form,
  .quote-panel {
    padding: 18px;
  }

  .intro-band {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .client-summary {
    grid-template-columns: 1fr;
  }

  .document-head,
  .section-heading,
  .preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .document-head strong {
    font-size: 22px;
  }

  .addon-panel label {
    display: flex;
    width: 50%;
    margin-right: 0;
  }

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

/* ========== Print ========== */
@media print {
  body {
    background: #fff;
  }

  .site-header,
  .quote-form,
  .preview-toolbar,
  .preview-actions,
  .site-footer,
  .intro-visual,
  .form-actions,
  .addon-panel,
  .ghost-button,
  .primary-button,
  .wechat-dialog,
  .free-badge-small,
  .contact-strip {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .workspace {
    display: block;
  }

  .quote-panel {
    position: static;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .quote-document {
    border: none;
    padding: 0;
  }
}

/* ========== 微信弹窗帮助列表 ========== */
.help-list {
  margin: 0;
  padding: 0 0 0 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.help-list li + li {
  margin-top: 6px;
}

.help-list strong {
  color: var(--text);
}

.help-list code {
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  font-size: 13px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent-dark);
}
