/* ============================================================
   Florir arte e decoração — Gerador de Orçamentos
   Paleta: rosa/mauve + sage + creme | Tipografia elegante
   ============================================================ */
:root {
  --brand:       #2f5d3a;   /* verde escuro da marca (logo) */
  --brand-strong:#244b2e;   /* verde mais escuro (hover) */
  --brand-bg:    #e8f0e9;   /* verde bem claro (fundos sutis) */
  --total-red:   #c5313c;   /* vermelho clean p/ o total do item */
  --sage:        #5b7b5a;
  --sage-bg:     #e9f0e8;
  --gold:        #c9a24b;
  --bg:          #fbf7f4;   /* fundo creme */
  --surface:     #ffffff;
  --surface-2:   #fcf9f7;
  --line:        #ece2dd;
  --line-strong: #d9cbc4;
  --text:        #3a2e33;   /* contraste AA sobre branco */
  --muted:       #8a7a80;
  --danger:      #c0392b;
  --ok:          #2e7d52;

  --radius:      14px;
  --radius-sm:   10px;
  --shadow:      0 1px 2px rgba(58,46,51,.06), 0 8px 24px rgba(58,46,51,.06);
  --shadow-lg:   0 12px 40px rgba(58,46,51,.18);
  --ring:        0 0 0 3px rgba(47,93,58,.30);

  --font-ui:     'Jost', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-serif:  'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-script: 'Great Vibes', cursive;

  --toolbar-h:   60px;
  --float-h:     64px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--float-h) + 24px + env(safe-area-inset-bottom, 0px));
}

/* Toque: remove atraso de 300ms e duplo-zoom acidental nos controles */
button, input, select, textarea, label, a { touch-action: manipulation; }

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

/* Garante que o atributo [hidden] sempre esconda, mesmo com display definido na classe */
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; letter-spacing: .2px; }

/* ----------------------------- Ícones ----------------------------- */
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico--sm { width: 14px; height: 14px; }
.ico--lg { width: 26px; height: 26px; }

/* ----------------------------- Botões ----------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: 14px; font-weight: 500;
  padding: 10px 16px; min-height: 44px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .08s ease, box-shadow .18s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-strong); }
.btn--ghost { background: transparent; border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface); }
.btn--ghost[aria-pressed="true"] { background: var(--brand-bg); border-color: var(--brand); color: var(--brand); }
.btn--sm { min-height: 38px; padding: 7px 12px; font-size: 13px; }
.btn--icon { padding: 8px; min-height: 40px; min-width: 40px; justify-content: center; background: transparent; }
.btn--icon:hover { background: var(--surface-2); }
.btn--add {
  width: 100%; justify-content: center; border: 1.5px dashed var(--line-strong);
  background: var(--surface-2); color: var(--brand); font-weight: 600; margin-top: 14px; padding: 16px;
}
.btn--add:hover { background: var(--brand-bg); border-color: var(--brand); }

/* ----------------------------- Toolbar ----------------------------- */
.toolbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: var(--toolbar-h); padding: 0 18px;
  background: rgba(251,247,244,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.toolbar__brand { display: flex; align-items: baseline; gap: 10px; }
.toolbar__logo { font-family: var(--font-script); font-size: 30px; color: var(--brand); line-height: 1; }
.toolbar__tag { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.toolbar__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Banner de preview */
.preview-banner {
  position: sticky; top: var(--toolbar-h); z-index: 90;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--sage-bg); color: var(--sage); border-bottom: 1px solid #cfe0cd;
  padding: 8px 18px; font-size: 14px;
}

/* ----------------------------- Documento ----------------------------- */
.document {
  max-width: 920px; margin: 28px auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 38px 40px; overflow: hidden; position: relative;
}


/* Cabeçalho / branding */
.doc-head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center;
  padding-bottom: 24px; margin-bottom: 26px; border-bottom: 2px solid var(--brand-bg);
}
.logo-drop {
  display: grid; place-items: center; width: 150px; height: 150px;
  border-radius: var(--radius); background: transparent;
  cursor: pointer; overflow: hidden; position: relative; transition: background .18s;
}
.logo-drop.is-dragover { background: var(--sage-bg); }
.logo-drop img { width: 100%; height: 100%; object-fit: contain; }
.logo-drop__change {
  position: absolute; inset: auto 0 0 0; display: flex; align-items: center; justify-content: center; gap: 4px;
  background: rgba(58,46,51,.78); color: #fff; font-size: 11px; padding: 5px; opacity: 0; transition: opacity .18s;
}
.logo-drop:hover .logo-drop__change, .logo-drop:focus-within .logo-drop__change { opacity: 1; }

