/* Certificados, crachás e documentos em lote (mala-direta.html) — complementa styles.css/site.css/studio.css/office.css */

/* Fontes OFL usadas nos modelos (as mesmas embutidas no PDF) */
@font-face { font-family: 'CJ Baskerville'; src: url(/vendor/fonts/LibreBaskerville-Regular.ttf) format('truetype'); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: 'CJ Baskerville'; src: url(/vendor/fonts/LibreBaskerville-Bold.ttf) format('truetype'); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: 'CJ Baskerville'; src: url(/vendor/fonts/LibreBaskerville-Italic.ttf) format('truetype'); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: 'CJ Baskerville'; src: url(/vendor/fonts/LibreBaskerville-Bold.ttf) format('truetype'); font-weight: 700; font-style: italic; font-display: block; }
@font-face { font-family: 'CJ Cinzel'; src: url(/vendor/fonts/Cinzel-Bold.ttf) format('truetype'); font-weight: 100 900; font-style: normal; font-display: block; }
@font-face { font-family: 'CJ Cinzel'; src: url(/vendor/fonts/Cinzel-Bold.ttf) format('truetype'); font-weight: 100 900; font-style: italic; font-display: block; }
@font-face { font-family: 'CJ Vibes'; src: url(/vendor/fonts/GreatVibes-Regular.ttf) format('truetype'); font-weight: 100 900; font-style: normal; font-display: block; }
@font-face { font-family: 'CJ Vibes'; src: url(/vendor/fonts/GreatVibes-Regular.ttf) format('truetype'); font-weight: 100 900; font-style: italic; font-display: block; }

.md-page { max-width: 1320px; }
.md-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-width: 0; }
.md-head .of-h { margin: 0; flex: 1; min-width: 0; }
.md-step { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex: none; }
.md-badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--biz-soft); color: var(--biz); white-space: nowrap; }
.md-badge:empty { display: none; }
.md-badge[data-ok="1"] { background: var(--img-soft); color: var(--img); }
.md-hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.md-row-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- 1. Dados ---------- */
.md-source { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.md-drop { display: flex; align-items: center; gap: 14px; padding: 18px; border: 2px dashed var(--line-2); border-radius: 16px; cursor: pointer; background: var(--bg); transition: border-color .2s, background .2s; min-width: 0; }
.md-drop:hover, .md-drop:focus-visible { border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2)); outline: none; }
.md-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.md-drop.busy { opacity: .6; pointer-events: none; }
.md-drop .ic { width: 34px; height: 34px; flex: none; color: var(--img); stroke-width: 1.6; }
.md-drop span { display: flex; flex-direction: column; gap: 3px; font-size: 14.5px; min-width: 0; }
.md-drop small { color: var(--muted); font-size: 12.5px; }
.md-paste { border: 1px solid var(--line); border-radius: 16px; padding: 0 14px; background: var(--bg); min-width: 0; }
.md-paste > summary { cursor: pointer; padding: 14px 0; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.md-paste[open] { padding-bottom: 12px; }
.md-paste textarea.input { height: auto; min-height: 96px; padding: 10px 12px; font: 400 13px/1.45 ui-monospace, Menlo, monospace; resize: vertical; margin-bottom: 8px; white-space: pre; }
.md-sample { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 13.5px; line-height: 1.45; }
.md-data-bar, .md-filter { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 10px; }
.md-file { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; min-width: 0; }
.md-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; min-width: 0; }
.md-page .md-inline .input { height: 36px; font-size: 14px; width: auto; max-width: 100%; }
.md-page .md-inline select.input { max-width: 200px; }
.md-page .md-inline .md-num { width: 74px; }
.md-page .md-inline #fVal { width: 160px; }
.md-table-wrap { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overscroll-behavior: contain; }
.md-table { border-collapse: collapse; font-size: 13px; width: max-content; min-width: 100%; }
.md-table th { position: sticky; top: 0; background: var(--bg-2); text-align: left; font-weight: 600; color: var(--ink-2); padding: 8px 10px; white-space: nowrap; z-index: 1; }
.md-table td { padding: 6px 10px; border-top: 1px solid var(--line); white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.md-table tbody tr { cursor: pointer; }
.md-table tbody tr:hover td { background: var(--bg); }
.md-table tr.skip td:not(.md-ck) { opacity: .4; text-decoration: line-through; text-decoration-color: var(--line-2); }
.md-table tr.cur td { background: var(--accent-soft); }
.md-table .md-ck { width: 34px; text-align: center; }
.md-table .md-ck input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.md-table .md-rn { color: var(--muted); font-variant-numeric: tabular-nums; width: 40px; }
.md-more { margin: 0; padding: 8px 12px; font-size: 12.5px; color: var(--muted); }
.md-count { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-2); }
.md-count b { color: var(--ink); }

