:root {
  font-family: Inter, 'Segoe UI', Arial, sans-serif; color: #172424; background: #f4f6f5; font-synthesis: none;
  --lime: #d5f879; --ink: #152121; --muted: #667470; --line: #dce2df; --green: #457127;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .44; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid #69952e; outline-offset: 3px; }
[hidden] { display: none !important; }

/* topo */
.topbar { height: 86px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 5%; background: #fff; }
.brand { display: flex; align-items: center; font-size: 27px; font-weight: 750; letter-spacing: -1.4px; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; background: var(--ink); color: var(--lime); border-radius: 9px; width: 36px; height: 36px; font-size: 32px; line-height: 1; }
.brand-divider { height: 24px; width: 1px; background: var(--line); margin: 0 6px; }
.brand-section { font-size: 17px; letter-spacing: -.2px; font-weight: 450; color: #67736f; }
.header-actions { display: flex; gap: 22px; align-items: center; }
.prototype { font-size: 11px; letter-spacing: 1.7px; border: 1px solid var(--line); padding: 7px 9px; font-weight: 600; }

/* botões */
.button { min-height: 44px; border: 1px solid transparent; padding: 11px 17px; border-radius: 7px; display: inline-flex; justify-content: center; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; transition: background .15s, transform .15s; text-decoration: none; }
.button:not(:disabled):active { transform: translateY(1px); }
.primary { background: var(--lime); color: var(--ink); }
.primary:hover:not(:disabled) { background: #c6ee5a; }
.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.secondary:hover:not(:disabled) { background: #edf2ed; }
.quiet { background: transparent; }
.text-button { border: 0; background: none; color: inherit; font-size: 14px; padding: 9px 0; text-underline-offset: 4px; }
.text-button:hover { text-decoration: underline; }
.full { width: 100%; }

/* layout */
main { max-width: 1480px; margin: auto; padding: 45px 5% 0; }
.page-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 29px; gap: 20px; }
.eyebrow { font-size: 11px; letter-spacing: 2px; font-weight: 700; margin: 0 0 13px; color: #577047; }
h1 { font-size: 36px; letter-spacing: -1.6px; font-weight: 620; margin: 0 0 10px; }
h2, h3, p { margin-top: 0; }
.subtitle { font-size: 16px; color: var(--muted); margin: 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.capture-section { min-width: 0; }

/* palco de captura */
.surface-top, .surface-bottom { padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; background: #172323; color: #c1ceca; gap: 14px; }
.surface-top { border-radius: 12px 12px 0 0; border-bottom: 1px solid #30413a; font-size: 13px; }
.live-label { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #87978e; }
.status-dot.busy { background: var(--lime); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.small-tag { font-size: 10px; letter-spacing: 1.4px; border: 1px solid #435147; color: #d3dfd2; border-radius: 3px; padding: 5px 7px; white-space: nowrap; }
.capture-stage { height: 510px; background-color: #101c1b; background-image: linear-gradient(#26332c40 1px, transparent 1px), linear-gradient(90deg, #26332c40 1px, transparent 1px); background-size: 32px 32px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; z-index: 1; padding: 0 16px; }
.viewfinder { height: 130px; width: 150px; position: relative; margin-bottom: 28px; }
.viewfinder > span { position: absolute; width: 22px; height: 22px; border-color: #8da782; border-style: solid; }
.viewfinder > span:nth-child(1) { top: 0; left: 0; border-width: 2px 0 0 2px; }
.viewfinder > span:nth-child(2) { top: 0; right: 0; border-width: 2px 2px 0 0; }
.viewfinder > span:nth-child(3) { bottom: 0; right: 0; border-width: 0 2px 2px 0; }
.viewfinder > span:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.viewfinder svg { width: 90px; height: 110px; margin-top: 10px; stroke: #829482; stroke-width: 1.5; fill: #82948208; }
.empty-state h2 { font-size: 22px; color: #f3f6ed; letter-spacing: -.4px; margin: 0 0 10px; font-weight: 500; }
.empty-state p { font-size: 14px; line-height: 1.7; color: #91a59c; margin-bottom: 25px; }
.empty-state .text-button { color: #c0ccc0; margin-top: 10px; }
.stage-corner { position: absolute; width: 32px; height: 32px; pointer-events: none; border: 1px solid #57654e; }
.stage-corner.top-left { top: 18px; left: 18px; border-width: 1px 0 0 1px; }
.stage-corner.bottom-right { bottom: 18px; right: 18px; border-width: 0 1px 1px 0; }
.surface-bottom { border-top: 1px solid #30413a; border-radius: 0 0 12px 12px; font-size: 12px; padding: 10px 22px; color: #96a79d; }
.surface-bottom .text-button { color: #d2e5ad; font-size: 12px; }
.lock-icon { margin-right: 5px; color: #bbd391; }
#photo-canvas { max-width: 100%; max-height: 100%; object-fit: contain; touch-action: none; cursor: crosshair; }
#camera-video { width: 100%; height: 100%; object-fit: contain; }
.stage-hint { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); padding: 10px 14px; border: 1px solid #7d937166; border-radius: 6px; background: #0a1817e8; color: #e9f5d9; font-size: 13px; max-width: 94%; width: max-content; text-align: center; pointer-events: none; z-index: 2; }
.camera-controls { position: absolute; bottom: 20px; display: flex; gap: 12px; }
.message { padding: 13px 16px; background: #edf5e0; border: 1px solid #d5e7bb; border-radius: 7px; margin-top: 16px; font-size: 14px; line-height: 1.5; }
.message.error { background: #fff2e9; border-color: #eed3bd; color: #8a4425; }
.suggestion-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; padding: 8px 8px 8px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; }
.suggestion-bar > div { display: flex; gap: 6px; }
.suggestion-bar .button { min-width: 44px; font-size: 20px; padding: 6px 12px; }
.photo-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.point-editor { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; margin-top: 15px; align-items: end; }
.point-editor label { font-size: 12px; color: var(--muted); }
.point-editor input, .point-editor select { width: 100%; margin-top: 6px; }

/* painel */
.settings-panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 25px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.panel-heading h2 { font-size: 20px; font-weight: 600; letter-spacing: -.4px; margin: 0; }
.index-number { font: 14px 'Courier New', monospace; color: #84917d; }
.object-form { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.object-form .field-row select, .object-form .field-row input { width: 100%; margin-top: 7px; font-size: 14px; }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: #eff2ef; border-radius: 7px; gap: 3px; }
.mode-button { background: transparent; border: 0; font-size: 13px; color: #6a766e; min-height: 38px; border-radius: 5px; padding: 7px; }
.mode-button.selected { background: white; color: var(--ink); box-shadow: 0 1px 5px #18342413; font-weight: 600; }
.steps { list-style: none; padding: 0; margin: 24px 0; display: grid; gap: 18px; }
.steps li { display: flex; gap: 13px; color: #809084; }
.steps li > span { height: 27px; min-width: 27px; border: 1px solid #dce4d8; border-radius: 50%; display: grid; place-items: center; font-size: 12px; }
.steps strong { font-size: 14px; font-weight: 600; display: block; margin: 3px 0 5px; }
.steps p { font-size: 12px; margin: 0; color: #7e897f; line-height: 1.4; }
.steps li.active { color: var(--ink); }
.steps li.active > span, .steps li.done > span { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.steps li.done { color: var(--green); }
.reference-form { padding: 19px 0 22px; border-top: 1px solid var(--line); }
.field-label { font-size: 13px; display: block; font-weight: 600; margin-bottom: 10px; }
select, input { border: 1px solid #d5ddd4; border-radius: 5px; min-height: 43px; background: #fff; color: var(--ink); padding: 9px 10px; max-width: 100%; }
select { width: 100%; font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.field-row label { font-size: 12px; color: #5d705f; }
.field-row label > span { float: right; color: #899286; }
.field-row input { width: 100%; font-size: 16px; margin-top: 7px; }
.field-note { font-size: 12px; line-height: 1.65; color: #7c8779; margin: 10px 0 0; }
.field-note a { color: var(--green); font-weight: 600; }
.shape-row { display: grid; gap: 8px; margin-top: 14px; font-size: 13px; }
.shape-row label { display: flex; align-items: center; gap: 8px; }
.shape-row input { min-height: auto; width: 18px; height: 18px; accent-color: var(--green); }
.shape-row small { color: var(--green); font-size: 11px; }
.ar-symbol { font-size: 44px; color: #699b31; margin: 22px 0 12px; }
.ar-description { font-size: 14px; line-height: 1.7; color: var(--muted); }
.support-box { padding: 12px; background: #f0f4e8; border: 1px solid #e0e8d5; border-radius: 6px; font-size: 13px; line-height: 1.6; margin: 18px 0; }
.support-box.unsupported { background: #f8f3e8; border-color: #e9dfc7; }
#ar-settings { padding-bottom: 24px; }

/* resultado */
.result-block { padding-top: 23px; border-top: 1px solid var(--line); }
.result-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 19px; }
.result-heading .eyebrow { margin: 0; font-size: 10px; letter-spacing: 1.7px; color: #6a7962; }
.result-badge { font-size: 11px; background: #f1f3ee; color: #7a8674; padding: 4px 7px; border-radius: 4px; }
.result-badge.ready { background: #edf8d7; color: #496629; }
.result-badge.warn { background: #fdf3dc; color: #7c5a12; }
.result-badge.bad { background: #fde8e1; color: #9a3a1c; }
.measurement-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.measurement-grid > div > span { font-size: 12px; color: #7c8677; display: block; margin-bottom: 8px; }
.measurement-grid strong { font-weight: 550; font-size: 30px; letter-spacing: -1px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.measurement-grid small { font-size: 13px; color: #7b8678; font-weight: 400; letter-spacing: 0; }
.measurement-grid em { display: block; font-style: normal; font-size: 12px; color: #6d7b66; margin-top: 4px; font-variant-numeric: tabular-nums; min-height: 1em; }
.area-row, .depth-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin-top: 16px; padding: 12px 0 0; border-top: 1px dashed #dbe3d4; gap: 10px; }
.area-row > span, .depth-row > label { color: #74826c; }
.area-row strong { font-size: 16px; font-weight: 550; }
.depth-row input { width: 92px; min-height: 36px; padding: 6px 8px; font-size: 15px; text-align: right; }
.result-block .button { margin-top: 17px; font-size: 13px; }
.export-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.export-row .button { margin-top: 8px; padding: 10px; gap: 6px; }
details { margin-top: 18px; font-size: 13px; }
summary { cursor: pointer; font-weight: 600; }
.measurement-warning { display: flex; gap: 9px; font-size: 11px; line-height: 1.6; color: #839078; padding-top: 20px; margin: 0; }
.measurement-warning span { font-size: 15px; }

/* histórico */
.history { margin-top: 36px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 25px; }
.history-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.history-heading h2 { font-size: 20px; font-weight: 600; letter-spacing: -.4px; margin: 0; }
.history-actions { display: flex; gap: 16px; align-items: center; }
.history-empty { font-size: 13px; color: var(--muted); margin: 16px 0 0; line-height: 1.6; }
.calibration { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 18px; }
.calibration > div { background: #f3f7ec; border-radius: 8px; padding: 10px 12px; }
.calibration span { display: block; font-size: 11px; color: #6f7d68; margin-bottom: 4px; }
.calibration strong { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.history-list { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.history-item img, .history-placeholder { width: 76px; height: 57px; object-fit: cover; border-radius: 5px; background: #172323; color: var(--lime); display: grid; place-items: center; font-size: 13px; }
.history-body strong { font-size: 14px; }
.history-body p { margin: 2px 0 0; }
.history-dims { font-size: 16px; font-variant-numeric: tabular-nums; }
.history-meta { font-size: 11px; color: var(--muted); }
.history-truth { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.history-truth label { display: flex; align-items: center; gap: 4px; }
.history-truth input { width: 78px; min-height: 32px; padding: 4px 6px; font-size: 14px; }
.history-remove { font-size: 12px; color: #9a3a1c; padding: 6px; }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 26px 0 30px; color: #87917f; font-size: 10px; letter-spacing: .8px; }
.footer-divider { padding: 0 8px; color: #c0c7b9; }

/* diálogo */
dialog { width: min(620px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 14px; padding: 28px; color: var(--ink); max-height: 85dvh; }
dialog::backdrop { background: #0b151bbb; backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: start; gap: 20px; justify-content: space-between; }
.dialog-heading h2 { font-size: 23px; letter-spacing: -.5px; }
.icon-button { border: 0; background: #edf2e8; border-radius: 5px; min-width: 35px; min-height: 35px; font-size: 24px; }
#help-content p { font-size: 14px; line-height: 1.8; color: #5b6d5c; }
#help-content a { color: var(--green); font-weight: 600; }

/* AR */
#xr-overlay { position: fixed; inset: 0; z-index: 100; background: transparent; color: white; padding: env(safe-area-inset-top) 18px env(safe-area-inset-bottom); pointer-events: none; }
#xr-overlay button { pointer-events: auto; }
.xr-top { display: flex; justify-content: space-between; gap: 10px; padding-top: 16px; align-items: center; }
.xr-top .small-tag { background: #13251dd9; }
.xr-instruction { max-width: 500px; margin: 18px auto; background: #12271cdb; padding: 15px; border-radius: 9px; font-size: 16px; line-height: 1.5; text-align: center; }
.xr-reticle { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; border: 2px solid var(--lime); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px #111; }
.xr-reticle::after { content: ''; position: absolute; left: 12px; top: 12px; width: 3px; height: 3px; background: white; }
.xr-point { position: absolute; transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 50%; background: var(--lime); color: var(--ink); display: grid; place-items: center; font-size: 13px; font-weight: 700; box-shadow: 0 0 0 2px #0f1d1a; }
.xr-bottom { position: absolute; bottom: max(25px, env(safe-area-inset-bottom)); left: 18px; right: 18px; max-width: 500px; margin: auto; background: #13251ddd; border-radius: 10px; padding: 16px; text-align: center; }
#xr-stats { font-size: 14px; line-height: 1.7; margin-bottom: 13px; }
#xr-undo { color: white; }
body:has(#xr-overlay:not([hidden])) > main { visibility: hidden; }

@media (min-width: 1500px) { .capture-stage { height: 580px; } }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
  main { padding: 32px 3% 0; }
  .topbar { padding: 0 3%; }
  .settings-panel { padding: 20px; }
  .capture-stage { height: 500px; }
  h1 { font-size: 31px; }
  .surface-bottom { padding: 10px 15px; flex-wrap: wrap; gap: 2px; }
}
@media (max-width: 760px) {
  .topbar { height: 68px; padding: 0 20px; }
  .brand { font-size: 23px; gap: 8px; }
  .brand-section { font-size: 15px; }
  .brand-divider { margin: 0 3px; }
  .brand-mark { width: 30px; height: 30px; }
  .prototype { display: none; }
  .header-actions .button { font-size: 12px; padding: 7px; }
  .header-actions { gap: 0; }
  main { padding: 27px 18px 0; }
  .page-heading { margin-bottom: 23px; gap: 12px; align-items: flex-start; }
  .page-heading .button { font-size: 0; padding: 10px; min-width: 38px; min-height: 38px; }
  .page-heading .button span { font-size: 16px; }
  h1 { font-size: 29px; letter-spacing: -1.2px; }
  .eyebrow { font-size: 10px; letter-spacing: 1.5px; }
  .subtitle { font-size: 14px; line-height: 1.5; }
  .workspace { grid-template-columns: 1fr; gap: 20px; }
  .capture-stage { height: 410px; }
  .surface-top { padding: 14px; font-size: 12px; }
  .small-tag { font-size: 9px; letter-spacing: .9px; }
  .empty-state h2 { font-size: 21px; }
  .surface-bottom { font-size: 11px; padding: 10px 14px; }
  .surface-bottom .text-button { font-size: 11px; }
  .settings-panel, .history { padding: 20px; }
  .steps strong { font-size: 15px; }
  .steps p, .field-note { font-size: 13px; }
  .field-label, .field-row label { font-size: 14px; }
  .mode-button { font-size: 14px; }
  .result-heading .eyebrow, .measurement-warning, .result-badge { font-size: 12px; }
  .measurement-grid > div > span { font-size: 14px; }
  .measurement-grid strong { font-size: 33px; }
  .point-editor { grid-template-columns: 2fr 1fr 1fr; }
  .point-editor button { grid-column: 1 / -1; }
  footer { font-size: 9px; letter-spacing: .2px; }
  .photo-toolbar .button { font-size: 12px; padding: 9px 12px; }
  .stage-hint { font-size: 12px; }
  .area-row, .depth-row { font-size: 14px; }
  .result-block .button { font-size: 14px; }
  .history-item { grid-template-columns: 64px minmax(0, 1fr); }
  .history-item img, .history-placeholder { width: 64px; height: 48px; }
  .history-remove { grid-column: 2; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  body { background: white; }
  .topbar, .page-heading, .capture-section, .mode-picker, #photo-settings, #ar-settings, .measurement-warning, footer, .export-row, #save-button, .history { display: none; }
  main { padding: 0; }
  .workspace { display: block; }
  .settings-panel { border: 0; }
}
