:root {
  --bg: #f6f4f8;
  --panel: #fff;
  --line: #e7e2ed;
  --text: #2b2533;
  --muted: #8a8294;
  --acc: #d6407f;
  --acc-d: #b02b63;
  --acc-l: #fde8f1;
  --stage: #e9e5ee;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0; }

/* ---------- topo ---------- */
header.top {
  height: 54px; flex: none; display: flex; align-items: center; gap: 24px;
  padding: 0 18px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; color: var(--acc-d); white-space: nowrap; }
nav { display: flex; gap: 4px; }
nav button {
  border: 0; background: none; padding: 8px 14px; border-radius: 8px;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
nav button:hover { color: var(--text); }
nav button.active { background: var(--acc-l); color: var(--acc-d); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ---------- telas ---------- */
main { flex: 1; min-height: 0; }
.screen { height: 100%; display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; }
.screen[hidden] { display: none; }
#scr-cfg { display: block; overflow: auto; }
#scr-cfg[hidden] { display: none; }
.left, .right { background: #fff; overflow: auto; min-height: 0; }
.left { border-right: 1px solid var(--line); padding: 14px; }
.right { border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; min-height: 52px;
}
.stage-wrap { flex: 1; position: relative; min-height: 0; background: var(--stage); }
.stage-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage-wrap .empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); font-size: 15px; pointer-events: none;
}
.stage-wrap .empty[hidden] { display: none; }
.zoom {
  position: absolute; right: 12px; bottom: 12px; z-index: 2; display: flex; background: #fff;
  border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 2px 8px rgba(40,20,60,.12); overflow: hidden;
}
.zoom button { border: 0; background: none; padding: 6px 11px; cursor: pointer; font-weight: 700; color: var(--muted); min-width: 34px; }
.zoom button:hover { background: #f6f3f9; color: var(--text); }
.zoom button:nth-child(2) { font-size: 12px; min-width: 56px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.statusbar { flex: none; padding: 6px 14px; font-size: 12px; color: var(--muted); background: #fff; border-top: 1px solid var(--line); }

/* ---------- controles ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 8px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: #d4cbdd; background: #faf8fc; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.primary:hover { background: var(--acc-d); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { color: #c62828; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.icon {
  border: 0; background: none; cursor: pointer; padding: 3px 6px; border-radius: 6px;
  color: var(--muted); font-size: 13px; line-height: 1;
}
.icon:hover:not(:disabled) { background: #f1edf5; color: var(--text); }
.icon:disabled { opacity: .3; cursor: default; }
.icon.on { color: var(--acc); }
.inp {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit;
  background: #fff; color: var(--text); width: 100%; min-width: 0;
}
.inp:focus, .name-input:focus { outline: 2px solid rgba(214, 64, 127, .25); border-color: var(--acc); }
.inp.num { width: 82px; }
.inp.big { font-size: 16px; padding: 10px 14px; }
select.inp { padding: 6px 8px; }
.lbl { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 5px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; margin: 8px 0; }
.seg { display: flex; background: #f1edf5; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px 10px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button.active { background: #fff; color: var(--acc-d); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.color { width: 38px; height: 28px; padding: 0 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.code { padding: 7px 10px; background: #f6f3f9; border-radius: 8px; font-weight: 700; color: var(--muted); }

/* ---------- produção: painel esquerdo ---------- */
.group { margin-bottom: 8px; }
.group .lbl:first-child { margin-top: 0; }
.slot-card {
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 10px; margin-top: 10px;
  cursor: pointer; transition: border-color .15s;
}
.slot-card.active { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-l); }
.slot-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.slot-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--acc-l); color: var(--acc-d);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.slot-title { font-weight: 700; }
.badge { font-size: 10px; background: #fff4d6; color: #9a6b00; padding: 2px 6px; border-radius: 10px; font-weight: 700; }
.tpl-pick {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  border: 1px dashed #d8cfe2; background: #fbfafc; border-radius: 8px; padding: 6px; cursor: pointer; min-height: 46px;
}
.tpl-pick:hover { border-color: var(--acc); }
.tpl-pick img { width: 110px; height: 34px; object-fit: contain; background: #fff; border-radius: 4px; flex: none; }
.tpl-pick .tp-txt { display: flex; flex-direction: column; min-width: 0; }
.tpl-pick b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-pick small { color: var(--muted); }
.tpl-pick > span { padding: 6px; }
.name-input {
  width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font: 600 17px "Segoe UI", sans-serif; color: var(--text);
}
.left-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.text-input { margin-top: 6px; font-size: 14px; }

/* ---------- abas de folha ---------- */
.tabs { display: flex; gap: 4px; flex: 1 1 100%; min-width: 0; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.tab {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; flex: none;
  cursor: pointer; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.tab-t { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.active { background: var(--acc-l); border-color: var(--acc); color: var(--acc-d); }
.tab .x { opacity: .5; padding: 0 2px; }
.tab .x:hover { opacity: 1; color: #c62828; }
.tab.add { border-style: dashed; }

/* ---------- painel direito ---------- */
.rtabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.rtabs button {
  flex: 1; border: 0; background: none; padding: 12px 6px; cursor: pointer; font-weight: 700;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.rtabs button.active { color: var(--acc-d); border-bottom-color: var(--acc); }
.rbody { flex: 1; overflow: auto; padding: 12px 14px 24px; }
.sec { border-bottom: 1px solid var(--line); padding: 4px 0 14px; margin-bottom: 12px; }
.sec:last-child { border-bottom: 0; }
.sec h4 { margin: 4px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.fld .inp { color: var(--text); font-weight: 400; font-size: 14px; }
.fld-row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.fld-row .fl { width: 82px; flex: none; font-size: 12px; color: var(--muted); font-weight: 600; }
.fld-row .fc { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.fld-row input[type=range] { flex: 1; min-width: 0; accent-color: var(--acc); }
.fld-row .val { width: 38px; text-align: right; font-size: 12px; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-bottom: 10px; }
.sw { height: 24px; border-radius: 6px; border: 0; cursor: pointer; }
.sw:hover { transform: translateY(-1px); }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid4 label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.grid4 .inp.num { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }
.layer {
  display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent;
}
.layer:hover { background: #f8f6fa; }
.layer.active { border-color: var(--acc); background: var(--acc-l); }
.layer.off { opacity: .5; }
.lay-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-text { margin: 0 0 12px; }
.text-edit { margin-bottom: 10px; font-size: 15px; }
.sel-note { background: var(--acc-l); color: var(--acc-d); padding: 6px 8px; border-radius: 6px; }
.dpi { margin-top: 10px; padding: 8px 10px; border-radius: 8px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.dpi small { opacity: .85; }
.dpi.ok { background: #e6f4ea; color: #1e6b36; }
.dpi.mid { background: #fff4d6; color: #8a5f00; }
.dpi.low { background: #fde3e3; color: #a52222; }
.layer img { width: 34px; height: 26px; object-fit: contain; background: #fff; border-radius: 4px; border: 1px solid var(--line); }
.lay-ic {
  width: 34px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  font-family: Georgia, serif; font-style: italic; font-weight: 700; color: var(--acc); background: #fff;
  border: 1px solid var(--line); border-radius: 4px;
}

/* ---------- fontes ---------- */
.font-tools { display: flex; gap: 6px; margin-bottom: 4px; }
.font-tools .btn { flex: none; }
.font-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.font-row { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 4px; cursor: pointer; }
.font-row:hover { border-color: #d4cbdd; background: #fdfcfe; }
.font-row.active { border-color: var(--acc); background: var(--acc-l); }
.font-prev { font-size: 30px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--acc-d); }
.font-meta { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.font-meta em { font-style: normal; background: #e6f4ea; color: #1e7b3c; padding: 1px 6px; border-radius: 8px; }
.star.on { color: #f0a500; }

/* ---------- biblioteca ---------- */
.lib-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.lib-actions .btn { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 4px 12px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--acc); border-color: var(--acc); color: #fff; }
.lib-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.tcard {
  display: flex; flex-direction: column; text-align: left; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 6px; cursor: pointer; gap: 4px;
}
.tcard:hover { border-color: #d4cbdd; }
.tcard.active { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-l); }
.tcard img { width: 100%; aspect-ratio: 297 / 70; object-fit: contain; background: #fafafa; border-radius: 6px; }
.tc-txt { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 0 2px; }
.tc-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-txt small { color: var(--muted); white-space: nowrap; }
.tb-title { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-test { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.tb-test .inp { width: 170px; }

/* ---------- modais ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 20, 40, .35); display: flex;
  align-items: flex-start; justify-content: center; padding: 6vh 20px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 14px; width: 480px; max-width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal.wide { width: 960px; }
.mhead { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.mhead h3 { margin: 0; flex: 1; font-size: 16px; }
.mhead .icon { font-size: 22px; }
.mbody { padding: 16px 18px; overflow: auto; }
.stack > * { margin-top: 0; }
.picker { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.pick-top { display: flex; gap: 14px; align-items: center; }
.pick-top .chk { white-space: nowrap; margin: 0; }
.pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-height: 62vh; overflow: auto; padding: 3px; }
.pick {
  border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius); padding: 6px;
  cursor: pointer; display: flex; flex-direction: column; gap: 4px; text-align: left;
}
.pick:hover { border-color: #d4cbdd; }
.pick.active { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-l); }
.pick img { width: 100%; aspect-ratio: 297 / 70; object-fit: contain; background: #fafafa; border-radius: 6px; }
.pk-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick small { color: var(--muted); }
.empty-msg { grid-column: 1 / -1; text-align: center; padding: 30px; }
.imp-box { border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; margin: 12px 0; }
.imp-box .row { margin: 8px 0; }
.stack > .btn { margin-top: 4px; }
.imp-scroll { max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin: 10px 0 14px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.imp-table th { position: sticky; top: 0; background: #f6f3f9; text-align: left; padding: 7px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.imp-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.imp-table td.st { font-weight: 700; text-align: center; width: 28px; }
.imp-table .st-ok td.st { color: #1e7b3c; }
.imp-table .st-aviso { background: #fffaeb; }
.imp-table .st-aviso td.st { color: #b07800; }
.imp-table .st-erro { background: #fdeeee; }
.imp-table .st-erro td.st { color: #c62828; }
.imp-err { color: #c62828; font-weight: 700; }
.imp-warn { color: #b07800; font-weight: 700; }
.imp-saved { color: #1e7b3c; font-weight: 700; }
.help h4 { margin: 14px 0 6px; color: var(--acc-d); }
.help h4:first-child { margin-top: 0; }
.help ul { margin: 0; padding-left: 20px; }
.help li { margin: 4px 0; }

/* ---------- transformar nome da imagem em caixa ---------- */
.er-overlay { padding: 3vh 2vw; }
.modal.eraser { width: 96vw; height: 92vh; max-height: 92vh; }
.er-hint { margin: 10px 18px 0; }
.er-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.er-fld { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.er-fld input[type=range] { width: 110px; accent-color: var(--acc); }
.er-stage { flex: 1; position: relative; min-height: 0; background: var(--stage); }
.er-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.er-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.er-status { font-size: 13px; color: var(--muted); }
.er-status.ok { color: #1e6b36; }
.er-status.warn { color: #a52222; font-weight: 600; }
.review { color: #9a6b00 !important; font-weight: 700; }
.btn.magic { border-color: var(--acc); color: var(--acc-d); background: var(--acc-l); }

/* ---------- nuvem ---------- */
.cloud-st { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; cursor: default; }
.cloud-st.ok { background: #e6f4ea; color: #1e6b36; }
.cloud-st.busy { background: #eef3fd; color: #2a56a8; }
.cloud-st.warn { background: #fde3e3; color: #a52222; }
.login-ov { align-items: center; background: var(--bg); }
.login-box { width: 380px; }
.login-box .inp { margin-bottom: 10px; }
.big-btn { width: 100%; padding: 11px; font-size: 15px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #2b2533; color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: opacity .4s;
}
.toast.out { opacity: 0; }
.busy { position: fixed; inset: 0; background: rgba(255,255,255,.7); z-index: 90; display: flex; align-items: center; justify-content: center; }
.busy-box { background: #fff; padding: 18px 24px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.15); display: flex; gap: 14px; align-items: center; font-weight: 600; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--acc-l); border-top-color: var(--acc); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- configurações ---------- */
.cfg { max-width: 1000px; margin: 0 auto; padding: 24px 24px 60px; }
.cfg h2 { margin: 0 0 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 6px; }
.pcards { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.pcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.pcard-head { display: flex; gap: 10px; margin-bottom: 10px; }
.pcard-head .title { font-weight: 700; font-size: 15px; max-width: 280px; }
.pcard-body { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.fields .inp.num { width: 100%; }
.pcard-side { display: flex; flex-direction: column; gap: 10px; }
.diag { position: relative; width: 100%; background: #fff; border: 1px solid #cfc6d9; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.dslot {
  position: absolute; background: var(--acc-l); border: 1px dashed var(--acc); color: var(--acc-d);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }

/* ---------- impressão ---------- */
#print-area { display: none; }
@media print {
  html, body { height: auto; overflow: visible; display: block; background: #fff; margin: 0; padding: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .pg { position: relative; overflow: hidden; break-after: page; page-break-after: always; }
  .pg:last-child { break-after: auto; page-break-after: auto; }
  .pg.land { width: 297mm; height: 210mm; }
  .pg.port { width: 210mm; height: 297mm; }
  .pg img { display: block; width: 100%; height: 100%; }
}

@media (max-width: 1200px) {
  .screen { grid-template-columns: 300px minmax(0, 1fr) 290px; }
  .pcard-body { grid-template-columns: 1fr; }
}