/* ---------- área de trabalho ---------- */
.md-work { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 18px; }
.md-side, .md-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.md-main { position: sticky; top: 76px; }

/* 2. Modelo */
.md-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.md-kinds .chip { padding: 7px 12px; font-size: 13.5px; }
.md-kinds .chip[aria-pressed="true"], .md-opts .chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.md-opts { display: flex; flex-direction: column; gap: 14px; }
.md-opts .field { gap: 7px; }
.md-opts .of-chips .chip { display: inline-flex; align-items: center; gap: 6px; }
.md-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px var(--line-2); }
.md-sig { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 8px; }
.md-page .md-sig .input { height: 38px; font-size: 14px; }
.md-bgpick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.md-bgpick small { flex: 1 1 160px; min-width: 0; line-height: 1.35; }
.md-file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

/* 3. Campos */
.md-add { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.md-add .btn { flex: 1 1 auto; }
.md-flist { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow: auto; overscroll-behavior: contain; }
.md-fitem { display: flex; align-items: center; gap: 4px; border: 1px solid transparent; border-radius: 12px; padding: 2px 4px 2px 2px; }
.md-fitem:hover { background: var(--bg); }
.md-fitem.sel { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.md-fitem.off .md-fsel { opacity: .45; }
.md-fsel { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 6px; text-align: left; cursor: pointer; color: var(--ink); font: inherit; border-radius: 10px; }
.md-fsel span { display: flex; flex-direction: column; min-width: 0; }
.md-fsel b { font-size: 13.5px; font-weight: 600; }
.md-fsel small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-fico { width: 28px; height: 28px; border-radius: 8px; background: var(--bg-2); display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 13px; flex: none; color: var(--ink-2); }
.md-fbtns { display: flex; gap: 0; flex: none; }
.md-fbtns .icon-btn { width: 30px; height: 30px; font-size: 13px; }
.md-fbtns .danger:hover:not(:disabled) { background: var(--pdf-soft); color: var(--pdf); }
.md-empty { color: var(--muted); font-size: 13px; padding: 8px; }
.md-props { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.md-props-head { display: flex; gap: 8px; align-items: center; }
.md-page .md-props-head .md-name { height: 38px; font-weight: 600; font-size: 14.5px; }
.md-page .md-props textarea.input { min-height: 0; font-size: 14px; }
.md-page .md-props .input { height: 40px; font-size: 14px; }
.md-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.md-ins { border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2); border-radius: 99px; padding: 4px 10px; font: 500 12.5px var(--font); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-ins:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.md-ins.alt { border-style: dashed; }
.md-toolrow { display: flex; flex-wrap: wrap; gap: 8px; }
.md-mini { flex: 0 0 auto; padding: 3px; gap: 2px; }
.md-mini button { padding: 5px 9px; min-width: 32px; font-size: 13px; }
.md-props .seg button[aria-checked="true"] { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 1px var(--line); }
.md-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.md-colors .of-swatch { width: 26px; height: 26px; }
.md-colors input[type=color] { width: 40px; height: 32px; }
.of-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.md-pos { border-top: 1px solid var(--line); padding-top: 10px; }
.md-pos > summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); padding: 2px 0; }
.md-pos > .of-grid { margin-top: 10px; }
.md-danger { color: var(--pdf); border-color: color-mix(in srgb, var(--pdf) 40%, var(--line-2)); }
.md-danger:hover { background: var(--pdf-soft) !important; }
.md-warn { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--biz-soft); font-size: 13px; margin-bottom: 12px; }
.md-warn b { color: var(--biz); }
.md-map { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.md-map code { font-size: 12.5px; background: var(--surface); padding: 2px 6px; border-radius: 6px; }
.md-page .md-map select.input { height: 34px; width: auto; flex: 1; min-width: 120px; font-size: 13.5px; }

/* ---------- prévia ---------- */
.md-stage-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; min-width: 0; }
.md-stagebar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 4px 10px; }
.md-sides { flex: none; padding: 3px; }
.md-sides button { padding: 5px 12px; }
.md-nav { display: flex; align-items: center; gap: 4px; }
.md-rowlabel { font-size: 13.5px; min-width: 64px; text-align: center; white-space: nowrap; }
.md-rowlabel small { color: var(--muted); }
.md-movetoggle { font-size: 13px; }
.md-stage { background: var(--bg-2); border-radius: 12px; padding: 20px; display: grid; place-items: center; overflow: hidden; min-height: 240px;
  background-image: radial-gradient(color-mix(in srgb, var(--line-2) 70%, transparent) 1px, transparent 1px); background-size: 16px 16px; }