.store-tagline {
  font-family: var(--font-serif); font-weight: 600; font-size: 24px; color: var(--text); line-height: 1.1; margin: 0 0 4px;
}
.store-line { margin: 2px 0; font-size: 15px; }
.store-line--muted { color: var(--muted); font-size: 14px; }
[contenteditable]:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
[contenteditable]:empty:before { content: attr(data-placeholder); color: var(--muted); opacity: .7; }

.doc-head__meta { text-align: right; }
.doc-badge {
  display: inline-block; font-family: var(--font-serif); font-size: 22px; font-weight: 700;
  color: var(--brand); border: 1.5px solid var(--brand-bg); border-radius: 999px; padding: 4px 16px; margin-bottom: 8px;
}
.doc-num, .doc-date { margin: 2px 0; font-size: 13px; color: var(--muted); }

/* ----------------------------- Cards / Formulários ----------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
}
.card__title {
  font-family: var(--font-serif); font-size: 22px; font-weight: 600;
  margin: 0 0 16px; color: var(--text); display: flex; align-items: center; gap: 10px;
}
.card__title::before { content: ""; width: 6px; height: 22px; border-radius: 3px; background: var(--brand); }

.client-card { background: var(--surface-2); margin-bottom: 26px; }

.field-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--brand); }

input, textarea, select {
  font-family: var(--font-ui); font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 11px 13px; width: 100%; min-height: 44px; transition: border-color .18s, box-shadow .18s;
}
textarea { min-height: auto; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .65; }

/* Filtros dos orçamentos salvos */
.saved-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.saved-filters input[type="search"] { flex: 1 1 130px; width: auto; min-width: 130px; }
.saved-filters select { width: auto; flex: 0 1 auto; }
.saved-filters input[type="date"] { width: auto; flex: 0 1 auto; }
.saved-filters .btn { flex: none; }

/* ----------------------------- Itens ----------------------------- */
.items-section { margin-bottom: 26px; }
.items-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.items-head__hint { color: var(--muted); font-size: 13px; margin: 0; }

