:root {
  --navy: #0E0F13;
  --navy-2: #1d3a59;
  --gold: #f1b83f;
  --gold-soft: #fdf3dc;
  --green: #1e9b64;
  --red: #b42335;
  --ink: #17283c;
  --ink-2: #4f6075;
  --muted: #6b7c90;
  --line: #e1e8ef;
  --bg: #f3f6fa;
  --card: #ffffff;
  --radius: 14px;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --topbar: #0E0F13;
  --field: #ffffff;
  --field-line: #cdd8e3;
  --soft: #f7f9fc;
  --soft-2: #eef2f6;
  --btn: #e7edf5;
  --accent-ink: #0E0F13;
  --link: #1d3a59;
  --sticky: #ffffffee;
  --ok-bg: #dff3ea; --ok-fg: #12643f;
  --no-bg: #fbe9ec;
  --warn-bg: #fff4d6; --warn-fg: #8a5a00;
  --info-bg: #e3ecfa; --info-fg: #1f4f96;
  --gold-line: #f3dfae;
  --m2-bg: #fff8e1; --m2-line: #f3dc8f;
  --shadow: #1b304308;
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
.hidden { display: none !important; }
h2 { margin: 0 0 16px; font-size: 21px; }
h3 { margin: 4px 0 12px; font-size: 16px; }
a { color: var(--link); }

/* ---------- Botões e campos ---------- */
button, .btn {
  border: 0; border-radius: 9px; padding: 10px 14px; cursor: pointer; font: inherit;
  font-weight: 650; font-size: 14px; background: var(--btn); color: var(--accent-ink);
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
}
button:hover { filter: brightness(.96); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--gold); color: #0E0F13; }
button.dark { background: var(--navy); color: #fff; }
button.green { background: var(--green); color: #fff; }
button.danger { background: var(--no-bg); color: var(--red); }
button.ghost { background: transparent; padding: 6px 9px; }
button.sm { padding: 6px 10px; font-size: 13px; }
label { font-size: 13px; font-weight: 650; display: block; margin: 10px 0 5px; color: var(--ink-2); }
input, select, textarea {
  width: 100%; padding: 10px 11px; border: 1px solid var(--field-line); border-radius: 8px;
  background: var(--field); font: inherit; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #FFC40088; border-color: var(--gold); }
textarea { min-height: 70px; resize: vertical; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--topbar); color: #fff; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px max(16px, calc((100vw - 1180px) / 2));
}
.brand strong { font-size: 21px; letter-spacing: .5px; display: block; }
.brand small { color: var(--gold); }
.userbox { display: flex; gap: 10px; align-items: center; font-size: 13px; color: #c9d5e2; }
.userbox button { background: var(--navy-2); color: #fff; }
.badge-demo { background: var(--gold); color: #0E0F13; border-radius: 20px; padding: 3px 9px; font-weight: 700; font-size: 11px; }
nav.tabs {
  background: var(--card); border-bottom: 1px solid var(--line); display: flex; gap: 4px; overflow-x: auto;
  padding: 8px max(16px, calc((100vw - 1180px) / 2)); position: sticky; top: 0; z-index: 5;
}
nav.tabs button { background: transparent; color: var(--ink-2); }
nav.tabs button.active { background: var(--navy); color: #fff; }
main { max-width: 1180px; margin: 22px auto 60px; padding: 0 16px; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  margin-bottom: 16px; box-shadow: 0 4px 15px var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.right { text-align: right; }

/* ---------- Indicadores ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat span { color: var(--muted); font-size: 13px; display: block; }
.stat b { font-size: 24px; display: block; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; }

/* ---------- Tabelas ---------- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.acts { text-align: right; white-space: nowrap; }
td.acts button { margin-left: 4px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--soft); }
.empty { text-align: center; color: var(--muted); padding: 26px 8px; }

.pill { display: inline-block; padding: 4px 9px; border-radius: 20px; font-size: 12px; font-weight: 650; background: var(--soft-2); color: var(--ink-2); }
.pill.Pendente { background: var(--warn-bg); color: var(--warn-fg); }
.pill.Aprovado { background: var(--ok-bg); color: var(--ok-fg); }
.pill.Recusado { background: var(--no-bg); color: var(--red); }
.pill.Concluído { background: var(--info-bg); color: var(--info-fg); }
.pill.pago { background: var(--ok-bg); color: var(--ok-fg); }
.pill.parcial { background: var(--warn-bg); color: var(--warn-fg); }
.pill.aberto { background: var(--no-bg); color: var(--red); }

/* ---------- Editor de orçamento ---------- */
.item-form { background: var(--soft); border: 1px dashed var(--field-line); border-radius: 12px; padding: 4px 14px 14px; }
.item-form .grid-item { display: grid; grid-template-columns: 2fr 1.4fr .8fr 1fr 1fr; gap: 0 10px; }
.totais { margin-left: auto; max-width: 340px; margin-top: 12px; }
.totais div { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 12px; }
.totais input { width: 140px; text-align: right; }
.totais .grand { font-size: 22px; font-weight: 800; border-top: 2px solid var(--accent-ink); margin-top: 4px; padding-top: 10px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--sticky); backdrop-filter: blur(4px); padding: 12px 0 4px; border-top: 1px solid var(--line); margin-top: 14px; }

/* ---------- Fornecedores ---------- */
.forn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.forn-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.forn-card h3 { margin: 0; }
.forn-card .margem-box { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.forn-card .margem-box input { width: 90px; font-size: 20px; font-weight: 800; text-align: right; padding: 6px 8px; }
.forn-card .margem-box span { font-size: 20px; font-weight: 800; }
.margem-input { width: 90px; text-align: right; }
.progress { height: 8px; background: var(--soft-2); border-radius: 4px; overflow: hidden; }
.progress div { height: 100%; background: var(--green); width: 0; transition: width .2s; }
.busca-forn { background: var(--gold-soft); border: 1px solid var(--gold-line); border-radius: 12px; padding: 4px 14px 12px; margin-bottom: 14px; }
.filtros-forn { display: grid; grid-template-columns: 2fr 1.3fr 1fr; gap: 8px; margin-bottom: 8px; }
#buscaFornFiltros { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.busca-forn .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.busca-forn .tags span { background: var(--soft-2); border-radius: 6px; padding: 3px 7px; font-size: 12px; color: var(--ink-2); }
.busca-forn .tags span.cor { background: var(--info-bg); color: var(--info-fg); font-weight: 700; }
.chip.destaque { background: var(--ok-bg); color: var(--ok-fg); }
.busca-forn .res-prod { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.busca-forn .res-prod h4 { margin: 0 0 2px; font-size: 14px; }
.busca-forn .res-var { margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.busca-forn .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.chip { background: var(--soft-2); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; font-weight: 600; color: var(--accent-ink); cursor: pointer; border: 1px solid transparent; text-align: left; line-height: 1.35; white-space: normal; }
.chip:hover { border-color: var(--accent-ink); background: var(--soft-2); }
.chip small { display: block; color: var(--muted); font-weight: 500; }

/* ---------- Gráfico ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--navy); color: #fff; border-radius: 8px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5; white-space: nowrap; transform: translate(-50%, -110%);
  box-shadow: 0 6px 18px #0003;
}
.bar-list div.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; margin-bottom: 10px; font-size: 14px; }
.bar-list .track { grid-column: 1 / -1; height: 8px; background: var(--soft-2); border-radius: 4px; overflow: hidden; }
.bar-list .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }

/* ---------- Diálogos ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; background: var(--card); color: var(--ink); width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px #0004; }
dialog::backdrop { background: #0b1a2a88; }
dialog form { padding: 20px; }
dialog.largo { width: min(820px, calc(100vw - 24px)); }
table.faixas td, table.faixas th { padding: 5px 4px; }
table.faixas input { width: 120px; text-align: right; padding: 7px 8px; }
table.faixas td.num { color: var(--ink-2); }
.campos-prod { gap: 0 12px; }
.prod-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.prod-tags span { background: var(--soft-2); border-radius: 6px; padding: 2px 7px; font-size: 12px; color: var(--ink-2); }
.prod-tags span.cor { background: var(--info-bg); color: var(--info-fg); font-weight: 700; }
.nova-cat { display: flex; gap: 6px; margin-top: 6px; }
.nova-cat input { flex: 1; }
#listaCats input { padding: 6px 8px; }
.faixa-lista { font-size: 13px; line-height: 1.6; }
dialog h3 { margin-bottom: 4px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--navy), #0d1b2b); }
.login-card { background: var(--card); border-radius: 18px; padding: 28px; width: min(380px, 100%); box-shadow: 0 20px 60px #0005; }
.login-card .brand strong { color: var(--accent-ink); }
.login-card .brand small { color: #b07d12; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: 0 8px 24px #0004;
  opacity: 0; pointer-events: none; transition: opacity .2s; white-space: pre-line; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; }
#toast.err { background: #b42335; }

.logo-preview { max-width: 220px; max-height: 90px; display: block; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }

@media (max-width: 820px) {
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: 1fr; }
  .item-form .grid-item { grid-template-columns: 1fr 1fr; }
  .item-form .grid-item > :first-child { grid-column: 1 / -1; }
  .filtros-forn, #buscaFornFiltros { grid-template-columns: 1fr 1fr; }
  .filtros-forn > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .grid, .grid3 { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .userbox span.email { display: none; }
  th, td { font-size: 13px; padding: 8px 5px; }
  .stat b { font-size: 19px; }
  .totais { max-width: none; }
  .brand strong { font-size: 17px; }
  .badge-demo { font-size: 10px; }
  table.cards > thead { display: none; }
}

/* Produtos dos fornecedores */
details.fp-precos { margin-top: 4px; }
details.fp-precos summary { cursor: pointer; color: var(--link); font-size: .85em; }
details.fp-precos .scroll { max-height: 320px; overflow: auto; margin-top: 6px; }
details.fp-precos table { font-size: .85em; width: 100%; }
details.fp-precos td, details.fp-precos th { padding: 3px 6px; }
.estrela { background: none; border: 0; padding: 0 6px 0 0; font-size: 1.25em; line-height: 1; cursor: pointer; color: var(--muted); box-shadow: none; min-height: 0; }
.estrela.on { color: #f5a400; }
.res-prod h4 .estrela { cursor: default; font-size: 1em; }

/* Pagamento e m² */
.pag-box { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 2px 14px 12px; margin-top: 12px; }
.meios { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.meios label, .tipo-cobranca label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; cursor: pointer; }
.meios input, .tipo-cobranca input { width: auto; min-height: 0; margin: 0; }
.pag-resumo { margin: 10px 0 0; font-weight: 600; color: var(--accent-ink); }
.pag-resumo:empty { display: none; }
.tipo-cobranca { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 12px 0 4px; }
.m2-box { background: var(--m2-bg); border: 1px solid var(--m2-line); border-radius: 10px; padding: 2px 12px 10px; margin: 8px 0 4px; }
.grid-m2 { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 0 10px; }
.m2-info { margin: 8px 0 0; font-size: .9em; }
.m2-info b { color: var(--accent-ink); }
#listaM2 input { min-width: 0; }
input[readonly] { background: var(--soft-2); color: var(--ink-2); }
@media (max-width: 700px) { .grid-m2 { grid-template-columns: 1fr 1fr; } .grid-m2 > :first-child { grid-column: 1 / -1; } }

/* Aprovação e andamento do pedido */
.btn.green { background: var(--green); color: #fff; }
.aprov-info { border-radius: 10px; padding: 10px 14px; margin-top: 12px; font-size: 14px; line-height: 1.5; background: var(--soft); }
.aprov-info.ok { background: var(--ok-bg); color: var(--ok-fg); }
.aprov-info.no { background: var(--no-bg); color: var(--red); }
.tag-cli { display: inline-block; margin-top: 3px; font-size: 11.5px; font-weight: 650; color: var(--ok-fg); }
.tag-cli.no { color: var(--red); }
.tag-venc { display: inline-block; margin-top: 3px; font-size: 11.5px; font-weight: 650; color: var(--warn-fg); }
select.etapa-sel { min-height: 0; padding: 5px 8px; font-size: 12.5px; width: auto; margin-top: 4px; }
.pill.etapa { background: var(--info-bg); color: var(--info-fg); }
/* Instalar app */
.userbox button.instalar { background: var(--gold); color: #0E0F13; }
.inst-qr { display: flex; justify-content: center; margin-top: 8px; min-height: 40px; }
.inst-qr img, .inst-qr canvas { width: 190px; height: 190px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.inst-passos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; font-size: 14px; }
.inst-passos ol { margin: 6px 0 0; padding-left: 20px; line-height: 1.55; }
@media (max-width: 600px) { .inst-passos { grid-template-columns: 1fr; } .userbox button.instalar { padding: 7px 9px; } }
#listaOrc td.acts { white-space: normal; min-width: 250px; }
#listaOrc td.acts button { margin: 3px 0 3px 4px; }
#listaOrc td:nth-child(2) { min-width: 150px; }
@media (max-width: 600px) { #listaOrc td.acts { min-width: 0; } #listaOrc td.acts button { margin: 6px 6px 0 0; } }

/* ---------- Tema escuro ---------- */
:root[data-theme="dark"] {
  --bg: #0e1620; --card: #17212d; --field: #101923; --field-line: #2e3d4f; --line: #263446;
  --ink: #e6edf5; --ink-2: #b6c3d1; --muted: #8b9cb0;
  --soft: #1c2836; --soft-2: #233143; --btn: #243346; --accent-ink: #a9c8ff; --link: #8fb9ff;
  --topbar: #0a121b; --navy: #24456e; --navy-2: #2a4a70; --sticky: #17212df2;
  --red: #ff8f9a; --green: #24a36b;
  --ok-bg: #123a2a; --ok-fg: #74d8a8; --no-bg: #3e1a21;
  --warn-bg: #3a2f10; --warn-fg: #f3cb6b; --info-bg: #1a2c48; --info-fg: #a3c4ff;
  --gold-soft: #262113; --gold-line: #4a3e1d; --m2-bg: #262113; --m2-line: #4a3e1d;
  --shadow: #0006;
  color-scheme: dark;
}
:root[data-theme="dark"] dialog::backdrop { background: #000a; }
:root[data-theme="dark"] .login-wrap { background: linear-gradient(160deg, #0a121b, #05090e); }
:root[data-theme="dark"] .logo-preview { background: #fff; }
.tema-btn { font-size: 15px; line-height: 1; }

/* ---------- Abas: ícones e menu "Mais" ---------- */
nav.tabs .ic { display: none; }
nav.tabs .mais { display: none; }
.mais-menu { display: none; }

/* ---------- Celular ---------- */
@media (max-width: 700px) {
  :root { --nav-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); }
  body { padding-bottom: calc(var(--nav-h) + var(--safe-b)); }
  .topbar { padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; position: sticky; top: 0; z-index: 6; }
  .brand small { display: none; }
  .brand strong { font-size: 16px; }
  .userbox { gap: 6px; }
  .userbox button { padding: 8px 10px; min-height: 38px; }
  .userbox button.instalar { font-size: 0; padding: 8px 10px; }
  .userbox button.instalar::before { content: '📲'; font-size: 16px; }

  /* barra de abas fixa embaixo */
  nav.tabs {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20; overflow: visible;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; padding: 4px 4px calc(4px + var(--safe-b));
    border-top: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -4px 16px var(--shadow);
  }
  nav.tabs button { flex-direction: column; gap: 2px; padding: 6px 2px; min-height: 52px; font-size: 11px; font-weight: 600; border-radius: 10px; justify-content: center; }
  nav.tabs button .ic { display: block; font-size: 20px; line-height: 1; }
  nav.tabs button .tx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  nav.tabs button.active { background: var(--soft-2); color: var(--accent-ink); }
  nav.tabs button.extra { display: none; }
  nav.tabs .mais { display: flex; }
  .mais-menu {
    display: flex; flex-direction: column; gap: 4px; position: fixed; right: 8px; z-index: 21;
    bottom: calc(var(--nav-h) + var(--safe-b) + 6px); background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; padding: 6px; box-shadow: 0 10px 30px #0004; min-width: 230px;
  }
  .mais-menu.hidden { display: none !important; }
  .mais-menu button { background: transparent; justify-content: flex-start; padding: 13px 12px; font-size: 15px; color: var(--ink); }
  .mais-menu button.active { background: var(--soft-2); color: var(--accent-ink); }

  main { margin: 12px auto 24px; padding: 0 10px; }
  .panel { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
  h2 { font-size: 19px; margin-bottom: 10px; }
  .panel-head > button, .panel-head .toolbar button { min-height: 42px; }

  /* toques e campos maiores (16px evita o zoom automático do iPhone) */
  input, select, textarea { font-size: 16px; min-height: 46px; }
  textarea { min-height: 80px; }
  button { min-height: 42px; }
  button.sm { min-height: 38px; padding: 8px 12px; }
  .toolbar input, .toolbar select { min-width: 0; width: 100%; flex: 1 1 100%; }
  .meios label, .tipo-cobranca label { min-height: 36px; }
  .meios input, .tipo-cobranca input { width: 20px; height: 20px; }

  /* barra de ações do editor fixa acima das abas */
  .sticky-actions {
    position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 15; margin: 0;
    padding: 8px 10px; flex-wrap: nowrap; overflow-x: auto; border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px var(--shadow); -webkit-overflow-scrolling: touch;
  }
  .sticky-actions button { flex: none; }
  #orcEditor { padding-bottom: 64px; }
  .totais .grand { font-size: 20px; }

  /* janelas abrem de baixo, ocupando a largura toda */
  dialog, dialog.largo {
    width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0;
    padding-bottom: var(--safe-b); overflow-y: auto;
  }
  dialog .actions { position: sticky; bottom: 0; background: var(--card); padding: 10px 0 4px; }
  dialog .actions button { flex: 1; justify-content: center; }

  #toast { bottom: calc(var(--nav-h) + var(--safe-b) + 14px); }
  .stat { padding: 12px; }
  .stat b { font-size: 18px; }
  .forn-grid { grid-template-columns: 1fr; }
  #buscaFornFiltros { grid-template-columns: 1fr 1fr; }
  .grid-m2 input { min-width: 0; }
  table.faixas input { width: 92px; }
}
@media (max-width: 700px) {
  .brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
  /* cartões da lista de orçamentos */
  #listaOrc tr[data-open] { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "num tot" "cli cli" "st st" "acts acts"; }
  #listaOrc tr[data-open] td:nth-child(1) { grid-area: num; }
  #listaOrc tr[data-open] td:nth-child(2) { grid-area: cli; min-width: 0; font-weight: 600; }
  #listaOrc tr[data-open] td:nth-child(3) { grid-area: tot; font-size: 16px; font-weight: 800; align-self: start; }
  #listaOrc tr[data-open] td:nth-child(4) { grid-area: st; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
  #listaOrc tr[data-open] td:nth-child(4) > div { margin: 0; }
  #listaOrc tr[data-open] td.acts { grid-area: acts; }
  #listaOrc tr[data-open] { padding: 12px 0; }
}
@media (max-width: 700px) { .chart { overflow-x: auto; } .chart svg { min-width: 640px; } }

/* Esconde o selo "Powered by Netlify" que a hospedagem injeta */
#nl-badge-frame, iframe[title="Powered by Netlify"] { display: none !important; visibility: hidden !important; pointer-events: none !important; }

/* ---------- Facilidade de uso ---------- */
.nowrap { white-space: nowrap; }
.sec-tit { margin: 18px 0 10px; font-size: 15px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.dica { color: var(--muted); font-size: 13px; margin: 6px 0 0; line-height: 1.45; }

/* atalhos do painel */
.atalhos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.atalho { flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 16px; min-height: 104px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink); box-shadow: 0 1px 2px var(--shadow); white-space: normal; min-width: 0; }
.atalho:hover { border-color: var(--gold); filter: none; }
.atalho .ai { font-size: 26px; line-height: 1; margin-bottom: 4px; }
.atalho .at { font-size: 16px; font-weight: 750; }
.atalho small { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.atalho.principal { background: var(--gold); border-color: var(--gold); color: #0E0F13; }
.atalho.principal small { color: #0E0F13cc; }
.atalho.principal .at { font-size: 19px; }

/* primeiros passos */
.primeiros { border: 2px dashed var(--gold); }
.primeiros h3 small { font-weight: 500; font-size: 13px; }
.pp-lista { list-style: none; padding: 0; margin: 0; }
.pp-lista li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pp-lista li:last-child { border-bottom: 0; }
.pp-lista li > span:first-child { width: 22px; text-align: center; font-weight: 800; color: var(--muted); }
.pp-lista li.feito > span:first-child { color: var(--green); }
.pp-lista li.feito .pp-txt { color: var(--muted); text-decoration: line-through; }
.pp-txt { flex: 1; }

/* editor em passos */
.editor-topo { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.editor-topo h2 { margin: 0; }
.passos-guia { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 12px; counter-reset: pg; }
.passos-guia li { flex: 1; counter-increment: pg; }
.passos-guia a { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px; border-radius: 10px; background: var(--soft);
  color: var(--ink-2, var(--ink)); text-decoration: none; font-weight: 650; font-size: 14px; border: 1px solid var(--line); }
.passos-guia a::before { content: counter(pg); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--field-line); font-size: 12px; font-weight: 800; }
.passos-guia li.feito a::before { content: '✔'; background: var(--green); border-color: var(--green); color: #fff; }
.passo { scroll-margin-top: 80px; }
.passo-tit { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 18px; }
.passo-tit .num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #0E0F13; font-weight: 800; font-size: 15px; flex: none; }
.como-add { display: flex; flex-wrap: wrap; gap: 4px 10px; background: var(--soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; line-height: 1.5; }
.como-add > b { width: 100%; }
.itens-tit { margin: 18px 0 6px; font-size: 15px; }
details.mais-det { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.mais-det summary { cursor: pointer; color: var(--link); font-weight: 600; padding: 6px 0; }
#btnAddItem { font-size: 15px; padding: 12px 18px; }

/* campo com problema */
@keyframes piscaErro { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 20%, 60% { box-shadow: 0 0 0 4px var(--red); } }
.campo-erro { animation: piscaErro 1.3s ease 2; border-color: var(--red) !important; border-radius: 10px; }

/* ajuda */
.ajuda-btn { white-space: nowrap; }
.ajuda-texto { line-height: 1.6; font-size: 15px; max-height: 60vh; overflow-y: auto; }
.ajuda-texto ul, .ajuda-texto ol { padding-left: 20px; }
.ajuda-texto li { margin-bottom: 6px; }
.ajuda-menu { display: grid; gap: 8px; }
.ajuda-menu button { justify-content: flex-start; padding: 12px; }

@media (max-width: 820px) {
  .atalhos { grid-template-columns: 1fr 1fr; }
  .atalho.principal { grid-column: 1 / -1; min-height: 84px; }
}
@media (max-width: 700px) {
  .atalhos { gap: 8px; }
  .atalho { padding: 12px; min-height: 92px; }
  .atalho .at { font-size: 15px; }
  .ajuda-btn .tx { display: none; }
  .passos-guia { position: sticky; top: calc(58px + env(safe-area-inset-top, 0px)); z-index: 5; background: var(--bg); padding: 6px 0; margin: -6px 0 8px; }
  .passos-guia a { flex-direction: column; gap: 2px; font-size: 11.5px; padding: 6px 2px; }
  .passo-tit { font-size: 17px; }
  .editor-topo h2 { font-size: 18px; }
  #btnAddItem { width: 100%; justify-content: center; }
}

/* =====================================================================
   Identidade visual nova — Color Designer (manual v1)
   Grafite #0E0F13 · Off-white #F5F5F2 · Amarelo #FFC400
   Espectro só em detalhes · Títulos em Sora · Textos em Manrope
   ===================================================================== */
:root {
  --navy: #0E0F13; --navy-2: #22252D;
  --gold: #FFC400; --gold-soft: #FFF6D6; --gold-line: #F3E2A6;
  --green: #1E9A5F; --red: #C4183C;
  --ink: #0E0F13; --ink-2: #3A3D46; --muted: #6B6E78;
  --line: #E4E4DE; --bg: #F3F3EF; --card: #FFFFFF;
  --topbar: #0E0F13; --field: #FFFFFF; --field-line: #D3D3CC;
  --soft: #F7F7F4; --soft-2: #ECECE6; --btn: #E9E9E4;
  --accent-ink: #0E0F13; --link: #5B22E0; --sticky: #FFFFFFEE;
  --series-1: #00B4D8; --series-2: #E6007E;
  --info-bg: #E2F5FA; --info-fg: #00657A;
  --m2-bg: #FFF8DD; --m2-line: #F3DC8F;
  --shadow: #0E0F130D;
  --espectro: linear-gradient(90deg, #E6007E, #FF6B00, #FFC400, #2BB673, #00B4D8, #6A2CF5);
  --f-titulo: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  --f-texto: "Manrope", "Helvetica Neue", Arial, sans-serif;
  font-family: var(--f-texto);
}
:root[data-theme="dark"] {
  --bg: #0E0F13; --card: #16181E; --field: #111216; --field-line: #343844; --line: #2C3039;
  --ink: #F5F5F2; --ink-2: #D6D7DB; --muted: #A3A6AE;
  --soft: #1B1D24; --soft-2: #22252D; --btn: #22252D; --accent-ink: #F5F5F2; --link: #7FD8EC;
  --topbar: #0A0B0E; --navy: #2C3039; --navy-2: #22252D; --sticky: #16181EF2;
  --gold-soft: #2A2410; --gold-line: #4A3E14; --m2-bg: #2A2410; --m2-line: #4A3E14;
  --info-bg: #0F2A33; --info-fg: #7FD8EC;
  --shadow: #0008;
}
body { font-family: var(--f-texto); }
h1, h2, h3, h4, .passo-tit, .atalho .at, .stat b, .totais .grand, .sec-tit, .editor-topo h2 { font-family: var(--f-titulo); letter-spacing: -.01em; }
button, input, select, textarea { font-family: var(--f-texto); }
.stat b { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* topo grafite com a faixa do espectro */
@media (min-width: 701px) { .topbar { position: relative; } }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--espectro); }
.brand { display: flex; flex-direction: column; gap: 3px; }
.brand .logo { height: 30px; width: auto; display: block; }
.brand small { color: #A3A6AE; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-family: var(--f-titulo); font-weight: 600; }
.userbox { color: #A3A6AE; }
.userbox button { background: #22252D; color: #F5F5F2; }
.badge-demo { background: var(--gold); color: #0E0F13; }

/* abas */
nav.tabs button { font-weight: 600; }
nav.tabs button.active { background: #0E0F13; color: #F5F5F2; }
:root[data-theme="dark"] nav.tabs button.active { background: #F5F5F2; color: #0E0F13; }

/* botões */
button.primary, .atalho.principal, .passo-tit .num { background: var(--gold); color: #0E0F13; }
button.dark { background: #0E0F13; color: #F5F5F2; }
:root[data-theme="dark"] button.dark { background: #F5F5F2; color: #0E0F13; }
.atalho:hover { border-color: #0E0F13; }
:root[data-theme="dark"] .atalho:hover { border-color: var(--gold); }
.atalho.principal { position: relative; overflow: hidden; }
.atalho.principal::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--espectro); }

/* tela de entrada */
.login-wrap { background: #0E0F13; position: relative; }
.login-wrap::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--espectro); }
.login-card { position: relative; overflow: hidden; }
.login-card .brand { margin-bottom: 8px; }
.login-card .brand .logo { height: 40px; }
.login-card .brand small { color: var(--muted); }
.login-card .logo-neg { display: none !important; }
:root[data-theme="dark"] .login-card .logo-pos { display: none !important; }
:root[data-theme="dark"] .login-card .logo-neg { display: block !important; }
:root[data-theme="dark"] .login-wrap { background: #050608; }

/* detalhes com o espectro */
.panel-head h2::after, section > .panel > h2::after { content: ''; display: block; width: 36px; height: 3px; border-radius: 2px; background: var(--espectro); margin-top: 6px; }
.primeiros { border-color: var(--gold); }
.passos-guia li.feito a::before { background: #2BB673; border-color: #2BB673; }

@media (max-width: 700px) {
  .brand .logo { height: 22px; }
  .brand small { display: none; }
  nav.tabs button.active { background: var(--soft-2); color: var(--ink); }
  nav.tabs button.active .ic { filter: none; }
  nav.tabs button.active::before { content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--espectro); }
  nav.tabs button { position: relative; }
}

/* ícones de linha (manual: traço único, sem excesso de emojis) */
.atalho .ai { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--soft-2); position: relative; }
.atalho .ai svg { width: 22px; height: 22px; }
.atalho .ai::after { content: ''; position: absolute; right: -2px; top: -2px; width: 9px; height: 9px; border-radius: 50%; background: conic-gradient(#E6007E, #FF6B00, #FFC400, #2BB673, #00B4D8, #6A2CF5, #E6007E); }
.atalho.principal .ai { background: #0E0F13; color: #FFC400; }
.mais-menu button svg { width: 20px; height: 20px; flex: none; }
nav.tabs .ic svg { width: 22px; height: 22px; display: block; margin: 0 auto; }

/* ---------- Ver orçamento na tela ---------- */
dialog.tela-cheia { position: fixed; inset: 0; width: auto; max-width: none; height: auto; max-height: none; margin: 0; border-radius: 0; padding: 0;
  display: none; flex-direction: column; background: #3A3D46; overflow: hidden; }
dialog.tela-cheia[open] { display: flex; }
.ver-topo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background: #0E0F13; color: #F5F5F2; position: relative; }
.ver-topo::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--espectro); }
.ver-tit { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ver-tit b { font-family: var(--f-titulo); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ver-tit small { color: #A3A6AE; font-size: 12px; }
.ver-abas { display: flex; gap: 4px; background: #22252D; border-radius: 10px; padding: 3px; }
.ver-abas button { background: transparent; color: #D6D7DB; padding: 8px 12px; font-size: 13.5px; }
.ver-abas button.active { background: #FFC400; color: #0E0F13; }
.ver-fechar { background: #22252D; color: #F5F5F2; }
.ver-corpo { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px 12px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ver-corpo.hidden { display: none !important; }
.ver-corpo.ampliado { align-items: flex-start; }
.ver-zoom { background: #22252D; color: #F5F5F2; }
.ver-folha { background: #fff; box-shadow: 0 6px 24px #0007; border-radius: 2px; max-width: 100%; height: auto; }
#verPaginaBox { padding: 0; }
#verPagina { border: 0; width: min(100%, 680px); flex: 1; min-height: 100%; background: var(--bg); }
.ver-carregando { color: #F5F5F2; margin-top: 40px; text-align: center; }
.ver-rodape { background: #0E0F13; color: #D6D7DB; font-size: 13px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); text-align: center; }
@media (max-width: 700px) {
  dialog.tela-cheia { inset: 0; width: auto; max-width: none; height: auto; max-height: none; margin: 0; border-radius: 0; padding-bottom: 0; }
  .ver-topo { gap: 8px; }
  .ver-abas { order: 3; width: 100%; }
  .ver-abas button { flex: 1; justify-content: center; }
  .ver-corpo { padding: 10px 6px; }
}
.logo-marca { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: inline-block; }
.logo-marca img { height: 30px; display: block; }

/* ---------- Listas em cartões no celular (cada linha vira um cartão com títulos) ---------- */
@media (max-width: 700px) {
  table.cards { display: block; width: 100%; }
  table.cards > thead { display: none; }
  table.cards > tbody { display: block; }
  table.cards > tbody > tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.cards > tbody > tr > td { display: block; border: 0; padding: 3px 0; text-align: left; white-space: normal; min-width: 0; overflow-wrap: anywhere; }
  table.cards > tbody > tr > td:first-child { font-size: 15px; padding-bottom: 6px; }
  /* demais campos: título à esquerda, valor à direita */
  table.cards > tbody:not(#listaOrc) > tr > td[data-label]:not(:first-child):not(.acts):not(.empty) {
    position: relative; padding: 5px 0 5px 42%; text-align: right; font-size: 14px; min-height: 26px; }
  table.cards > tbody:not(#listaOrc) > tr > td[data-label]:not(:first-child):not(.acts):not(.empty)::before {
    content: attr(data-label); position: absolute; left: 0; top: 6px; width: 40%; text-align: left; color: var(--muted); font-size: 12.5px; font-weight: 600; }
  table.cards > tbody:not(#listaOrc) > tr > td[data-label]:not(:first-child) input,
  table.cards > tbody:not(#listaOrc) > tr > td[data-label]:not(:first-child) select { width: 100%; text-align: right; }
  table.cards > tbody:not(#listaOrc) > tr > td[data-label]:not(:first-child):has(input, select)::before { top: 50%; transform: translateY(-50%); }
  table.cards > tbody > tr > td:first-child input { width: 100%; }
  table.cards > tbody > tr > td.acts { padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
  table.cards > tbody > tr > td.acts::before { display: none; }
  table.cards > tbody > tr > td.acts button { margin: 0; }
  table.cards > tbody > tr > td.empty { text-align: center; padding: 18px 0; }
  table.cards > tbody > tr > td.faixa-lista { display: block !important; }
  table.cards > tbody > tr > td.faixa-lista::before { display: block !important; margin-bottom: 4px; max-width: none !important; }
  /* lista de orçamentos mantém o layout próprio */
  #listaOrc tr[data-open] { display: grid; }
  /* tabela de preços dentro do produto: fica como tabela normal */
  details.fp-precos table { display: table; width: 100%; }
  details.fp-precos table td, details.fp-precos table th { display: table-cell; font-size: 12.5px; padding: 4px 6px; }
  .estrela { vertical-align: middle; }
  /* aba ativa no tema escuro do celular */
  :root[data-theme="dark"] nav.tabs button.active { background: var(--soft-2); color: var(--ink); }
}
@media (max-width: 700px) {
  .topbar { gap: 8px; }
  .topbar .brand { flex: 1 1 auto; min-width: 0; }
  .topbar .brand .logo { max-width: 100%; height: auto; max-height: 22px; }
  .userbox { flex: none; gap: 5px; }
  .userbox button { padding: 8px 9px; }
  .badge-demo { display: none; }
}
@media (max-width: 360px) { .topbar .brand .logo { max-height: 18px; } .userbox button { padding: 7px 7px; } }

/* Janela Enviar ao cliente */
.dlg-enviar { width: min(560px, calc(100vw - 24px)); }
.dlg-enviar textarea { width: 100%; min-height: 190px; font-size: 14px; line-height: 1.45; }
.enviar-bts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.enviar-bts button { justify-content: center; white-space: normal; min-width: 0; }
@media (max-width: 520px) { .enviar-bts { grid-template-columns: 1fr; } }
.tag-cobrar { display: inline-block; margin-top: 3px; font-size: 11.5px; font-weight: 700; color: var(--red); }
button.cobrar { background: #FFC400; color: #0E0F13; border-color: #FFC400; font-weight: 700; }
button.cobrar:hover { filter: brightness(.95); }