.md-pagebox { position: relative; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .12), 0 12px 32px -12px rgba(0, 0, 0, .3); user-select: none; -webkit-user-select: none; }
.md-pagebox > canvas { position: absolute; inset: 0; display: block; }
.md-decor, .md-layer { position: absolute; inset: 0; }
.md-decor { pointer-events: none; }
.md-decor svg, .md-item .md-svg { position: absolute; left: 0; top: 0; display: block; overflow: visible; }
.md-item { position: absolute; outline: 1px dashed transparent; outline-offset: 0; cursor: move; touch-action: none; }
.md-item:hover { outline-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.md-item:focus-visible { outline: 2px solid var(--accent); }
.md-item.sel { outline: 1.5px solid var(--accent); z-index: 2; }
.md-item.off { opacity: .25; }
.md-txt { position: absolute; inset: 0; pointer-events: none; }
.md-txt span { position: absolute; white-space: pre; font-kerning: none; font-synthesis: none; font-variant-ligatures: common-ligatures contextual; text-rendering: geometricPrecision; }
.md-rule { position: absolute; left: 0; right: 0; top: -.5px; height: 1px; }
.md-img { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.md-img img { width: 100%; height: 100%; display: block; }
.md-img > i { position: absolute; inset: 0; }
.md-img-empty { border: 1.5px dashed #b9b5c8; display: grid; place-items: center; background: rgba(255, 255, 255, .55); }
.md-img-empty span { font: 600 11px var(--font); color: #7a7690; }
.md-h { position: absolute; width: 11px; height: 11px; border-radius: 3px; background: #fff; border: 1.5px solid var(--accent); display: none; z-index: 3; }
.md-item.sel .md-h { display: block; }
.md-h.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.md-h.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.md-h.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.md-h.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.md-guide { position: absolute; pointer-events: none; z-index: 4; }
.md-guide.v { top: 0; bottom: 0; left: 50%; border-left: 1px dashed #e5484d; }
.md-guide.h { left: 0; right: 0; top: 50%; border-top: 1px dashed #e5484d; }
.md-tip { margin: 8px 6px 2px; font-size: 12.5px; color: var(--muted); }

/* 4. Gerar */
.md-out { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.md-out .seg button[aria-checked="true"], .md-opts .seg button[aria-checked="true"] { color: var(--accent); }
.md-fname { display: flex; align-items: center; gap: 6px; }
.md-fname em { font-style: normal; color: var(--muted); font-size: 14px; }
.md-go { width: 100%; }
.md-progress { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.md-bar { height: 10px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.md-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .2s; }
.md-prog-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.md-page .of-next { margin-top: 12px; }

/* ---------- responsivo ---------- */
@media (max-width: 1080px) {
  .md-work { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .md-work { display: flex; flex-direction: column; }
  .md-side, .md-main { display: contents; }
  #modelCard { order: 1; }
  .md-stage-card { order: 2; }
  #fieldsCard { order: 3; }
  #outCard { order: 4; }
  .md-work > * > * { width: 100%; }
  .md-source { grid-template-columns: minmax(0, 1fr); }
  .md-flist { max-height: 240px; }
}
@media (max-width: 760px) {
  .md-stage { padding: 8px; }
  .md-stage:not(.can-move) .md-item { cursor: pointer; touch-action: auto; }
  .md-stage:not(.can-move) .md-h { display: none !important; }
  .md-h { width: 16px; height: 16px; }
  .md-h.nw { left: -9px; top: -9px; } .md-h.ne { right: -9px; top: -9px; } .md-h.sw { left: -9px; bottom: -9px; } .md-h.se { right: -9px; bottom: -9px; }
  .of-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-stage-card { padding: 8px; }
}
@media (max-width: 520px) {
  .md-page .md-inline select.input { max-width: 150px; }
  .md-page .md-inline #fVal { width: 120px; }
  .md-sig { grid-template-columns: minmax(0, 1fr); }
  .md-out .seg button { flex: 1 1 100%; }
  .md-drop { padding: 14px; }
}
