/* Portal del ingeniero (diseño 49 y 50). Paleta calmada de Mi Estanque. */
:root {
  --navy: #0f2233;
  --primary: #16525f;
  --primary-dark: #0e3843;
  --soft: #ddefec;
  --on-soft: #0f4a52;
  --calm: #9fdcd2;
  --success: #2f9c8c;
  --ground: #f4f3ef;
  --surface: #ffffff;
  --panel: #eae8e2;
  --line: #d8d6cf;
  --line-strong: #b5b2a9;
  --line-soft: #eceae4; /* separación entre filas (diseño 49 y 50) */
  --muted: #4b5a66;
  --warn-bg: #fbe6d6;
  --on-warn: #7a2e06;
  --warn: #b8480f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--navy);
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 16px;
}
h1, .display { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; margin: 0; }
h1 { font-size: 34px; }
/* Títulos de sección: Atkinson 18 en negrita, como el diseño. */
h2 { font-size: 18px; font-weight: 700; margin: 0; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
button, select, textarea, input { font: inherit; }
.loading { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
/* Se lee con lector de pantalla, pero no se ve. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Barra lateral (diseño 49) ── */
.app { display: flex; min-height: 100vh; }
nav.side {
  width: 260px; flex-shrink: 0; background: var(--navy); color: #fff;
  padding: 28px 18px; display: flex; flex-direction: column; gap: 6px;
}
nav.side .brand { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 24px; color: var(--calm); padding: 0 10px; }
nav.side .sub { font-size: 14px; opacity: 0.8; padding: 0 10px 18px; }
nav.side a {
  color: var(--soft); text-decoration: none; padding: 0 12px; border-radius: 10px;
  display: flex; justify-content: space-between; align-items: center; min-height: 44px;
}
nav.side a[aria-current='page'] { background: var(--primary); color: #fff; font-weight: 700; }
nav.side a:hover { background: var(--primary-dark); color: #fff; }
nav.side .count { background: var(--calm); color: var(--navy); border-radius: 999px; padding: 1px 9px; font-size: 14px; }
nav.side .spacer { flex-grow: 1; }
nav.side .who { font-size: 14px; opacity: 0.8; padding: 0 10px; }
nav.side button.out { margin-top: 8px; background: transparent; color: #fff; border: 1px solid #4b6577; border-radius: 10px; min-height: 44px; cursor: pointer; }

/* Contenido: 1100 de ancho como el diseño, centrado en pantallas anchas. */
main {
  flex-grow: 1; min-width: 0; max-width: 1100px; margin: 0 auto;
  padding: 32px 40px; display: flex; flex-direction: column; gap: 22px;
}
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.head .title { display: flex; flex-direction: column; gap: 4px; }
.head .title p { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer; font-size: 15px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--navy);
}
.chip[aria-pressed='true'] { border: 2px solid var(--primary); background: var(--primary); color: #fff; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat span { font-size: 14px; color: var(--muted); }
.stat b { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 30px; }
.stat b.warn { color: var(--warn); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }

/* ── Tabla de casos (diseño 49) ── */
.card.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 16px; }
.table th { text-align: left; font-size: 14px; font-weight: 700; color: var(--muted); padding: 14px 12px; }
.table td { padding: 14px 12px; vertical-align: middle; }
.table th:first-child, .table td:first-child,
.table th:last-child, .table td:last-child { padding-left: 18px; padding-right: 18px; }
.table tbody tr { border-top: 1px solid var(--line-soft); }
.table td.action { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 2px; }
.who-name { font-weight: 700; }
.thumbs { display: flex; gap: 4px; }
.thumb { width: 40px; height: 32px; border-radius: 6px; background: var(--panel); object-fit: cover; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.pill.warn { background: var(--warn-bg); color: var(--on-warn); }
.pill.dead { font-size: 16px; }
.pill.ok { background: var(--soft); color: var(--on-soft); }
.pill.fix { background: var(--navy); color: var(--calm); }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { background: var(--line-strong); cursor: default; }
.btn.outline { background: var(--surface); color: var(--primary); border: 1px solid var(--line-strong); }
.btn.row { min-height: 44px; white-space: nowrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ── Un caso (diseño 50): página completa, sin barra lateral ── */
.page {
  width: 100%; min-height: 100vh; padding: 28px 40px 40px;
  display: flex; flex-direction: column; gap: 22px;
}
.page h1 { font-size: 30px; }
.case-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.case-head .title { display: flex; flex-direction: column; gap: 2px; }
.case-head .title span { font-size: 15px; color: var(--muted); }
.back {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--navy);
  text-decoration: none; font-weight: 700;
}
.back:hover { color: var(--navy); border-color: var(--primary); }
.detail { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.detail .col { display: flex; flex-direction: column; gap: 18px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.photo { height: 220px; border-radius: 12px; background: var(--panel); cursor: zoom-in; border: none; padding: 0; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
.facts h2 { grid-column: 1 / -1; }
.fact { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.fact span:first-child { font-size: 14px; color: var(--muted); }
.fact span:last-child { font-size: 16px; font-weight: 700; }
.pacu { background: var(--navy); color: #fff; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.pacu .label { color: var(--calm); font-weight: 700; font-size: 14px; }
.pacu .display { font-size: 24px; }
.pacu .body { font-size: 16px; line-height: 1.45; opacity: 0.92; }

/* Panel de revisión. */
.card.review { border: 2px solid var(--primary); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.review h2 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 22px; }
.review p { margin: 0; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button { min-height: 52px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--navy); cursor: pointer; font-size: 17px; }
.choice button[aria-pressed='true'] { border: 2px solid var(--primary); background: var(--primary); color: #fff; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 16px; font-weight: 700; }
select, textarea, input[type='text'], input[type='email'] {
  border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; color: var(--navy); font-size: 16px; font-weight: 400;
}
select, input[type='text'], input[type='email'] { min-height: 48px; padding: 0 12px; }
textarea { padding: 12px; line-height: 1.45; resize: vertical; min-height: 120px; }
.btn.send { width: 100%; min-height: 56px; border-radius: 14px; font-size: 18px; }
.help { font-size: 14px; color: var(--muted); line-height: 1.4; }

.login { margin: auto; max-width: 420px; padding: 32px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.login h1 { font-size: 30px; }
.login .card { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.error { color: var(--on-warn); background: var(--warn-bg); border-radius: 12px; padding: 12px; margin: 0; }

.zoom { position: fixed; inset: 0; background: rgba(15, 34, 51, 0.92); display: flex; align-items: center; justify-content: center; z-index: 10; }
.zoom[hidden] { display: none; }
.zoom img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }
.zoom-close { position: absolute; top: 16px; right: 20px; font-size: 40px; color: #fff; background: none; border: none; cursor: pointer; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 14px 20px; border-radius: 12px; z-index: 20; }
.toast[hidden] { display: none; }

/* En el teléfono: una columna. La tabla se desliza de costado. */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  nav.side { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  nav.side .spacer, nav.side .sub { display: none; }
  nav.side button.out { margin-top: 0; }
  main { padding: 18px 16px; }
  .page { padding: 18px 16px 28px; }
  .detail { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .photo { height: 160px; }
}

/* El botón de Google: mientras carga (o si Google no acepta la dirección)
   muestra uno provisorio cuyos estilos bloquea la política de seguridad.
   Que su logo nunca crezca. */
.google-button { min-height: 44px; max-width: 320px; }
.google-button svg, .google-button img { width: 20px; height: 20px; }

/* Guía de enfermedades (sin diseño propio: mismo estilo que el resto). */
.guide { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.guide-item { display: flex; flex-direction: column; gap: 10px; }
.guide-item h2 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 20px; }
.guide-item p { margin: 0; line-height: 1.45; }
.guide-item .urgent-if { background: var(--warn-bg); color: var(--on-warn); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
@media (max-width: 860px) { .guide { grid-template-columns: 1fr; } }

/* Pagos de la membresía (sin diseño propio: mismo estilo que el resto). */
.chip-link { display: inline-flex; align-items: center; text-decoration: none; }
.chip-link:hover { color: var(--navy); border-color: var(--primary); }
.chip-link[aria-current='page'] { border: 2px solid var(--primary); background: var(--primary); color: #fff; font-weight: 700; }
.receipt-button { border: none; padding: 0; background: none; cursor: zoom-in; border-radius: 8px; }
.thumb.receipt { width: 56px; height: 56px; display: block; }
.pay-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn.danger { color: var(--warn); }
.btn.danger:hover { background: var(--warn-bg); color: var(--on-warn); }
.btn.danger-fill { background: var(--warn); }
.btn.danger-fill:hover { background: var(--on-warn); }
.reject-box { display: flex; flex-direction: column; gap: 8px; min-width: 280px; text-align: left; }
.reject-box textarea { min-height: 80px; }
.reject-box .error { padding: 8px 10px; }

/* Equipo y regalos (documents/portal-equipo.md) */
nav.side .who.role { font-size: 13px; opacity: 0.65; margin-top: -6px; }
.form-card { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.form-card > .field, .form-card > input { width: 100%; }
.form-row { display: flex; gap: 14px; width: 100%; flex-wrap: wrap; }
.form-row .field { min-width: 180px; }
.form-row .field.grow { flex: 1 1 280px; }
.section-title { margin: 10px 0 0; }
.role-card { display: flex; flex-direction: column; gap: 14px; }
.role-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.role-head input { max-width: 320px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 12px; cursor: pointer; }
.perm input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.perm span { display: flex; flex-direction: column; gap: 2px; }
.perm:has(input:disabled) { cursor: default; opacity: 0.75; }
