:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --ink: #1b1e24;
  --muted: #6b7280;
  --line: #e2e5ea;
  --soft: #f6f7f9;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-ink: #ffffff;
  --cut: #e5262b;
  --warn-bg: #fff6e0;
  --warn-ink: #7a5200;
  --stage: #e6e8ec;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121317;
    --panel: #1b1d22;
    --ink: #eceef2;
    --muted: #9aa0aa;
    --line: #2d3037;
    --soft: #23262c;
    --accent: #8b84ff;
    --accent-soft: #2a2842;
    --accent-ink: #111;
    --warn-bg: #3a2f14;
    --warn-ink: #ffd88a;
    --stage: #0e0f12;
  }
}

* { box-sizing: border-box; }

/* barras de rolagem no tema (finas, trilho transparente) */
:root { color-scheme: light dark; --rolagem: #c3c8d1; --rolagem-hover: #9aa0aa; }
@media (prefers-color-scheme: dark) { :root { --rolagem: #3a3d46; --rolagem-hover: #565a66; } }
* { scrollbar-width: thin; scrollbar-color: var(--rolagem) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rolagem); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--rolagem-hover); }
::-webkit-scrollbar-corner { background: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.link { color: var(--accent); text-decoration: underline; cursor: pointer; }

/* topo */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
/* marca CapaCut: símbolo da logo + "Capa" na cor do texto e "Cut" no roxo da logo */
.logo { height: 28px; width: auto; display: block; }
.marca-nome { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.marca-nome b { color: #7f5efb; font-weight: 700; }
@media (prefers-color-scheme: dark) { .marca-nome b { color: #8f74ff; } }
.tag {
  font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}

/* layout */
.layout { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.panel {
  overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px;
  border-right: 1px solid var(--line);
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 12px;
}
select, input[type=number] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft);
}
#modeloInfo { margin: 8px 0 0; }
.busca { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.busca input {
  width: 100%; padding: 8px 10px 8px 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center;
}
.busca input:focus { outline: none; border-color: var(--accent); }

/* upload */
.drop {
  display: block; border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px; cursor: pointer;
  background: var(--soft); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-empty { display: flex; flex-direction: column; gap: 2px; text-align: center; padding: 10px 0; }
.drop-filled { display: flex; gap: 12px; align-items: center; }
.drop-filled > div { display: flex; flex-direction: column; min-width: 0; }
.drop-filled strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #0002; }

/* botões */
.btn {
  border: 1px solid var(--line); background: var(--soft); border-radius: 8px; padding: 7px 12px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
a.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: 9px 18px; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 12px; padding: 5px 10px; }
.btn.icon { flex: 1; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.btn-row .btn { flex: 1; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* campos */
.field { display: block; margin: 10px 0; }
.field > span { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.field output { color: var(--muted); font-variant-numeric: tabular-nums; }
.field.inline { display: flex; align-items: center; justify-content: space-between; }
.field.inline > span { margin: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 44px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: var(--soft); }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; cursor: pointer; }
.sub summary, .adv summary { cursor: pointer; }
.sub summary { font-size: 13px; color: var(--muted); padding: 4px 0; }
.adv summary { list-style: none; }
.adv summary::-webkit-details-marker { display: none; }
.adv summary h2 { margin: 0; }
.adv summary h2::after { content: "▸"; margin-left: auto; color: var(--muted); }
.adv[open] summary h2::after { content: "▾"; }
.note { font-size: 12px; background: var(--soft); border-radius: 8px; padding: 8px 10px; margin: 12px 0 8px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.num { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 6px; font-size: 12px; }
.num span { grid-column: 1 / -1; color: var(--muted); }
.num input, .num select { padding: 6px 8px; }
.num em { font-style: normal; color: var(--muted); font-size: 11px; }
.seg.small-seg { display: flex; gap: 12px; font-size: 13px; margin: 10px 0; }
.small-seg label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.holes { width: 100%; border-collapse: collapse; font-size: 12px; }
.holes th { text-align: left; color: var(--muted); font-weight: 500; padding: 2px 4px; }
.holes td { padding: 2px 2px; }
.holes td:first-child { white-space: nowrap; padding-right: 6px; }
.holes input { padding: 4px 6px; font-size: 12px; }

/* palco */
.stage-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; padding: 10px 14px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.badge.good { color: #177245; border-color: #9bd5b4; }
.badge.ok { color: #8a5b00; border-color: #f0cf87; }
.badge.low { color: #b3261e; border-color: #f2a39d; }
.stage { flex: 1; position: relative; min-height: 0; background: var(--stage); margin: 0 14px; border-radius: var(--radius); overflow: hidden; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
#stage.dragging { cursor: grabbing; }
.stage3d { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage3d:active { cursor: grabbing; }
.bar3d {
  position: absolute; bottom: 10px; left: 10px; right: 10px; z-index: 2;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; pointer-events: none;
}
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 12px;
  font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; pointer-events: auto;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.check3d input { margin: 0; accent-color: var(--accent); }
.loading3d {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px;
}
.empty-hint {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px;
  display: flex; flex-direction: column; align-items: center; pointer-events: none; font-size: 13px;
}
.empty-hint span { color: var(--muted); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 16px 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend .hint { margin-left: auto; }
.lg { display: inline-block; width: 18px; height: 0; vertical-align: middle; margin-right: 4px; }
.lg.cut { border-top: 2px solid var(--cut); }
.lg.bleed { border-top: 2px dashed var(--muted); }
.lg.cam { height: 10px; width: 10px; border-radius: 50%; background: repeating-linear-gradient(45deg, #333 0 2px, #888 2px 4px); }

/* diálogo */
dialog { border: 0; padding: 0; border-radius: 16px; background: var(--panel); color: var(--ink); max-width: min(960px, 96vw); width: 100%; }
dialog::backdrop { background: #0008; }
.dlg header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg header h2 { margin: 0; }
.x { border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.dlg-body { display: grid; grid-template-columns: 300px 1fr; gap: 18px; padding: 18px; max-height: 80vh; overflow: auto; }
.dlg-preview { margin: 0; display: flex; flex-direction: column; gap: 6px; }
#expPreview { width: 100%; height: auto; border-radius: 4px; box-shadow: 0 2px 12px #0003; background: #fff; }
.dl-list { display: flex; flex-direction: column; gap: 8px; }
.dl {
  text-align: left; border: 1px solid var(--line); background: var(--soft); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.dl span { font-size: 12px; color: var(--muted); }
.dl.primary { border-color: var(--accent); background: var(--accent-soft); }
.dl:hover { border-color: var(--accent); }
.dl.busy { opacity: .6; pointer-events: none; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.howto { margin-top: 14px; font-size: 13px; }
.howto summary { font-weight: 600; cursor: pointer; }
.howto ol { padding-left: 20px; margin: 8px 0 0; }
.howto li { margin: 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 6px 20px #0004; max-width: 90vw;
}

/* celular */
@media (max-width: 820px) {
  body { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .panel { border-right: 0; overflow: visible; padding: 16px; }
  .stage-wrap { order: -1; height: 72vh; }
  .stage { margin: 0 16px; }
  .stage-bar { padding: 10px 16px; }
  .seg button { padding: 6px 9px; font-size: 13px; }
  .topbar .btn.primary { padding: 8px 12px; }
  .tag { display: none; }
  .legend .hint { margin-left: 0; }
  .dlg-body { grid-template-columns: 1fr; }
  .dlg-preview { max-width: 260px; margin: 0 auto; }
}

/* login / assinatura */
.top-acoes { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }
.user-chip > span { display: flex; flex-direction: column; line-height: 1.2; }
.gate {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.gate-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; text-align: center;
}
.gate-brand { justify-content: center; margin-bottom: 18px; }
.gate-brand .logo { height: 40px; }
.gate-brand .marca-nome { font-size: 24px; }
.gate-card h2 { justify-content: center; font-size: 18px; }
.gate-btn { width: 100%; margin: 8px 0 10px; }
.gate-preco { font-size: 20px; font-weight: 600; margin: 6px 0; }
@media (max-width: 640px) { .user-chip > span { display: none; } }

/* envio para a cortadora */
.corte-estado { padding: 8px 10px; border-radius: 8px; background: var(--soft); margin: -2px 0 4px; }
.corte-estado.ok { color: #177245; }
.corte-estado.erro { color: #b3261e; }
@media (prefers-color-scheme: dark) { .corte-estado.ok { color: #6fd39b; } .corte-estado.erro { color: #ff9a92; } }

/* estado dos ajustes do modelo (padrão / salvos / não salvos) */
.ajustes-estado { font-size: 12px; padding: 7px 10px; border-radius: 8px; background: var(--soft); margin: 8px 0 6px; }
.ajustes-estado.salvo { color: #177245; }
.ajustes-estado.sujo { background: var(--warn-bg); color: var(--warn-ink); }
@media (prefers-color-scheme: dark) { .ajustes-estado.salvo { color: #6fd39b; } }

.modo-ajuda { margin: 6px 0 8px; }
