:root {
  --blue: #005596;
  --blue-dark: #003f72;
  --blue-soft: #e8f3fa;
  --orange: #ff6b21;
  --ink: #16324a;
  --muted: #617587;
  --line: #d7e0e7;
  --surface: #ffffff;
  --background: #f3f6f8;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 10px 30px rgba(21, 50, 74, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--background); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-header {
  height: 76px;
  padding: 0 max(22px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 16px; border: 0; background: none; color: var(--blue); padding: 0; }
.brand img { width: 128px; height: 48px; object-fit: contain; }
.brand span { font-weight: 750; font-size: 1.12rem; border-left: 1px solid var(--line); padding-left: 16px; }
.sync-indicator { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px; color: var(--success); font-size: .82rem; font-weight: 700; border: 1px solid var(--line); border-radius: 10px; background: white; }
.sync-indicator > span:first-child { width: 9px; height: 9px; border-radius: 50%; background: #18a66a; box-shadow: 0 0 0 4px #e3f6ee; }
.sync-indicator.pending { color: #92400e; }
.sync-indicator.pending > span:first-child { background: var(--orange); box-shadow: 0 0 0 4px #fff0e8; }
.sync-indicator.offline { color: var(--danger); }
.sync-indicator.offline > span:first-child { background: #d92d20; box-shadow: 0 0 0 4px #fee4e2; }
.sync-area { display: grid; justify-items: end; gap: 3px; }
.sync-area > small { color: var(--muted); font-size: .64rem; letter-spacing: .01em; }

.page { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 70px; }
.page-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 30px; }
.page-intro h1 { margin: 3px 0 4px; font-size: clamp(1.8rem, 4vw, 2.7rem); letter-spacing: -.04em; }
.page-intro p { margin: 0; color: var(--muted); }
.eyebrow { font-weight: 800; color: var(--orange) !important; font-size: .74rem; letter-spacing: .14em; }

.button { min-height: 46px; border-radius: 11px; border: 1px solid transparent; padding: 0 18px; font-weight: 720; transition: transform .15s, box-shadow .15s, background .15s; }
.button:active { transform: translateY(1px); }
.button.primary { color: white; background: var(--blue); box-shadow: 0 7px 18px rgba(0, 85, 150, .2); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: var(--blue); background: white; border-color: #a9c7dc; }
.button.quiet { color: var(--ink); background: transparent; border-color: var(--line); }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 24px; }
.summary-grid article { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 20px 22px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.summary-grid article::before { content: ""; position: absolute; top: 0; left: 0; width: 5px; height: 100%; background: var(--blue); }
.summary-grid article:nth-child(2)::before { background: var(--orange); }
.summary-grid article:nth-child(3)::before { background: #18a66a; }
.summary-grid span { color: var(--muted); font-size: .86rem; }
.summary-grid strong { display: block; margin-top: 6px; font-size: 1.8rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.panel-heading { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 1.13rem; }
.search { display: flex; align-items: center; gap: 8px; width: min(340px, 52vw); padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--background); }
.search input { width: 100%; min-height: 42px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.report-list { display: grid; }
.report-item { display: grid; grid-template-columns: 145px 1.3fr 1fr 110px minmax(210px, auto); gap: 18px; align-items: center; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.report-item:last-child { border-bottom: 0; }
.report-item:hover { background: #f9fbfc; }
.report-item button.open-report { text-align: left; background: none; border: 0; padding: 0; color: inherit; }
.report-item strong { display: block; font-size: .92rem; }
.report-item small { display: block; color: var(--muted); margin-top: 4px; }
.status { display: inline-flex; width: fit-content; padding: 5px 9px; border-radius: 999px; font-size: .73rem; font-weight: 750; }
.status.draft { color: #92400e; background: #fff3d6; }
.status.completed { color: var(--success); background: #dff7ec; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--danger); }
.report-actions { display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.report-action { min-height: 38px; padding: 0 10px; border: 1px solid #a9c7dc; border-radius: 9px; color: var(--blue); background: white; font-size: .76rem; font-weight: 750; white-space: nowrap; }
.report-action.send { color: white; border-color: var(--blue); background: var(--blue); }
.report-action:disabled { color: #8b9ba7; border-color: var(--line); background: #f3f6f8; cursor: not-allowed; }
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state h3 { margin: 14px 0 5px; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-icon { width: 52px; height: 52px; margin: auto; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-weight: 800; font-size: 1.3rem; }

.editor { width: min(1000px, calc(100% - 40px)); }
.editor-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.editor-topbar > div { text-align: right; }
.report-number { display: block; font-weight: 800; color: var(--blue); letter-spacing: .04em; font-size: .82rem; }
.save-state { color: var(--muted); font-size: .76rem; }
.steps { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.step { min-width: 88px; min-height: 56px; border: 0; border-radius: 10px; background: white; color: var(--muted); font-size: .72rem; padding: 7px; border-bottom: 3px solid transparent; }
.step strong { display: block; color: inherit; font-size: .82rem; }
.step.active { color: var(--blue); background: var(--blue-soft); border-bottom-color: var(--blue); }
.step.done { color: var(--success); }

.form-section { display: none; min-height: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: clamp(22px, 5vw, 38px); box-shadow: var(--shadow); }
.form-section.active { display: block; }
.section-heading { display: flex; gap: 15px; align-items: center; margin-bottom: 28px; padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.section-heading > span { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; color: white; background: var(--blue); border-radius: 11px; font-size: .78rem; font-weight: 800; }
.section-heading h2 { margin: 0 0 3px; font-size: 1.35rem; }
.section-heading p { margin: 0; color: var(--muted); font-size: .86rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--ink); font-size: .875rem; font-weight: 680; }
input, select, textarea { width: 100%; border: 1px solid #bac9d4; border-radius: 10px; padding: 12px 13px; background: white; color: var(--ink); outline: none; font-weight: 450; }
input, select, textarea { font-size: 1rem; }
input, select { min-height: 47px; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 85, 150, .12); }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-radius: 10px 0 0 10px; }
.input-unit > span { display: grid; place-items: center; min-width: 45px; padding: 0 10px; color: var(--muted); background: #edf2f5; border: 1px solid #bac9d4; border-left: 0; border-radius: 0 10px 10px 0; font-size: .72rem; }
.fixed-recipient { display: grid; gap: 4px; padding: 15px 17px; border: 1px solid #a9c7dc; border-radius: 11px; background: var(--blue-soft); }
.fixed-recipient span { color: var(--muted); font-size: .82rem; }
.fixed-recipient strong { color: var(--blue); }
.serial-control { display: grid; grid-template-columns: 1fr auto; }
.serial-control input { border-radius: 10px 0 0 10px; }
.scan-button { min-width: 118px; border: 1px solid var(--blue); border-left: 0; border-radius: 0 10px 10px 0; color: white; background: var(--blue); font-weight: 700; }

.checklist { display: grid; gap: 10px; }
.check-item { display: grid; grid-template-columns: minmax(180px, 1fr) 155px 1.2fr; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcfd; }
.check-item > strong { font-size: .88rem; }
.check-item select, .check-item input { min-height: 42px; padding: 9px 11px; }
.check-item select.conforme { border-color: #72c9a4; background: #f0fbf6; }
.check-item select.nao-conforme { border-color: #f1998e; background: #fff5f4; }
.check-item select.atencao { border-color: #eeba72; background: #fffaeb; }

.repeater { display: grid; gap: 12px; margin-bottom: 18px; }
.repeat-row { display: grid; grid-template-columns: 1.25fr .75fr .55fr 1.4fr 42px; gap: 10px; align-items: end; padding: 14px; background: #f8fafb; border: 1px solid var(--line); border-radius: 12px; }
.repeat-row.finding { grid-template-columns: 155px 1.2fr 1.2fr 42px; }
.repeat-row label { font-size: .72rem; }
.repeat-row input, .repeat-row select, .repeat-row textarea { min-height: 42px; padding: 9px 10px; }
.remove-row { width: 42px; height: 42px; border-radius: 9px; border: 1px solid #f3b4ae; color: var(--danger); background: #fff; }
.service-options { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.service-option { grid-template-columns: 24px 1fr; align-items: center; min-height: 52px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcfd; cursor: pointer; }
.service-option:has(input:checked) { color: var(--blue); border-color: #7eb4d8; background: var(--blue-soft); }
.service-option input, .no-anomaly input { width: 20px; height: 20px; min-height: 0; accent-color: var(--blue); }
.battery-blocks { margin-top: 18px; padding: 17px; border: 1px solid #f2b383; border-radius: 12px; background: #fff8f3; }
.service-notes { margin-top: 20px; }
.no-anomaly { grid-template-columns: 24px 1fr; align-items: center; min-height: 74px; padding: 16px; border: 1px solid #72c9a4; border-radius: 12px; background: #effbf5; cursor: pointer; }
.no-anomaly span { display: grid; gap: 3px; }
.no-anomaly small { color: var(--muted); font-weight: 450; }
#findingArea { margin-top: 18px; }

.scanner-dialog { width: min(520px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 16px; color: var(--ink); background: white; box-shadow: 0 24px 80px rgba(15, 36, 53, .28); }
.scanner-dialog::backdrop { background: rgba(6, 24, 38, .72); backdrop-filter: blur(4px); }
.scanner-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.scanner-header > div { display: grid; gap: 2px; }
.scanner-header small { color: var(--muted); }
.scanner-header button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; font-size: 1.4rem; }
#barcodeReader { min-height: 300px; background: #101820; }
#scannerMessage { min-height: 44px; margin: 0; padding: 13px 18px; color: var(--muted); font-size: .88rem; }
.scanner-fallback { display: grid; gap: 3px; margin: 0 18px 18px; padding: 13px 16px; text-align: center; border: 1px solid #a9c7dc; border-radius: 10px; color: var(--blue); background: var(--blue-soft); cursor: pointer; }
.scanner-fallback input { display: none; }
.scanner-fallback span { font-weight: 750; }
.scanner-fallback small { color: var(--muted); font-weight: 450; }

.battery-bank-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px; margin-bottom: 18px; border: 1px solid #a9c7dc; border-radius: 13px; background: var(--blue-soft); }
.battery-branch { margin-top: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfd; overflow: hidden; }
.battery-branch summary { display: flex; justify-content: space-between; align-items: center; padding: 15px 17px; cursor: pointer; color: var(--blue); font-weight: 750; background: white; }
.battery-branch summary b { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 7px; border-radius: 50%; color: white; background: var(--blue); }
.battery-branch:nth-of-type(2) summary b { background: var(--orange); }
.battery-branch summary small { color: var(--muted); font-weight: 500; }
.battery-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 15px; border-top: 1px solid var(--line); }
.battery-cell { gap: 4px; }
.battery-cell > span { color: var(--muted); font-size: .7rem; }
.battery-cell input { min-width: 0; min-height: 41px; padding: 8px; }
.battery-cell .input-unit > span { min-width: 31px; padding: 0 6px; }

.photo-picker { min-height: 180px; place-items: center; align-content: center; text-align: center; border: 2px dashed #9bbdd5; border-radius: 15px; background: #f5fafd; cursor: pointer; color: var(--blue); }
.photo-picker input { display: none; }
.photo-picker small { color: var(--muted); font-weight: 450; }
.camera-icon { font-size: 2rem; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 20px; }
.photo-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; position: relative; }
.photo-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.photo-card input { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.photo-card button { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(22, 50, 74, .82); color: white; }

.signature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 25px; }
.signature-card { border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.signature-card > div { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.signature-card button { border: 0; background: transparent; color: var(--blue); font-size: .78rem; }
.signature-card canvas { display: block; width: 100%; height: 150px; background: #fbfcfd; border: 1px dashed #9fb2bf; border-radius: 9px; touch-action: none; margin-bottom: 10px; }
.editor-actions { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: space-between; gap: 12px; padding: 17px 0 calc(17px + env(safe-area-inset-bottom)); margin-top: 15px; background: rgba(243, 246, 248, .94); backdrop-filter: blur(8px); }
.editor-actions > div { display: flex; gap: 10px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 10px; background: var(--ink); color: white; box-shadow: var(--shadow); transition: .2s; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 760px) {
  .app-header { height: 66px; padding: 0 16px; }
  .brand img { width: 98px; height: 40px; }
  .brand span { font-size: .95rem; padding-left: 10px; }
  .sync-indicator { max-width: 145px; font-size: .72rem; }
  .sync-area > small { font-size: .58rem; }
  .page { width: min(100% - 24px, 1000px); padding-top: 24px; }
  .page-intro { align-items: stretch; flex-direction: column; }
  .page-intro .button { width: 100%; }
  .summary-grid { gap: 9px; }
  .summary-grid article { padding: 15px 14px; }
  .summary-grid strong { font-size: 1.45rem; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .report-item { grid-template-columns: 1fr; gap: 12px; }
  .report-item > :not(.open-report):not(.report-actions) { display: none; }
  .report-actions { justify-content: flex-start; flex-wrap: wrap; }
  .report-action { min-height: 44px; padding: 0 13px; }
  .report-actions .icon-button { min-width: 44px; min-height: 44px; margin-left: auto; }
  .form-grid, .signature-grid { grid-template-columns: 1fr; }
  .service-options { grid-template-columns: 1fr; }
  .battery-bank-summary { grid-template-columns: 1fr; }
  .battery-grid { grid-template-columns: repeat(2, 1fr); padding: 12px; }
  .form-grid .wide { grid-column: auto; }
  .form-section { min-height: 480px; padding: 20px 16px; }
  .check-item { grid-template-columns: 1fr; }
  .repeat-row, .repeat-row.finding { grid-template-columns: 1fr 1fr; }
  .repeat-row > label:last-of-type { grid-column: 1 / -1; }
  .remove-row { grid-column: 2; justify-self: end; }
  .photo-grid { grid-template-columns: 1fr 1fr; }
  .editor-topbar { align-items: flex-start; }
  .editor-topbar > div { max-width: 48%; }
  .editor-actions { align-items: stretch; }
  .editor-actions > div { flex: 1; }
  .editor-actions .button { padding: 0 12px; }
  #saveDraft { display: none; }
  #nextStep, #finishReport { flex: 1; }
}

@media (max-width: 430px) {
  .summary-grid span { font-size: .72rem; }
  .photo-grid { grid-template-columns: 1fr; }
  .editor-actions > .button { font-size: 0; width: 48px; padding: 0; }
  .editor-actions > .button::after { content: "←"; font-size: 1rem; }
}
/* Pedidos do Excel e PDFs recebidos */
.requests-panel { margin-top: 24px; }
.requests-controls { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; padding: 16px 0; }
.requests-controls label { display: grid; gap: 8px; }
.requests-controls input, .requests-controls select { padding: 12px; border: 1px solid #cad6df; border-radius: 8px; font: inherit; }
.request-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 0; border-bottom: 1px solid #cad6df; }
.request-item small { display: block; margin-top: 6px; }
.request-item p { margin-bottom: 0; }
.request-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
#requestsMessage, .excel-pending { color: #b54708; }
@media (max-width: 700px) { .request-item { display: block; } .request-actions { margin-top: 16px; } .requests-controls > * { width: 100%; } }

.appointment-dialog { width: min(620px, 94vw); max-height: 90vh; overflow: auto; border: 1px solid #cad6df; border-radius: 16px; padding: 24px; }
.appointment-dialog::backdrop { background: #16324a88; }
.appointment-dialog label { display: grid; gap: 6px; margin: 12px 0; }
.appointment-dialog input, .appointment-dialog textarea { width: 100%; box-sizing: border-box; padding: 10px; }
.appointment-dialog .request-actions { flex-wrap: wrap; }
