:root {
  --bg: #0f1216;
  --bg-panel: #171c23;
  --bg-card: #1c232d;
  --border: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #007BC8;
  --accent-2: #4FB5F0;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --orange: #e67e22;
  --red: #e74c3c;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(135deg, #101418 0%, #1c2733 55%, #005A92 120%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-size: 20px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.brand-sub { color: var(--accent-2); font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; }

.layout { display: flex; height: calc(100vh - 54px - 34px); }

.sidebar {
  width: 360px;
  min-width: 360px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.side-scroll { height: 100%; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.card-title { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent-2); display: flex; align-items: center; gap: 6px; }
.tag { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 700; font-size: 12px; color: #fff; }
.tag-a { background: var(--accent); }
.tag-b { background: var(--orange); }
.muted { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; line-height: 1.4; }

.lbl { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.select, .input {
  width: 100%;
  background: #0d1117;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
}
.select:focus, .input:focus { outline: none; border-color: var(--accent); }
textarea.input { resize: vertical; font-family: inherit; }

.specs { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.specs b { color: var(--text); font-weight: 600; }

.range { width: 100%; accent-color: var(--accent); }
.range-val { font-size: 12px; color: var(--accent-2); text-align: right; margin-top: 2px; }

.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: #232c37;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #2b3644; border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-tool { flex: 1; font-size: 12px; padding: 7px 6px; }

.tool-row { display: flex; gap: 6px; margin-top: 8px; }

.result { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; font-size: 13px; }
.result-row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.result-row b { color: var(--text); font-weight: 600; }
.verdict { margin-top: 8px; padding: 8px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; text-align: center; }
.verdict.compativel { background: rgba(46,204,113,.15); color: var(--green); border: 1px solid var(--green); }
.verdict.incompativel { background: rgba(231,76,60,.15); color: var(--red); border: 1px solid var(--red); }
.verdict.inconclusivo { background: rgba(241,196,15,.15); color: var(--yellow); border: 1px solid var(--yellow); }

.measure-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12px; }
.measure-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); color: var(--muted); }
.measure-list li b { color: var(--text); }

.scene-wrap { position: relative; flex: 1; }
.scene { position: absolute; inset: 0; }
.scene canvas { display: block; }
.hud {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(13,17,23,.8); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 20px; font-size: 12px; pointer-events: none;
}
.measure-hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 6px 14px; border-radius: 6px;
  font-size: 13px; box-shadow: 0 2px 10px rgba(0,0,0,.4);
}

.hidden { display: none !important; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; width: min(720px, 92vw); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }
.field-row { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.report-preview { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; line-height: 1.6; }

/* Cena 3D labels (CSS2DRenderer) */
.measure-label {
  background: rgba(0,0,0,.75); color: #fff; border: 1px solid var(--accent);
  padding: 2px 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; pointer-events: none;
}
.measure-label.area { border-color: var(--green); }
.measure-label.angle { border-color: var(--yellow); }

.photo-stage { margin-top: 10px; background: #000; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; min-height: 40px; }
.photo-stage canvas { display: block; max-width: 100%; height: auto; cursor: crosshair; }

.cases-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.case-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--bg-card); }
.case-item .ci-main { flex: 1; min-width: 0; }
.case-item .ci-title { font-weight: 600; font-size: 13px; }
.case-item .ci-sub { color: var(--muted); font-size: 12px; }
.case-item .btn { flex-shrink: 0; }

.app-footer { height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-top: 1px solid var(--border); background: var(--bg-panel); font-size: 11px; color: var(--muted); }
.footer-links { display: flex; gap: 14px; }
.legal-link { color: var(--accent-2); text-decoration: none; }
.legal-link:hover { text-decoration: underline; }

.cookie-banner { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; max-width: 640px; box-shadow: 0 6px 24px rgba(0,0,0,.5); font-size: 13px; }
.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }

.support-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; margin-bottom: 12px; }
.support-msg { padding: 8px 12px; border-radius: 8px; font-size: 13px; max-width: 85%; line-height: 1.4; }
.support-msg.mine { align-self: flex-end; background: var(--accent); color: #fff; }
.support-msg.theirs { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); }
.support-msg .sm-meta { font-size: 10px; opacity: .8; margin-bottom: 2px; }

.help-panel { max-height: 64vh; overflow-y: auto; }
.help-panel details { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--bg-card); }
.help-panel summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13px; color: var(--accent-2); }
.help-panel details[open] summary { border-bottom: 1px solid var(--border); }
.help-panel details > :not(summary) { padding: 10px 14px; font-size: 13px; line-height: 1.6; color: var(--text); }
.help-panel ul, .help-panel ol { margin: 6px 0 6px 20px; padding: 0; }
.help-panel li { margin: 3px 0; }
.help-panel h3 { font-size: 14px; color: var(--accent-2); margin: 14px 0 6px; }
.help-panel h4 { font-size: 13px; color: var(--text); margin: 12px 0 4px; }

.legal-body { max-height: 68vh; overflow-y: auto; font-size: 13px; line-height: 1.6; color: var(--text); }
.legal-body h3 { color: var(--accent-2); margin: 0 0 10px; }
.legal-body h4 { color: var(--text); margin: 14px 0 4px; }
.legal-body ul { margin: 6px 0 6px 20px; padding: 0; }
.legal-body li { margin: 3px 0; }

.admin-panel { max-height: 62vh; overflow-y: auto; }
.admin-inbox-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg-card); }
.aii-head { font-size: 12px; font-weight: 600; color: var(--accent-2); margin-bottom: 4px; }
.aii-body { font-size: 13px; margin-bottom: 6px; line-height: 1.5; }
.aii-reply { font-size: 12px; color: var(--muted); background: var(--bg-panel); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.admin-table th { background: var(--bg-panel); font-weight: 600; }

/* O relatório é impresso num iframe dedicado (report.js), não precisa de @media print no documento principal. */

