/* Gerador de QR Code — mesmos tokens da Calculadora de Precificação:
   mesa de aço (fundo), folha (painéis), tinta e PEI dourado (destaque). */

:root {
  --plate: #E6E8EB;
  --sheet: #FFFFFF;
  --ink: #15171C;
  --muted: #5D636D;
  --rule: #D3D7DD;
  --field: #F4F5F7;
  --pei: #B8862B;
  --pei-deep: #8C6316;
  --loss: #CF3F2B;
  --f-filamento: #2E9C74;
  --check: #E9EBEE;

  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Martian Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius: 6px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --plate: #111317;
    --sheet: #1A1D23;
    --ink: #ECEEF1;
    --muted: #9AA1AC;
    --rule: #2B3038;
    --field: #22262D;
    --pei: #D3A447;
    --pei-deep: #E8C072;
    --loss: #FF7A63;
    --check: #2A2E35;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --plate: #111317;
  --sheet: #1A1D23;
  --ink: #ECEEF1;
  --muted: #9AA1AC;
  --rule: #2B3038;
  --field: #22262D;
  --pei: #D3A447;
  --pei-deep: #E8C072;
  --loss: #FF7A63;
  --check: #2A2E35;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plate);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  font-variation-settings: "wdth" 100;
}

:focus-visible { outline: 2px solid var(--pei); outline-offset: 2px; }

/* ---------- Topo ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 32px;
  padding: 28px var(--gutter) 20px;
  max-width: 1240px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; fill: var(--ink); }
.brand-mark .l1 { fill: var(--ferramenta, var(--pei)); }
.brand-mark .l2 { fill: color-mix(in srgb, var(--ferramenta, var(--pei)) 55%, var(--ink)); }
.brand-name {
  font-family: var(--display);
  font-variation-settings: "wdth" 125;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.01em;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-sub {
  font-variation-settings: "wdth" 62;
  font-weight: 500;
  font-size: 18px;
  color: var(--muted);
}
.top-lede { margin: 0; color: var(--muted); max-width: 52ch; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 24px;
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter) 48px;
}

/* ---------- Formulário ---------- */
.inputs { display: grid; gap: 14px; min-width: 0; }

.group {
  margin: 0;
  min-width: 0;
  padding: 20px 22px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
}
.group-title {
  float: left;
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
  font-family: var(--display);
  font-variation-settings: "wdth" 125;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.group-title + * { clear: both; }

.row { display: grid; gap: 12px; margin-top: 12px; }
.row-first { margin-top: 0; }
.row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field { display: grid; gap: 5px; min-width: 0; }
.field-gap { margin-top: 12px; }
.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--field);
  transition: border-color .15s, background .15s;
}
.input:focus-within { border-color: var(--pei); background: var(--sheet); }
.input input, .input select {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  padding: 0;
  outline: none;
}
.input select { cursor: pointer; }
.input b, .input i {
  font-style: normal;
  font-weight: 500;
  font-family: var(--mono);
  font-variation-settings: "wdth" 75;
  font-size: 11.5px;
  color: var(--muted);
}
.input-big { height: 50px; }
.input-big input {
  font-family: var(--mono);
  font-variation-settings: "wdth" 87.5;
  font-size: 18px;
  font-weight: 600;
}

.area {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  resize: vertical;
  outline: none;
  transition: border-color .15s, background .15s;
}
.area:focus { border-color: var(--pei); background: var(--sheet); }

.input-color { gap: 10px; }
.input-color input[type="color"] {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
}
.input-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.input-color input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 3px; }
.input-color code {
  font-family: var(--mono);
  font-variation-settings: "wdth" 87.5;
  font-size: 12.5px;
  color: var(--muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
  min-height: 42px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); flex: none; cursor: pointer; }
.check span { display: grid; }
.check small { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.check-block { align-items: flex-start; margin-top: 14px; min-height: 0; }
.check-block input { margin-top: 2px; }

.note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }
.note:empty { display: none; }
.note.is-warn { color: var(--pei-deep); }

/* Tipos e níveis: botões segmentados */
.kinds { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.levels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.kind { position: relative; cursor: pointer; min-width: 0; }
.kind input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.kind span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-height: 42px;
  padding: 8px 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
  text-align: center;
  transition: border-color .15s, background .15s, color .15s;
}
.kind small { font-weight: 400; color: var(--muted); font-size: 12px; font-family: var(--mono); font-variation-settings: "wdth" 87.5; }
.kind:hover span { border-color: var(--muted); }
.kind input:checked + span { border-color: var(--ink); background: var(--ink); color: var(--sheet); }
.kind input:checked + span small { color: inherit; opacity: .7; }
.kind input:focus-visible + span { outline: 2px solid var(--pei); outline-offset: 2px; }

/* ---------- Resultado ---------- */
.result {
  position: sticky;
  top: 16px;
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  overflow: hidden;
}
.stage { padding: 24px 24px 20px; }
.preview {
  aspect-ratio: 1;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  border-radius: 4px;
  background: repeating-conic-gradient(var(--check) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
  transition: opacity .15s;
}
.preview svg { display: block; width: 100%; height: 100%; }
.preview.is-empty { opacity: .15; }
.problem {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--loss);
  background: var(--field);
  font-size: 13.5px;
}
.problem.is-hint { border-left-color: var(--rule); color: var(--muted); }

.facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; }
.fact { margin: 0; padding: 12px 24px; border-top: 1px solid var(--rule); }
.fact:nth-child(odd) { border-right: 1px solid var(--rule); }
.fact dt { font-size: 12px; color: var(--muted); }
.fact dd {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-variation-settings: "wdth" 87.5;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.actions { display: grid; gap: 8px; padding: 18px 24px; border-top: 1px solid var(--rule); }
.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-name { margin-top: 6px; }
.btn {
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--sheet);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--pei-deep); border-color: var(--pei-deep); color: #fff; }
.btn-main { height: 50px; font-size: 15px; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { background: var(--field); border-color: var(--muted); color: var(--ink); }
.btn:disabled, .btn:disabled:hover { opacity: .4; cursor: not-allowed; background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.btn-ghost:disabled, .btn-ghost:disabled:hover { background: transparent; border-color: var(--rule); color: var(--ink); }

.payload { padding: 14px 24px 16px; border-top: 1px solid var(--rule); }
.payload-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 12.5px; color: var(--muted); }
.payload code {
  display: block;
  margin-top: 6px;
  max-height: 96px;
  overflow: auto;
  font-family: var(--mono);
  font-variation-settings: "wdth" 75;
  font-size: 11.5px;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
}
.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--pei-deep);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover { color: var(--ink); }
.link:disabled { opacity: .4; cursor: not-allowed; }
.status { margin: 8px 0 0; font-size: 13px; color: var(--pei-deep); }
.status:empty { display: none; }

.safety { margin: 0; padding: 14px 24px 18px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); }

.foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter) 40px;
  font-size: 12.5px;
  color: var(--muted);
}
.foot p { margin: 0; max-width: 80ch; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .result { position: static; order: -1; }
  .preview { max-width: 260px; }
}

@media (max-width: 640px) {
  .kinds { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-2, .row-3 { grid-template-columns: minmax(0, 1fr); }
  .group { padding: 18px 16px 16px; }
  .stage { padding: 20px 16px 16px; }
  .fact, .actions, .payload, .safety { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .preview, .btn, .kind span { transition: none; }
}
