/* ================================================
   RELATÓRIO TÉCNICO — Blue Compact System
   ================================================ */
:root {
  --rt-blue:       #1d4ed8;
  --rt-blue-dark:  #1e3a8a;
  --rt-blue-light: #eff6ff;
  --rt-blue-mid:   #bfdbfe;
  --rt-green:      #15803d;
  --rt-green-bg:   #dcfce7;
  --rt-red:        #dc2626;
  --rt-red-bg:     #fee2e2;
  --rt-gray:       #6b7280;
  --rt-gray-light: #f9fafb;
  --rt-gray-mid:   #e5e7eb;
  --rt-text:       #111827;
  --rt-text-2:     #374151;
  --rt-text-3:     #9ca3af;
  --rt-surface:    #ffffff;
  --rt-radius:     8px;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

*, *::before, *::after {
  box-sizing: border-box;
}

.menu-btn span { background: #ffffff; }

/* ── Layout ── */
.page-relatorio {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 0 6px 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--rt-text);
}

/* ── Action bar ── */
.rt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.rt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--rt-radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.rt-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.rt-btn-primary   { background: var(--rt-blue); color: #fff; }
.rt-btn-primary:hover { background: var(--rt-blue-dark); }
.rt-btn-ghost     { background: var(--rt-gray-light); color: var(--rt-text-2); border: 1px solid var(--rt-gray-mid); }
.rt-btn-ghost:hover { background: var(--rt-gray-mid); }

/* ── Multi-técnico picker ── */
.rt-tech-picker { display: flex; flex-direction: column; gap: 8px; }
.rt-tech-add-row { display: flex; gap: 8px; align-items: center; }
.rt-tech-add-row select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--rt-gray-mid);
  border-radius: var(--rt-radius);
  background: #fff;
  font-size: 13px;
  color: var(--rt-text);
  appearance: auto;
}
.rt-tech-add-btn {
  white-space: nowrap;
  padding: 8px 12px;
  border: 1px solid var(--rt-blue);
  border-radius: var(--rt-radius);
  background: transparent;
  color: var(--rt-blue);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rt-tech-add-btn:hover { background: var(--rt-blue); color: #fff; }
.rt-tech-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.rt-tech-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 10px;
  background: #e8edfa;
  border: 1px solid #c3cff5;
  border-radius: 20px;
  font-size: 12px;
  color: #1a2b5e;
  font-weight: 600;
}
.rt-tech-chip-name { flex: 1; }
.rt-tech-chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #1a2b5e;
  opacity: .6;
  transition: opacity .15s, background .15s;
}
.rt-tech-chip-remove:hover { opacity: 1; background: #c3cff5; }

/* ── Page header card (blue dark) ── */
.rt-header {
  background: #ffffff;
  border-radius: var(--rt-radius);
  border: 1px solid rgba(148, 163, 184, .24);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
  padding: 12px 12px 10px;
  margin-bottom: 10px;
  color: var(--rt-text);
}
.rt-header-eyebrow {
  font-size: 10px;
  font-weight: 600;
  opacity: .75;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
  color: var(--rt-gray);
}
.rt-header-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 10px;
  line-height: 1.2;
  color: var(--rt-text);
}
.rt-header-sub {
  font-size: 11px;
  opacity: .7;
  margin-bottom: 10px;
}
.rt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rt-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
}
.rt-chip svg { width: 11px; height: 11px; opacity: .75; }

/* ── Section label ── */
.rt-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--rt-gray);
  margin-bottom: 8px;
}

/* ── Info blocks (detalhe) ── */
.rt-info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
@media (min-width: 600px) {
  .rt-info-grid { grid-template-columns: repeat(2, 1fr); }
}
.rt-info-block {
  background: var(--rt-surface);
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: var(--rt-radius);
  padding: 10px 12px;
}
.rt-info-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--rt-gray);
  margin-bottom: 3px;
}
.rt-info-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--rt-text);
  line-height: 1.4;
}
.rt-info-block.full { grid-column: 1 / -1; }

/* ── Text blocks (o que foi feito etc.) ── */
.rt-text-block {
  background: var(--rt-surface);
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: var(--rt-radius);
  padding: 12px;
  margin-bottom: 10px;
}
.rt-text-block-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--rt-blue-dark);
  margin-bottom: 6px;
  padding-bottom: 0;
  border-bottom: 0;
}
.rt-text-block-body {
  font-size: 13px;
  color: var(--rt-text-2);
  line-height: 1.55;
  white-space: pre-wrap;
  margin: 0;
}

/* ── Gallery ── */
.rt-gallery-section { margin-bottom: 14px; }
.rt-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.rt-gallery img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--rt-gray-mid);
  display: block;
  cursor: zoom-in;
  transition: opacity .15s;
}
.rt-gallery img:hover { opacity: .88; }
.rt-gallery-empty {
  font-size: 12px;
  color: var(--rt-text-3);
  padding: 8px 0;
}

