/* Estilos de la plataforma Gestión de Visitas */
  :root {
    /* Marca LEDESMA & Asoc.: naranja + negro */
    --brand: #ff5c01;
    --brand-ink: #111111;
    --bg: #f6f3f0;
    --surface: #ffffff;
    --border: #e4ddd6;
    --text: #1a1a1a;
    --muted: #6b625b;
    --primary: #d9560f;
    --primary-text: #ffffff;
    --accent-soft: #fdeadf;
    --ok-bg: #e3f4e8; --ok: #1d7a3a;
    --warn-bg: #fff1d0; --warn: #8a5a00;
    --bad-bg: #fde4e2; --bad: #b3261e;
    --info-bg: #fdeadf; --info: #a8430b;
    --radius: 12px;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #131211; --surface: #1d1b1a; --border: #36312d; --text: #ece8e4; --muted: #a59c94;
      --primary: #ff7a2e; --primary-text: #111111; --accent-soft: #3a2316;
      --ok-bg: #16331f; --ok: #7fd69a; --warn-bg: #3a2e10; --warn: #f2c35b;
      --bad-bg: #3d1a18; --bad: #ff9a90; --info-bg: #3a2316; --info: #ffb07a;
    }
  }
  :root[data-theme="dark"] {
    --bg: #131211; --surface: #1d1b1a; --border: #36312d; --text: #ece8e4; --muted: #a59c94;
    --primary: #ff7a2e; --primary-text: #111111; --accent-soft: #3a2316;
    --ok-bg: #16331f; --ok: #7fd69a; --warn-bg: #3a2e10; --warn: #f2c35b;
    --bad-bg: #3d1a18; --bad: #ff9a90; --info-bg: #3a2316; --info: #ffb07a;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; }
  body {
    background: var(--bg); color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  }
  /* Encabezado y pestañas quedan fijos arriba al desplazarse */
  .cabecera { position: sticky; top: 0; z-index: 1000; }
  header {
    background:
      linear-gradient(160deg, transparent 0 62%, rgba(255,255,255,.55) 62% 63%, transparent 63%),
      var(--brand);
    color: var(--brand-ink);
    border-bottom: 3px solid var(--brand-ink);
    display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
    padding: 10px 16px;
  }
  .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .brand-mark { width: 34px; height: 38px; flex: none; color: var(--brand-ink); }
  .brand-img { height: 64px; }
  @media (max-width: 560px) { .brand-img { height: 52px; } }
  .brand-text { line-height: 1.05; }
  .brand-text .small-top { font-size: 11px; color: #fff; font-weight: 600; }
  .brand-text .name { font-size: 20px; font-weight: 900; letter-spacing: .5px; color: var(--brand-ink); }
  .brand-text .name span { font-size: 12px; font-weight: 600; letter-spacing: 0; }
  .brand-text .sub { font-size: 11px; color: var(--brand-ink); }
  .user-chip { font-size: 13px; color: var(--brand-ink); display: flex; align-items: center; gap: 8px; }
  .user-chip button { background: var(--brand-ink); color: #fff; border-color: var(--brand-ink); }
  .login-hero { background: var(--brand); border-radius: var(--radius); padding: 28px 16px; text-align: center; margin-bottom: 14px; border-bottom: 4px solid var(--brand-ink); }
  .login-hero .brand { justify-content: center; }
  .login-hero .brand-img { height: auto; width: min(340px, 100%); }
  .login-hero .brand-mark { width: 56px; height: 64px; }
  .login-hero .brand-text { text-align: left; }
  .login-hero .brand-text .name { font-size: 32px; }
  .login-hero p { margin: 14px 0 0; color: var(--brand-ink); font-weight: 600; }

  main { max-width: 760px; margin: 0 auto; padding: 16px; }
  h2 { font-size: 20px; margin: 4px 0 14px; border-left: 4px solid var(--primary); padding-left: 10px; }
  h3 { font-size: 15px; margin: 0 0 10px; }
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
  label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
  input, select, textarea {
    width: 100%; font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  }
  textarea { min-height: 110px; resize: vertical; }
  button {
    font: inherit; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); padding: 9px 14px; cursor: pointer;
  }
  button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
  button.small { padding: 5px 10px; font-size: 13px; }
  button:disabled { opacity: .5; cursor: not-allowed; }
  .row { display: flex; gap: 10px; flex-wrap: wrap; }
  .row > * { flex: 1 1 160px; }
  .between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
  .muted { color: var(--muted); font-size: 13px; }
  .badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
  .b-ok { background: var(--ok-bg); color: var(--ok); }
  .b-warn { background: var(--warn-bg); color: var(--warn); }
  .b-bad { background: var(--bad-bg); color: var(--bad); }
  button.peligro { color: var(--bad); border-color: var(--bad); background: var(--surface); }
  .edif-inactivo { opacity: .6; background: var(--bg); }
  button.peligro:hover { background: var(--bad-bg); }
  .b-info { background: var(--info-bg); color: var(--info); }
  .b-dark { background: var(--text); color: var(--bg); }
  .error { color: var(--bad); font-size: 13px; margin-top: 8px; }
  .notice { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-top: 10px; }

  /* Selector de edificio con filtro */
  .combo { position: relative; }
  .combo-list {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 500; margin-top: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    max-height: 260px; overflow-y: auto; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  }
  .combo-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
  .combo-item:last-child { border-bottom: 0; }
  .combo-item:hover, .combo-item.active { background: var(--info-bg); }
  .combo-item small { display: block; color: var(--muted); }

  /* Firma */
  /* Firma: botón + vista previa; la firma se hace en una hoja a pantalla completa */
  .dictado { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
  /* Botones de ícono (dictar, foto, adjuntar): chicos y fáciles de tocar en el teléfono */
  .btn-icono { width: 44px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 20px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; flex: none; margin: 0; font-weight: normal; }
  .btn-icono:hover { background: var(--accent-soft); }
  .btn-icono:disabled { opacity: .5; }
  .r-herr { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
  .r-herr .dictado-txt { font-size: 12px; }
  .r-herr .dictado-txt:empty { display: none; }
  .r-adj { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .r-adj:empty { display: none; }
  .mini { position: relative; width: 64px; height: 64px; flex: none; }
  .mini img, .mini .mini-arch { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 26px; background: var(--accent-soft); }
  .mini .mini-arch small { display: none; }
  .mini button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 12px; line-height: 1; }
  .r-err { color: var(--bad); font-size: 12px; margin-top: 4px; }
  .r-err:empty { display: none; }
  .adj-total { font-size: 12px; margin-top: 6px; text-align: right; }
  .btn-dictar { font-weight: 600; }
  .btn-dictar.grabando { background: #c62828; border-color: #c62828; color: #fff; animation: latido 1.2s ease-in-out infinite; }
  .btn-dictar.btn-icono { font-weight: normal; }
  @keyframes latido { 50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, .2); } }
  .btn-firma { width: 100%; padding: 12px; font-weight: 600; border: 2px dashed var(--primary); color: var(--primary); background: var(--accent-soft); }
  .firma-vista { display: block; width: 100%; max-width: 420px; height: 130px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
  #firmaEncargado.disabled, #firmaCert.disabled { opacity: .4; }
  .firmante-opciones { display: flex; gap: 18px; flex-wrap: wrap; }
  .firmante-opciones .check { margin: 4px 0; }
  .hoja-firma { position: fixed; inset: 0; z-index: 5000; background: #fff; color: #111; display: flex; flex-direction: column;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); touch-action: none; overscroll-behavior: contain; }
  .hoja-top { padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid #e5e5e5; font-size: 16px; }
  .hoja-top span { font-size: 13px; color: #666; }
  .hoja-lienzo { flex: 1; position: relative; margin: 12px; border: 2px dashed #c9c9c9; border-radius: 12px; overflow: hidden; background: #fff; }
  .hoja-lienzo canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
  .hoja-linea { position: absolute; left: 8%; right: 8%; bottom: 30%; border-bottom: 1px solid #aaa; pointer-events: none; }
  .hoja-botones { display: flex; gap: 10px; padding: 0 12px 12px; }
  .hoja-botones button { flex: 1; padding: 14px 8px; font-size: 16px; background: #f2f2f2; color: #111; border-color: #ddd; }
  .hoja-botones button.primary { background: #d9560f; color: #fff; border-color: #d9560f; }
  .check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 10px 0; }
  .check input { width: auto; }

  /* Lista de casillas (edificios habilitados) */
  .check-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
  .check-row { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 9px 12px; font-weight: 400; font-size: 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
  .check-row:last-child { border-bottom: 0; }
  .check-row input { width: auto; margin-top: 3px; }
  .check-row small { display: block; color: var(--muted); }

  .geo-box { border-radius: 8px; padding: 10px 12px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

  /* Listas */
  .clickable { cursor: pointer; }
  .clickable:hover { border-color: var(--primary); }
  .g-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
  .g-title { font-weight: 600; }
  .g-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
  .filters input, .filters select { padding: 8px 10px; font-size: 14px; }
  .item-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .item-row:last-child { border-bottom: 0; }
  .item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

  dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
  dl.kv dt { color: var(--muted); font-size: 13px; }
  dl.kv dd { margin: 0; word-break: break-word; }
  #map, #mapT { height: 260px; border-radius: 8px; margin-top: 10px; }
  .sig-img { background: #fff; border: 1px solid var(--border); border-radius: 8px; max-width: 100%; }
  .hist-item { border-left: 3px solid var(--primary); padding: 4px 0 4px 10px; margin-bottom: 10px; font-size: 14px; }

  nav.tabs {
    background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; box-shadow: 0 2px 6px rgba(0,0,0,.06);
  }
  nav.tabs button {
    flex: 1; border: 0; border-radius: 0; background: none; padding: 12px 4px; font-size: 14px; color: var(--muted);
  }
  .fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 1000; width: 60px; height: 60px; padding: 0;
    border: none; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .3); cursor: pointer; }
  .fab svg { width: 28px; height: 28px; display: block; }
  .fab:hover { filter: brightness(1.06); } .fab:active { transform: scale(.94); }
  body.con-fab #app { padding-bottom: 96px; }
  .g-sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
  .g-zonas { font-size: 13px; color: var(--muted); margin-top: 4px; }
  nav.tabs button.on { color: var(--primary); font-weight: 700; box-shadow: inset 0 -3px 0 var(--primary); }

  /* Formulario de certificado dentro de la gestión */
  .renglones { display: flex; flex-direction: column; gap: 10px; }
  .renglon { border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 10px; padding: 10px 12px 12px; background: var(--surface); }
  .renglon-cab { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); font-weight: 600; }
  .renglon-campos { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
  .renglon-campos label { margin-top: 6px; }
  .renglon-campos textarea { min-height: 80px; }
  @media (min-width: 720px) { .renglon-campos { grid-template-columns: 190px 1fr 150px; align-items: start; } }
  .btn-agregar-renglon { width: 100%; margin-top: 10px; border-style: dashed; font-weight: 600; }
  .rver { padding: 10px 0; border-top: 1px solid var(--border); }
  .rver:first-child { border-top: none; padding-top: 0; }
  .rver-cab { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
  .rver-agregado { font-size: 12px; font-weight: 700; color: var(--info); background: var(--info-bg); border-radius: 999px; padding: 2px 8px; }
  .rver-num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; align-items: center; justify-content: center; }
  /* Cabecera del renglón: estado y botones del mismo alto (32 px); los botones, cuadrados con el ícono centrado */
  .rver select { width: auto; height: 32px; padding: 0 8px; font-size: 13px; box-sizing: border-box; }
  .rver-acc { margin-left: auto; display: flex; align-items: center; gap: 6px; }
  .rver-acc .btn-icono { width: 32px; height: 32px; box-sizing: border-box; font-size: 15px; line-height: 1; }
  .cert-form { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 8px; padding: 12px; margin-top: 10px; }

  /* Certificado imprimible (siempre en colores claros, como el papel) */
  .cert { background: #fff; color: #111; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; font-size: 14px; }
  .cert-head { display: flex; align-items: center; gap: 12px; border-bottom: 3px solid #f26a1b; padding-bottom: 12px; margin-bottom: 14px; }
  .cert-head .brand-mark { color: #111; }
  .cert-org { font-weight: 800; letter-spacing: .5px; }
  .cert-title { font-weight: 700; color: #c24d0d; font-size: 13px; }
  .cert-num { margin-left: auto; font-weight: 700; font-size: 13px; white-space: nowrap; }
  .cert-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
  .cert-fields .full { grid-column: 1 / -1; }
  .cert-fields span { font-weight: 700; }
  .cert h4 { margin: 16px 0 6px; font-size: 14px; }
  .cert-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 4px 16px; }
  .cert-opt { display: flex; gap: 8px; align-items: center; }
  .cert-box { width: 16px; height: 16px; border: 1.5px solid #111; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex: none; }
  .cert p { text-align: justify; margin: 0; }
  .cert-otros { white-space: pre-wrap; border-bottom: 1px dashed #999; padding-bottom: 4px; }
  .cert-firmas { display: flex; justify-content: space-between; gap: 24px; margin-top: 24px; align-items: flex-end; }
  .cert-firmas > div { flex: 1; text-align: center; }
  .cert-firmas img { max-width: 100%; height: 90px; object-fit: contain; }
  .cert-line { border-top: 1px solid #111; padding-top: 4px; font-size: 13px; }
  .cert-small { font-size: 12px; color: #444; }
  .cert-dni { font-size: 16px; padding-bottom: 4px; }
  .cert-foot { margin-top: 22px; font-size: 11px; color: #555; border-top: 1px dashed #bbb; padding-top: 8px; }
  @media (max-width: 520px) { .cert { padding: 16px; } .cert-fields { grid-template-columns: 1fr; } }
  @media print {
    header, nav.tabs, .no-print { display: none !important; }
    body { background: #fff; padding: 0; }
    main { max-width: none; padding: 0; }
    .cert { border: 0; padding: 0; }
    @page { margin: 15mm; }
  }

  /* Fotos y archivos adjuntos */
  .btn-file {
    display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 9px 14px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px;
  }
  .row > .btn-file { flex: 0 0 auto; }
  .adj-barra { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 10px; }
  .adj-barra span { display: block; height: 100%; background: var(--primary); }
  .adj-lista { display: grid; gap: 8px; margin-top: 8px; }
  .adj-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
  .adj-thumb { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; flex: none; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 22px; }
  .adj-name { flex: 1; min-width: 0; font-size: 14px; }
  .adj-name div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Calendario de visitas */
  .cal-barra { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
  .cal-barra select { flex: 1 1 180px; width: auto; min-width: 0; }
  .cal-vistas { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
  .cal-vistas button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); }
  .cal-vistas button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
  .cal-modo { margin: 4px 0 10px; }
  .cal-leyenda { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
  .ev { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
  .ev-programada { background: var(--warn-bg); color: var(--warn); }
  .ev-realizada { background: var(--ok-bg); color: var(--ok); }
  .ev-sinrealizar { background: var(--bad-bg); color: var(--bad); }
  .ev-cancelada { background: var(--border); color: var(--muted); text-decoration: line-through; }
  .cal-grupo { display: flex; align-items: baseline; gap: 8px; margin: 16px 0 8px; }
  .cal-grupo h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; text-transform: capitalize; }
  .cal-grupo-mal h3 { color: var(--bad); }
  .cal-tarjeta { width: 100%; text-align: left; display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: start; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 8px; cursor: pointer; }
  .cal-tarjeta:hover { border-color: var(--brand); }
  .cal-fecha { text-align: center; border-right: 1px solid var(--border); padding-right: 8px; font-variant-numeric: tabular-nums; }
  .cal-fecha .dia { font-size: 24px; font-weight: 800; line-height: 1; }
  .cal-fecha .mes { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
  .cal-cuerpo { min-width: 0; }
  .cal-nota { font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
  .cal-hechas summary { cursor: pointer; font-weight: 700; color: var(--muted); margin: 16px 0 8px; }
  .cal-cab { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
  .cal-cab h3 { flex: 1; margin: 0; text-transform: capitalize; }
  .cal-ayuda { font-size: 12px; margin: 0 0 6px; }
  .cal-grilla { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
  .cal-grilla .dsem { background: var(--surface); font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 6px 0; text-transform: uppercase; }
  .cal-celda { background: var(--surface); min-height: 96px; padding: 5px; display: flex; flex-direction: column; gap: 3px; min-width: 0; cursor: pointer; }
  .cal-celda.fuera { background: var(--bg); color: var(--muted); }
  .cal-celda .num { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .cal-celda.hoy .num { background: var(--brand); color: #fff; border-radius: 999px; width: 24px; height: 24px; display: grid; place-items: center; }
  .cal-celda.sel { box-shadow: inset 0 0 0 2px var(--brand); }
  .cal-chip { font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cal-celda .mas, .cal-col .mas { font-size: 11px; color: var(--muted); }
  .cal-celda .puntos { display: none; gap: 3px; flex-wrap: wrap; }
  .cal-celda .puntos i { width: 7px; height: 7px; border-radius: 50%; display: block; padding: 0; }
  .cal-semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
  .cal-col { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; min-width: 0; min-height: 90px; }
  .cal-col.hoy { border-color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
  .cal-col h4 { margin: 0 0 6px; font-size: 13px; text-transform: capitalize; }
  .cal-bloque { width: 100%; text-align: left; border: 0; border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: 13px; text-decoration: none; }
  .cal-bloque b, .cal-bloque span, .cal-bloque small { display: block; overflow-wrap: anywhere; }
  .cal-bloque small { opacity: .8; }
  .cal-velo { position: fixed; inset: 0; z-index: 2050; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
  .cal-hoja { background: var(--surface); color: var(--text); width: 100%; max-width: 560px; max-height: 92%; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  @media (min-width: 700px) { .cal-velo { align-items: center; } .cal-hoja { border-radius: 16px; } }
  .cal-estados { display: flex; gap: 12px; flex-wrap: wrap; }
  .cal-acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
  .cal-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); background: var(--text); color: var(--surface);
    padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 2200; max-width: calc(100% - 32px); }
  .cal-toast button { margin-left: 10px; background: none; border: 0; color: var(--brand); font-weight: 800; text-decoration: underline; padding: 0; }
  #calCont .arrastrable { cursor: grab; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  body.arrastrando, body.arrastrando * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
  #calCont .levantado { opacity: .35; }
  .cal-fantasma { position: fixed; z-index: 2300; pointer-events: none; transform: rotate(-2deg); box-shadow: 0 8px 22px rgba(0, 0, 0, .3); max-width: 220px; }
  .destino-ok { box-shadow: inset 0 0 0 3px var(--brand) !important; }
  .destino-no { box-shadow: inset 0 0 0 3px var(--bad) !important; }
  @media (max-width: 640px) {
    .cal-tarjeta { grid-template-columns: 46px 1fr; }
    .cal-tarjeta > .ev { grid-column: 2; justify-self: start; }
    .cal-celda { min-height: 54px; padding: 3px; }
    .cal-celda .cal-chip, .cal-celda .mas { display: none; }
    .cal-celda .puntos { display: flex; }
    .cal-semana { grid-template-columns: 1fr; }
  }
  /* Órdenes de trabajo */
  .ot-pct-fila { display: flex; align-items: center; gap: 6px; margin-top: 6px; max-width: 260px; }
  .ot-pct { flex: 1; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; min-width: 60px; }
  .ot-pct span { display: block; height: 100%; background: var(--brand); }
  .ot-pct-txt { font-size: 12px; font-variant-numeric: tabular-nums; }
  .ot-avance { padding: 12px 0; border-top: 1px solid var(--border); }
  .ot-avance:first-of-type { border-top: none; }
  .ot-av-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .ot-av-cab .ot-pct { max-width: 140px; }
  .ot-coment { margin-top: 6px; font-size: 14px; background: var(--bg); border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; }
  .ot-geo { margin-top: 8px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .ot-form { border-left: 4px solid var(--brand); }
  .ot-subs { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px 8px; }
  .ot-subs .check { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--border); font-weight: 400; }
  .ot-subs .check:last-child { border-bottom: 0; }
  .ot-sub { padding: 10px 0; border-top: 1px solid var(--border); }
  .ot-sub:first-of-type { border-top: 0; }
  .ot-inicial { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
  .confirmar-velo { position: fixed; inset: 0; z-index: 2100; background: rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
  .confirmar-caja { background: var(--surface); color: var(--text); border-radius: 14px; padding: 18px; width: 100%; max-width: 360px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
  .confirmar-caja h3 { margin: 0 0 8px; font-size: 17px; }
  .confirmar-caja p { margin: 0 0 10px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
  .confirmar-caja img { width: 100%; max-height: 180px; object-fit: contain; border-radius: 8px; background: var(--accent-soft); margin-bottom: 10px; }
  .confirmar-botones { display: flex; gap: 8px; justify-content: flex-end; }
  .confirmar-botones button { min-width: 110px; padding: 10px 14px; font-weight: 700; }
  .confirmar-botones .peligro-lleno { background: var(--bad); border-color: var(--bad); color: #fff; }
  .visor { position: fixed; inset: 0; z-index: 2000; background: #0e0e10; display: flex; flex-direction: column; color: #fff; touch-action: pan-y pinch-zoom; }
  .visor-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .visor-top .visor-cont { font-weight: 700; font-size: 14px; }
  .visor-top .visor-nombre { flex: 1; min-width: 0; font-size: 13px; color: #cfcac4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .visor button { background: rgba(255, 255, 255, .12); color: #fff; border: none; border-radius: 999px; }
  .visor button:hover { background: rgba(255, 255, 255, .22); }
  .visor-cerrar { width: 40px; height: 40px; font-size: 20px; padding: 0; }
  .visor-centro { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
  .visor-centro img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .15s, transform .12s ease-out; cursor: zoom-in; transform-origin: center; }
  .visor-centro img.ampliada { cursor: grab; } .visor-centro img.arrastrando { cursor: grabbing; transition: opacity .15s; }
  .visor-zoom { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 999px; pointer-events: none; }
  .visor-zoom:empty { display: none; }
  .visor-centro img.cargando { opacity: .3; }
  .visor-flecha { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 26px; padding: 0; }
  .visor-flecha.izq { left: 12px; } .visor-flecha.der { right: 12px; }
  .visor-pie { padding: 8px 14px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); font-size: 12px; color: #cfcac4; text-align: center; min-height: 20px; }
  .visor-tiras { display: flex; gap: 6px; overflow-x: auto; padding: 0 14px 10px; justify-content: center; }
  .visor-tiras img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; opacity: .5; cursor: pointer; flex: none; border: 2px solid transparent; }
  .visor-tiras img.actual { opacity: 1; border-color: var(--brand); }
  @media (max-width: 560px) { .visor-flecha { width: 40px; height: 40px; font-size: 22px; } .visor-flecha.izq { left: 6px; } .visor-flecha.der { right: 6px; } }
  .galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 6px; }
  .r-galeria .galeria { grid-template-columns: repeat(auto-fill, 82px); }
  .galeria .tile { position: relative; }
  .galeria a { display: block; text-decoration: none; color: var(--text); }
  .galeria img, .archivo-tile { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--border); }
  .archivo-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px; background: var(--accent-soft); }
  .archivo-tile span { font-size: 30px; }
  .archivo-tile small { font-size: 11px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .galeria .borrar { position: absolute; top: 4px; right: 4px; padding: 2px 8px; background: rgba(0,0,0,.6); color: #fff; border: 0; }

  .comentario { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; margin-bottom: 10px; }
  a.tel { color: var(--primary); font-weight: 600; text-decoration: none; white-space: nowrap; display: inline-block; padding: 3px 0; }
  /* Mapa de edificios */
  #mapaEdificios { height: calc(100vh - 260px); min-height: 380px; border-radius: 8px; border: 1px solid var(--border); }
  .pin-edificio { background: none; border: none; cursor: pointer; }
  .pin-yo { background: #1d72f3 !important; border-color: #fff !important; box-shadow: 0 0 0 4px rgba(29, 114, 243, .25); }
  #mapaEdificios .maplibregl-ctrl-group button { width: 36px; height: 36px; }
  #mapaEdificios .maplibregl-popup-content { border-radius: 10px; padding: 10px 12px; }
  .pin { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
    font: 800 12px system-ui, sans-serif; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); font-style: normal; }
  .pin-pend { background: #d9560f; } .pin-ok { background: #1d7a3a; } .pin-vacio { background: #6b625b; }
  .leyenda-mapa { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; align-items: center; }
  .leyenda-mapa .pin { width: 16px; height: 16px; border-width: 1px; vertical-align: middle; margin-right: 4px; }
  .popup-edificio { min-width: 200px; font: 13px/1.4 system-ui, sans-serif; color: #1a1a1a; }
  .popup-edificio .muted { color: #6b625b; }
  .popup-titulo { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
  .popup-cuentas { display: flex; gap: 6px; margin: 8px 0; }
  .login-users { display: grid; gap: 8px; }
  .login-users button { text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .hidden { display: none !important; }
