/* 农资智能报价单生成器 */
:root {
  --qg-green: #1a4d2e;
  --qg-green-soft: #e8f4ec;
  --qg-bg: #eef3f0;
  --qg-accent: #c45c1a;
  --qg-card: #fff;
  --qg-radius: 12px;
}

.qg-page {
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--qg-bg);
  color: #222;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

.qg-page .p2-layout-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 14px 88px;
  box-sizing: border-box;
}

.qg-hero h1 {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--qg-green);
  font-weight: 700;
}

.qg-hero p {
  margin: 0 0 14px;
  font-size: 14px;
  color: #555;
  line-height: 1.55;
  max-width: 920px;
}

.qg-workflow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.qg-workflow-strip article {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid #d8e5dc;
  border-left: 4px solid var(--qg-green);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f7fbf8);
  box-sizing: border-box;
}

.qg-workflow-strip b {
  font-size: 14px;
  color: var(--qg-green);
}

.qg-workflow-strip span {
  font-size: 12px;
  line-height: 1.45;
  color: #5f6b63;
}

.qg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: stretch;
}

.qg-toolbar .p2-btn-primary,
.qg-toolbar .p2-btn-muted,
.qg-toolbar .qg-btn {
  min-height: 44px;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  box-sizing: border-box;
}

.qg-toolbar .qg-btn {
  background: #fff;
  border: 1px solid #c8d4cc;
  color: var(--qg-green);
}

.qg-toolbar .qg-btn:hover {
  background: var(--qg-green-soft);
}

.qg-status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 1fr)) minmax(220px, 1.45fr);
  gap: 10px;
  align-items: stretch;
  margin: 0 0 14px;
}

.qg-status-cell,
.qg-status-strip p {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #d9e4dd;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(26, 77, 46, 0.05);
  box-sizing: border-box;
}

.qg-status-cell {
  display: grid;
  gap: 4px;
}

.qg-status-cell span {
  font-size: 12px;
  color: #6c776f;
}

.qg-status-cell strong {
  overflow: hidden;
  color: #1f3e2b;
  font-size: 15px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qg-status-strip p {
  display: flex;
  align-items: center;
  color: #7a4a1a;
  background: #fff8ee;
  border-color: #f0d9bd;
  font-size: 13px;
  line-height: 1.45;
}

.qg-status-strip.is-ready p {
  color: #1a4d2e;
  background: #f0f8f3;
  border-color: #cde4d4;
}

.qg-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 16px;
  align-items: start;
  min-height: 0;
}

.qg-left-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

.qg-preview-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

/* 覆盖 site-layout.css 对 .qg-card 的 overflow:hidden，避免填写区被卡片裁切 */
.qg-page .qg-card {
  overflow: visible;
}

.qg-page .qg-left-col .qg-card:last-child {
  margin-bottom: 0;
}

@media (max-width: 1024px) {
  .qg-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .qg-left-col,
  .qg-preview-col {
    max-height: none;
  }
}

.qg-card {
  background: var(--qg-card);
  border-radius: var(--qg-radius);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  padding: 16px 18px;
  margin-bottom: 14px;
  border: 1px solid #e2e8e4;
}

.qg-card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--qg-green);
  border-bottom: 1px solid var(--qg-green-soft);
  padding-bottom: 8px;
}

.qg-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.qg-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
}

@media (max-width: 720px) {
  .qg-grid-2,
  .qg-grid-3 {
    grid-template-columns: 1fr;
  }
}

.rp-cn-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 720px) {
  .rp-cn-row {
    grid-template-columns: 1fr;
  }
  .qg-page {
    min-height: 0;
  }
  .qg-page .p2-layout-main {
    padding: 10px 12px max(56px, env(safe-area-inset-bottom, 0px));
  }
  .qg-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .qg-toolbar .p2-btn-primary,
  .qg-toolbar .p2-btn-muted,
  .qg-toolbar .qg-btn {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    font-size: 13px;
    justify-content: center;
    text-align: center;
  }
  .qg-workflow-strip,
  .qg-status-strip {
    grid-template-columns: 1fr;
  }
  .qg-status-cell strong {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
  .qg-workflow-strip article {
    min-height: auto;
  }
}

.qg-field label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.qg-field input,
.qg-field select,
.qg-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #cfd8d2;
  border-radius: 6px;
  font-size: 14px;
}

.qg-items-table .qg-price-unit {
  min-width: 88px;
  font-size: 13px;
  padding: 6px 4px;
}

.qg-field textarea {
  min-height: 64px;
  resize: vertical;
}

.qg-field .qg-readonly {
  background: #f5f8f6;
  color: #444;
}

.qg-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
}

.qg-link-row button {
  background: none;
  border: none;
  color: #2a6b45;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 2px;
  font-size: inherit;
}

.qg-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #dfe8e2;
  border-radius: 8px;
  background: #fafcfb;
}

