/* RAIM DOCOS — Quotation workspace (Phase 1). Draft editor + live A4 preview. */

.qw-body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-on-dark, #ebe6dc);
  font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 90% 55% at 10% -10%, rgba(212, 175, 103, 0.12), transparent 42%),
    linear-gradient(165deg, #050a12 0%, #0c1628 38%, #080f1a 100%);
  -webkit-font-smoothing: antialiased;
}

.qw-body .site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(10, 20, 40, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.qw-top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.qw-main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.qw-workspace-bar {
  padding: 22px 0 8px;
}

.qw-workspace-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.qw-eyebrow {
  margin: 0 0 6px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(212, 175, 103, 0.85);
}

.qw-h1 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
}

.qw-workspace-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.qw-draft-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(233, 238, 245, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.qw-draft-pill.is-issued {
  border-color: rgba(120, 200, 160, 0.45);
  background: rgba(80, 160, 120, 0.15);
  color: #c8f5d8;
}

.qw-official-hint {
  margin: 6px 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(212, 175, 103, 0.88);
}

.qw-editor.is-issued {
  opacity: 0.88;
}

.qw-editor.is-issued input:not([type="hidden"]),
.qw-editor.is-issued textarea,
.qw-editor.is-issued select,
.qw-editor.is-issued button:not(#qw-btn-print) {
  opacity: 0.92;
}

.btn-qw-primary,
.btn-qw-secondary,
.btn-qw-line {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 999px;
  padding: 10px 18px;
  border: 1px solid transparent;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.btn-qw-primary {
  color: #141a22;
  background: linear-gradient(145deg, var(--gold-1, #e8dcc4) 0%, var(--gold-2, #c8ae7a) 45%, var(--gold-3, #a68d5c) 100%);
  box-shadow: var(--gold-shadow, 0 6px 20px rgba(20, 15, 8, 0.12));
}

.btn-qw-primary:hover {
  transform: translateY(-1px);
}

.btn-qw-secondary {
  color: rgba(233, 238, 245, 0.92);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-qw-secondary:hover {
  border-color: rgba(212, 175, 103, 0.45);
  background: rgba(212, 175, 103, 0.1);
}

.btn-qw-line {
  margin-top: 12px;
  color: rgba(233, 238, 245, 0.92);
  background: transparent;
  border-color: rgba(212, 175, 103, 0.35);
}

.btn-qw-line:hover {
  border-color: rgba(212, 175, 103, 0.55);
  background: rgba(212, 175, 103, 0.08);
}

.qw-workspace-hint {
  margin: 14px 0 0;
  max-width: 52rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: rgba(233, 238, 245, 0.48);
}

.qw-persist-row {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 14, 24, 0.45);
}

.qw-persist-row-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.qw-draft-picker-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(212, 175, 103, 0.85);
}

.qw-draft-picker {
  min-width: min(100%, 220px);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 14, 22, 0.75);
  color: rgba(233, 238, 245, 0.95);
  font: inherit;
  font-size: 0.86rem;
}

.qw-save-status {
  font-size: 0.8rem;
  color: rgba(233, 238, 245, 0.55);
  flex: 1 1 140px;
  min-width: 0;
}

.qw-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
  gap: 24px;
  align-items: start;
}

@media (max-width: 1024px) {
  .qw-split {
    grid-template-columns: 1fr;
  }
}

/* iPad / tablet: comfortable preview scale and safe-area padding */
@media (min-width: 768px) and (max-width: 1024px) {
  .qw-main {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .qw-preview-scale {
    transform: scale(0.9);
  }
}

.qw-panel {
  padding: 22px 20px 28px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(165deg, rgba(22, 34, 52, 0.88) 0%, rgba(10, 16, 28, 0.95) 100%);
  box-shadow: var(--shadow-card-dark, 0 8px 26px rgba(0, 0, 0, 0.14));
}

.qw-panel-title {
  margin: 0 0 18px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.qw-fieldset {
  margin: 0 0 18px;
  padding: 0;
  border: none;
}

.qw-fieldset legend {
  padding: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(212, 175, 103, 0.88);
}

.qw-grid2 {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .qw-grid2 {
    grid-template-columns: 1fr 1fr;
  }
}

.qw-field {
  display: grid;
  gap: 6px;
}

.qw-field label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(233, 238, 245, 0.65);
}

.qw-field input,
.qw-field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 14, 24, 0.55);
  color: var(--white, #f7f3ec);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}

.qw-field input:focus-visible,
.qw-field textarea:focus-visible {
  border-color: rgba(212, 175, 103, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 175, 103, 0.14);
}

.qw-table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.qw-editor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.qw-editor-table th,
.qw-editor-table td {
  padding: 10px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: middle;
}

.qw-editor-table th {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(212, 175, 103, 0.85);
}

.qw-line-num {
  width: 2rem;
  color: rgba(233, 238, 245, 0.45);
  font-variant-numeric: tabular-nums;
}

.qw-editor-table input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 14, 24, 0.55);
  color: inherit;
  font: inherit;
}

