:root {
  --surface: #fcfcfb; --bg: #f3f4f7; --card: #fff; --ink: #0b0b0b; --ink2: #52514e; --muted: #7a7974; --line: #e6e6e2;
  --primary: #2a78d6; --primary-soft: #e8f1fc; --primary-ink: #1c5cab;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --good: #0ca30c; --good-ink: #006300; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --radius: 12px; --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary-ink); }
button { font: inherit; cursor: pointer; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }

.layout { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: #12161f; color: #c9ccd3; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; padding: 4px 10px 18px; }
.side .logo img { width: 30px; height: 30px; border-radius: 8px; }
.side a { color: inherit; text-decoration: none; padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.side a:hover { background: #1d2330; }
.side a.on { background: #26304a; color: #fff; }
.side .foot { margin-top: auto; font-size: 12px; padding: 10px 12px; border-top: 1px solid #252b38; }
.side .foot button { background: none; border: 0; color: #8fa2c6; padding: 0; margin-top: 4px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink2); }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1100px) { .g2, .g3 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f6f6f4; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-ink); }
.btn-danger { color: var(--critical); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, select.input, textarea.input { width: 100%; padding: 8px 10px; border: 1px solid #d6d6d1; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink2); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.error { color: var(--critical); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--primary-ink); border-color: var(--primary); font-weight: 600; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--ink2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid #f0f0ed; vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #fafaf8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #f0efec; color: var(--ink2); white-space: nowrap; }
.pill.valida, .pill.publicado, .pill.ativo { background: #e3f4e3; color: var(--good-ink); }
.pill.suspeita, .pill.rascunho, .pill.pausado { background: #fff3d6; color: #7a5200; }
.pill.rejeitada, .pill.encerrado { background: #fbe5e5; color: #9b2222; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .lab { font-size: 12px; color: var(--ink2); }
.kpi .val { font-size: 26px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .det { font-size: 12px; color: var(--muted); }
.meter { height: 8px; background: #ecebe7; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter > div { height: 100%; background: var(--primary); border-radius: 99px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; background: var(--card); padding: 12px 14px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--ink2); gap: 4px; }
.filters .input { width: auto; min-width: 150px; }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }
#map, .map { height: 420px; border-radius: 10px; z-index: 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink2); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.heat { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 11px; }
.heat td { height: 22px; border-radius: 3px; text-align: center; color: transparent; }
.heat td:hover { outline: 2px solid var(--ink); color: inherit; }
.heat th { font-weight: 500; color: var(--muted); }

.q-card h3 { display: flex; gap: 8px; align-items: baseline; }
.q-card .code { font-size: 11px; color: var(--muted); font-weight: 500; }
.bars .bar-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 90px; gap: 10px; align-items: center; padding: 4px 0; }
.bars .bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.bars .track { height: 18px; background: #f3f3f0; border-radius: 4px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink2); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--primary-soft); color: var(--primary-ink); border-radius: 99px; padding: 3px 10px; font-size: 12px; }
.quote { border-left: 3px solid var(--line); padding: 4px 10px; margin: 6px 0; color: var(--ink2); }
.stat-row { display: flex; gap: 22px; margin-bottom: 10px; flex-wrap: wrap; }
.stat-row div b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat-row div span { font-size: 12px; color: var(--muted); }
.nps-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 8px 0; }
.nps-bar div { display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 600; }

.contract-card { cursor: pointer; transition: box-shadow .15s; }
.contract-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.09); }
.contract-card .client { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Construtor */
.builder { display: grid; grid-template-columns: 220px minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1250px) { .builder { grid-template-columns: 190px minmax(0, 1fr) 300px; } }
.palette { position: sticky; top: 16px; }
.palette button { display: flex; width: 100%; gap: 8px; align-items: center; border: 1px solid var(--line); background: #fff; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; text-align: left; }
.palette button:hover { border-color: var(--primary); background: var(--primary-soft); }
.palette .ico { width: 22px; text-align: center; }
.qlist { min-height: 200px; }
.qitem { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 12px 8px; margin-bottom: 8px; display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.qitem.sel { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.qitem.drag-over { border-top: 3px solid var(--primary); }
.qitem .handle { cursor: grab; color: #b0b0aa; padding: 0 4px; user-select: none; font-size: 18px; line-height: 1; }
.qitem .n { font-weight: 700; color: var(--muted); min-width: 22px; }
.qitem .body { flex: 1; min-width: 0; }
.qitem .meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.qitem .acts { display: flex; gap: 2px; opacity: .4; }
.qitem:hover .acts, .qitem.sel .acts { opacity: 1; }
.qitem .acts button { border: 0; background: none; padding: 3px 6px; border-radius: 4px; color: var(--ink2); }
.qitem .acts button:hover { background: #f0efec; }
.props { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.opt-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.opt-row .input { flex: 1; }
.opt-row .code-in { flex: 0 0 46px; padding: 8px 6px; }
.logic-box { background: #f7f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.save-state { font-size: 12px; color: var(--muted); }
.empty { text-align: center; padding: 40px; color: var(--muted); }

.modal-bg { position: fixed; inset: 0; background: rgba(10,12,18,.5); display: grid; place-items: center; z-index: 1000; padding: 20px; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: min(640px, 100%); max-height: 92vh; overflow: auto; }
.modal.wide { width: min(1000px, 100%); }
.toast { position: fixed; bottom: 24px; right: 24px; background: #12161f; color: #fff; padding: 12px 18px; border-radius: 10px; opacity: 0; transform: translateY(10px); transition: .2s; z-index: 2000; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

/* Pré-visualização (simula o tablet) */
.tablet-frame { background: #1b1f27; border-radius: 28px; padding: 18px; }
.tablet-screen { background: #f4f6fb; border-radius: 14px; padding: 22px; min-height: 420px; font-size: 16px; }
.tablet-screen .fe-label { font-size: 1.3rem; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-wrap .card { width: 380px; padding: 28px; }

@media print {
  .side, .filters, .no-print, .tabs { display: none !important; }
  .layout { display: block; } .main { padding: 0; } .card, .kpi { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

/* Estilos das perguntas na pré-visualização (copiados do app do tablet) */
.tablet-screen .fe-label{ font-size: 1.45rem; font-weight: 700; }
.tablet-screen .fe-req{ color: #d63b3b; }
.tablet-screen .fe-help{ color: #6b7489; margin: 4px 0 14px; }
.tablet-screen .fe-body{ margin-top: 18px; }
.tablet-screen .fe-note{ font-size: 1.3rem; line-height: 1.5; }
.tablet-screen .fe-choices{ display: grid; gap: 12px; }
.tablet-screen .fe-grid{ grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tablet-screen .fe-yesno{ grid-template-columns: 1fr 1fr; }
.tablet-screen .fe-choice{ display: flex; align-items: center; gap: 14px; text-align: left; border: 2px solid #e3e7f0; background: #fff; border-radius: 14px; padding: 18px; min-height: 64px; font-size: 1.1rem; color: #1b2233; }
.tablet-screen .fe-yesno .fe-choice{ justify-content: center; font-size: 1.3rem; font-weight: 700; min-height: 90px; }
.tablet-screen .fe-choice.on{ border-color: #1f4fd8; background: #e8eefc; }
.tablet-screen .fe-radio, .tablet-screen .fe-check{ flex: 0 0 26px; height: 26px; border: 2px solid #b8c2d8; border-radius: 50%; position: relative; }
.tablet-screen .fe-check{ border-radius: 7px; }
.tablet-screen .fe-choice.on .fe-radio, .tablet-screen .fe-choice.on .fe-check{ border-color: #1f4fd8; background: #1f4fd8; }
.tablet-screen .fe-choice.on .fe-radio::after{ content: ""; position: absolute; inset: 6px; background: #fff; border-radius: 50%; }
.tablet-screen .fe-choice.on .fe-check::after{ content: "✓"; position: absolute; inset: 0; color: #fff; display: grid; place-items: center; font-size: 16px; font-weight: 900; }
.tablet-screen .fe-other{ margin-top: 12px; }
.tablet-screen .fe-scale{ display: flex; gap: 8px; flex-wrap: wrap; }
.tablet-screen .fe-scale-btn{ flex: 1 0 56px; min-height: 64px; border: 2px solid #e3e7f0; background: #fff; border-radius: 12px; font-size: 1.3rem; font-weight: 700; color: #1b2233; }
.tablet-screen .fe-scale-btn.on{ background: #1f4fd8; border-color: #1f4fd8; color: #fff; }
.tablet-screen .fe-scale-btn.det.on{ background: #d63b3b; border-color: #d63b3b; }
.tablet-screen .fe-scale-btn.neu.on{ background: #e08a00; border-color: #e08a00; }
.tablet-screen .fe-scale-btn.pro.on{ background: #1a9d5c; border-color: #1a9d5c; }
.tablet-screen .fe-scale-labels{ display: flex; justify-content: space-between; color: #6b7489; font-size: .85rem; margin-top: 8px; }
.tablet-screen .fe-num{ max-width: 280px; font-size: 1.6rem; }
.tablet-screen .fe-unit{ margin-left: 10px; color: #6b7489; }
.tablet-screen .fe-gps-info{ margin-top: 12px; color: #6b7489; }
.tablet-screen .fe-file{ display: none; }
.tablet-screen .fe-photo{ display: block; max-width: 100%; max-height: 50vh; margin-top: 14px; border-radius: 12px; }
.tablet-screen .fe-error{ margin-top: 16px; padding: 12px 14px; background: #fde8e8; color: #d63b3b; border-radius: 12px; font-weight: 600; }
.tablet-screen .fe-input { width:100%; font:inherit; padding:12px; border:2px solid #e3e7f0; border-radius:12px; }
.tablet-screen .btn-lg { padding:12px 18px; }

[hidden] { display: none !important; }

.area-label { background: rgba(255,255,255,.92); border: 1px solid #d6d6d1; box-shadow: none; font-weight: 600; color: #0b0b0b; }

.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1100px) { .how { grid-template-columns: 1fr; } }
.how-step { display: flex; gap: 12px; align-items: flex-start; }
.how-step p { margin: 4px 0; color: var(--ink2); }
.how-n { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* ---------- Análise ---------- */
.seg-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -4px 0 16px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary-ink); border-radius: 99px; padding: 4px 6px 4px 12px; font-size: 13px; }
.chip button { border: 0; background: transparent; color: inherit; padding: 0 6px; font-size: 12px; }
.seg-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; margin: 10px 0; }
.an-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.q-index { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 14px; }
.q-index a { text-decoration: none; color: var(--ink2); font-size: 13px; padding: 5px 6px; border-radius: 6px; }
.q-index a:hover { background: #f3f3f0; color: var(--ink); }
.an-cards { display: flex; flex-direction: column; gap: 16px; }
.an-card { scroll-margin-top: 16px; }
.hbars { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 110px; gap: 12px; align-items: center; }
.hbar-label { font-size: 13px; }
.hbar-track { height: 18px; background: #f3f3f0; border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar.fixed .hbar-fill { background: #a9a8a3; }
.hbar.fixed .hbar-label { color: var(--ink2); }
.hbar-val { font-variant-numeric: tabular-nums; text-align: right; }
.t.banner { margin-top: 12px; }
.t.banner td.num, .t.banner th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t.banner th.tot, .t.banner td.tot { border-right: 2px solid var(--line); font-weight: 600; }
.t.banner td.low { color: var(--muted); }
.t.banner tr.fixed td:first-child { color: var(--ink2); font-style: italic; }
.t.banner .up { color: var(--good-ink); font-size: 11px; }
.t.banner .down { color: #9b2222; font-size: 11px; }
.t.banner caption { caption-side: bottom; text-align: left; padding-top: 6px; }
@media (max-width: 1000px) { .an-layout { grid-template-columns: 1fr; } .q-index { position: static; max-height: none; } }