.qg-items-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.qg-items-table th {
  background: var(--qg-green-soft);
  color: var(--qg-green);
  font-weight: 600;
  padding: 8px 6px;
  border: 1px solid #cfe0d4;
  white-space: nowrap;
}

.qg-items-table td {
  border: 1px solid #e0e8e3;
  padding: 4px;
  vertical-align: middle;
  background: #fff;
}

.qg-items-table input,
.qg-items-table select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #d5ddd8;
  border-radius: 4px;
  padding: 6px 4px;
  font-size: 13px;
}

.qg-items-table .qg-td-sub,
.qg-items-table .qg-td-warn {
  text-align: right;
  white-space: nowrap;
  padding: 6px 8px;
}

.qg-items-table .qg-td-warn {
  font-size: 11px;
  color: var(--qg-accent);
  max-width: 120px;
}

.qg-num {
  text-align: right;
}

.qg-sum-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.qg-sum-panel .qg-sum-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--qg-green);
}

.qg-sum-panel .qg-sum-val.qg-money-xl {
  font-size: 22px;
  color: var(--qg-accent);
}

.qg-preview-sticky {
  position: sticky;
  top: 8px;
}

@media (max-width: 1024px) {
  .qg-preview-sticky {
    position: static;
  }
}

.qg-a4-sheet {
  width: 100%;
  max-width: 210mm;
  min-height: 260mm;
  margin: 0 auto;
  background: #fff;
  box-sizing: border-box;
  padding: 14mm 12mm;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  font-size: 12px;
  line-height: 1.45;
}

.qg-preview-col .qg-a4-sheet {
  transform: scale(1.07);
  transform-origin: top center;
  margin-bottom: 28px;
  font-size: 13px;
}

.qg-a4-sheet .qg-doc-title {
  text-align: center;
  font-size: 20px;
  letter-spacing: 4px;
  color: var(--qg-green);
  margin: 0 0 6px;
}

.qg-a4-sheet .qg-doc-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--qg-green);
  padding-bottom: 8px;
}

.qg-a4-block {
  margin-bottom: 10px;
}

.qg-a4-block h3 {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--qg-green);
}

.qg-a4-kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 12px;
  font-size: 11px;
}

@media (max-width: 400px) {
  .qg-a4-kv {
    grid-template-columns: 1fr;
  }
}

.qg-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  margin: 8px 0;
}

.qg-preview-table th,
.qg-preview-table td {
  border: 1px solid #333;
  padding: 4px 3px;
  vertical-align: top;
}

.qg-preview-table th {
  background: #f0f4f1;
}

.qg-preview-table .t-r {
  text-align: right;
}

.qg-preview-table .t-c {
  text-align: center;
}

.qg-preview-totals {
  width: 100%;
  max-width: none;
  margin-left: 0;
  font-size: 11px;
  border-collapse: collapse;
}

.qg-preview-totals td {
  border: 1px solid #333;
  padding: 4px 8px;
}

.qg-preview-totals .t-r {
  text-align: right;
  font-weight: 700;
  color: var(--qg-green);
}

.qg-preview-footer {
  margin-top: 12px;
  font-size: 10px;
  color: #444;
  border-top: 1px dashed #999;
  padding-top: 8px;
}

.qg-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(26, 77, 46, 0.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw;
  text-align: center;
}

.qg-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.qg-toast.err {
  background: rgba(140, 40, 20, 0.94);
}

.qg-card--ai .qg-ai-note {
  margin: 0 0 10px;
  font-size: 12px;
  color: #666;
  line-height: 1.55;
}
.qg-card--ai label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--qg-green);
  margin-bottom: 4px;
}
.qg-ai-ta {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #cfe0d4;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
  resize: vertical;
  min-height: 48px;
}
.qg-ai-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.qg-ai-out {
  margin: 0;
  padding: 10px;
  background: #f4f4f5;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}

@media print {
  html,
  body {
    background: #fff !important;
    height: auto !important;
    min-height: 0 !important;
  }
  .qg-page {
    min-height: 0 !important;
    background: #fff !important;
  }
  .site-bottom-dock,
  #siteBottomDock,
  nav#navbar,
  #navbar,
  .site-navbar-desktop,
  .mobile-header,
  #mobileHeader,
  .mobile-drawer,
  #mobileDrawer,
  #mobileDrawerBackdrop,
  .mobile-drawer-backdrop,
  .nav-mobile-overlay,
  .no-print,
  .qg-left-col,
  .qg-toolbar,
  .qg-hero,
  header.qg-hero,
  #qgToast {
    display: none !important;
  }
  main.p2-layout-main {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }
  .qg-layout {
    display: block !important;
  }
  .qg-preview-col {
    width: 100% !important;
    max-width: none !important;
    display: block !important;
  }
  .qg-preview-sticky {
    position: static !important;
    top: auto !important;
  }
  .qg-card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .qg-a4-sheet {
    box-shadow: none !important;
    border: none !important;
    max-width: none !important;
    min-height: auto !important;
    padding: 8mm !important;
    page-break-inside: avoid;
  }
  #qgPrintArea {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
