.quote-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.quote-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 1rem;
  align-items: start;
}

.quote-builder,
.quote-preview-wrap {
  min-width: 0;
}

.quote-panel {
  background: #ffffff;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.quote-panel h3 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #0f3b66;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  padding-left: 0.55rem;
  border-left: 5px solid #0f5596;
}

.quote-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.quote-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.quote-form-grid label span {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.quote-wide {
  grid-column: span 2;
}

.quote-lines {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.quote-line-editor {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr 64px 96px 96px 1fr 36px;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.5rem;
  padding: 0.55rem;
  background: #fff;
  border: 1px solid #dbe4ef;
  min-width: 980px;
}

.quote-line-editor-flow {
  grid-template-columns: 0.85fr 0.9fr 1.1fr 0.75fr 0.9fr 58px 82px 82px 82px 78px 98px 0.9fr 34px;
  min-width: 1480px;
}

.quote-line-editor-stock {
  grid-template-columns: 0.9fr 0.95fr 1.25fr 58px 92px 92px 0.9fr 34px;
  min-width: 980px;
}

.quote-line-field {
  display: block;
  min-width: 0;
}

.quote-line-field span {
  display: block;
  margin-bottom: 0.2rem;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
}

.quote-line-field.internal span {
  color: #9f1239;
}

.quote-line-product {
  min-width: 150px;
}

.quote-num {
  text-align: right;
}

.quote-readonly {
  background: #f8fafc;
  color: #1d4ed8;
  font-weight: 800;
}

.quote-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.quote-icon-btn:hover {
  color: #dc2626;
  background: #fff1f2;
}

.quote-editor-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid #e2e8f0;
}

.quote-editor-summary div {
  flex: 1 1 180px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #d6e3f7;
  border-radius: 8px;
  background: #f6f9ff;
}

.quote-editor-summary span {
  color: #475569;
  font-size: 0.82rem;
  font-weight: 800;
}

.quote-editor-summary strong {
  color: #1d4ed8;
  font-size: 1.05rem;
  white-space: nowrap;
}

.quote-profit-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.quote-profit-summary div {
  padding: 0.8rem;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff;
}

.quote-profit-summary span {
  display: block;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
}

.quote-profit-summary strong {
  display: block;
  margin-top: 0.25rem;
  color: #991b1b;
  font-size: 1.12rem;
}

.quote-lease-rates {
  margin-bottom: 0.8rem;
  padding: 0.85rem;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
}

.quote-lease-rate-title {
  margin-bottom: 0.55rem;
  color: #1e3a8a;
  font-size: 0.85rem;
  font-weight: 900;
}

.quote-lease-control-row {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(220px, 1fr);
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.quote-lease-control-row label span,
.quote-lease-result span {
  display: block;
  margin-bottom: 0.25rem;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
}

.quote-lease-result {
  padding: 0.62rem 0.8rem;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.quote-lease-result strong {
  display: block;
  color: #1d4ed8;
  font-size: 1.1rem;
}

.quote-lease-rate-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(76px, 1fr));
  gap: 0.55rem;
}

.quote-lease-rate-grid label {
  position: relative;
  display: block;
}

.quote-lease-rate-grid span {
  display: block;
  margin-bottom: 0.2rem;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
}

.quote-lease-rate-grid input {
  padding-right: 1.45rem;
}

.quote-lease-rate-grid em {
  position: absolute;
  right: 0.45rem;
  bottom: 0.58rem;
  color: #64748b;
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 800;
}

.quote-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.quote-sheet {
  background: #e5e7eb;
  padding: 1rem;
  border-radius: 8px;
  overflow: auto;
}

.quote-a4 {
  width: 210mm;
  min-height: 297mm;
  max-height: 297mm;
  margin: 0 auto;
  padding: 13mm 14mm;
  background: #fff;
  color: #111827;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  font-size: 10.5px;
  line-height: 1.35;
}

.quote-doc-head,
.quote-doc-parties,
.quote-total-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.quote-doc-kicker {
  color: #2563eb;
  font-weight: 800;
  font-size: 0.85rem;
}

.quote-doc-head h1 {
  font-size: 1.8rem;
  margin: 0.2rem 0 0;
  letter-spacing: 0;
}

.quote-doc-meta {
  min-width: 46mm;
  text-align: right;
  color: #475569;
}

.quote-doc-parties {
  margin: 9mm 0 7mm;
}

.quote-doc-project {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr;
  gap: 0;
  margin-bottom: 5mm;
  border: 1px solid #dbe3ef;
}

.quote-doc-project div {
  padding: 0.35rem 0.45rem;
  border-right: 1px solid #dbe3ef;
}

.quote-doc-project div:last-child {
  border-right: 0;
}

.quote-doc-project span {
  display: block;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 800;
}

.quote-summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4mm;
  margin-bottom: 5mm;
}