.qw-line-amount {
  font-variant-numeric: tabular-nums;
  color: rgba(233, 238, 245, 0.78);
  white-space: nowrap;
}

.qw-line-actions {
  width: 1%;
  white-space: nowrap;
}

.btn-table {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 103, 0.45);
  background: rgba(212, 175, 103, 0.12);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-table:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-table.btn-table--danger {
  border-color: rgba(220, 120, 120, 0.55);
  background: rgba(180, 60, 60, 0.18);
}

.qw-grand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid rgba(212, 175, 103, 0.2);
  font-size: 0.95rem;
  color: rgba(233, 238, 245, 0.72);
}

.qw-grand-row strong {
  font-size: 1.1rem;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.qw-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;
}

/* --- Preview column --- */
.qw-preview-wrap {
  position: sticky;
  top: 88px;
  align-self: start;
}

@media (max-width: 1024px) {
  .qw-preview-wrap {
    position: relative;
    top: auto;
  }
}

.qw-preview-label {
  margin-bottom: 10px;
}

.qw-preview-label-text {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(212, 175, 103, 0.9);
  border: 1px solid rgba(212, 175, 103, 0.35);
  background: rgba(212, 175, 103, 0.08);
}

.qw-preview-scale {
  display: flex;
  justify-content: center;
  padding: 8px 0 24px;
  transform-origin: top center;
}

@media (min-width: 1025px) {
  .qw-preview-scale {
    transform: scale(0.88);
  }
}

@media (max-width: 1024px) {
  .qw-preview-scale {
    transform: scale(0.92);
  }
}

@media (max-width: 480px) {
  .qw-preview-scale {
    transform: scale(0.78);
    padding-bottom: 32px;
  }
}

