/* fatia Documentos (tela): barra de ações no tema do app e folha A4 sempre clara, como papel.
   Medidas da folha em pt, como o PDF do Android (util/PdfGenerator.kt; spec 07 §2–§5).
   A cor de destaque (--doc-accent, --doc-accent-soft) vem do perfil da empresa, aplicada por JS na folha. */

.doc-view { max-width: 980px; gap: 16px; }

/* ---------- barra de ações (não sai na impressão) ---------- */
.doc-toolbar { display: grid; gap: 10px; }
.doc-toolbar .back { justify-self: start; }
.doc-toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; }
.doc-toolbar-text { min-width: 0; flex: 1 1 260px; display: grid; gap: 2px; }
.doc-toolbar-title { font-size: 1.05rem; }
.doc-hint { margin: 0; }
.doc-print { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; }
.doc-picker { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 18px; }
.doc-picker label { font-weight: 600; }
.doc-select { flex: 1 1 280px; min-width: 0; min-height: 44px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--outline); border-radius: 10px; padding: 8px 12px; }
.doc-select:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

/* ---------- folha ---------- */
.doc-stage { overflow-x: auto; padding: 4px 0 24px; }
.doc-sheet {
  --doc-accent: #145E91;
  --doc-accent-soft: #EEF3F7;
  --doc-ink: #263238;
  --doc-muted: #59666C;
  --doc-historical: #9C3030;
  --doc-surface: #F6F7F8;
  --doc-rule: #DDE0E2;
  --doc-row-rule: #EBECED;
  color-scheme: light;
  box-sizing: border-box;
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  margin: 0 auto;
  padding: 12mm 14.11mm 14mm;
  background: #FFFFFF;
  color: var(--doc-ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 8px 28px rgba(15, 23, 42, .10);
  border-radius: 2px;
  font-family: Roboto, "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  font-size: 10pt;
  line-height: 1.4;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-align: left;
  display: flex;
  flex-direction: column;
}
.doc-sheet.doc-font-classic { font-family: "Noto Serif", Georgia, Cambria, "Times New Roman", Times, serif; }
.doc-sheet p { margin: 0; }
.doc-sheet h1, .doc-sheet h2, .doc-sheet h3 { margin: 0; letter-spacing: 0; }

/* cabeçalho: faixa de destaque, empresa, contatos e logo à direita */
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16pt; padding-bottom: 8pt; border-bottom: .6pt solid var(--doc-rule); min-height: 46pt; }
.doc-head.has-logo { min-height: 66pt; }
.doc-company { min-width: 0; flex: 1; display: grid; gap: 2pt; }
.doc-bar { display: block; width: 32pt; height: 3pt; background: var(--doc-accent); margin-bottom: 7pt; }
.doc-company-name { font-size: 18pt; font-weight: 700; line-height: 1.17; color: var(--doc-ink); overflow-wrap: anywhere; }
.doc-company-line { font-size: 9pt; line-height: 1.33; color: var(--doc-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-company-name + .doc-company-line { margin-top: 2pt; }
.doc-logo { flex: none; width: 100pt; height: 58pt; margin-top: 8pt; display: flex; align-items: center; justify-content: center; }
.doc-logo[hidden] { display: none; }
.doc-logo-img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }

/* título, referência e data */
.doc-titlebox { padding-top: 14pt; }
.doc-title { font-size: 18pt; font-weight: 700; line-height: 1.2; color: var(--doc-ink); }
.doc-refline { display: flex; align-items: baseline; justify-content: space-between; gap: 12pt; margin-top: 4pt; }
.doc-ref { font-size: 10pt; color: var(--doc-ink); overflow-wrap: anywhere; min-width: 0; }
.doc-date { font-size: 9.5pt; color: var(--doc-muted); white-space: nowrap; }

/* cliente */
.doc-client { margin-top: 16pt; background: var(--doc-surface); border-radius: 4pt; padding: 10pt 12pt; display: grid; gap: 3pt; }
.doc-client-label { font-size: 8.5pt; font-weight: 700; letter-spacing: .04em; color: var(--doc-accent); }
.doc-client-name { font-size: 11.5pt; font-weight: 700; color: var(--doc-ink); overflow-wrap: anywhere; }
.doc-client-phone { font-size: 9.5pt; color: var(--doc-muted); }

.doc-historical { margin-top: 12pt !important; font-size: 11pt; font-weight: 700; color: var(--doc-historical); }

/* seções e textos */
.doc-section { margin-top: 18pt; }
.doc-h { font-size: 12pt; font-weight: 700; line-height: 1.25; color: var(--doc-accent); margin-bottom: 6pt !important; }
.doc-h3 { font-size: 10.5pt; font-weight: 700; line-height: 1.3; color: var(--doc-accent); margin: 10pt 0 3pt !important; }
.doc-text { font-size: 10.5pt; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-muted { color: var(--doc-muted); }
.doc-strong { font-weight: 700; }
.doc-right { text-align: right; font-size: 10.5pt; font-variant-numeric: tabular-nums; }

/* tabelas de itens: Descrição | Qtd. | Unitário | Subtotal (ou Descrição | Qtd. sem preços) */
.doc-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.doc-table col.c-qty { width: 15%; }
.doc-table col.c-unit { width: 18%; }
.doc-table col.c-sub { width: 18%; }
.doc-table col.c-qty-wide { width: 22%; }
.doc-table th { background: var(--doc-accent-soft); color: var(--doc-accent); font-size: 9pt; font-weight: 700; text-align: left;
  padding: 6.5pt 8pt; line-height: 1.3; }
.doc-table td { font-size: 10pt; color: var(--doc-ink); padding: 6pt 8pt; border-bottom: .75pt solid var(--doc-row-rule); vertical-align: top; line-height: 1.4; }
/* Números à direita e quebrando dentro da coluna, como o wrap() do Android (PdfGenerator.kt: quebra no último espaço
   que cabe; sem espaço, no meio): unidade longa ou valor de até R$ 1 bilhão nunca invade a coluna vizinha. */
.doc-table .num { text-align: right; white-space: normal; overflow-wrap: anywhere; }
/* Número com separadores de milhar: inteiro numa linha se couber; senão quebra num ponto (<wbr>; document.js). */
.doc-table .doc-numtok { display: inline-block; max-width: 100%; }
.doc-table td.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-table-section .doc-right { margin-top: 7pt; }
.doc-supplied { margin-top: 6pt !important; font-size: 9.5pt; }

/* resumo: subtotal/desconto, avisos e TOTAL alinhados à direita */
.doc-summary { margin-top: 12pt; display: grid; gap: 3pt; }
.doc-discount { margin-bottom: 2pt !important; }
.doc-warn { font-size: 9pt; color: var(--doc-historical); }
.doc-note { font-size: 8.5pt; color: var(--doc-muted); }
.doc-total { align-self: flex-end; width: min(300pt, 100%); margin-top: 12pt; border-top: 1.2pt solid var(--doc-accent);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12pt; padding-top: 9pt; color: var(--doc-accent); }
.doc-total-label { font-size: 9pt; font-weight: 700; letter-spacing: .04em; }
.doc-total-value { font-size: 19pt; font-weight: 700; line-height: 1.15; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.doc-validity { margin-top: 16pt !important; font-size: 10.5pt; }

/* garantias e privacidade */
.doc-terms { margin-top: 20pt; }
.doc-term + .doc-term { margin-top: 6pt; }
.doc-terms-text { font-size: 9pt; line-height: 1.45; color: var(--doc-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-terms-legacy > .doc-terms-text { margin-bottom: 4pt !important; }

/* assinatura do cliente (OS) */
.doc-signature-box { width: 260pt; max-width: 100%; height: 80pt; display: flex; align-items: center; justify-content: center; }
.doc-signature-img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.doc-signature-line { width: 260pt; max-width: 100%; border-top: 1pt solid #CCCCCC; margin-top: 7pt; }
.doc-signature-label { margin-top: 6pt !important; font-size: 10pt; }
.doc-signature-date { font-size: 9pt; margin-top: 2pt !important; }
.doc-completed { margin-top: 16pt !important; font-size: 9.5pt; }

/* anexo de fotos: na tela, separado por uma linha; na impressão começa em página nova */
.doc-photos { margin-top: 26pt; padding-top: 18pt; border-top: 1pt dashed var(--doc-rule); display: grid; gap: 22pt; }
.doc-photo { margin: 0; }
.doc-photo-frame { background: var(--doc-surface); display: flex; align-items: center; justify-content: center; min-height: 40pt; }
.doc-photo-img { display: block; max-width: 100%; max-height: 320pt; width: auto; height: auto; }
.doc-photo figcaption { margin-top: 8pt; display: grid; gap: 3pt; }
.doc-photo-caption { font-size: 10.5pt; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-photo-annotation { font-size: 10pt; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-photo-missing { font-size: 9.5pt; padding: 12pt; }

/* rodapé: empurrado para o fim da folha na tela */
.doc-footer { margin-top: auto; padding-top: 24pt; }
.doc-footer span { display: block; border-top: .6pt solid var(--doc-rule); padding-top: 7pt; font-size: 8.5pt; color: var(--doc-muted); }

/* tema escuro: a folha continua papel branco; só o entorno acompanha o app */
@media (prefers-color-scheme: dark) {
  .doc-sheet { box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 10px 32px rgba(0, 0, 0, .55); }
}

/* celular: folha fluida, margens menores, mesma hierarquia */
@media (max-width: 760px) {
  .doc-toolbar-row { padding: 12px 14px; }
  .doc-print { width: 100%; }
  .doc-picker { padding: 12px 14px; }
  .doc-sheet { width: 100%; min-height: 0; padding: 18px 16px 16px; font-size: 9.5pt; }
  .doc-head { gap: 10pt; }
  .doc-company-name { font-size: 15pt; }
  .doc-logo { width: 72pt; height: 42pt; margin-top: 6pt; }
  .doc-head.has-logo { min-height: 0; }
  .doc-title { font-size: 15pt; }
  .doc-refline { flex-wrap: wrap; gap: 2pt 12pt; }
  .doc-table th { padding: 5pt 4pt; font-size: 8pt; }
  .doc-table td { padding: 5pt 4pt; font-size: 8.5pt; }
  .doc-table th:first-child, .doc-table td:first-child { padding-left: 6pt; }
  .doc-table th:last-child, .doc-table td:last-child { padding-right: 6pt; }
  .doc-table col.c-qty { width: 19%; }
  .doc-table col.c-unit { width: 23%; }
  .doc-table col.c-sub { width: 23%; }
  .doc-total-value { font-size: 16pt; }
  .doc-signature-box, .doc-signature-line { width: 100%; }
}
