:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #1d2735;
  --muted: #5f6f83;
  --line: #d9e1ec;
  --line-strong: #b8c5d6;
  --primary: #2468a9;
  --primary-dark: #174d83;
  --accent: #9f2633;
  --success: #166534;
  --warning-bg: #fff7e6;
  --warning-line: #ffd18a;
  --radius: 8px;
  --shadow: 0 18px 38px rgba(31, 55, 86, 0.1);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

body { font-size: 15px; line-height: 1.55; }

button, input, textarea { font: inherit; }

.page-shell { min-height: 100vh; }

.site-header {
  background: linear-gradient(180deg, #ffffff 0%, #eef4f9 100%);
  border-bottom: 1px solid var(--line);
  padding: 34px max(24px, calc((100vw - 1180px) / 2)) 28px;
  text-align: center;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-kicker {
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  color: var(--primary-dark);
  font-size: 26px;
  line-height: 1.35;
  font-weight: 700;
}

.header-note {
  max-width: 840px;
  margin: 14px auto 0;
  color: var(--muted);
}

.main-layout {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 0;
  display: grid;
  gap: 18px;
}

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

.order-panel { padding: 22px; }
.form-panel { padding: 24px; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

h2 {
  margin-bottom: 16px;
  color: var(--primary-dark);
  font-size: 21px;
}

h3 {
  margin: 18px 0 12px;
  color: var(--primary-dark);
  font-size: 17px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.book-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fff;
}

.book-table th,
.book-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: center;
  vertical-align: middle;
}

.book-table th:first-child,
.book-table td:first-child { text-align: center; }
.book-table thead th { background: #eef4f9; color: #203c5b; }
.book-table tfoot th,
.book-table tfoot td { background: #fbfcfe; border-bottom: 0; }

.muted-cell { color: var(--muted); text-align: center !important; }

.quantity-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.quantity-control input {
  width: 96px;
  height: 36px;
  text-align: center;
}

.stock-note {
  display: block;
  margin-top: 6px;
  color: var(--accent);
  font-size: 13px;
}

section + section {
  margin-top: 24px;
  padding-top: 6px;
}

.field-group {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.field-group legend,
.field-row label {
  display: block;
  margin-bottom: 7px;
  color: #26384b;
  font-weight: 700;
}

.field-row label {
  justify-self: start;
  margin-bottom: 0;
  white-space: nowrap;
  text-align: left;
}

.field-group legend span,
.field-row label span { color: var(--accent); }

.radio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px 18px;
}

#buyerTypeGroup {
  grid-template-columns: repeat(7, max-content);
  justify-content: flex-start;
  align-items: center;
  overflow-x: auto;
}

#buyerTypeGroup label {
  justify-content: flex-start;
  white-space: nowrap;
  text-align: left;
}

.radio-inline,
.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.inline-radio-row {
  display: block;
  overflow: hidden;
}

.inline-radio-row legend {
  float: left;
  margin: 0 14px 0 0;
  padding: 0;
  line-height: 32px;
  white-space: nowrap;
}

.inline-radio-row .radio-inline {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  min-height: 32px;
}

.inline-radio-row label {
  white-space: nowrap;
}
.radio-button-row {
  display: block;
  overflow: hidden;
}

.radio-button-row legend {
  float: left;
  margin: 0 14px 0 0;
  padding: 0;
  line-height: 36px;
  white-space: nowrap;
}

.radio-button-group {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
}

.radio-button-group label {
  min-width: 88px;
  min-height: 36px;
  justify-content: center;
  padding: 0 16px;
  color: var(--primary-dark);
  background: #fff;
  border-right: 1px solid var(--line-strong);
  cursor: pointer;
}

.radio-button-group label:last-child { border-right: 0; }

.radio-button-group input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-button-group label:has(input:checked) {
  color: #fff;
  background: var(--primary);
}

.radio-button-group label:has(input:focus-visible) {
  box-shadow: inset 0 0 0 2px rgba(36, 104, 169, 0.35);
}
.radio-grid label,
.radio-inline label,
.segmented-control label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
}

#invoiceFields[hidden] { display: none !important; }

.two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  margin-bottom: 16px;
}

.field-row:has(textarea) { align-items: start; }

.field-row .form-help { grid-column: 2; }
.field-row.full { width: 100%; }

input[type="radio"] { width: auto; }

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 104, 169, 0.14);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] { border-color: var(--accent); }

.form-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--accent);
}

.form-message.success { color: var(--success); }

.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 18px;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}

.primary-button {
  min-width: 150px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.primary-button:disabled { cursor: not-allowed; opacity: .66; }

.ghost-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--primary-dark);
}

.ghost-button:hover { border-color: var(--primary); }

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 0;
  padding: 0 0 32px;
  color: var(--primary-dark);
  text-align: center;
  font-size: 13px;
}

.site-footer p { margin-bottom: 5px; }

@media (max-width: 760px) {
  .site-header { padding: 24px 16px; }
  .brand-row { align-items: flex-start; }
  .brand-mark { flex-basis: 52px; width: 52px; height: 52px; }
  h1 { font-size: 20px; }
  .header-note { margin-left: 0; }
  .main-layout { width: calc(100% - 20px); margin-top: 14px; }
  .order-panel, .form-panel { padding: 16px; }
  .radio-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .two-cols { grid-template-columns: 1fr; gap: 0; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .primary-button { width: 100%; }
}

@media (max-width: 440px) {
  .brand-row { gap: 12px; }
  .radio-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
