:root {
  --ink: #13233c;
  --blue: #2176ff;
  --blue-soft: #e9f2ff;
  --orange: #ff9d45;
  --paper: #ffffff;
  --canvas: #eef2f6;
  --mist: #f7f9fc;
  --line: #d8e0ea;
  --muted: #6d7786;
  --danger: #c43e44;
  --success: #14845d;
  --shadow: 0 18px 50px rgba(19, 35, 60, .11);
  --display: "Arial Black", "Microsoft YaHei", sans-serif;
  --body: "Microsoft YaHei", "PingFang SC", sans-serif;
  --data: Consolas, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(19, 35, 60, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 35, 60, .025) 1px, transparent 1px),
    var(--canvas);
  background-size: 24px 24px;
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(33, 118, 255, .28);
  outline-offset: 2px;
}

.demo-ribbon {
  min-height: 34px;
  padding: 7px 20px;
  color: #fff;
  background: var(--ink);
  font-size: 12px;
  letter-spacing: .08em;
  text-align: center;
}
.demo-ribbon__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(255,157,69,.15);
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  padding: 0 max(28px, calc((100vw - 1500px) / 2));
  border-bottom: 1px solid rgba(19,35,60,.1);
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
}
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand__mark {
  position: relative;
  width: 37px;
  height: 43px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--blue-soft);
}
.brand__mark::after { content: ""; position: absolute; right: -2px; top: -2px; border-style: solid; border-width: 0 13px 13px 0; border-color: transparent var(--orange) transparent transparent; }
.brand__mark i { position: absolute; left: 8px; right: 8px; top: 21px; height: 2px; background: var(--blue); box-shadow: 0 7px 0 var(--blue); }
.brand strong { display: block; font-family: var(--display); font-size: 19px; letter-spacing: .06em; }
.brand small { display: block; margin-top: -2px; font-family: var(--data); font-size: 9px; letter-spacing: .15em; color: var(--muted); }
.header-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(20,132,93,.12); }