/* A4 sheet — print-oriented proportions */
.qw-a4-page {
  width: 210mm;
  min-height: 297mm;
  padding: 14mm 16mm 18mm;
  box-sizing: border-box;
  background: var(--surface, #faf7f2);
  color: var(--ink, #1e2228);
  border-radius: 4px;
  border: 1px solid rgba(42, 53, 68, 0.12);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

/* --- Document typography (light paper) --- */
.qw-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid rgba(166, 141, 92, 0.35);
  margin-bottom: 16px;
}

.qw-doc-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qw-doc-logo {
  display: block;
  height: auto;
  max-width: 140px;
}

.qw-doc-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qw-doc-brand-text span {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted, #3d4550);
}

.qw-doc-brand-text small {
  font-size: 0.58rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  color: var(--slate, #5f6775);
}

.qw-doc-title-block {
  text-align: right;
}

.qw-doc-h1 {
  margin: 0 0 6px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--heading, #111);
  letter-spacing: -0.02em;
}

.qw-doc-meta {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-body, #424853);
}

.qw-doc-meta-sub {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--slate, #5f6775);
}

.qw-doc-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

@media (max-width: 520px) {
  .qw-doc-parties {
    grid-template-columns: 1fr;
  }
}

.qw-doc-party h2 {
  margin: 0 0 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(166, 141, 92, 0.95);
}

.qw-doc-party p {
  margin: 0 0 4px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-body, #424853);
}

.qw-doc-strong {
  font-weight: 700;
  color: var(--heading, #111);
}

.qw-doc-address {
  white-space: pre-wrap;
}

.qw-doc-table-wrap {
  margin-bottom: 16px;
}

.qw-doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.qw-doc-table th,
.qw-doc-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(42, 53, 68, 0.12);
  vertical-align: top;
}

.qw-doc-table th {
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(166, 141, 92, 0.95);
}

.qw-doc-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.qw-doc-desc {
  width: 58%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.qw-doc-total-label {
  text-align: right;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.qw-doc-grand {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--heading, #111);
}

.qw-doc-notes {
  margin-bottom: 18px;
}

.qw-doc-notes h3 {
  margin: 0 0 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(166, 141, 92, 0.95);
}

.qw-doc-notes p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-body, #424853);
}

.qw-doc-subhead {
  margin: 0 0 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(166, 141, 92, 0.95);
}

.qw-doc-signature-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px 18px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(42, 53, 68, 0.12);
  align-items: flex-start;
}

@media (max-width: 520px) {
  .qw-doc-signature-row {
    grid-template-columns: 1fr;
  }
}

.qw-doc-signatory-col {
  min-width: 0;
}

.qw-doc-official-col {
  min-width: 0;
}

.qw-official-muted {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(95, 103, 117, 0.85);
  font-style: italic;
}

.qw-official-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.qw-official-visual--muted {
  padding: 10px 0 4px;
}

.qw-sig-figure {
  margin: 0;
  text-align: center;
  min-width: 0;
}

.qw-sig-figure--stamp {
  max-width: 120px;
}

.qw-sig-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.qw-sig-figure.is-missing .qw-sig-img {
  display: none;
}

.qw-sig-figure.is-missing {
  min-height: 48px;
  border: 1px dashed rgba(42, 53, 68, 0.28);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.qw-sig-cap {
  margin: 6px 0 0;
  font-size: 0.65rem;
  color: var(--slate, #5f6775);
}

.qw-doc-verify {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 53, 68, 0.1);
}

.qw-doc-verify-title {
  margin: 0 0 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(166, 141, 92, 0.95);
}

.qw-qr-mount {
  display: inline-block;
  min-height: 96px;
  margin-bottom: 6px;
}

.qw-qr-img {
  display: block;
  max-width: 120px;
  height: auto;
}

.qw-qr-mount img,
.qw-qr-mount canvas,
.qw-qr-mount table {
  max-width: 120px !important;
  height: auto !important;
}

.qw-qr-fallback {
  margin: 0;
  font-size: 0.72rem;
}

.qw-qr-fallback a {
  color: rgba(42, 53, 68, 0.85);
  font-weight: 700;
}

.qw-qr-inline-fallback {
  margin: 0;
  font-size: 0.72rem;
}

.qw-doc-sig-line {
  height: 1px;
  background: rgba(42, 53, 68, 0.35);
  margin-bottom: 8px;
}

.qw-doc-sig-name {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--heading, #111);
}

.qw-doc-sig-title {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--slate, #5f6775);
}

.qw-doc-sig-hint {
  margin: 8px 0 0;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate, #5f6775);
}

.qw-doc-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 53, 68, 0.15);
}

.qw-doc-footer p {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.45;
  color: var(--slate, #5f6775);
}

/* --- Print / PDF export foundation --- */
@page {
  size: A4;
  margin: 12mm;
}

@media print {
  html,
  body.qw-body {
    background: #fff !important;
    color: #111 !important;
  }

  .qw-no-print {
    display: none !important;
  }

  .qw-main {
    padding: 0 !important;
    max-width: none !important;
  }

  .qw-split {
    display: block !important;
  }

  .qw-preview-wrap {
    position: static !important;
  }

  .qw-preview-scale {
    transform: none !important;
    padding: 0 !important;
    display: block !important;
  }

  .qw-a4-page {
    width: 100% !important;
    min-height: auto !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    page-break-after: auto;
  }

  /* Signature scans and QR bitmap: reduce “blank” or washed output in Chrome/Safari */
  .qw-sig-img,
  .qw-qr-img,
  .qw-qr-mount canvas,
  .qw-qr-mount img {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .qw-doc-verify {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .qw-qr-fallback {
    font-size: 0.65rem;
  }

  .qw-qr-fallback a {
    word-break: break-all;
  }
}