/* ── Historico: tech list cards ── */
.rt-tech-list { display: grid; gap: 8px; }
.rt-tech-card {
  background: var(--rt-surface);
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: var(--rt-radius);
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rt-tech-info { flex: 1; min-width: 0; }
.rt-tech-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--rt-text);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.rt-tech-count {
  font-size: 10px;
  color: var(--rt-gray);
  margin-top: 1px;
}
.rt-link-btn {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: var(--rt-radius);
  background: var(--rt-blue-light);
  color: var(--rt-blue-dark);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--rt-blue-mid);
  white-space: nowrap;
}
.rt-link-btn:hover { background: var(--rt-blue-mid); }

/* ── Historico tecnico: report list cards ── */
.rt-report-list { display: grid; gap: 8px; }
.rt-report-card {
  background: var(--rt-surface);
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: var(--rt-radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rt-report-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--rt-text);
}
.rt-report-meta {
  font-size: 12px;
  color: var(--rt-gray);
}
.rt-report-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 0;
}
.rt-report-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--rt-blue);
  text-decoration: none;
}
.rt-report-link:hover { text-decoration: underline; }
.rt-report-link.ghost {
  color: var(--rt-gray);
}

/* ── Empty state ── */
.rt-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--rt-gray);
  font-size: 13px;
}

/* ── Form styles (novo relatório) ── */
.rt-form-section { margin-bottom: 14px; }
.rt-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 600px) {
  .rt-form-grid { grid-template-columns: repeat(2, 1fr); }
}
.rt-field { display: flex; flex-direction: column; gap: 5px; }
.rt-field.full { grid-column: 1 / -1; }
.rt-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--rt-gray);
}
.rt-field input,
.rt-field select,
.rt-field textarea {
  min-height: 42px;
  border: 1px solid var(--rt-gray-mid);
  border-radius: var(--rt-radius);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--rt-text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.rt-field input:focus,
.rt-field select:focus,
.rt-field textarea:focus { border-color: var(--rt-blue); box-shadow: 0 0 0 3px rgba(29,78,216,.08); }
.rt-field textarea { min-height: 100px; resize: vertical; }

.rt-feedback {
  border-radius: var(--rt-radius);
  padding: 10px 12px;
  margin-top: 10px;
  font-weight: 600;
  font-size: 13px;
}
.rt-feedback.error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.rt-feedback.success { background: #ecfdf3; color: #047857; border: 1px solid #a7f3d0; }

.rt-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.rt-preview-card {
  border: 1px solid var(--rt-gray-mid);
  border-radius: var(--rt-radius);
  padding: 6px;
  background: var(--rt-gray-light);
}
.rt-preview-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}
.rt-preview-card button {
  margin-top: 5px;
  width: 100%;
  min-height: 30px;
  border-radius: 5px;
  border: none;
  background: var(--rt-red);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
}

@media (max-width: 767px) {
  .rt-header { padding: 11px 10px 9px; }
  .rt-header-title { font-size: 16px; margin-bottom: 6px; }
  .rt-header-eyebrow { font-size: 9px; margin-bottom: 2px; opacity: .82; }
  .rt-btn { padding: 7px 10px; font-size: 11px; }
  .rt-btn,
  .rt-link-btn {
    white-space: normal;
    text-align: center;
  }
  .rt-tech-card {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .rt-link-btn {
    width: auto;
    min-width: 102px;
    justify-content: center;
    display: inline-flex;
    padding: 6px 8px;
    white-space: nowrap;
  }
  .rt-report-actions {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  .rt-report-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }
}

@media print {
  .appm, .navbar, .rt-actions, .app-footer { display: none !important; }
}

/* ════════════════════════════════════════════════════
   DETALHE — Redesign (prefixo .rtd-)
   ════════════════════════════════════════════════════ */

/* ── Page wrapper ── */
.page-rtd {
  max-width: 520px;
  margin: 0 auto;
  background: #f1f3f8;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Action bar ── */
.rtd-actions {
  display: flex;
  gap: 6px;
  padding: 8px 8px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}
.rtd-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  white-space: nowrap;
  line-height: 1;
}
.rtd-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.rtd-btn-primary { background: #1a2b5e; color: #fff; border-color: #1a2b5e; }
.rtd-btn-primary:hover { background: #14224c; }
.rtd-btn:not(.rtd-btn-primary):hover { background: #f3f4f6; }

/* ── Hero ── */
.rtd-hero {
  background: linear-gradient(160deg, #1a2b5e 0%, #243580 100%);
  padding: 16px 10px 18px;
  position: relative;
  overflow: hidden;
}
.rtd-hero::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,.03);
  pointer-events: none;
}
.rtd-hero-title {
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  margin-bottom: 8px;
  letter-spacing: -.015em;
  word-break: break-word;
}
.rtd-hero-subtitle {
  font-size: 12px;
  color: rgba(255,255,255,.6);
  font-weight: 400;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.rtd-hero-subtitle::before {
  content: '';
  display: inline-block;
  width: 13px; height: 13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(255,255,255,.45)' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
  opacity: .6;
}
.rtd-hero-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 0; }
.rtd-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,.1);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10.5px;
  color: rgba(255,255,255,.8);
  border: 1px solid rgba(255,255,255,.08);
}
.rtd-meta-pill svg { width: 12px; height: 12px; flex-shrink: 0; }
/* chip de ID — mais discreto */
.rtd-meta-pill-id {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.45);
  font-size: 10px;
  letter-spacing: .02em;
}

/* ── Content area ── */
.rtd-content { padding: 10px 8px 24px; display: flex; flex-direction: column; gap: 10px; }

/* ── Section card ── */
.rtd-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}
.rtd-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-bottom: 1px solid #f0f2f5;
  background: #fafbfd;
}
.rtd-card-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: #e8edfa;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rtd-card-icon svg { width: 16px; height: 16px; color: #1a2b5e; }
.rtd-card-title {
  font-size: 11px;
  font-weight: 800;
  color: #1a2b5e;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.rtd-card-body {
  padding: 12px 10px;
  font-size: 14.5px;
  color: #1f2937;
  line-height: 1.65;
  white-space: pre-wrap;
}
.rtd-card-body.empty { color: #9ca3af; }

/* empty state badge */
.rtd-empty-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff3e0;
  color: #bf360c;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 6px;
}
.rtd-empty-badge svg { width: 13px; height: 13px; flex-shrink: 0; }
.rtd-empty-text { font-style: italic; font-size: 13px; }

