/* inmobiliario · mini-web local */
:root {
  --bg: #fafaf7;
  --bg-card: #ffffff;
  --fg: #1a1a1a;
  --muted: #666;
  --border: #e4e4e0;
  --accent: #d97706;
  --pau: #2563eb;
  --carlos: #ea580c;
  --conv: #16a34a;
  --err: #dc2626;
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--fg);
  margin: 0; line-height: 1.5;
}
header {
  background: var(--fg); color: white;
  padding: 12px 24px;
  display: flex; align-items: center; gap: 24px;
  position: sticky; top: 0; z-index: 10;
}
header .logo { color: white; font-weight: bold; text-decoration: none; font-size: 1.1em; }
header nav { display: flex; gap: 16px; flex-wrap: wrap; }
header nav a {
  color: #ccc; text-decoration: none; font-size: 0.9em;
}
header nav a:hover { color: white; }
main { padding: 20px 24px; max-width: 1400px; margin: 0 auto; }

.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; margin-bottom: 12px;
  flex-wrap: wrap;
}

table.listings {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 0.92em;
}
table.listings th, table.listings td {
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.listings th { background: #f3f3f0; font-weight: 600; }
table.listings tr:hover { background: #fbf9f3; }
table.listings .num { text-align: right; font-variant-numeric: tabular-nums; }
table.listings a { color: var(--fg); text-decoration: none; font-weight: 500; }
table.listings a:hover { color: var(--accent); }
table.listings code { background: #f0efe9; padding: 2px 6px; border-radius: 3px; font-size: 0.85em; }

.score {
  display: inline-block; min-width: 32px; text-align: center;
  font-weight: 600; padding: 2px 6px; border-radius: 4px;
  background: #f0efe9;
}
.err { color: var(--err); font-weight: 500; font-size: 0.85em; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.78em; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em;
}
.chip-convergente { background: #dcfce7; color: var(--conv); }
.chip-solo_pau    { background: #dbeafe; color: var(--pau); }
.chip-solo_carlos { background: #fed7aa; color: var(--carlos); }
.chip-descartado  { background: #f5f5f5; color: var(--muted); }
.chip-sin_evaluar { background: #fef3c7; color: #92400e; }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 16px 20px; margin: 12px 0; border-radius: 6px;
}
.card h2 { margin-top: 0; font-size: 1.15em; }

.kv { width: 100%; border-collapse: collapse; }
.kv th {
  text-align: left; padding: 4px 12px 4px 0;
  width: 180px; color: var(--muted); font-weight: 500;
}
.kv td { padding: 4px 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.big-score {
  font-size: 1.5em; font-weight: 700;
  margin: 0 0 8px; color: var(--accent);
}
.big-score em { font-style: normal; font-weight: 500; color: var(--fg); font-size: 0.7em; }
blockquote {
  border-left: 3px solid var(--accent); margin: 8px 0;
  padding: 4px 12px; color: var(--fg); font-style: italic;
}

.back { color: var(--muted); font-size: 0.9em; display: inline-block; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 0.92em; }

textarea, select, button {
  font-family: inherit; font-size: 1em;
  border: 1px solid var(--border); border-radius: 4px;
  padding: 8px 12px;
}
textarea { width: 100%; }
button {
  background: var(--accent); color: white; border: 0;
  padding: 10px 24px; font-weight: 600; cursor: pointer;
  margin-top: 8px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.md-render h1 { border-bottom: 2px solid var(--border); padding-bottom: 4px; }
.md-render h2 { margin-top: 24px; }
.md-render hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.md-render a { color: var(--accent); }

#respuesta .q { font-weight: 600; color: var(--muted); margin-bottom: 12px; }
#respuesta .a { font-size: 1.05em; }
.faded { opacity: 0.6; }

/* ── Responsive / mobile-first (se consulta sobre todo desde el móvil) ── */

/* Informes en markdown: tablas, código e imágenes no rompen el ancho */
.md-render { overflow-wrap: anywhere; }
.md-render pre { overflow-x: auto; }
.md-render table { display: block; overflow-x: auto; max-width: 100%; }
.md-render img { max-width: 100%; height: auto; }

@media (max-width: 640px) {
  /* Header: logo arriba; nav como barra horizontal deslizable (no se apelmaza) */
  /* Rejilla: logo y Salir en la primera línea, nav deslizable en la segunda.
     En columna simple el botón acababa descolgado del logo. */
  header {
    display: grid; grid-template-columns: 1fr auto;
    grid-template-areas: "logo salir" "nav nav";
    align-items: center; gap: 8px; padding: 10px 14px;
  }
  header .logo { grid-area: logo; }
  header nav { grid-area: nav; }
  header form.salir { grid-area: salir; margin: 0; }
  header form.salir button { width: auto; }
  header nav {
    flex-wrap: nowrap; overflow-x: auto; gap: 4px 18px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  header nav::-webkit-scrollbar { display: none; }
  header nav a { white-space: nowrap; padding: 6px 0; font-size: 0.95em; }

  main { padding: 14px; }
  .toolbar { gap: 8px 10px; }
  .toolbar select { flex: 1 1 auto; padding: 8px; }

  /* Listado: cada fila → tarjeta apilada con etiqueta por campo */
  table.listings { border: 0; font-size: 1em; }
  table.listings thead { display: none; }
  table.listings tr {
    display: flex; flex-direction: column;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; margin-bottom: 12px; padding: 4px 14px;
  }
  table.listings td {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 14px; padding: 9px 0; text-align: right;
    border-bottom: 1px solid #f2f1ec;
  }
  table.listings td:last-child { border-bottom: 0; }
  table.listings td::before {
    content: attr(data-label); font-weight: 600;
    color: var(--muted); text-align: left; flex: 0 0 auto;
  }
  /* El título es la cabecera de la tarjeta (arriba del todo, sin etiqueta) */
  table.listings td.col-titulo {
    order: -1; display: block; text-align: left;
    padding-top: 12px; border-bottom: 1px solid #f2f1ec;
  }
  table.listings td.col-titulo::before { display: none; }
  table.listings td.col-titulo a { font-size: 1.1em; font-weight: 600; }

  /* Ficha de propiedad: pares clave/valor apilados */
  .kv, .kv tbody, .kv tr, .kv th, .kv td { display: block; width: auto; }
  .kv th { padding: 10px 0 2px; }
  .kv td { padding: 0 0 6px; }

  .card { padding: 14px 16px; }
  button { width: 100%; }
}

/* ------------------------------------------------------------------ acceso */
/* Pantalla de login. La nav solo se pinta con sesión (base.html), así que
   aquí la tarjeta se queda sola y centrada. */
.acceso { max-width: 380px; margin: 8vh auto 0; }
.acceso h1 { margin-top: 0; font-size: 1.25em; }
.acceso label {
  display: block; margin: 14px 0 5px; font-size: 0.85em; color: #666;
}
.acceso input {
  width: 100%; padding: 10px; font: inherit; box-sizing: border-box;
  border: 1px solid #ccc; border-radius: 6px;
}
.acceso button { width: 100%; margin-top: 18px; }
/* Salir: pegado a la derecha del header, fuera de la nav (en móvil la nav es
   una barra deslizable y el botón quedaría escondido al final). */
header form.salir { margin: 0 0 0 auto; }
header form.salir button {
  padding: 4px 10px; font-size: 0.9em; width: auto;
  background: transparent; border: 1px solid rgba(255,255,255,.45); color: #fff;
}

.acceso #btn-huella {
  background: transparent; border: 1px solid #999; color: inherit;
}
.oculto { display: none !important; }

/* --------------------------------------------------------------- huella */
.lista-passkeys { margin-top: 10px; }
.fila-passkey {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid #ddd; gap: 10px;
}
.fila-passkey:last-child { border-bottom: 0; }
.fila-passkey .nombre { font-weight: 600; }
.fila-passkey .fechas { font-size: 0.8em; color: #666; margin-top: 2px; }
.fila-passkey form { flex-shrink: 0; }