/* Aviso "Mix de flores" */
.mix-note {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--brand-bg); border: 1px solid #cfe0d2; border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 14px;
}
.mix-note .ico { color: var(--brand); margin-top: 1px; flex: none; }
.mix-note__text { flex: 1; }
.mix-note strong { display: block; color: var(--brand); font-size: 14px; }
.mix-note__desc { font-size: 13px; color: var(--text); }
.mix-note__cores { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.mix-note__cores label { font-size: 13px; font-weight: 600; color: var(--brand); white-space: nowrap; }
.mix-note__cores input { max-width: 300px; min-height: 38px; background: var(--surface); }
body.preview .mix-note__cores:has(input:placeholder-shown) { display: none; }

.item-cols {
  display: grid; grid-template-columns: 120px 80px 1fr 130px 130px 44px; gap: 14px;
  padding: 0 14px 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
}

.items-list { display: flex; flex-direction: column; gap: 14px; }

.item-row {
  display: grid; grid-template-columns: 120px 80px 1fr 130px 130px 44px; gap: 14px;
  align-items: start; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; transition: border-color .18s, box-shadow .18s;
  animation: rowIn .22s ease;
}
.item-row:hover { border-color: var(--line-strong); }
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Foto do item */
.item-photo {
  position: relative; display: grid; place-items: center;
  width: 120px; height: 120px; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line-strong); background: var(--surface-2);
  cursor: pointer; overflow: hidden; transition: border-color .18s, background .18s;
}
.item-photo:hover { border-color: var(--brand); background: var(--brand-bg); }
.item-photo.is-dragover { border-color: var(--sage); background: var(--sage-bg); }
.item-photo__img { width: 100%; height: 100%; object-fit: cover; }
.item-photo__hint { display: grid; place-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.item-photo__remove {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(58,46,51,.6); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.item-photo__remove:hover { background: var(--danger); }

.item-desc__input { height: 100%; min-height: 120px; }

.item-mini-label { display: none; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.item-qty__input { text-align: center; }
.money-input { font-variant-numeric: tabular-nums; }

.item-total { display: flex; flex-direction: column; gap: 4px; padding-top: 12px; }
.item-total__value { font-family: var(--font-ui); font-weight: 600; font-size: 17px; color: var(--total-red); }

.item-remove {
  align-self: center; width: 44px; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; transition: all .18s;
}
.item-remove:hover { color: var(--danger); border-color: var(--danger); background: #fdf0ee; }

/* ----------------------------- Rodapé do documento ----------------------------- */
.doc-footer { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.obs-card textarea { width: 100%; }
.atendente-field { margin-top: 12px; }
.totals-card { background: var(--brand-bg); border-color: #cfe0d2; padding: 18px 20px; }
.totals-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 15px; }
.totals-row label { color: var(--muted); font-size: 14px; }
.totals-row--discount .money-input--sm { max-width: 96px; text-align: right; min-height: 38px; padding: 7px 10px; }
.discount-control { display: flex; align-items: center; gap: 6px; }
.discount-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.discount-toggle button {
  border: none; background: var(--surface); color: var(--muted);
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; padding: 6px 9px;
  min-height: 36px; cursor: pointer; transition: background .15s, color .15s;
}
.discount-toggle button + button { border-left: 1px solid var(--line-strong); }
.discount-toggle button.is-active { background: var(--brand); color: #fff; }
.totals-row--grand {
  margin-top: 8px; padding-top: 14px; border-top: 1.5px solid #c2d6c5;
  font-family: var(--font-ui); font-size: 17px; font-weight: 700;
}
.totals-row--grand .num { font-size: 24px; color: var(--total-red); }

.doc-thanks { text-align: center; color: var(--muted); font-family: var(--font-serif); font-size: 18px; margin: 30px 0 4px; }

/* ----------------------------- Rodapé flutuante ----------------------------- */
.floating-total {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 95; width: min(920px, calc(100% - 32px));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: var(--float-h); padding: 0 18px;
  background: var(--text); color: #fff; border-radius: 999px; box-shadow: var(--shadow-lg);
}
.floating-total__info { display: flex; align-items: baseline; gap: 18px; }
.floating-total__label { font-size: 13px; color: #e9dbe1; }
.floating-total__value { font-size: 15px; }
.floating-total__value strong { font-family: var(--font-serif); font-size: 24px; color: #fff; margin-left: 4px; }
.floating-total .btn--ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.floating-total .btn--ghost:hover { background: rgba(255,255,255,.12); }
.floating-total__actions { display: flex; gap: 8px; }

/* ----------------------------- Modal ----------------------------- */
.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }

/* Modal "cliente diferente": acima de tudo (preview 250, compartilhar 260) */
.modal--savemode { z-index: 270; }
.modal--savemode .modal__box { width: min(440px, 100%); }
.savemode-txt { margin: 0; font-size: 14.5px; line-height: 1.55; }
.savemode-txt b { color: var(--brand); }
.modal__foot--savemode { flex-direction: column; align-items: stretch; }
.modal__foot--savemode .btn { justify-content: center; }

/* Chip "Editando Nº X · Cliente" na barra inferior */
.edit-chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: rgba(255,255,255,.14); color: #e9dbe1; max-width: 46vw; overflow: hidden; text-overflow: ellipsis;
}
.edit-chip--editing { background: var(--gold); color: #3a2e33; font-weight: 600; }

/* Modal de compartilhar: fica ACIMA da pré-visualização (.cp-overlay é 250) */
.modal--share { z-index: 260; }
.modal--share .modal__box { width: min(480px, 100%); max-width: calc(100vw - 32px); }
.modal--share .share-hint { font-size: 13.5px; margin: 0 0 10px; }
.modal--share textarea { width: 100%; font-size: 14.5px; }
.modal__foot--share { justify-content: flex-end; }
.ico--fill { fill: currentColor; stroke: none; }
.modal__overlay { position: absolute; inset: 0; background: rgba(58,46,51,.5); animation: fade .2s ease; }
.modal__box {
  position: relative; width: min(620px, 100%); max-width: calc(100vw - 32px); max-height: 86vh; max-height: 86dvh; overflow: hidden;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: pop .22s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-family: var(--font-serif); font-size: 24px; margin: 0; }
.modal__body { padding: 16px 20px; overflow-y: auto; }
.modal__foot { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color .18s, background .18s;
}
.saved-item:hover { border-color: var(--brand); background: var(--surface-2); }
.saved-item__main { min-width: 0; }
.saved-item__name { font-weight: 600; font-size: 15px; }
.saved-item__meta { font-size: 13px; color: var(--muted); }
.saved-item__total { font-family: var(--font-ui); font-weight: 700; color: var(--brand); font-size: 16px; font-variant-numeric: tabular-nums; }
.saved-item__actions { display: flex; gap: 6px; }
.saved-empty { text-align: center; padding: 40px 20px; color: var(--text); }
.muted { color: var(--muted); }

/* ----------------------------- Toast ----------------------------- */
.toast {
  position: fixed; bottom: calc(var(--float-h) + 30px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  z-index: 300; background: var(--text); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
}
.toast--ok { background: var(--ok); }
.toast--err { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ----------------------------- Visualização do cliente (iframe) ----------------------------- */
.cp-overlay { position: fixed; inset: 0; z-index: 250; display: flex; flex-direction: column; background: #ece5de; animation: fade .18s ease; }
.cp-overlay[hidden] { display: none; }
.cp-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 6px rgba(58,46,51,.08); flex: none;
}
.cp-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--brand); }
.cp-actions { display: flex; gap: 8px; }
.cp-frame-wrap { flex: 1; min-height: 0; }
#cpFrame { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 560px) {
  .cp-title__text { display: none; }
  .cp-bar { padding: 8px 10px; }
  .cp-actions { flex: 1; justify-content: flex-end; }
}

/* ----------------------------- Auth gate ----------------------------- */
body.gated { overflow: hidden; }
.auth-gate { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; background: var(--bg); }
.auth-gate[hidden] { display: none; }
.auth-gate__box { text-align: center; max-width: 360px; padding: 24px; }
.auth-gate__logo { width: 130px; height: 130px; object-fit: contain; }
.auth-gate__spinner {
  width: 34px; height: 34px; margin: 14px auto;
  border: 3px solid var(--brand-bg); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth-gate__warn { color: var(--sage); font-weight: 600; margin-bottom: 4px; }
.auth-gate code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ----------------------------- Área de usuário (toolbar) ----------------------------- */
.toolbar__user { display: flex; align-items: center; gap: 8px; }
.user-chip {
  font-size: 13px; color: var(--muted); padding: 5px 11px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
}

/* ----------------------------- Painel de funcionários ----------------------------- */
.admin-form {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 22px; display: flex; flex-direction: column; gap: 12px;
}
.admin-form__title { font-family: var(--font-serif); font-size: 19px; margin: 0 0 2px; }
.admin-form .btn--primary { justify-content: center; }
.admin-msg { font-size: 14px; padding: 9px 12px; border-radius: var(--radius-sm); margin: 0; }
.admin-msg--ok { background: #eaf5ee; color: var(--ok); }
.admin-msg--err { background: #fdf0ee; color: var(--danger); }
.user-role { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--brand-bg); color: var(--brand); }
.user-role--admin { background: var(--sage-bg); color: var(--sage); }

/* ============================================================
   MODO PRÉ-VISUALIZAÇÃO (versão do cliente)
   ============================================================ */
.preview-only { display: none; }
body.preview .edit-only { display: none !important; }
body.preview .preview-only { display: flex; }
body.preview .floating-total { display: none; }

body.preview input, body.preview textarea, body.preview select,
body.preview [contenteditable] {
  border: none !important; background: transparent !important; box-shadow: none !important;
  padding: 0 !important; min-height: 0 !important; resize: none; pointer-events: none; cursor: default;
}
body.preview .card { background: transparent; border-color: var(--line); }
body.preview .client-card { background: var(--surface-2); }
body.preview .item-row { border-color: var(--line); }
body.preview .item-photo { border: none; background: var(--surface-2); cursor: default; }
body.preview .item-desc__input { min-height: auto; }
body.preview .totals-card { background: var(--brand-bg); }
/* itens incompletos (sem qtd/descrição/valor) não aparecem para o cliente */
body.preview .item-row.is-incomplete { display: none; }

/* ---- Pré-visualização: cada item vira um cartão elegante (mobile-first) ---- */
body.preview .items-list { gap: 12px; }
body.preview .item-row {
  grid-template-columns: 104px 1fr;
  grid-template-areas:
    "photo desc"
    "photo qty"
    "photo unit"
    "photo total";
  column-gap: 16px; row-gap: 0; align-items: start;
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: #fff;
}
body.preview .item-row:has(.item-photo__img[hidden]) {
  grid-template-columns: 1fr;
  grid-template-areas: "desc" "qty" "unit" "total";
}
body.preview .item-row:has(.item-photo__img[hidden]) .item-photo { display: none; }
body.preview .item-photo { grid-area: photo; width: 104px; height: 104px; border-radius: 10px; }
body.preview .item-desc { grid-area: desc; margin-bottom: 6px; }
body.preview .item-desc__input { font-size: 15px; font-weight: 500; color: var(--text); line-height: 1.45; overflow: hidden; }
body.preview .item-qty   { grid-area: qty; }
body.preview .item-unit  { grid-area: unit; }
body.preview .item-total { grid-area: total; }
body.preview .item-qty, body.preview .item-unit, body.preview .item-total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 6px 0; margin: 0; background: none; border-top: 1px dashed var(--line); border-radius: 0;
}
body.preview .item-total { border-top: 1.5px solid var(--brand-bg); padding-top: 8px; }
body.preview .item-mini-label { display: block; margin: 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
body.preview .item-qty__input, body.preview .item-unit__input { width: auto; text-align: right; font-weight: 600; font-size: 15px; }
body.preview .item-qty__input::-webkit-inner-spin-button { -webkit-appearance: none; }
body.preview .item-total__value { font-size: 19px; }
/* esconde fields vazios na versão limpa */
body.preview .field:has(input:placeholder-shown) { display: none; }
body.preview .obs-card:has(textarea:placeholder-shown):has(#atendente:placeholder-shown) { display: none; }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 860px) {
  .document { padding: 24px 18px; margin: 16px auto; border-radius: 0; border-left: none; border-right: none; }
  .doc-head { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .doc-head__meta { text-align: center; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .doc-footer { grid-template-columns: 1fr; }
  /* fonte 16px evita o zoom automático do iOS ao focar campos */
  input, textarea, select { font-size: 16px; }
  .toolbar__user { justify-content: center; flex-wrap: wrap; }
  .totals-card { padding: 16px; }
  .item-cols { display: none; }

  /* Itens viram cartões empilhados */
  .item-row {
    grid-template-columns: 100px 1fr; grid-template-areas:
      "photo desc"
      "qty   unit"
      "total total"
      "rm    rm";
  }
  .item-photo { grid-area: photo; width: 100px; height: 100px; }
  .item-desc { grid-area: desc; }
  .item-desc__input { min-height: 100px; }
  .item-qty { grid-area: qty; }
  .item-unit { grid-area: unit; }
  .item-total { grid-area: total; flex-direction: row; align-items: center; justify-content: space-between;
    background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 14px; }
  .item-remove { grid-area: rm; width: 100%; }
  .item-mini-label { display: block; }
  body.preview .item-row { grid-template-columns: 100px 1fr; }

  .toolbar { height: auto; padding: 10px 12px; flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar__actions { justify-content: center; }
  .toolbar__actions .btn { flex: 1 1 auto; justify-content: center; }
  .preview-banner { top: 0; flex-direction: column; text-align: center; }
  .floating-total__info { flex-direction: column; gap: 0; align-items: flex-start; }
}

/* ---------- Celular (até 560px): toque confortável e tela aproveitada ---------- */
@media (max-width: 560px) {
  /* A toolbar deixa de ser fixa (o total flutuante já dá acesso a Salvar);
     o formulário ganha a tela toda ao rolar. */
  .toolbar { position: static; }
  .toolbar__actions { gap: 8px; }
  .toolbar__actions .btn { flex: 1 1 30%; padding: 10px 8px; font-size: 13.5px; }
  .toolbar__brand { justify-content: center; }

  /* Modais viram "folha" ancorada embaixo — padrão de app, fácil de alcançar */
  .modal { place-items: end center; padding: 0; }
  .modal__box {
    width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh;
    border-radius: 18px 18px 0 0;
  }
  .modal__foot { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  @keyframes pop { from { opacity: 0; transform: translateY(28px); } }

  /* Alvos de toque ≥44px */
  .btn--sm { min-height: 44px; }
  .btn--icon { min-height: 44px; min-width: 44px; }
  .item-photo__remove { width: 34px; height: 34px; }
  .discount-toggle button { min-height: 42px; padding: 6px 12px; }

  /* Filtros dos salvos: busca em linha própria; mês + data lado a lado */
  .saved-filters input[type="search"] { flex: 1 1 100%; }
  .saved-filters select { flex: 1 1 38%; }
  .saved-filters input[type="date"] { flex: 1 1 34%; }

  /* Cartão de orçamento salvo: nome em cima, total + ações embaixo */
  .saved-item { flex-wrap: wrap; }
  .saved-item__main { flex: 1 1 100%; }
  .saved-item__total { flex: 1; }
  .saved-item__actions { margin-left: auto; }

  /* Total flutuante mais enxuto */
  .floating-total { padding: 0 16px; gap: 10px; }
  .floating-total__label { display: none; }

  .document { padding: 20px 14px; }
  .card { padding: 16px; }
}

@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
  .toolbar__actions .btn span { font-size: 13px; }
}

/* ---------- Tablet (768–1024px): aproveita a largura sem apertar ---------- */
@media (min-width: 861px) and (max-width: 1024px) {
  .field-grid { grid-template-columns: repeat(2, 1fr); }
  .item-row, .item-cols { grid-template-columns: 110px 70px 1fr 118px 118px 44px; gap: 12px; }
  .document { max-width: min(920px, calc(100% - 32px)); margin: 20px auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   IMPRESSÃO / PDF
   ============================================================ */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; padding: 0; }
  .no-print, .edit-only, .item-mini-label { display: none !important; }
  .preview-only { display: flex !important; }
  .document { box-shadow: none; border: none; margin: 0; max-width: 100%; padding: 0; }

  input, textarea, select, [contenteditable] {
    border: none !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; min-height: 0 !important;
  }
  .card, .item-row, .client-card { break-inside: avoid; border-color: #e0d6d0 !important; }
  .item-photo { border: none; background: #f7f3f1; }
  .item-row:has(.item-photo__img[hidden]) .item-photo { display: none; }
  .item-row { grid-template-columns: 110px 60px 1fr 110px 110px; }
  .item-row.is-incomplete { display: none; }
  .field:has(input:placeholder-shown) { display: none; }
  .obs-card:has(textarea:placeholder-shown):has(#atendente:placeholder-shown) { display: none; }
  .mix-note__cores:has(input:placeholder-shown) { display: none; }
  .totals-card { background: #e8f0e9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-badge, .item-total__value, .totals-row--grand .num, .store-name { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
