:root {
  --blue: #087fc1;
  --blue-dark: #07569c;
  --green: #178629;
  --yellow: #c79300;
  --gold: #c79300;
  --red: #d9281d;
  --ink: #182231;
  --muted: #747b86;
  --surface: #fff;
  --bg: #f4f6fa;
  --shadow: 0 8px 22px rgba(29, 41, 57, .14);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: #dde2ea;
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }
.hidden { display: none !important; }

/* -------------------------------------------------------------------------- */
/* AUTENTICACIÓN                                                              */
/* -------------------------------------------------------------------------- */
.auth-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #fff 0, #e8edf4 55%, #cbd4df 100%);
}
.auth-card {
  width: min(100%, 440px);
  background: #fff;
  border-radius: 26px;
  padding: 30px;
  box-shadow: 0 18px 55px rgba(29, 41, 57, .2);
}
.auth-card h1 { margin: 15px 0 5px; text-align: center; font-size: 30px; }
.auth-subtitle { margin: 0 0 24px; text-align: center; color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: #e8edf3; border-radius: 12px; padding: 4px; }
.auth-tab { border: 0; border-radius: 9px; padding: 11px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.auth-tab.active { background: #fff; color: var(--blue-dark); box-shadow: 0 2px 7px rgba(0, 0, 0, .1); }
.auth-form { display: flex; flex-direction: column; margin-top: 22px; }
.auth-form label { margin: 11px 0 6px; font-size: 14px; font-weight: 700; }
.auth-form input, .dialog-content input {
  width: 100%;
  border: 1px solid #c7ced7;
  border-radius: 9px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
}
.auth-form small { margin: 5px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.auth-form .primary-button { margin-top: 22px; }
.form-status { min-height: 22px; margin: 14px 0 0; text-align: center; color: var(--red); font-size: 13px; font-weight: 600; }

/* -------------------------------------------------------------------------- */
/* LOGO / ISOTIPO DE MARCA                                                    */
/* -------------------------------------------------------------------------- */
.brand {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1e2530;
  color: #d5ba43;
  border: 3px solid #b2a55d;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}
.brand small { margin-top: 3px; color: #e3d69d; font-size: 5px; }
.brand-large { width: 76px; height: 76px; margin: auto; font-size: 29px; }
.brand-large small { font-size: 7px; }

/* -------------------------------------------------------------------------- */
/* SHELL Y CONTENEDOR PRINCIPAL                                              */
/* -------------------------------------------------------------------------- */
.app-shell {
  width: min(100%, 490px);
  min-height: 100dvh;
  margin: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 158px;
  box-shadow: 0 0 30px rgba(0, 0, 0, .15);
}
.topbar {
  height: 76px;
  padding: 8px 14px;
  background: #fafafa;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .1);
}
.topbar h1 { margin: 0; text-align: center; font-size: 24px; }
.icon-button { border: 0; background: none; color: #222; font-size: 35px; cursor: pointer; }
.back-button { visibility: hidden; }
.app-main { flex: 1; }
.screen { display: none; padding: 22px 18px 16px; }
.screen.active { display: block; animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.welcome { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.screen-title { margin: 0 0 18px; text-align: center; font-size: 32px; font-weight: 800; text-transform: uppercase; }

/* -------------------------------------------------------------------------- */
/* GRID DE MÓDULOS (ESTILO EXACTO CONSERVADO)                                 */
/* -------------------------------------------------------------------------- */
.module-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.module-card {
  height: 220px;
  border: 0;
  border-radius: 24px;
  background: linear-gradient(to bottom, var(--accent) 0 45%, #fff 45%);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 12px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.module-card:hover { box-shadow: 0 10px 28px rgba(29, 41, 57, .18); }
.module-card:active { transform: scale(.98); }
.module-card.blue { --accent: var(--blue); }
.module-card.green { --accent: var(--green); }
.module-card.yellow, .module-card.gold { --accent: #c79300; }
.module-card.red { --accent: var(--red); }
.module-icon {
  width: 104px;
  height: 104px;
  border-radius: 22px;
  background: #fff;
  color: #30343a;
  display: grid;
  place-items: center;
  font-size: 60px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .08);
}
.module-card strong {
  max-width: 155px;
  font-size: 17px;
  line-height: 1.15;
  text-align: center;
}

/* Submódulos de Cuadernos */
.submodules-grid {
  margin-top: 18px;
}

/* -------------------------------------------------------------------------- */
/* BARRA DE GESTIÓN Y PERSISTENCIA DE OBRAS                                   */
/* -------------------------------------------------------------------------- */
.project-management-bar {
  margin-bottom: 18px;
}
.project-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.project-row label { font-size: 15px; font-weight: 700; white-space: nowrap; }
.project-row select, .conversation-toolbar select {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 9px;
  background: #e0e5ed;
  color: var(--ink);
  font-weight: 600;
  padding: 10px 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.round-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 24px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 7px rgba(0, 0, 0, .2);
  transition: transform .12s;
}
.round-button:hover { transform: scale(1.05); }
.round-button.gold-bg { background: var(--gold); }
.round-button.edit-button { background: #4b5563; font-size: 18px; }
.danger-button { background: var(--red); font-size: 18px; }
.row-spacer { width: 42px; }

/* Ficha / Badge de Obra Activa */
.obra-badge-card {
  background: #fff;
  border: 1px solid #d5dce6;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
}
.obra-badge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid #eef1f5;
  padding-bottom: 6px;
}
.obra-badge-header strong {
  color: var(--blue-dark);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folio-counter-pill {
  background: #eef7fc;
  color: var(--blue-dark);
  border: 1px solid #c2e1f5;
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.obra-badge-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  font-size: 12px;
}
.obra-badge-details p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obra-badge-details span { color: var(--muted); font-weight: 500; }
.obra-badge-details strong { color: var(--ink); }

/* Barra indicadora de folio en editor */
.folio-indicator-bar {
  background: #182231;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.folio-indicator-bar strong { color: #f5c842; }

/* -------------------------------------------------------------------------- */
/* FORMULARIOS DE LIBROS DE OBRAS                                         */
/* -------------------------------------------------------------------------- */
.cuaderno-form-card {
  margin-top: 10px;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cuaderno-form-body {
  padding: 16px;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.form-field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.form-field input, .form-field select {
  width: 100%;
  border: 1px solid #c7ced7;
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  font-size: 13px;
}
.cuaderno-textarea {
  width: 100%;
  border: 1px solid #c7ced7;
  border-radius: 8px;
  padding: 12px;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
  background: #fafbfc;
}

/* Selector de Tipo de Acta */
.acta-type-group {
  margin-bottom: 14px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e0e5ed;
}
.acta-type-group label strong { color: var(--blue-dark); font-size: 13px; }
.acta-type-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.acta-type-option {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  padding: 6px 8px;
  border: 1px solid #d5dce6;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.acta-type-option:has(input:checked) {
  border-color: var(--blue);
  background: #eef7fc;
  color: var(--blue-dark);
}

/* Tablas Dinámicas de Libro de Partes */
.parte-form-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef1f5;
}
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.section-header-row label strong { font-size: 13px; color: var(--blue-dark); }
.compact-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  border: 0;
  border-radius: 6px;
  background: #e0e7ff;
  color: var(--blue-dark);
  cursor: pointer;
}
.compact-btn:hover { background: #c7d2fe; }
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.dynamic-entry-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
  font-size: 12px;
}
.dynamic-entry-table th {
  background: #f1f4f8;
  padding: 6px 8px;
  border: 1px solid #d5dce6;
  font-size: 11px;
  text-align: left;
}
.dynamic-entry-table td {
  padding: 4px 6px;
  border: 1px solid #e0e5ed;
  vertical-align: middle;
}
.dynamic-entry-table input, .dynamic-entry-table select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 5px 7px;
  font-size: 12px;
}
.btn-remove-row {
  background: #fee2e2;
  color: var(--red);
  border: 0;
  border-radius: 4px;
  padding: 4px 8px;
  font-weight: 800;
  cursor: pointer;
}

/* Vista previa de firmas */
.signatures-preview-box {
  margin: 16px 0;
  padding: 12px;
  border: 1px dashed #c7ced7;
  border-radius: 8px;
  background: #fbfcfd;
  display: flex;
  justify-content: space-between;
  gap: 15px;
}
.sig-preview-col {
  width: 48%;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #4a5568;
  border-top: 1px solid #94a3b8;
  padding-top: 6px;
}

/* Barra de Acciones de Cuadernos */
.cuaderno-actions-bar {
  display: grid;
  grid-template-columns: 1.5fr 1fr repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

/* Modal Obra Completo (5 campos) */
.project-modal-card {
  width: min(100%, 460px);
}
.modal-intro {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.project-full-form .form-field {
  margin-bottom: 10px;
}

/* -------------------------------------------------------------------------- */
/* CAPTURA E INFORMES (AVANCES / PATOLOGÍAS)                                 */
/* -------------------------------------------------------------------------- */
.capture-card { margin-top: 16px; overflow: hidden; background: #fff; border-radius: 24px; box-shadow: var(--shadow); }
.capture-top { height: 15px; background: var(--blue); }
.media-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 18px 18px 10px; }
.media-btn {
  padding: 14px;
  border: 2px dashed #b0b7c3;
  border-radius: 12px;
  background: #f4f6fa;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.media-btn:hover { border-color: var(--blue); background: #f0f7ff; color: var(--blue); }
.media-icon { font-size: 30px; }
.image-grid { max-height: 220px; padding: 0 18px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.img-preview-box { position: relative; min-height: 110px; border: 1px solid #e0e5ed; border-radius: 9px; overflow: hidden; background: #eef1f5; }
.img-preview-box img { width: 100%; height: 120px; object-fit: cover; display: block; }
.img-fallback { height: 120px; padding: 10px; display: none; place-items: center; text-align: center; color: var(--muted); font-size: 12px; word-break: break-word; }
.remove-img {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(217, 40, 29, .9);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.file-status { margin: 10px 18px; color: var(--muted); font-size: 13px; text-align: center; }
.context-box { padding: 4px 18px 15px; }
.context-header { margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.context-header label { font-size: 14px; font-weight: 700; }
.attach-context-btn { padding: 0; border: 0; background: none; color: var(--blue); font-size: 14px; font-weight: 700; cursor: pointer; }
.context-box textarea {
  width: 100%;
  height: 84px;
  padding: 10px;
  border: 1px solid #c8cdd4;
  border-radius: 10px;
  resize: vertical;
  background: #fafafa;
  color: var(--ink);
  font-size: 14px;
}
.context-files { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.context-file-badge { max-width: 100%; padding: 5px 9px; border-radius: 6px; background: #e0e5ed; font-size: 11px; display: flex; align-items: center; gap: 6px; }
.context-file-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-file-badge button { padding: 0; border: 0; background: none; color: var(--red); font-weight: 800; cursor: pointer; }

/* Selector de nivel de análisis */
.analysis-level {
  min-width: 0;
  margin: 0 18px 16px;
  padding: 10px;
  border: 1px solid #d5dbe3;
  border-radius: 12px;
  background: #f8fafc;
}
.analysis-level legend { padding: 0 6px; color: var(--ink); font-size: 13px; font-weight: 800; }
.analysis-options { display: grid; gap: 8px; }
.analysis-option {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d7dde5;
  border-radius: 9px;
  background: #fff;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: start;
  gap: 8px;
  cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.analysis-option:has(input:checked) {
  border-color: var(--blue);
  background: #eef7fc;
  box-shadow: 0 0 0 2px rgba(8, 127, 193, .09);
}
.analysis-option input { margin: 3px 0 0; accent-color: var(--blue-dark); }
.analysis-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.analysis-copy strong { color: var(--blue-dark); font-size: 13px; }
.analysis-copy small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.capture-actions { padding: 0 18px 18px; }
.generate-button, .primary-button {
  width: 100%;
  min-height: 48px;
  padding: 11px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--blue-dark);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: opacity .15s;
}
.generate-button { min-height: 56px; font-size: 19px; box-shadow: 0 4px 10px rgba(0, 62, 119, .25); }
button:disabled { opacity: .55; cursor: not-allowed; }
.generation-status { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.4; }
.generation-status.error { color: var(--red); font-weight: 700; }
.generation-status.success { color: var(--green); font-weight: 700; }

/* -------------------------------------------------------------------------- */
/* CONFIGURACIÓN Y CUENTA                                                     */
/* -------------------------------------------------------------------------- */
.settings-card { margin-bottom: 18px; padding: 18px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.settings-card h3 { margin: 0 0 14px; font-size: 18px; }
.account-summary p { margin: 6px 0; overflow-wrap: anywhere; }
.account-summary p:first-child { margin-bottom: 12px; font-size: 18px; color: var(--blue-dark); }
.account-summary p span:first-child { color: var(--muted); }
.secondary-button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #c7ced7;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.account-summary .secondary-button { width: 100%; margin-top: 12px; }
.danger-text { color: var(--red); border-color: rgba(217, 40, 29, .35); }
.server-status { margin: 4px 0 13px; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #9aa1ab; box-shadow: 0 0 0 4px rgba(154, 161, 171, .14); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(23, 134, 41, .14); }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 4px rgba(217, 40, 29, .14); }
.status-details { color: var(--muted); font-size: 13px; line-height: 1.5; }
.privacy-note { margin: 15px 0 0; padding: 12px; border-radius: 10px; background: #eef6fc; color: #24435d; font-size: 12px; line-height: 1.45; }
.legal-card details { border-top: 1px solid #e0e5ed; }
.legal-card summary { padding: 13px 2px; color: var(--blue-dark); font-weight: 700; cursor: pointer; }
.legal-copy { padding: 0 4px 12px; color: #454d58; font-size: 13px; line-height: 1.6; }
.legal-copy p { margin: 0 0 10px; }
.copyright { padding: 8px 20px 20px; color: var(--muted); font-size: 11px; line-height: 1.4; text-align: center; }

/* -------------------------------------------------------------------------- */
/* MODALES Y EDITOR DE DOCUMENTOS                                            */
/* -------------------------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; padding: 16px; background: rgba(0, 0, 0, .62); align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-content { width: min(100%, 880px); height: 92dvh; border-radius: 20px; overflow: hidden; background: #fff; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal-header { min-height: 60px; padding: 12px 18px; border-bottom: 1px solid #ddd; background: var(--bg); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 18px; }
.close-button { padding: 0 5px; border: 0; background: none; color: var(--ink); font-size: 28px; cursor: pointer; }
.modal-body { flex: 1; padding: 16px; overflow-y: auto; background: #e9e9e9; }
.rich-text-editor {
  min-height: 100%;
  padding: 30px 35px;
  outline: 0;
  background: #fff;
  color: #000;
  font: 10pt/1.5 Arial, Helvetica, sans-serif;
  text-align: justify;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
}
.rich-text-editor h1, .rich-text-editor h2 { color: var(--blue-dark); text-align: center; margin-top: 0; }
.rich-text-editor h3 { margin: 16px 0 6px; color: var(--blue-dark); font-size: 12pt; }
.rich-text-editor p { margin: 0 0 8px; }
.report-metadata { text-align: center; color: #4a5360; margin-bottom: 14px; font-size: 9pt; }

/* Anexo Fotográfico */
.report-photos-section { margin-top: 25px; padding-top: 15px; border-top: 2px solid #e0e5ed; }
.report-photos-section h3 { margin: 0 0 12px; color: var(--blue-dark); text-align: left; }
.report-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.report-figure { margin: 0; padding: 8px; border: 1px solid #ccd2d9; border-radius: 8px; background: #f8fafc; display: flex; flex-direction: column; align-items: center; text-align: center; break-inside: avoid; page-break-inside: avoid; }
.report-figure img { width: 100%; height: 200px; object-fit: cover; border-radius: 5px; border: 1px solid #d5dce6; background: #eee; display: block; }
.report-figure figcaption { margin-top: 6px; font-size: 9pt; line-height: 1.35; color: #3f4753; word-break: break-word; }
.report-figure figcaption strong { color: var(--blue-dark); }

/* Acciones en Footer de Modal */
.modal-footer { padding: 11px 14px; border-top: 1px solid #ddd; background: #fafafa; }
.report-actions { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 8px; }
.document-button {
  padding: 9px 8px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.document-button span { color: var(--blue-dark); font-size: 18px; }
.document-button.docx span { color: #1e40af; }
.document-button.pdf span { color: var(--red); }

/* Diálogos modales */
.dialog-content { width: min(100%, 400px); padding: 22px; border-radius: 18px; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.dialog-content h3 { margin: 0 0 10px; font-size: 18px; }
.dialog-content p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.dialog-content input { margin-bottom: 16px; }
.dialog-content input.confirm-mode { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.compact { width: auto; min-height: 40px; }

/* Cámara */
.camera-modal { z-index: 200; padding: 0; }
.camera-content { width: 100%; height: 100dvh; position: relative; background: #000; }
.camera-content video { width: 100%; height: 100%; object-fit: cover; }
.camera-actions { position: absolute; right: 0; bottom: 30px; left: 0; display: flex; justify-content: center; gap: 40px; }
.camera-action { width: 62px; height: 62px; }
.capture-button { width: 72px; height: 72px; border: 4px solid #aaa; background: #fff; color: #111; }

/* -------------------------------------------------------------------------- */
/* CHAT NORMATIVAS-CONSULTAS-IA EN PANTALLA COMPLETA (v5.2)                   */
/* -------------------------------------------------------------------------- */
.chat-modal { z-index: 150; }
.chat-modal-fullscreen {
  padding: 0 !important;
  background: rgba(0, 0, 0, .85);
}
.chat-content-fullscreen {
  width: 100vw !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}
.chat-header-fullscreen {
  min-height: 68px;
  padding: 12px 24px;
  background: #182231;
  color: #fff;
  border-bottom: 2px solid #b2a55d;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-title-group h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #fff;
}
.chat-title-group small {
  display: block;
  margin-top: 3px;
  color: #d5ba43;
  font-size: 11.5px;
  font-weight: 500;
}
.fullscreen-close-btn {
  background: #dc2626 !important;
  color: #fff !important;
  border-radius: 8px;
  font-size: 13px !important;
  font-weight: 700;
  padding: 8px 16px !important;
  transition: background .15s ease;
}
.fullscreen-close-btn:hover {
  background: #b91c1c !important;
}

.conversation-toolbar-fullscreen {
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.conv-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 280px;
}
.conv-select-row select {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-size: 13px;
  color: #1e293b;
}

.chat-messages-fullscreen {
  flex: 1;
  padding: 24px 30px;
  overflow-y: auto;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-empty { margin: auto; max-width: 500px; color: var(--muted); text-align: center; font-size: 15px; line-height: 1.6; }
.chat-message { max-width: 82%; padding: 14px 18px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.chat-message.user { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--blue-dark); color: #fff; }
.chat-message.assistant { align-self: flex-start; border-bottom-left-radius: 4px; background: #fff; color: var(--ink); border: 1px solid #e2e8f0; }
.chat-message.pending { color: var(--muted); font-style: italic; }

.chat-form-fullscreen {
  padding: 16px 24px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-form-fullscreen textarea {
  width: 100%;
  min-height: 75px;
  max-height: 180px;
  padding: 12px 16px;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  resize: vertical;
  font-size: 14.5px;
  line-height: 1.5;
  background: #fafbfc;
  font-family: inherit;
}
.chat-form-fullscreen textarea:focus {
  border-color: var(--blue);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(8, 127, 193, .15);
}
.chat-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}
.send-chat-btn {
  width: auto !important;
  min-height: 42px !important;
  padding: 10px 24px !important;
  font-size: 14px !important;
  letter-spacing: .5px;
}

/* -------------------------------------------------------------------------- */
/* ENTRADA RÁPIDA Y NAVEGACIÓN INFERIOR                                       */
/* -------------------------------------------------------------------------- */
.quick-entry {
  position: fixed;
  z-index: 9;
  bottom: 70px;
  left: 50%;
  width: min(calc(100% - 28px), 460px);
  height: 64px;
  padding: 6px 10px;
  border-radius: 32px;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 40px 40px;
  align-items: center;
}
.quick-entry input { min-width: 0; padding: 10px 16px; border: 0; outline: 0; font-size: 13.5px; }
.voice-button, .send-button { padding: 0; border: 0; background: none; color: #80848a; font-size: 20px; cursor: pointer; }
.send-button { color: var(--blue); font-size: 28px; }

.bottom-nav {
  position: fixed;
  z-index: 8;
  bottom: 0;
  left: 50%;
  width: min(100%, 490px);
  height: 72px;
  background: #fff;
  box-shadow: 0 -3px 12px rgba(0, 0, 0, .08);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.nav-item {
  border: 0;
  border-top: 3px solid transparent;
  background: #fff;
  color: #323840;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 0;
  font-weight: 600;
  transition: all .15s ease;
}
.nav-item span { font-size: 22px; line-height: 1; }
.nav-item.active { border-top-color: var(--blue-dark); background: #f8faff; color: var(--blue-dark); font-weight: 700; }

.toast { position: fixed; z-index: 500; bottom: 154px; left: 50%; width: min(calc(100% - 40px), 430px); padding: 12px 16px; border-radius: 10px; background: #17212d; color: #fff; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .25s; font-size: 13px; font-weight: 600; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [contenteditable]:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(8, 127, 193, .3);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------- */
/* RESPONSIVIDAD (MOBILE & DESKTOP)                                           */
/* -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .module-grid { gap: 14px; }
  .module-card { height: 195px; padding: 10px; gap: 16px; }
  .module-icon { width: 90px; height: 90px; font-size: 50px; }
  .module-card strong { font-size: 15px; }
  .project-row { grid-template-columns: auto 1fr auto auto; }
  .obra-badge-details { grid-template-columns: 1fr; }
  .acta-type-options { grid-template-columns: 1fr; }
  .cuaderno-actions-bar { grid-template-columns: 1fr 1fr; }
  .cuaderno-actions-bar .primary-button { grid-column: span 2; }
  .report-actions { grid-template-columns: 1fr 1fr; }
  .report-actions .primary-button { grid-column: span 2; }
  .rich-text-editor { padding: 18px; }
  .report-gallery { grid-template-columns: 1fr; }
  .report-figure img { height: 180px; }
  .analysis-level-chat .analysis-options { grid-template-columns: 1fr; }
}

@media (min-width: 700px) {
  body { padding: 25px 0; }
  .app-shell { min-height: calc(100dvh - 50px); border-radius: 30px; overflow: hidden; }
  .topbar { position: relative; }
  .bottom-nav, .quick-entry { position: absolute; }
  .modal { position: fixed; }
}

/* -------------------------------------------------------------------------- */
/* REGLAS DE IMPRESIÓN Y EXPORTACIÓN A4 DOCUMENTAL                            */
/* -------------------------------------------------------------------------- */
@media print {
  @page {
    size: A4 portrait;
    margin-top: 20mm;
    margin-bottom: 20mm;
    margin-right: 20mm;
    margin-left: 25mm;
  }
  body {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 10pt !important;
  }
  body > *:not(#reportModal),
  .topbar,
  .bottom-nav,
  .quick-entry,
  .modal-header,
  .modal-footer,
  .toast,
  .auth-view {
    display: none !important;
  }
  .modal {
    position: static !important;
    display: block !important;
    padding: 0 !important;
    background: none !important;
  }
  .modal-content {
    width: 100% !important;
    height: auto !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    background: #fff !important;
  }
  .modal-body {
    padding: 0 !important;
    background: #fff !important;
    overflow: visible !important;
  }
  .rich-text-editor {
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    color: #000 !important;
    font-size: 10pt !important;
    line-height: 1.5 !important;
    text-align: justify !important;
  }
  .report-photos-section {
    break-before: page !important;
    page-break-before: always !important;
    margin-top: 20px !important;
    padding-top: 10px !important;
    border-top: none !important;
  }
  .report-gallery {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }
  .report-figure {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    border: 1px solid #777 !important;
    background: #fff !important;
    padding: 6px !important;
  }
  .report-figure img {
    max-height: 220px !important;
    object-fit: contain !important;
    background: #fff !important;
  }
}
