/* ============================================================
   Prueba de Integridad PHE · Gas Trazador
   Mismo tema que FCA-20 (encabezado azul, botones, tarjetas).
============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, Helvetica, sans-serif; font-size: 14px; background: #f0f2f5; color: #222; }

:root {
  --azul: #0D2C54;
  --azul-med: #0056B3;
  --rojo: #C8362B;
  --verde: #1a7a3a;
  --borde: #d0d5dd;
  --pass: #10B981;
  --warn: #F59E0B;
  --fail: #EF4444;
  --pend: #9ca3af;
}

/* ========= ENCABEZADO ========= */
.app-header {
  background: var(--azul); 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; background: white; border-radius: 4px; padding: 2px 6px; }
.app-header h1 { font-size: 17px; flex: 1; }
.header-actions { display: flex; gap: 8px; }

/* ========= BOTONES ========= */
.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; line-height: 1.3;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--rojo); color: white; }
.btn-primary:hover:not(:disabled) { background: #a82820; }
.btn-success { background: var(--verde); color: white; }
.btn-success:hover:not(:disabled) { background: #145f2c; }
.btn-azul { background: var(--azul); color: white; }
.btn-azul:hover:not(:disabled) { background: #0a2140; }
.btn-outline { background: white; color: var(--azul); border: 1.5px solid var(--azul); }
.btn-outline:hover:not(:disabled) { background: #e8f0fa; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover:not(:disabled) { background: #b02a37; }
.btn-gris { background: #eef0f3; color: #333; border: 1px solid #ccc; }
.btn-gris:hover:not(:disabled) { background: #e0e3e8; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-lg { padding: 11px 20px; font-size: 14px; font-weight: bold; }

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

/* ========= MENU PRINCIPAL ========= */
.home-toolbar { display: flex; gap: 12px; align-items: center; padding: 18px 20px 10px; flex-wrap: wrap; }
.search-box { flex: 1; min-width: 220px; padding: 8px 12px; border: 1.5px solid #ccc; border-radius: 6px; font-size: 14px; }
.search-box:focus { outline: none; border-color: var(--rojo); }
.backup-bar { display: flex; align-items: center; gap: 10px; padding: 6px 20px 14px; font-size: 12px; color: #555; flex-wrap: wrap; }
.link-status { color: var(--verde); font-weight: bold; }
.link-status.error { color: var(--rojo); }
.spacer-h { flex: 1; }
.home-sub { font-size: 15px; color: var(--azul); padding: 4px 20px 10px; }
.home-sub span { font-weight: normal; color: #888; font-size: 12px; }
.empty-state { text-align: center; color: #888; padding: 60px 20px; font-size: 16px; line-height: 2; }

.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 var(--rojo);
}
.doc-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.15); }
.doc-card-info { flex: 1; min-width: 0; }
.doc-card-folio { font-weight: bold; font-size: 15px; color: var(--rojo); font-family: Consolas, monospace; }
.doc-card-sub { font-size: 12px; color: #444; margin-top: 3px; }
.doc-card-date { font-size: 11px; color: #999; margin-top: 3px; }
.doc-card-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 4px; font-weight: bold; font-size: 11px; color: white; text-transform: uppercase; white-space: nowrap; }

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

.srv-head {
  background: white; border: 1px solid var(--borde); border-radius: 8px;
  padding: 12px 16px; margin-bottom: 14px;
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
}
.srv-folio label, .srv-general label { display: block; font-size: 11px; color: #666; font-weight: bold; text-transform: uppercase; margin-bottom: 3px; }
.srv-folio .folio { font-family: Consolas, monospace; font-size: 18px; font-weight: bold; color: var(--rojo); }
.srv-folio .folio.pend { color: #999; font-size: 13px; font-family: Arial, sans-serif; font-weight: normal; font-style: italic; }
.srv-folio .ant { font-size: 11px; color: #888; margin-top: 2px; }
.srv-general { margin-left: auto; text-align: right; }
.srv-general .badge { font-size: 13px; padding: 6px 12px; }

.block-title {
  font-size: 13px; font-weight: bold; color: white;
  background: var(--azul); padding: 7px 12px; border-radius: 4px 4px 0 0;
  margin-top: 18px; display: flex; align-items: center; gap: 10px;
}
.block-title .sub { font-weight: normal; opacity: .8; font-size: 12px; }
.block-body {
  background: white; border: 1px solid var(--borde); 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; background: white;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--rojo); }
.field textarea { resize: vertical; line-height: 1.45; }
.field input:disabled, .field textarea:disabled, .field select:disabled { background: #f5f6f8; color: #444; }
.input-error { border-color: var(--fail) !important; color: var(--fail); font-weight: bold; }
.input-success { border-color: var(--pass) !important; color: #0b7a55; font-weight: bold; }
.msg-cal { font-size: 11px; margin-top: 4px; font-weight: bold; }
.msg-cal.mal { color: var(--fail); }
.msg-cal.bien { color: #0b7a55; }
.aviso-presion { display: none; margin-top: 4px; font-size: 11px; font-weight: bold; color: #b45309; }
.aviso-presion.visible { display: block; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.span-2 { grid-column: span 2; }

/* ========= PUNTOS DE PRUEBA ========= */
.puntos-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.punto-tab {
  border: 1.5px solid var(--borde); background: #f8f9fb; border-radius: 6px;
  padding: 7px 10px 6px; cursor: pointer; min-width: 92px; text-align: left;
  font-family: Arial, sans-serif; border-left-width: 5px;
}
.punto-tab:hover { border-color: var(--azul-med); }
.punto-tab.activo { background: #e8f0fa; border-color: var(--azul); box-shadow: 0 0 0 1px var(--azul) inset; }
.punto-tab .et { font-weight: bold; font-size: 15px; color: var(--azul); font-family: Consolas, monospace; }
.punto-tab .pk { font-size: 11px; color: #555; margin-top: 1px; }
.punto-tab .dc { font-size: 9.5px; font-weight: bold; text-transform: uppercase; margin-top: 2px; }
.puntos-acciones { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.puntos-acciones .hint { font-size: 11px; color: #888; }

.punto-head {
  margin-top: 22px; background: var(--azul-med); color: white;
  border-radius: 6px; padding: 9px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.punto-head .tt { font-size: 15px; font-weight: bold; flex: 1; }
.punto-head .tt span { font-family: Consolas, monospace; background: rgba(255,255,255,.18); padding: 1px 8px; border-radius: 4px; margin-left: 4px; }
.punto-head .btn { background: rgba(255,255,255,.15); color: white; border: 1px solid rgba(255,255,255,.4); }
.punto-head .btn:hover { background: rgba(255,255,255,.28); }

/* ========= EJECUCION (panel de control) ========= */
.control-panel { background: var(--azul); border-radius: 8px; color: white; margin-bottom: 14px; overflow: hidden; }
.mode-tabs { display: flex; }
.mode-tab { flex: 1; padding: 11px 16px; font-size: 13px; font-weight: bold; cursor: pointer; border: none; background: #1b3d6b; color: #b8c6da; text-align: center; font-family: Arial, sans-serif; }
.mode-tab.active { background: var(--rojo); color: white; }
.mode-tab:hover:not(.active) { background: #24497c; color: white; }
.mode-panel { display: none; padding: 18px 20px; }
.mode-panel.active { display: block; }
.timer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.timer-grid > div:first-child { border-right: 1px solid #2f5487; padding-right: 20px; text-align: center; }
.timer-grid > div:last-child { padding-left: 20px; }
.timer-display { font-size: 48px; font-family: Consolas, monospace; font-weight: bold; color: white; text-align: center; }
.control-panel label { display: block; font-size: 11px; font-weight: bold; color: #b8c6da; text-transform: uppercase; margin-bottom: 4px; }
.control-panel input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; background: white; color: #222; }
.control-panel input:disabled { background: #d9dee6; }
.btn-start { background: var(--rojo); color: white; padding: 10px 20px; font-weight: bold; }
.btn-start:hover:not(:disabled) { background: #a82820; }
.btn-stop { background: #dc3545; color: white; padding: 10px 20px; font-weight: bold; display: none; }
.btn-capture { background: white; color: var(--azul); width: 100%; padding: 13px; font-size: 15px; font-weight: bold; }
.btn-capture:disabled { background: #8a9bb3; color: #e5e9ef; }
.kbd { background: #2f5487; padding: 2px 5px; border-radius: 3px; }
.manual-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 8px; }
.manual-hint { font-size: 11px; color: #b8c6da; margin-top: 6px; }
.paste-box { display: none; margin-top: 12px; background: #1b3d6b; border-radius: 6px; padding: 14px; }
.paste-box.visible { display: block; }
.paste-box textarea { width: 100%; font-family: Consolas, monospace; font-size: 12px; background: #0f2747; color: #e5e7eb; border: 1px solid #2f5487; border-radius: 4px; padding: 8px; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-box { border: 1px solid #ccc; background: white; padding: 10px; border-radius: 4px; }
.tabla-box { max-height: 300px; overflow-y: auto; border: 1px solid #ddd; border-radius: 4px; }
table.lect { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lect th { background: var(--azul); color: white; padding: 7px 8px; text-align: left; font-size: 12px; position: sticky; top: 0; }
table.lect td { border-bottom: 1px solid #eee; padding: 6px 8px; }
table.lect td.t { font-family: Consolas, monospace; }
table.lect td.v { text-align: right; font-weight: bold; }
table.lect button { background: none; border: none; color: #aaa; cursor: pointer; padding: 2px 6px; font-size: 13px; }
table.lect button:hover { color: #dc3545; }

/* ========= RESULTADOS ========= */
.res-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 14px; }
.res-pico { text-align: center; padding: 18px; border: 1px solid #ddd; border-radius: 6px; background: #fafbfc; }
.res-pico p { font-size: 12px; color: #666; text-transform: uppercase; }
.res-pico h2 { margin: 10px 0; font-size: 40px; color: var(--azul); }
.res-pico h2 small { font-size: 20px; }
.res-pico .badge { font-size: 13px; padding: 6px 12px; }

/* ========= FOTOS ========= */
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.photo-slot { border: 2px dashed var(--borde); border-radius: 6px; background: #f9fafb; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.photo-slot .area { min-height: 240px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.photo-slot:hover { border-color: var(--azul-med); }
.photo-slot.has-photo { border-style: solid; border-color: var(--azul-med); }
.photo-slot img { width: 100%; height: 240px; object-fit: contain; display: none; background: #f0f0f0; }
.photo-slot.has-photo img { display: block; }
.photo-slot.has-photo .ph { display: none; }
.photo-slot .ph { text-align: center; color: #888; pointer-events: none; font-size: 12px; font-weight: bold; text-transform: uppercase; }
.photo-slot .ph span { font-size: 40px; display: block; margin-bottom: 6px; }
.photo-slot .cap { width: 100%; padding: 7px 10px; font-size: 12px; border: none; border-top: 1px solid var(--borde); background: white; font-family: Arial, sans-serif; }
.photo-slot .cap:focus { outline: none; background: #f4f8fd; }
.photo-slot .quitar { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.55); color: white; border: none; border-radius: 50%; width: 26px; height: 26px; font-size: 15px; cursor: pointer; display: none; }
.photo-slot.has-photo .quitar { display: block; }
.photo-slot .subiendo { position: absolute; inset: 0; background: rgba(255,255,255,.8); display: none; align-items: center; justify-content: center; font-weight: bold; color: var(--azul); }
.photo-slot.cargando .subiendo { display: flex; }

/* ========= PIE DEL EDITOR ========= */
.editor-footer {
  position: sticky; bottom: 0; background: #fff;
  border-top: 2px solid #eee; padding: 12px 20px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08); z-index: 10;
}
.save-indicator { font-size: 12px; color: #888; flex: 1; min-width: 180px; }
.save-indicator.saving { color: #e08800; }
.save-indicator.saved { color: var(--verde); }
.save-indicator.error { color: #dc3545; font-weight: bold; }

#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;
}
#sinAcceso { padding: 60px 20px; }

/* ========= REPORTE (PDF / impresion) =========
   Ancho util de una hoja carta con margenes de 13 mm (190 mm ~ 718 px).
   El encabezado con logo, la marca de agua y "Pagina X de Y" los dibuja
   jsPDF en cada hoja; aqui solo va el contenido. */
#pdfHost { position: fixed; left: -10000px; top: 0; width: 700px; }
.rp { width: 700px; background: white; color: #111; font-family: Arial, Helvetica, sans-serif; font-size: 11px; }
.rp h2.rp-titulo { font-size: 17px; color: var(--azul); text-transform: uppercase; margin: 0 0 2px; }
.rp .rp-subt { font-size: 11px; color: #555; margin-bottom: 12px; }
.rp-idbox { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--azul); padding-bottom: 8px; margin-bottom: 12px; }
.rp-idbox .der { text-align: right; font-size: 11px; line-height: 1.5; }
.rp-box { border: 1px solid #ccc; border-radius: 5px; padding: 10px 12px; margin-bottom: 12px; }
.rp-box-title { font-size: 11px; font-weight: bold; color: var(--rojo); text-transform: uppercase; margin-bottom: 8px; border-bottom: 1px solid #eee; padding-bottom: 4px; }
.rp-datos { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; row-gap: 6px; }
.rp-dato { display: flex; font-size: 11px; }
.rp-dato .l { width: 130px; font-weight: bold; color: #555; flex-shrink: 0; }
.rp-dato .v { flex: 1; border-bottom: 1px solid #ddd; font-family: Consolas, monospace; font-size: 11.5px; color: #000; }
.rp-dato .v.alerta { color: #c0392b; font-weight: bold; }
.rp-res { display: flex; gap: 14px; margin-bottom: 12px; }
.rp-card { border: 2px solid var(--azul); border-radius: 5px; padding: 12px; text-align: center; flex: 1; }
.rp-card p { font-size: 10.5px; color: #555; text-transform: uppercase; }
.rp-card h3 { font-size: 26px; margin: 8px 0 4px; color: #000; }
.rp-card .nota { font-size: 10px; color: #666; }
table.rp-tabla { width: 100%; border-collapse: collapse; font-size: 11px; }
table.rp-tabla th { background: var(--azul); color: white; padding: 6px 8px; text-align: left; font-size: 10.5px; }
table.rp-tabla td { border: 1px solid #ccc; padding: 5px 8px; }
table.rp-tabla td.num { text-align: right; font-family: Consolas, monospace; }
table.rp-tabla td.et { font-weight: bold; font-family: Consolas, monospace; }
table.rp-tabla .dict { display: inline-block; padding: 2px 8px; border-radius: 3px; color: white; font-weight: bold; font-size: 10px; }
.rp-punto-cab { background: var(--azul-med); color: white; border-radius: 4px; padding: 7px 12px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rp-punto-cab .t { font-size: 14px; font-weight: bold; }
.rp-punto-cab .d { font-size: 11px; font-weight: bold; background: white; padding: 3px 10px; border-radius: 3px; }
.rp-graf { border: 1px solid #ccc; padding: 8px; text-align: center; margin-bottom: 12px; }
.rp-graf h4 { font-size: 11px; color: #555; margin-bottom: 4px; }
.rp-texto { font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; text-align: justify; }
.rp-obs-l { font-size: 10px; font-weight: bold; color: #555; text-transform: uppercase; margin: 8px 0 3px; }
.rp-obs-l:first-of-type { margin-top: 0; }
.rp-obs { border: 1px solid #ddd; border-radius: 4px; padding: 7px 9px; font-size: 11px; line-height: 1.5; white-space: pre-wrap; text-align: justify; min-height: 30px; color: #333; }
.rp-fotos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.rp-foto { border: 1px solid #ddd; border-radius: 4px; overflow: hidden; min-width: 0; }
/* html2canvas no soporta object-fit: la foto se centra en un marco fijo y
   ajustarFotoReporte() (app.js) le fija en px el tamano con su proporcion. */
.rp-foto .marco { height: 280px; display: flex; align-items: center; justify-content: center; background: #f5f5f5; }
.rp-foto img { max-width: 100%; max-height: 280px; width: auto; height: auto; display: block; }
.rp-foto .pie { font-size: 10px; padding: 5px 8px; background: #f5f5f5; color: #555; text-align: center; font-style: italic; }
.rp-sinfotos { font-size: 11px; color: #999; font-style: italic; text-align: center; padding: 10px; }
.rp-firma { display: flex; justify-content: center; margin-top: 46px; }
.rp-firma > div { width: 330px; text-align: center; }
.rp-firma .linea { border-top: 1px solid #000; margin-bottom: 5px; }
.rp-firma b { font-size: 13px; display: block; }
.rp-firma span { font-size: 11px; color: #666; }

/* ========= RESPONSIVO ========= */
@media (max-width: 760px) {
  .row-2, .row-3, .row-4, .chart-grid, .res-grid, .photo-grid, .timer-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .timer-grid > div:first-child { border-right: none; padding-right: 0; border-bottom: 1px solid #2f5487; padding-bottom: 14px; margin-bottom: 14px; }
  .timer-grid > div:last-child { padding-left: 0; }
  .app-header { flex-wrap: wrap; }
  .app-header h1 { font-size: 15px; }
  .srv-general { margin-left: 0; text-align: left; }
}