.workspace {
  display: grid;
  grid-template-columns: minmax(560px, .92fr) minmax(520px, 1.08fr);
  gap: clamp(28px, 4vw, 64px);
  width: min(1500px, calc(100% - 56px));
  margin: 0 auto;
  padding: 56px 0 100px;
  align-items: start;
}
.editor-column { min-width: 0; }
.intro-block { display: grid; grid-template-columns: 1fr 210px; gap: 24px; align-items: end; margin-bottom: 34px; }
.eyebrow { margin: 0 0 12px; color: var(--blue); font-family: var(--data); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.intro-block h1 { margin: 0; font-family: var(--display); font-size: clamp(32px, 3.2vw, 49px); line-height: 1.08; letter-spacing: -.04em; }
.intro-block h1 span { color: transparent; -webkit-text-stroke: 1.3px var(--ink); }
.intro-note { margin: 0; padding-left: 17px; border-left: 3px solid var(--orange); color: var(--muted); font-size: 13px; }

.form-card, .records-panel {
  margin-bottom: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 7px 24px rgba(19,35,60,.04);
}
.section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.section-heading--actions { flex-wrap: wrap; }
.section-heading--actions .button { margin-left: auto; }
.section-index { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 1px solid var(--ink); font-family: var(--data); font-size: 13px; font-weight: 700; box-shadow: 3px 3px 0 var(--orange); }
.section-heading h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; }
.field--wide { grid-column: 1 / -1; }
.field { display: block; min-width: 0; }
.field > span { display: block; margin-bottom: 7px; color: #425064; font-size: 12px; font-weight: 700; }
.field em { color: var(--orange); font-style: normal; }
.field input {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid #c9d3df;
  border-radius: 3px;
  color: var(--ink);
  background: #fff;
  transition: border-color .18s, box-shadow .18s;
}
.field input:hover { border-color: #9eacbc; }
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33,118,255,.1); outline: none; }
.field input.is-invalid { border-color: var(--danger); background: #fffafb; }
.field-error { display: block; min-height: 18px; padding-top: 4px; color: var(--danger); font-size: 11px; }
.readonly-value { display: flex; justify-content: space-between; align-items: center; min-height: 45px; padding: 10px 12px; border: 1px dashed #b9c4d2; border-radius: 3px; background: var(--mist); }
.readonly-value code { font-family: var(--data); font-size: 13px; font-weight: 700; }
.readonly-value span { color: var(--muted); font-size: 11px; }

.items-editor { display: grid; gap: 12px; }
.item-editor { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 4px; background: var(--mist); }
.item-editor__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.item-editor__top strong { font-family: var(--data); font-size: 12px; letter-spacing: .06em; }
.remove-item { border: 0; padding: 5px 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.remove-item:hover { color: var(--danger); }
.item-grid { display: grid; grid-template-columns: minmax(140px, 1.8fr) .65fr .65fr .9fr; gap: 10px; }
.item-grid .field > span { font-size: 11px; }
.item-grid .field input { min-height: 41px; padding: 8px 10px; }
.item-note { grid-column: 1 / -1; }
.item-subtotal { display: flex; justify-content: flex-end; gap: 12px; margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.item-subtotal output { min-width: 88px; color: var(--ink); font-family: var(--data); font-weight: 700; text-align: right; }
.section-error, .form-summary { margin: 12px 0 0; color: var(--danger); font-size: 12px; }
.form-summary:empty, .section-error:empty { display: none; }

.discount-line { display: grid; grid-template-columns: minmax(180px, .65fr) 1.35fr; gap: 28px; align-items: start; }
.suffix-input { position: relative; }
.suffix-input input { padding-right: 38px; }
.suffix-input > span { position: absolute; right: 13px; top: 11px; color: var(--muted); font-family: var(--data); }
.live-totals { margin: 0; padding: 16px 18px; background: var(--ink); color: #fff; }
.live-totals div { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 8px; }
.live-totals dt { color: #aebbd0; font-size: 12px; }
.live-totals dd { margin: 0; font-family: var(--data); font-size: 13px; }
.live-totals .live-totals__grand { margin: 13px 0 0; padding-top: 13px; border-top: 1px solid rgba(255,255,255,.22); align-items: baseline; }
.live-totals__grand dt { color: #fff; font-weight: 700; }
.live-totals__grand dd { color: var(--orange); font-size: 21px; font-weight: 700; }

.button { min-height: 43px; padding: 10px 16px; border: 1px solid transparent; border-radius: 3px; font-weight: 700; cursor: pointer; transition: transform .16s, box-shadow .16s, background .16s; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button--small { min-height: 36px; padding: 7px 12px; font-size: 12px; }
.button--outline { border-color: var(--blue); color: var(--blue); background: #fff; }
.button--primary { color: #fff; background: var(--blue); box-shadow: 0 6px 16px rgba(33,118,255,.22); }
.button--ink { color: #fff; background: var(--ink); }
.button--ghost { border-color: var(--line); background: #fff; }
.button--danger { color: var(--danger); }
.primary-actions { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr 1fr; gap: 10px; margin: 18px 0 28px; }

.records-panel { box-shadow: none; background: rgba(247,249,252,.84); }
.records-panel .section-heading { margin-bottom: 14px; }
.records-list { display: grid; gap: 9px; }
.records-empty { margin: 0; padding: 17px; border: 1px dashed #bdc8d5; color: var(--muted); text-align: center; font-size: 12px; }
.record-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); background: #fff; }
.record-row strong, .record-row small { display: block; }
.record-row strong { font-size: 13px; }
.record-row small { margin-top: 3px; color: var(--muted); font-family: var(--data); font-size: 10px; }
.record-row__actions { display: flex; gap: 6px; }
.record-row button { padding: 6px 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 11px; }
.record-row .delete-record { color: var(--danger); }

.preview-column { position: sticky; top: 24px; min-width: 0; }
.preview-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.preview-label span { font-family: var(--data); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.preview-label small { color: var(--muted); font-size: 11px; }
.quote-sheet { position: relative; min-height: 790px; padding: clamp(34px, 4vw, 62px); overflow: hidden; background: var(--paper); box-shadow: var(--shadow); }
.quote-sheet::after { content: "DEMO"; position: absolute; right: -29px; top: 25px; width: 130px; padding: 5px 0; transform: rotate(45deg); color: #fff; background: var(--orange); font-family: var(--data); font-size: 10px; font-weight: 700; letter-spacing: .18em; text-align: center; }
.paper-ruler { position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: repeating-linear-gradient(to bottom, var(--blue) 0 1px, transparent 1px 12px, var(--blue) 12px 13px, transparent 13px 24px); opacity: .55; }
.quote-head { display: flex; justify-content: space-between; gap: 24px; align-items: start; padding-bottom: 26px; border-bottom: 2px solid var(--ink); }
.quote-brand { display: flex; gap: 10px; align-items: center; }
.quote-brand__mark { width: 27px; height: 32px; border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--blue-soft); }
.quote-brand__mark::after { content: ""; display: block; width: 11px; height: 2px; margin: 12px 0 0 6px; background: var(--blue); box-shadow: 0 6px 0 var(--blue); }
.quote-brand strong, .quote-brand small { display: block; }
.quote-brand strong { font-family: var(--display); font-size: 15px; letter-spacing: .05em; }
.quote-brand small { color: var(--muted); font-size: 8px; }
.quote-title { text-align: right; }
.quote-title span { color: var(--blue); font-family: var(--data); font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.quote-title h2 { margin: 3px 0 0; font-family: var(--display); font-size: clamp(23px, 2.4vw, 34px); line-height: 1; letter-spacing: .04em; }
.quote-meta { display: grid; grid-template-columns: 1.15fr .85fr; gap: 32px; padding: 27px 0; }
.quote-meta__client span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.quote-meta__client strong { display: block; font-size: 19px; }
.quote-meta__client small { display: block; margin-top: 6px; color: var(--muted); }
.quote-meta dl { margin: 0; }
.quote-meta dl div { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 6px; font-size: 10px; }
.quote-meta dt { color: var(--muted); }
.quote-meta dd { margin: 0; font-family: var(--data); text-align: right; }
.quote-table-wrap { min-height: 245px; }
.quote-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.quote-table th { padding: 10px 8px; color: #fff; background: var(--ink); font-size: 9px; font-weight: 400; letter-spacing: .06em; text-align: left; }
.quote-table th:nth-child(1) { width: 42%; }
.quote-table th:nth-child(2) { width: 19%; }
.quote-table th:nth-child(3), .quote-table th:nth-child(4) { width: 19.5%; text-align: right; }
.quote-table td { padding: 13px 8px; border-bottom: 1px solid var(--line); font-size: 10px; vertical-align: top; }
.quote-table td:nth-child(3), .quote-table td:nth-child(4) { font-family: var(--data); text-align: right; }
.quote-table td strong, .quote-table td small { display: block; overflow-wrap: anywhere; }
.quote-table td small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.quote-empty td { padding: 42px 10px; color: var(--muted); text-align: center !important; }
.quote-total-block { display: grid; grid-template-columns: 1fr minmax(230px, .75fr); gap: 24px; align-items: start; margin-top: 24px; }
.quote-total-block > p { margin: 0; font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.quote-total-block > p small { display: block; margin-top: 3px; color: var(--muted); font-family: var(--data); font-size: 8px; font-weight: 400; }
.quote-total-block dl { margin: 0; }
.quote-total-block dl div { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 8px; font-size: 10px; }
.quote-total-block dd { margin: 0; font-family: var(--data); }
.quote-total-block .quote-grand { margin: 13px 0 0; padding-top: 13px; border-top: 2px solid var(--ink); align-items: baseline; }
.quote-grand dt { font-weight: 700; }
.quote-grand dd { color: var(--blue); font-size: 20px; font-weight: 700; }
.quote-foot { display: flex; justify-content: space-between; gap: 24px; margin-top: 50px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); }
.quote-foot p { max-width: 68%; margin: 0; font-size: 8px; }
.quote-foot p strong { color: var(--ink); }
.quote-foot div { text-align: right; }
.quote-foot span, .quote-foot small { display: block; }
.quote-foot span { color: var(--success); font-family: var(--data); font-size: 8px; font-weight: 700; }
.quote-foot small { margin-top: 3px; font-size: 7px; }
.mobile-action-bar { display: none; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; padding: 11px 16px; border-radius: 3px; color: #fff; background: var(--ink); box-shadow: 0 10px 32px rgba(19,35,60,.25); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .22s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; width: min(760px, calc(100% - 40px)); }
  .preview-column { position: static; }
  .quote-sheet { min-height: 0; }
}

@media (max-width: 640px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); background-size: 18px 18px; }
  .demo-ribbon { min-height: 30px; padding: 6px 12px; font-size: 10px; letter-spacing: .02em; }
  .app-header { height: 64px; padding: 0 16px; }
  .brand__mark { width: 30px; height: 35px; box-shadow: 4px 4px 0 var(--blue-soft); }
  .brand__mark i { top: 17px; }
  .brand strong { font-size: 16px; }
  .header-status { max-width: 108px; font-size: 10px; line-height: 1.3; }
  .workspace { width: 100%; padding: 34px 14px 44px; gap: 30px; }
  .intro-block { display: block; padding: 0 5px; margin-bottom: 26px; }
  .intro-block h1 { font-size: 31px; }
  .intro-note { margin-top: 18px; }
  .form-card, .records-panel { padding: 19px 16px; border-radius: 4px; }
  .field-grid { grid-template-columns: 1fr; gap: 12px; }
  .field--wide { grid-column: auto; }
  .section-heading--actions .button { width: 100%; margin: 4px 0 0 47px; }
  .item-editor { padding: 15px 13px; }
  .item-grid { grid-template-columns: 1fr 1fr; }
  .item-grid .field:first-child, .item-note { grid-column: 1 / -1; }
  .discount-line { grid-template-columns: 1fr; gap: 10px; }
  .primary-actions { grid-template-columns: 1fr 1fr; }
  .preview-label { padding: 0 4px; }
  .preview-label small { display: none; }
  .quote-sheet { padding: 28px 20px 30px 27px; box-shadow: 0 12px 32px rgba(19,35,60,.12); }
  .quote-head { gap: 12px; }
  .quote-brand small { display: none; }
  .quote-title h2 { font-size: 22px; }
  .quote-meta { grid-template-columns: 1fr; gap: 18px; }
  .quote-table-wrap { min-height: 200px; overflow-x: auto; }
  .quote-table { min-width: 520px; }
  .quote-total-block { grid-template-columns: 1fr; }
  .quote-total-block > p { display: none; }
  .quote-foot { margin-top: 34px; }
  .quote-foot p { max-width: 100%; }
  .quote-foot div { display: none; }
  .mobile-action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: grid; grid-template-columns: .8fr 1fr 1.3fr; gap: 1px; padding-bottom: env(safe-area-inset-bottom); background: #cbd4df; box-shadow: 0 -8px 24px rgba(19,35,60,.13); }
  .mobile-action-bar button { min-height: 58px; border: 0; background: #fff; font-size: 12px; font-weight: 700; cursor: pointer; }
  .mobile-action-bar button:last-child { color: #fff; background: var(--ink); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 40px); text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@page { size: A4 portrait; margin: 12mm; }
@media print {
  html, body { width: 210mm; min-height: 297mm; background: #fff !important; }
  body { padding: 0 !important; }
  .demo-ribbon, .app-header, .editor-column, .preview-label, .mobile-action-bar, .toast { display: none !important; }
  .workspace { display: block; width: auto; margin: 0; padding: 0; }
  .preview-column { position: static; }
  .quote-sheet { width: 100%; min-height: 270mm; padding: 14mm; overflow: visible; box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .quote-sheet::after { background: var(--orange) !important; color: #fff !important; }
  .quote-table th { background: var(--ink) !important; color: #fff !important; }
  .quote-head, .quote-table tr, .quote-total-block, .quote-foot { break-inside: avoid; }
}
