[hidden] { display: none !important; }
:root {
  --fundo: #f3f4f6;
  --painel: #ffffff;
  --borda: #dde1e6;
  --texto: #1f2933;
  --suave: #64707d;
  --accent: #1d4ed8;
  --accent-esc: #1e3a8a;
  --linha-alt: #f8f9fb;
  --erro: #b42318;
  --raio: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, Roboto, "Segoe UI", sans-serif; font-size: 14px; color: var(--texto);
  background: var(--fundo); display: flex; flex-direction: column;
}
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); margin: 16px 0 6px; }

.topo {
  height: 48px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: #111827; color: #fff;
}
.marca { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.marca small { font-weight: 400; color: #9ca3af; font-size: 13px; }
.logo { color: #fbbf24; }
.beta { font-size: 12px; color: #9ca3af; border: 1px solid #374151; padding: 2px 8px; border-radius: 99px; }

.layout { flex: 1; display: grid; grid-template-columns: 290px 1fr 380px; min-height: 0; }
.painel, .folha { background: var(--painel); padding: 16px; overflow-y: auto; }
.painel { border-right: 1px solid var(--borda); }
.folha { border-left: 1px solid var(--borda); }

.abas { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden; margin-bottom: 14px; }
.aba { border: 0; background: var(--linha-alt); padding: 8px; font: inherit; font-weight: 500; color: var(--suave); cursor: pointer; }
.aba.ativa { background: var(--accent); color: #fff; }
textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--borda); border-radius: var(--raio); font: inherit; resize: vertical; }
.propostas { display: grid; gap: 10px; margin-top: 12px; }
.proposta { border: 1px solid var(--borda); border-radius: var(--raio); padding: 8px; background: var(--linha-alt); }
.proposta img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 4px; display: block; }
.proposta-cab { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 12px; }
.proposta-cab b { font-size: 13px; }
.proposta-cab span { color: var(--suave); }
.proposta .btn { width: 100%; margin-top: 6px; }
.soltar {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 130px;
  border: 1.5px dashed #b8c0cc; border-radius: var(--raio); color: var(--suave); cursor: pointer;
  padding: 10px; background: var(--linha-alt); font-size: 13px;
}
.soltar.sobre { border-color: var(--accent); background: #eef2ff; }
.soltar img { max-width: 100%; max-height: 180px; }

.campo { margin-bottom: 10px; }
.campo label { display: flex; justify-content: space-between; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
.campo output { color: var(--suave); font-weight: 400; }
.campo small, .dica, .obs { color: var(--suave); font-size: 12px; display: block; margin-top: 3px; }
input[type=number], input:not([type]), select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--borda); border-radius: var(--raio);
  font: inherit; background: #fff; color: var(--texto);
}
input[type=range] { width: 100%; accent-color: var(--accent); }
.linha2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 6px; margin: 4px 0 12px; font-size: 13px; cursor: pointer; }
.check.mini { margin: 0; white-space: nowrap; }

.btn {
  border: 1px solid var(--borda); background: #fff; color: var(--texto); border-radius: var(--raio);
  padding: 7px 12px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--linha-alt); }