.quote-summary-cards div {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  padding: 0.45rem 0.6rem;
}

.quote-summary-cards span {
  display: block;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 800;
}

.quote-summary-cards strong {
  display: block;
  color: #1e3a8a;
  font-size: 1.05rem;
  margin-top: 0.1rem;
}

.quote-party-label {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.quote-customer-name {
  font-size: 1rem;
  font-weight: 800;
}

.quote-seller-block {
  min-width: 48mm;
  text-align: right;
}

.quote-doc-section {
  margin-top: 5mm;
}

.quote-doc-section h2 {
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
  color: #7f1d1d;
  border-left: 4px solid #b91c1c;
  padding-left: 0.4rem;
}

.quote-doc-table,
.quote-total-table {
  width: 100%;
  border-collapse: collapse;
}

.quote-doc-table th,
.quote-doc-table td,
.quote-total-table th,
.quote-total-table td {
  border: 1px solid #dbe3ef;
  padding: 0.28rem 0.38rem;
  vertical-align: top;
}

.quote-doc-table th {
  background: #b91c1c;
  color: #fff;
}

.quote-doc-table td:nth-child(n+2),
.quote-doc-table tfoot td {
  text-align: right;
  white-space: nowrap;
}

.quote-line-memo {
  color: #64748b;
  font-size: 0.72rem;
}

.quote-empty {
  color: #94a3b8;
  text-align: center;
}

.quote-total-row {
  margin-top: 6mm;
  align-items: flex-start;
}

.quote-note-box {
  flex: 1;
  min-height: 24mm;
  border: 1px solid #dbe3ef;
  padding: 0.5rem;
  color: #475569;
}

.quote-total-table {
  width: 62mm;
}

.quote-total-table th {
  background: #f8fafc;
  text-align: left;
}

.quote-total-table td {
  text-align: right;
  white-space: nowrap;
}

.quote-total-table .grand th,
.quote-total-table .grand td {
  background: #eff6ff;
  font-size: 0.95rem;
  font-weight: 900;
}

.quote-total-table .monthly th,
.quote-total-table .monthly td {
  background: #ecfdf5;
  color: #065f46;
  font-size: 0.95rem;
  font-weight: 900;
}

.quote-flow-table {
  font-size: 0.85em;
}

.quote-flow-table th:nth-child(1) {
  width: 15%;
}

@media (max-width: 1180px) {
  .quote-workspace {
    grid-template-columns: 1fr;
  }

  .quote-form-grid,
  .quote-profit-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .quote-line-editor,
  .quote-line-editor-flow {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .quote-page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .quote-lease-rate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-lease-control-row {
    grid-template-columns: 1fr;
  }

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

  .quote-wide {
    grid-column: 1;
  }

  .quote-icon-btn {
    width: 100%;
  }
}

@media print {
  body * {
    visibility: hidden !important;
  }

  #quote-print-sheet,
  #quote-print-sheet * {
    visibility: visible !important;
  }

  #quote-print-sheet {
    position: absolute;
    inset: 0;
    padding: 0;
    background: #fff;
    border-radius: 0;
    overflow: visible;
  }

  .quote-a4 {
    width: 210mm;
    min-height: 297mm;
    max-height: 297mm;
    box-shadow: none;
    margin: 0;
  }

  @page {
    size: A4;
    margin: 0;
  }
}
