/* ========= RESET / BASE ========= */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, Helvetica, sans-serif; font-size: 14px; background: #f0f2f5; color: #222; }

/* ========= APP HEADER ========= */
.app-header {
  background: #0D2C54; color: white;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.app-logo { height: 38px; }
.app-header h1 { font-size: 17px; flex: 1; }
.header-actions { display: flex; gap: 8px; }

/* ========= BUTTONS ========= */
.btn {
  padding: 7px 14px; border: none; border-radius: 6px;
  font-size: 13px; cursor: pointer; font-family: Arial, sans-serif;
  text-decoration: none; display: inline-block;
}
.btn-primary { background: #C8362B; color: white; }
.btn-primary:hover { background: #a82820; }
.btn-success { background: #1a7a3a; color: white; }
.btn-success:hover { background: #145f2c; }
.btn-outline { background: white; color: #0D2C54; border: 1.5px solid #0D2C54; }
.btn-outline:hover { background: #e8f0fa; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #b02a37; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 10px; }

/* ========= VIEWS ========= */
.view { display: none; }
.view.active { display: block; }

/* ========= HOME VIEW ========= */
.home-toolbar {
  display: flex; gap: 12px; align-items: center;
  padding: 18px 20px 10px;
}
.search-box {
  flex: 1; padding: 8px 12px; border: 1.5px solid #ccc;
  border-radius: 6px; font-size: 14px;
}
.search-box:focus { outline: none; border-color: #C8362B; }

.backup-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 20px 14px; font-size: 12px; color: #555;
}
.link-status { color: #1a7a3a; font-weight: bold; }
.link-status.error { color: #C8362B; }
.spacer-h { flex: 1; }

.empty-state {
  text-align: center; color: #888; padding: 60px 20px;
  font-size: 16px; line-height: 2;
}

/* ========= DOC LIST ========= */
.doc-list { padding: 0 20px 20px; display: grid; gap: 10px; }
.doc-card {
  background: white; border-radius: 8px; padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  border-left: 5px solid #C8362B;
}
.doc-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.15); }
.doc-card-info { flex: 1; }
.doc-card-folio { font-weight: bold; font-size: 15px; color: #C8362B; }
.doc-card-sub { font-size: 12px; color: #666; margin-top: 2px; }
.doc-card-date { font-size: 11px; color: #999; }
.doc-card-actions { display: flex; gap: 6px; }

/* ========= EDITOR VIEW ========= */
.editor-wrap { max-width: 860px; margin: 0 auto; padding: 20px; }

.block-title {
  font-size: 13px; font-weight: bold; color: white;
  background: #0D2C54; padding: 7px 12px; border-radius: 4px 4px 0 0;
  margin-top: 18px; margin-bottom: 0;
}
.block-title:first-child { margin-top: 0; }

.block-body {
  background: white; border: 1px solid #d0d5dd; border-top: none;
  border-radius: 0 0 6px 6px; padding: 14px; margin-bottom: 6px;
}

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: #555; margin-bottom: 4px; font-weight: bold; }
.field input, .field textarea, .field select {
  width: 100%; padding: 7px 10px; border: 1.5px solid #ccc;
  border-radius: 5px; font-size: 13px; font-family: Arial, sans-serif;
}
.field input:focus, .field textarea:focus { outline: none; border-color: #C8362B; }
.field textarea { resize: vertical; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.check-group { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 0; }
.check-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check-item input { width: auto; margin: 0; cursor: pointer; }

.desc-row {
  display: grid; grid-template-columns: auto 1fr; gap: 8px;
  align-items: center; margin-bottom: 8px;
}
.desc-row label { white-space: nowrap; font-size: 13px; }

/* Acciones table */
.acciones-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.acciones-table th {
  background: #0D2C54; color: white; padding: 6px 8px;
  text-align: left; font-size: 11px;
}
.acciones-table td { border: 1px solid #ddd; padding: 4px 6px; vertical-align: middle; }
.acciones-table input[type="text"], .acciones-table input[type="date"],
.acciones-table textarea {
  width: 100%; border: none; padding: 3px; font-size: 12px;
  font-family: Arial, sans-serif; background: transparent;
}
.acciones-table input[type="checkbox"] { width: auto; }
.acciones-table tr:hover td { background: #fafafa; }

/* Firmas */
.firmas-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* Editor footer */
.editor-footer {
  position: sticky; bottom: 0; background: #fff;
  border-top: 2px solid #eee; padding: 12px 20px;
  display: flex; gap: 12px; align-items: center;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 10;
}
.save-indicator { font-size: 12px; color: #888; flex: 1; }
.save-indicator.saving { color: #e08800; }
.save-indicator.saved { color: #1a7a3a; }

/* Conn banner */
#connBanner {
  display: none; background: #f8d7da; color: #721c24;
  border: 2px solid #dc3545; border-radius: 6px;
  padding: 12px 16px; margin: 10px; font-weight: bold;
  text-align: center; font-size: 13px;
}

/* ========= REPORT / PDF STYLES ========= */
#print-report { display: none; }

.fca-page {
  width: 1028px;
  min-height: 760px;
  display: flex;
  flex-direction: column;
  page-break-after: always;
  break-after: page;
  box-sizing: border-box;
  background: white;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
  color: #111;
}
.fca-page:last-child { page-break-after: auto; break-after: auto; }

/* Report Header */
.fca-rpt-header {
  display: flex;
  align-items: center;
  border-bottom: 2.5px solid #0D2C54;
  padding: 8px 12px;
  gap: 12px;
}
.fca-rpt-logo { height: 44px; width: auto; }
.fca-rpt-titles { flex: 1; text-align: center; }
.fca-rpt-company { font-size: 14pt; font-weight: bold; color: #0D2C54; letter-spacing: 0.5px; }
.fca-rpt-docname { font-size: 9.5pt; font-weight: bold; color: #C8362B; }

/* Report body */
.fca-rpt-body { flex: 1; padding: 6px 12px 4px; overflow: hidden; }

/* Folio row */
.fca-folio-row {
  display: flex; justify-content: flex-end;
  margin-bottom: 3px;
}
.fca-folio-box {
  display: flex; align-items: center; gap: 4px;
  border: 1px solid #333; padding: 2px 8px; font-size: 8pt;
}
.fca-folio-val { min-width: 80px; border-left: 1px solid #333; padding-left: 6px; }

/* Standard rows */
.fca-r { display: flex; border: 1px solid #bbb; margin-top: -1px; }
.fca-lbl {
  background: #e8edf5; font-weight: bold; font-size: 7.5pt;
  padding: 3px 6px; white-space: nowrap; display: flex;
  align-items: center; border-right: 1px solid #bbb; min-width: 0;
}
.fca-val { padding: 3px 6px; flex: 1; word-break: break-word; min-width: 0; }
.fca-check-cell {
  padding: 3px 8px; display: flex; align-items: center;
  gap: 4px; white-space: nowrap; border-right: 1px solid #bbb; font-size: 7.5pt;
}
.fca-chk {
  display: inline-block; width: 9px; height: 9px;
  border: 1px solid #333; vertical-align: middle;
  flex-shrink: 0;
}
.fca-chk.on { background: #333; }

/* Section headers */
.fca-sec {
  background: #0D2C54; color: white; font-weight: bold;
  font-size: 7.5pt; padding: 3px 7px; margin-top: 4px;
}

/* Sección 1 description table */
.fca-desc-table { width: 100%; border-collapse: collapse; border: 1px solid #bbb; }
.fca-desc-table td { border: 1px solid #bbb; padding: 3px 6px; font-size: 7.5pt; vertical-align: top; }
.fca-desc-table .td-lbl { background: #e8edf5; font-weight: bold; width: 60px; white-space: nowrap; }
.fca-desc-table .td-chk { width: 18px; text-align: center; }
.fca-desc-table .td-val { word-break: break-word; }
.fca-desc-table .td-header { background: #e8edf5; font-weight: bold; text-align: center; }

/* Text areas in report */
.fca-text-block {
  border: 1px solid #bbb; min-height: 50px; padding: 4px 7px;
  font-size: 8pt; word-break: break-word; white-space: pre-wrap;
  margin-top: -1px;
}

/* Ishikawa area */
.fca-ishikawa-wrap {
  display: flex; border: 1px solid #bbb; margin-top: -1px; gap: 0;
}
.fca-ishikawa-main { flex: 1; padding: 4px 6px; }
.fca-ishikawa-side {
  width: 80px; border-left: 1px solid #bbb;
  padding: 4px 6px; font-size: 7.5pt;
}
.fca-evidencia-title { font-weight: bold; text-align: center; margin-bottom: 6px; font-size: 7.5pt; }
.fca-evidencia-item { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 8px; font-size: 7pt; }

/* Causas grid below fishbone */
.fca-causas-table { width: 100%; border-collapse: collapse; margin-top: 3px; }
.fca-causas-table td {
  border: 1px solid #bbb; padding: 3px 5px;
  font-size: 7pt; vertical-align: top; width: 33%;
}
.fca-causas-table .caus-lbl { font-weight: bold; color: #0D2C54; font-size: 7pt; }
.fca-causas-table .caus-val { min-height: 20px; word-break: break-word; white-space: pre-wrap; }

/* 5 Porqués table */
.fca-pq-table { width: 100%; border-collapse: collapse; }
.fca-pq-table td { border: 1px solid #bbb; padding: 4px 6px; vertical-align: top; width: 20%; }
.fca-pq-table .pq-lbl { font-weight: bold; background: #e8edf5; font-size: 7.5pt; text-align: center; }
.fca-pq-table .pq-val { min-height: 50px; font-size: 7.5pt; word-break: break-word; white-space: pre-wrap; }

/* Acciones correctivas table */
.fca-ac-table { width: 100%; border-collapse: collapse; }
.fca-ac-table th { background: #0D2C54; color: white; padding: 4px 6px; font-size: 7pt; text-align: left; }
.fca-ac-table td { border: 1px solid #bbb; padding: 3px 5px; font-size: 7pt; vertical-align: top; }
.fca-ac-table .ac-no { width: 20px; text-align: center; }
.fca-ac-table .ac-accion { width: 40%; }
.fca-ac-table .ac-resp { width: 16%; }
.fca-ac-table .ac-fecha { width: 12%; }
.fca-ac-table .ac-verif { width: 22%; text-align: center; }

/* Re-clasificación */
.fca-reclas { padding: 4px 7px; font-size: 7.5pt; border: 1px solid #bbb; margin-top: -1px; }

/* Firmas */
.fca-firmas-row { display: flex; border: 1px solid #bbb; margin-top: -1px; }
.fca-firma-cell {
  flex: 1; border-right: 1px solid #bbb; padding: 4px 8px;
  min-height: 50px; font-size: 7.5pt;
}
.fca-firma-cell:last-child { border-right: none; }
.fca-firma-label { font-weight: bold; text-align: center; margin-bottom: 4px; }
.fca-firma-val { text-align: center; font-size: 7pt; color: #444; }

/* Report Footer */
.fca-rpt-footer {
  margin-top: auto;
  border-top: 1.5px solid #0D2C54;
  display: flex; justify-content: space-between;
  padding: 4px 12px; font-size: 7pt; color: #444;
}