/* ── Photo card ── */
.rtd-ba-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin: 10px 10px 6px;
}
.rtd-ba-tag.antes  { background: #fff3e0; color: #bf360c; }
.rtd-ba-tag.depois { background: #e8f5e9; color: #1b5e20; }

.rtd-imgs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 10px;
}
.rtd-imgs-grid:last-of-type { padding-bottom: 14px; }
.rtd-img-thumb {
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: #e5e7eb;
  position: relative;
  cursor: zoom-in;
}
.rtd-img-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .15s;
}
.rtd-img-thumb img:hover { opacity: .88; }

/* ── Crop Modal ── */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,.88);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 10px;
}
.crop-modal.hidden { display: none; }

.crop-modal-inner {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  overflow: hidden;
  align-self: center;
  max-height: calc(100dvh - 20px);
}

.crop-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.crop-modal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--rt-text);
  white-space: nowrap;
}
.crop-ratio-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.crop-ratio-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--rt-gray-mid);
  background: var(--rt-gray-light);
  color: var(--rt-text-2);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.crop-ratio-btn svg { flex-shrink: 0; }
.crop-ratio-btn.active {
  background: var(--rt-blue);
  border-color: var(--rt-blue);
  color: #fff;
}

.crop-stage {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 200px;
  height: 0;              /* flex faz crescer */
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#crop-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}
.crop-box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.52);
  cursor: grab;
  touch-action: none;
  outline: none;
}
.crop-box:active { cursor: grabbing; }

/* Corner resize handles */
.crop-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border: 2px solid #1d4ed8;
  border-radius: 3px;
  z-index: 1;
  touch-action: none;
}
.crop-handle.tl { top: -5px;    left: -5px;   cursor: nwse-resize; }
.crop-handle.tr { top: -5px;    right: -5px;  cursor: nesw-resize; }
.crop-handle.bl { bottom: -5px; left: -5px;   cursor: nesw-resize; }
.crop-handle.br { bottom: -5px; right: -5px;  cursor: nwse-resize; }

.crop-hint {
  font-size: 11px;
  color: var(--rt-gray);
  text-align: center;
  margin-top: -4px;
}

.crop-modal-actions {
  display: flex;
  gap: 8px;
}

/* Mobile visual refresh */
.page-relatorio {
  padding-inline: 8px;
}

.rt-header {
  border-radius: 14px;
  border-color: rgba(36, 56, 129, 0.12);
  box-shadow: 0 10px 26px rgba(16, 35, 70, 0.08);
  padding: 14px 12px;
}

.rt-header-title {
  color: #172b67;
  letter-spacing: 0;
}

.rt-actions {
  margin: 10px 0 14px;
}

.rt-btn {
  border-radius: 12px;
  min-height: 40px;
}

.rt-btn-primary {
  background: linear-gradient(135deg, #243881, #315ad8);
  box-shadow: 0 8px 18px rgba(36, 56, 129, 0.18);
}

.rt-section-label {
  margin: 4px 2px 8px;
  color: #65738a;
}

.rt-tech-list,
.rt-report-list {
  gap: 10px;
}

.rt-tech-card,
.rt-report-card,
.rt-info-block,
.rt-text-block {
  border-radius: 12px;
  border-color: rgba(36, 56, 129, 0.12);
  box-shadow: 0 6px 18px rgba(16, 35, 70, 0.06);
}

.rt-tech-card {
  padding: 12px;
}

.rt-tech-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #111827;
  line-height: 1.25;
}

.rt-link-btn {
  border-radius: 10px;
  min-height: 36px;
  background: #edf3ff;
  border-color: rgba(36, 56, 129, 0.16);
}

@media (max-width: 767px) {
  .rt-header-title {
    font-size: 18px;
  }

  .rt-actions .rt-btn {
    width: auto;
  }
}