.btn.primario { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; padding: 10px; margin-top: 4px; }
.btn.primario:hover { background: var(--accent-esc); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ativo { background: #eef2ff; border-color: var(--accent); color: var(--accent); }
.aviso { color: var(--erro); font-size: 13px; }

.area-sim { display: flex; min-width: 0; min-height: 0; }
.vazio { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; }
.vazio > div { max-width: 520px; color: var(--suave); line-height: 1.6; }
.vazio h1 { color: var(--texto); }
.sim { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sim-barra {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 12px;
  background: var(--painel); border-bottom: 1px solid var(--borda);
}
.grupo { display: flex; gap: 6px; align-items: center; }
.grupo select { width: auto; }
.tela { flex: 1; position: relative; overflow: hidden; background: #e5e7eb; cursor: grab; min-height: 300px; }
.tela:active { cursor: grabbing; }
.tela canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tela #mapa { position: absolute; inset: 0; margin: auto; max-width: 92%; max-height: 92%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.15); }
.selo {
  position: absolute; left: 12px; top: 12px; background: rgba(17,24,39,.82); color: #fff;
  padding: 6px 10px; border-radius: var(--raio); font-size: 12px; display: flex; gap: 8px; align-items: center;
}
.selo i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; border: 1px solid rgba(255,255,255,.5); }
.agulha {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.25); pointer-events: none;
}
.linha-tempo { background: var(--painel); border-top: 1px solid var(--borda); padding: 8px 12px; }
.tempos { display: flex; justify-content: space-between; font-size: 12px; color: var(--suave); font-variant-numeric: tabular-nums; }

.folha-cab { display: flex; justify-content: space-between; align-items: center; }
.folha-cab h2 { margin: 0; }
.desenho { margin: 10px 0; font-size: 13px; }
.tabela-kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela-kv td { padding: 4px 6px; border-bottom: 1px solid #eef0f3; }
.tabela-kv td:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.tabela-kv tr.destaque td { background: #fffbeb; font-weight: 600; }
.tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela th { text-align: left; font-weight: 600; font-size: 12px; color: var(--suave); border-bottom: 1px solid var(--borda); padding: 5px 4px; }
.tabela td { padding: 4px; border-bottom: 1px solid #eef0f3; }
.tabela tbody tr:nth-child(even) { background: var(--linha-alt); }
.tabela tbody tr.atual { background: #eef2ff; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela .amostra { width: 34px; height: 14px; border: 1px solid #9aa3ae; display: inline-block; vertical-align: middle; border-radius: 2px; }
.tabela [contenteditable] { outline: none; border-radius: 3px; padding: 1px 3px; min-width: 18px; display: inline-block; }
.tabela [contenteditable]:focus { background: #fff; box-shadow: 0 0 0 1.5px var(--accent); }
.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.downloads a { text-decoration: none; text-align: center; }
.downloads a.principal { grid-column: 1 / -1; background: var(--accent); color: #fff; border-color: var(--accent); }

.carregando {
  position: fixed; inset: 0; background: rgba(255,255,255,.75); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; z-index: 10; font-weight: 500;
}
.spin { width: 34px; height: 34px; border: 3px solid #c7d2fe; border-top-color: var(--accent); border-radius: 50%; animation: gira 0.8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

.impressao { display: none; }

.avancado { border: 1px solid var(--borda); border-radius: var(--raio); padding: 0 10px; margin-bottom: 12px; }
.avancado summary { cursor: pointer; padding: 9px 0; font-weight: 500; font-size: 13px; color: var(--suave); }
.avancado[open] summary { margin-bottom: 4px; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.zoom .btn { width: 36px; height: 36px; padding: 0; font-size: 18px; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tela canvas { touch-action: pan-y; }

/* Tablet: simulador ao lado do painel, folha embaixo em duas colunas */
@media (max-width: 1100px) {
  body { height: auto; }
  .layout { grid-template-columns: 270px 1fr; }
  .painel { overflow: visible; }
  .tela { height: 72vh; min-height: 360px; flex: none; }
  .area-sim { align-self: start; position: sticky; top: 0; }
  .folha { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--borda);
           display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; align-content: start; }
  .folha > .folha-cab, .folha > .desenho { grid-column: 1 / -1; }
  .folha > #f-stats { grid-row: span 6; }
}

/* Celular: tudo em uma coluna, sem rolagem lateral */
@media (max-width: 720px) {
  body { height: auto; }
  .topo { height: 44px; padding: 0 12px; }
  .so-desk { display: none; }
  .layout { display: block; }
  .painel, .folha { padding: 14px 16px; }
  .painel { border-right: 0; border-bottom: 1px solid var(--borda); }
  .folha { display: block; border-top: 1px solid var(--borda); }
  .vazio { padding: 24px 16px; }
  .vazio h1 { font-size: 19px; }
  .area-sim { position: static; }
  /* barra do simulador numa linha só, rolando de lado */
  .sim-barra { padding: 8px; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .sim-barra::-webkit-scrollbar { display: none; }
  .grupo { flex: none; gap: 6px; }
  .tempos { flex-direction: column; gap: 2px; }
  .sim-barra .btn, .sim-barra select { padding: 7px 9px; }
  .tela { height: min(100vw, 72vh); min-height: 0; flex: none; }
  .selo { left: 8px; top: 8px; right: 52px; font-size: 11px; flex-wrap: wrap; }
  .propostas { grid-template-columns: 1fr 1fr; }
  .proposta { padding: 6px; }
  .proposta-cab span { display: none; }
  .proposta .btn { font-size: 13px; padding: 7px 4px; white-space: normal; }
  .downloads { grid-template-columns: 1fr 1fr; }
  .tabela, .tabela-kv { font-size: 13px; }
  /* iOS dá zoom na página ao focar campo com fonte < 16px */
  input, select, textarea { font-size: 16px !important; }
  .btn.primario { padding: 12px; font-size: 15px; }
  .soltar { min-height: 110px; }
}

/* ---------- Impressão: imita a folha do Wilcom ---------- */
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; display: block; height: auto; }
  .topo, .layout, .carregando { display: none !important; }
  .impressao { display: block; font-size: 11px; color: #000; }
  .imp-cab { display: grid; grid-template-columns: 1fr 210px; border: 1px solid #000; }
  .imp-cab > div { padding: 6px 8px; }
  .imp-cab > div + div { border-left: 1px solid #000; }
  .imp-cab h1 { font-size: 18px; margin: 0 0 2px; }
  .imp-corpo { display: grid; grid-template-columns: 1fr 230px; border: 1px solid #000; border-top: 0; }
  .imp-corpo > div + div { border-left: 1px solid #000; padding: 6px 8px; }
  .imp-img { display: flex; align-items: center; justify-content: center; background: #eee; }
  .imp-img img { max-width: 100%; max-height: 175mm; }
  .imp-kv { width: 100%; border-collapse: collapse; }
  .imp-kv td { padding: 1px 0; }
  .imp-kv td:last-child { text-align: right; }
  .imp-seq { width: 100%; border-collapse: collapse; margin-top: 6px; }
  .imp-seq th { text-align: left; border-bottom: 1px solid #000; }
  .imp-seq td, .imp-seq th { padding: 1px 3px; }
  .imp-seq i { display: inline-block; width: 30px; height: 11px; border: 1px solid #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .imp-rod { display: flex; justify-content: space-between; border: 1px solid #000; border-top: 0; padding: 3px 8px; }
}
