:root{
  --bg:#eef4f8;--panel:#ffffff;--ink:#152432;--muted:#657587;--line:#dde7ef;
  --brand:#0f3d5e;--brand-2:#1e709e;--accent:#d9a441;--danger:#d94f4f;--ok:#1f9d73;
  --shadow:0 18px 45px rgba(15,61,94,.12);--radius:22px;--sidebar:292px;
}
*{box-sizing:border-box} body{margin:0;font-family:Inter,Segoe UI,Roboto,Arial,sans-serif;background:radial-gradient(circle at top left,#dcecf6,transparent 34%),var(--bg);color:var(--ink)}
button,input,select,textarea{font:inherit}.app-shell{min-height:100vh;display:flex}.sidebar{width:var(--sidebar);background:linear-gradient(180deg,#0d334f,#08263b);color:#fff;padding:24px;display:flex;flex-direction:column;gap:24px;position:fixed;inset:0 auto 0 0;z-index:10}.brand-stack{display:grid;gap:12px}.client-logo-box,.product-logo-box{height:58px;border-radius:18px;background:rgba(255,255,255,.1);display:flex;align-items:center;justify-content:center;overflow:hidden;border:1px solid rgba(255,255,255,.15)}.client-logo-box img,.product-logo-box img{max-width:88%;max-height:80%;object-fit:contain}.logo-missing:after{content:'Logo';opacity:.55}.eyebrow{margin:0;color:var(--muted);text-transform:uppercase;font-size:11px;letter-spacing:.13em;font-weight:800}.sidebar .eyebrow{color:#9fbed1}.brand-stack h1{margin:0;font-size:31px;letter-spacing:.05em}.menu{display:grid;gap:8px}.menu-item{width:100%;border:0;background:transparent;color:#d8e7f1;text-align:left;padding:13px 14px;border-radius:16px;display:flex;gap:12px;align-items:center;cursor:pointer}.menu-item:hover,.menu-item.active{background:rgba(255,255,255,.12);color:#fff}.menu-item span{width:24px;text-align:center;color:var(--accent)}.sidebar-footer{margin-top:auto;border-top:1px solid rgba(255,255,255,.14);padding-top:18px;display:flex;gap:11px;align-items:center}.sidebar-footer small{display:block;color:#a9c0cf}.status-dot{width:10px;height:10px;border-radius:50%;background:#64d98a;box-shadow:0 0 0 6px rgba(100,217,138,.12)}
.main{margin-left:var(--sidebar);width:calc(100% - var(--sidebar));padding:24px}.topbar{height:82px;background:rgba(255,255,255,.78);backdrop-filter:blur(16px);border:1px solid rgba(255,255,255,.85);box-shadow:var(--shadow);border-radius:var(--radius);display:flex;align-items:center;gap:18px;padding:0 18px;position:sticky;top:18px;z-index:5}.topbar h2,.panel h3,.hero-panel h3{margin:3px 0 0}.topbar-actions{margin-left:auto;display:flex;align-items:center;gap:10px}.search-box{height:44px;min-width:310px;background:#f3f7fa;border:1px solid var(--line);border-radius:14px;display:flex;align-items:center;gap:10px;padding:0 13px}.search-box input{border:0;background:transparent;outline:0;width:100%}.icon-btn,.ghost-btn,.primary-btn{border:0;border-radius:14px;cursor:pointer}.icon-btn{width:42px;height:42px;background:#eef5f9}.ghost-btn{height:42px;padding:0 15px;background:#edf4f8;color:var(--brand);font-weight:800}.primary-btn{height:42px;padding:0 17px;background:linear-gradient(135deg,var(--brand),var(--brand-2));color:#fff;font-weight:900;box-shadow:0 12px 26px rgba(15,61,94,.22)}.view{display:none;margin-top:24px}.active-view{display:block}.hero-panel{display:flex;justify-content:space-between;gap:20px;align-items:center;padding:28px;border-radius:28px;color:white;background:linear-gradient(135deg,#0f3d5e,#1d78aa 60%,#d9a441);box-shadow:var(--shadow)}.hero-panel p{max-width:650px;color:#e4f1f7}.hero-metric{background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.28);border-radius:24px;padding:22px;min-width:190px;text-align:center}.hero-metric strong{display:block;font-size:48px}.hero-metric span{font-weight:800}.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin:18px 0}.stat-card,.panel{background:var(--panel);border:1px solid rgba(255,255,255,.9);box-shadow:var(--shadow);border-radius:var(--radius)}.stat-card{padding:20px}.stat-card span{color:var(--muted);font-weight:800}.stat-card strong{display:block;font-size:34px;margin:8px 0}.stat-card small{color:var(--muted)}.content-grid{display:grid;grid-template-columns:1.4fr .8fr;gap:18px}.panel{padding:20px}.panel-header{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:16px}.timeline{display:grid;gap:12px}.timeline-item{display:flex;align-items:center;gap:12px;padding:14px;border-radius:16px;background:#f5f8fa}.badge{font-size:12px;font-weight:900;border-radius:999px;padding:6px 10px;background:#eaf2f7;color:var(--brand)}.badge.warn{background:#fff4d9;color:#9a6500}.badge.danger{background:#ffe6e6;color:#b93333}.donut-wrap{display:flex;align-items:center;justify-content:center;gap:24px;min-height:255px}.donut{width:150px;height:150px;border-radius:50%;background:conic-gradient(var(--brand) 0 42%,var(--brand-2) 42% 70%,var(--accent) 70% 86%,#9db4c5 86% 100%);position:relative}.donut:after{content:'';position:absolute;inset:26px;border-radius:50%;background:#fff}.legend{display:grid;gap:10px}.legend-row{display:flex;gap:10px;align-items:center;color:var(--muted);font-weight:700}.legend-dot{width:12px;height:12px;border-radius:50%;background:var(--brand)}.module-toolbar{display:flex;justify-content:space-between;gap:14px;align-items:center;margin-bottom:16px}.tabs{display:flex;gap:8px;flex-wrap:wrap}.tab{border:0;border-radius:999px;background:#fff;color:var(--brand);padding:10px 14px;font-weight:900;box-shadow:0 8px 20px rgba(15,61,94,.08);cursor:pointer}.tab.active{background:var(--brand);color:#fff}.toolbar-right{display:flex;gap:10px}.table-panel{padding-bottom:10px}.record-count{background:#edf4f8;color:var(--brand);font-weight:900;border-radius:999px;padding:8px 12px}.table-scroll{overflow:auto}table{width:100%;border-collapse:separate;border-spacing:0 10px;min-width:850px}th{font-size:12px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);text-align:left;padding:0 14px}td{background:#f8fbfd;padding:14px;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}td:first-child{border-left:1px solid var(--line);border-radius:16px 0 0 16px;font-weight:900;color:var(--brand)}td:last-child{border-right:1px solid var(--line);border-radius:0 16px 16px 0}.row-actions{display:flex;gap:8px}.mini-btn{border:0;border-radius:10px;padding:8px 10px;background:#e8f1f7;color:var(--brand);font-weight:800;cursor:pointer}.mini-btn.danger{background:#ffe9e9;color:#b53636}.modal-backdrop{position:fixed;inset:0;background:rgba(10,24,35,.55);display:none;align-items:center;justify-content:center;z-index:30;padding:20px}.modal-backdrop.is-open{display:flex}.modal{width:min(860px,96vw);max-height:90vh;overflow:auto;background:#fff;border-radius:26px;padding:22px;box-shadow:0 30px 80px rgba(0,0,0,.28)}.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}.field{display:grid;gap:7px}.field label{font-weight:900;color:#304556}.field input,.field select,.field textarea{border:1px solid var(--line);border-radius:14px;padding:12px;background:#f8fbfd;outline:0}.field.full{grid-column:1/-1}.modal-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:18px}.toast{position:fixed;right:24px;bottom:24px;background:#102f47;color:white;border-radius:16px;padding:15px 18px;box-shadow:var(--shadow);z-index:40;font-weight:800;display:none}.toast.is-open{display:block}
@media (max-width:1050px){.sidebar{transform:translateX(-105%);transition:.25s}.sidebar.open{transform:translateX(0)}.main{margin-left:0;width:100%}.topbar{align-items:flex-start;height:auto;padding:16px;flex-wrap:wrap}.topbar-actions{width:100%;margin-left:0;flex-wrap:wrap}.search-box{min-width:100%;}.stats-grid,.content-grid{grid-template-columns:1fr 1fr}.hero-panel{flex-direction:column;align-items:flex-start}.module-toolbar{align-items:flex-start;flex-direction:column}.form-grid{grid-template-columns:1fr}}@media (max-width:680px){.main{padding:12px}.stats-grid,.content-grid{grid-template-columns:1fr}.toolbar-right{width:100%;}.toolbar-right button,.topbar-actions button{flex:1}.hero-metric{width:100%}}

/* Corrección: el atributo hidden debe ocultar realmente overlays/toasts aunque el componente tenga display:flex definido. */
.modal-backdrop[hidden],
.toast[hidden] {
  display: none !important;
}


/* V3: modal cerrado por defecto. No depende del atributo hidden para evitar bloqueos y problemas de cache. */
#modalBackdrop{display:none !important;}
#modalBackdrop.is-open{display:flex !important;}
#toast{display:none !important;}
#toast.is-open{display:block !important;}


/* V4: logos sobre tarjeta clara para que no se pierdan con el fondo oscuro lateral. */
.client-logo-box,
.product-logo-box{
  height:64px;
  background:linear-gradient(180deg,#ffffff,#f3f8fc) !important;
  border:1px solid rgba(255,255,255,.75) !important;
  box-shadow:0 12px 28px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.9);
}
.client-logo-box img,
.product-logo-box img{
  max-width:86%;
  max-height:76%;
  filter:none;
}
.product-logo-box{
  margin-top:2px;
}
.logo-missing:after{
  color:#0f3d5e;
  opacity:.7;
}

/* V5: ajustes de experiencia móvil, menú, submenú Nuevo, tabs y tarjetas responsive. */
.new-record-wrap{position:relative;display:inline-flex}.new-record-wrap.is-hidden{display:none !important}.new-record-menu{position:absolute;right:0;top:calc(100% + 10px);width:255px;background:#fff;border:1px solid var(--line);border-radius:18px;box-shadow:0 22px 55px rgba(15,61,94,.18);padding:8px;display:none;z-index:20}.new-record-menu.is-open{display:grid;gap:4px}.new-record-menu button{border:0;background:transparent;text-align:left;padding:12px 13px;border-radius:13px;color:var(--ink);font-weight:800;cursor:pointer}.new-record-menu button:hover{background:#edf4f8;color:var(--brand)}.sidebar-overlay{display:none}.tabs{background:rgba(255,255,255,.68);border:1px solid rgba(255,255,255,.85);box-shadow:0 12px 28px rgba(15,61,94,.08);padding:8px;border-radius:22px;gap:6px}.tab{box-shadow:none;background:transparent;border-radius:16px;padding:12px 16px;transition:.18s}.tab:hover{background:#f4f8fb}.tab.active{box-shadow:0 10px 24px rgba(15,61,94,.20)}

@media (max-width:1050px){
  .sidebar{z-index:25;box-shadow:24px 0 70px rgba(0,0,0,.24)}
  .sidebar-overlay{position:fixed;inset:0;background:rgba(7,24,38,.36);backdrop-filter:blur(2px);z-index:18;display:none}.sidebar-overlay.is-open{display:block}
}

@media (max-width:680px){
  .client-logo-box,.product-logo-box{height:58px;border-radius:18px}.client-logo-box img{max-width:84%;max-height:68%}.product-logo-box img{max-width:64%;max-height:42px;width:auto;height:auto;object-fit:contain}.sidebar .eyebrow{font-size:10px;line-height:1.25;letter-spacing:.11em}.brand-stack h1{font-size:30px}.new-record-wrap{flex:1}.new-record-wrap .primary-btn{width:100%}.new-record-menu{position:fixed;left:18px;right:18px;top:auto;bottom:18px;width:auto;border-radius:22px;padding:10px;z-index:35}.tabs{width:100%;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border-radius:24px;padding:8px}.tab{width:100%;text-align:center;padding:13px 8px;font-size:16px}.toolbar-right{justify-content:center}.table-scroll{overflow:visible}table{min-width:0;border-collapse:collapse;border-spacing:0}table thead{display:none}table,tbody,tr,td{display:block;width:100%}tbody{display:grid;gap:14px}tbody tr{background:#f8fbfd;border:1px solid var(--line);border-radius:20px;padding:14px;box-shadow:0 10px 24px rgba(15,61,94,.06)}td{display:grid;grid-template-columns:110px 1fr;gap:12px;align-items:start;background:transparent !important;border:0 !important;border-radius:0 !important;padding:8px 0;color:var(--ink)}td:first-child{font-weight:900;color:var(--brand)}td::before{content:attr(data-label);font-size:11px;letter-spacing:.09em;text-transform:uppercase;color:var(--muted);font-weight:900;line-height:1.35}.row-actions{flex-wrap:wrap}.row-actions .mini-btn{flex:1;min-width:82px}.panel-header{align-items:flex-start}.record-count{white-space:nowrap}}


/* V6: ajustes solicitados. Menú Nuevo solo como desplegable en Dashboard, tabs móviles estilo anterior. */
.new-record-menu{
  max-height:min(460px, calc(100dvh - 170px));
  overflow:auto;
  overscroll-behavior:contain;
}

@media (max-width:680px){
  /* Mantiene el diseño nuevo en PC, pero en teléfono vuelve a un grupo de botones tipo píldora. */
  .tabs{
    width:100%;
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    padding:0;
    background:transparent;
    border:0;
    box-shadow:none;
    border-radius:0;
  }
  .tab{
    width:auto;
    flex:0 0 auto;
    text-align:center;
    border-radius:999px;
    background:#fff;
    padding:10px 14px;
    font-size:16px;
    box-shadow:0 8px 20px rgba(15,61,94,.08);
  }
  .tab.active{
    background:var(--brand);
    color:#fff;
    box-shadow:0 10px 24px rgba(15,61,94,.20);
  }

  /* El menú rápido solo existe en Dashboard. Cuando aparezca, se comporta como hoja inferior completa. */
  .new-record-menu{
    left:14px;
    right:14px;
    bottom:14px;
    max-height:calc(100dvh - 120px);
    overflow:auto;
  }
}


/* V7: corrección definitiva del menú + Nuevo en móvil.
   En iPhone/Safari algunas posiciones ancladas al botón quedaban cortadas por el viewport dinámico.
   Por eso, en móvil el menú se muestra como panel flotante amplio, separado del topbar. */
@media (max-width:680px){
  #newRecordMenu.new-record-menu.is-open{
    position:fixed !important;
    left:16px !important;
    right:16px !important;
    top:92px !important;
    bottom:calc(env(safe-area-inset-bottom, 0px) + 18px) !important;
    width:auto !important;
    max-height:none !important;
    overflow-y:auto !important;
    display:block !important;
    z-index:9999 !important;
    padding:12px !important;
    border-radius:24px !important;
    box-shadow:0 28px 80px rgba(7,24,38,.28) !important;
    -webkit-overflow-scrolling:touch;
  }
  #newRecordMenu.new-record-menu.is-open button{
    display:block;
    width:100%;
    padding:14px 15px;
    margin:2px 0;
    border-radius:15px;
    font-size:15px;
  }
}


/* V8: el selector de creación rápida en móvil se sacó del topbar.
   Ahora se muestra como una hoja inferior independiente para evitar cortes en Safari/iPhone. */
.quick-create-backdrop{
  position:fixed;
  inset:0;
  display:none;
  align-items:flex-end;
  justify-content:center;
  background:rgba(7,24,38,.38);
  backdrop-filter:blur(3px);
  z-index:10000;
  padding:16px;
}
.quick-create-backdrop.is-open{display:flex;}
.quick-create-sheet{
  width:min(520px,100%);
  max-height:calc(100dvh - 40px);
  overflow:auto;
  background:#fff;
  border:1px solid var(--line);
  border-radius:26px;
  box-shadow:0 30px 90px rgba(7,24,38,.34);
  padding:18px;
  -webkit-overflow-scrolling:touch;
}
.quick-create-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}
.quick-create-header h3{margin:2px 0 0;}
.quick-create-list{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.quick-create-list button{
  border:1px solid var(--line);
  background:#f8fbfd;
  color:var(--brand);
  text-align:left;
  border-radius:16px;
  padding:14px 13px;
  font-weight:900;
  cursor:pointer;
}
.quick-create-list button:hover{background:#edf4f8;}
body.sheet-open{overflow:hidden;}

@media (max-width:680px){
  /* En móvil el menú anclado al botón queda deshabilitado; se usa la hoja inferior. */
  #newRecordMenu.new-record-menu.is-open{display:none !important;}
  .quick-create-backdrop{padding:12px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);}
  .quick-create-sheet{border-radius:24px;max-height:min(78dvh, 620px);}
  .quick-create-list{grid-template-columns:1fr;gap:8px;}
  .quick-create-list button{padding:14px 15px;font-size:15px;}
}


/* V9: nuevos ajustes generales solicitados. */
.search-box.is-hidden{display:none !important;}
.tabs.is-hidden{display:none !important;}
.module-toolbar.is-no-tabs{justify-content:flex-end;}

@media (max-width:680px){
  /* Submenús de módulos en una sola línea con desplazamiento horizontal, manteniendo el look de PC. */
  .tabs{
    width:100%;
    display:flex !important;
    flex-wrap:nowrap !important;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    background:rgba(255,255,255,.68);
    border:1px solid rgba(255,255,255,.85);
    box-shadow:0 12px 28px rgba(15,61,94,.08);
    border-radius:22px;
    padding:8px;
    gap:8px;
  }
  .tabs::-webkit-scrollbar{display:none;}
  .tab{
    flex:0 0 auto !important;
    width:auto !important;
    white-space:nowrap;
    padding:11px 16px;
    border-radius:16px;
    background:transparent;
    box-shadow:none;
    font-size:15px;
  }
  .tab.active{
    box-shadow:0 10px 24px rgba(15,61,94,.20);
  }

  /* Tarjetas móviles: acciones sin título y en una sola línea ocupando todo el ancho. */
  td.actions-cell{
    grid-template-columns:1fr;
    padding-top:14px;
  }
  td.actions-cell::before{display:none;content:none;}
  .row-actions{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:10px;
    width:100%;
  }
  .row-actions .mini-btn{
    width:100%;
    min-width:0;
    padding:11px 8px;
    text-align:center;
  }
}


/* V11: Diseño especializado para Tomadores. */
.modal:has(.tomador-form){
  width:min(1120px,96vw);
}

.tomador-form{
  display:grid;
  gap:18px;
}

.tomador-intro{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:20px;
  border-radius:24px;
  background:linear-gradient(135deg,#eef7fc,#ffffff);
  border:1px solid var(--line);
}

.tomador-intro h4{
  margin:4px 0 8px;
  font-size:24px;
}

.tomador-intro p{
  margin:0;
  color:var(--muted);
  max-width:680px;
}

.tomador-pill{
  flex:0 0 auto;
  background:linear-gradient(135deg,var(--brand),var(--brand-2));
  color:#fff;
  border-radius:999px;
  padding:11px 15px;
  font-weight:900;
  box-shadow:0 12px 26px rgba(15,61,94,.18);
}

.form-section{
  background:#fbfdff;
  border:1px solid var(--line);
  border-radius:24px;
  padding:18px;
}

.section-title{
  display:flex;
  align-items:flex-start;
  gap:12px;
  margin-bottom:16px;
}

.section-title > span{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:12px;
  color:#fff;
  background:var(--brand);
  font-size:12px;
  font-weight:900;
}

.section-title h4{
  margin:0;
  font-size:18px;
}

.section-title p{
  margin:3px 0 0;
  color:var(--muted);
  font-size:14px;
}

.type-switch{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:14px;
}

.type-option{
  display:flex;
  align-items:center;
  gap:8px;
  padding:11px 14px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
  color:var(--brand);
  font-weight:900;
  cursor:pointer;
}

.type-option:has(input:checked){
  background:var(--brand);
  color:#fff;
  border-color:var(--brand);
  box-shadow:0 10px 24px rgba(15,61,94,.18);
}

.type-option input{
  accent-color:var(--brand-2);
}

.section-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}

.section-grid .full{
  grid-column:1/-1;
}

.family-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}

.family-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:20px;
  padding:14px;
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}

.family-card h5{
  grid-column:1/-1;
  margin:0;
  color:var(--brand);
  font-size:15px;
}

.documents-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}

.document-card{
  min-height:130px;
  border:1px dashed #b8ccd9;
  border-radius:20px;
  padding:16px;
  background:#fff;
  display:grid;
  gap:10px;
  align-content:start;
  cursor:pointer;
}

.document-card span{
  color:var(--brand);
  font-weight:900;
}

.document-card small{
  color:var(--muted);
}

.document-card .doc-status{
  color:var(--ok);
  font-weight:800;
}

.document-card input{
  border:0;
  padding:0;
  background:transparent;
  font-size:13px;
}

.policy-shortcuts{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.related-policies{
  margin-top:14px;
  padding:14px;
  border-radius:18px;
  background:#f3f8fb;
  color:var(--muted);
}

.related-policies p{
  margin:0;
}

.related-list{
  display:grid;
  gap:10px;
}

.related-list article{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:12px;
  border-radius:14px;
  background:#fff;
  border:1px solid var(--line);
}

.related-list strong{
  color:var(--brand);
}

.related-list span{
  color:var(--muted);
}

@media (max-width:900px){
  .section-grid,
  .family-grid,
  .documents-grid{
    grid-template-columns:1fr;
  }

  .family-card{
    grid-template-columns:1fr;
  }
}

@media (max-width:680px){
  .modal:has(.tomador-form){
    width:96vw;
    padding:16px;
  }

  .tomador-intro{
    align-items:flex-start;
    flex-direction:column;
    padding:16px;
  }

  .tomador-intro h4{
    font-size:20px;
  }

  .tomador-pill{
    width:100%;
    text-align:center;
  }

  .form-section{
    padding:15px;
    border-radius:20px;
  }

  .section-title{
    gap:10px;
  }

  .type-switch{
    display:grid;
    grid-template-columns:1fr;
  }

  .type-option{
    justify-content:center;
  }

  .policy-shortcuts{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .policy-shortcuts .mini-btn{
    width:100%;
  }

  .related-list article{
    flex-direction:column;
  }
}


/* V12: ajustes de Tomadores solicitados. */
.primary-btn:disabled{
  opacity:.48;
  cursor:not-allowed;
  box-shadow:none;
  filter:saturate(.55);
}

.field > span::after{
  content:'';
}

.field input[required] + small{
  display:none;
}

.field-error input,
.field-error textarea{
  border-color:#d94f4f !important;
  box-shadow:0 0 0 3px rgba(217,79,79,.10);
}

.field-error > span{
  color:#b53636;
}

@media (max-width:680px){
  html,
  body{
    width:100%;
    max-width:100%;
    overflow-x:hidden;
  }

  .app-shell,
  .main,
  .topbar,
  .panel,
  .modal,
  .modal-backdrop,
  .tomador-form,
  .form-section,
  .section-grid,
  .family-grid,
  .family-card,
  .documents-grid,
  .document-card{
    max-width:100%;
  }

  .modal-backdrop{
    padding:10px;
    align-items:flex-start;
    overflow-y:auto;
    overflow-x:hidden;
  }

  .modal:has(.tomador-form){
    width:100%;
    max-width:100%;
    max-height:none;
    overflow-x:hidden;
  }

  .tomador-form{
    overflow-x:hidden;
  }

  .section-grid,
  .family-grid,
  .family-card,
  .documents-grid{
    width:100%;
    min-width:0;
  }

  .field,
  .field input,
  .field textarea,
  .document-card input{
    min-width:0;
    width:100%;
  }

  .section-title{
    min-width:0;
  }

  .section-title div{
    min-width:0;
  }

  .section-title h4,
  .section-title p,
  .tomador-intro h4,
  .tomador-intro p{
    overflow-wrap:anywhere;
  }
}


/* V19: ajustes responsive de Tomadores en móvil. */
input[type="date"]{
  text-align:left;
  justify-content:flex-start;
  min-width:0;
}

@media (max-width:680px){
  .modal-backdrop,
  .modal,
  .tomador-form,
  .form-section,
  .section-grid,
  .family-grid,
  .family-card,
  .documents-grid,
  .document-card,
  .table-card,
  .table-wrap,
  table,
  tbody,
  tr,
  td{
    max-width:100%;
    box-sizing:border-box;
  }

  .table-wrap{
    overflow-x:hidden !important;
  }

  table{
    width:100%;
    min-width:0 !important;
    table-layout:fixed;
  }

  tbody tr{
    width:100%;
    min-width:0;
    overflow:hidden;
  }

  tbody td{
    min-width:0;
    width:100%;
    grid-template-columns:minmax(82px,34%) minmax(0,1fr);
    column-gap:12px;
    align-items:start;
  }

  tbody td::before{
    min-width:0;
    overflow-wrap:anywhere;
  }

  tbody td:not(.actions-cell){
    overflow-wrap:anywhere;
    word-break:break-word;
  }

  tbody td:not(.actions-cell) *{
    max-width:100%;
    overflow-wrap:anywhere;
    word-break:break-word;
  }

  .actions-cell{
    width:100%;
  }

  .row-actions{
    grid-template-columns:repeat(3,minmax(0,1fr));
    width:100%;
  }

  .row-actions .mini-btn{
    min-width:0;
    width:100%;
    padding-left:6px;
    padding-right:6px;
  }

  .field input[type="date"]{
    display:block;
    width:100%;
    max-width:100%;
    min-width:0;
    text-align:left;
    -webkit-appearance:none;
    appearance:none;
    padding-left:13px;
    padding-right:13px;
  }

  .field:has(input[type="date"]){
    min-width:0;
    overflow:hidden;
  }

  .family-card .field{
    min-width:0;
  }
}


/* V20: pulido final base para Tomadores. */

/* Encabezado fijo al hacer scroll dentro de la rejilla en PC. */
@media (min-width:681px){
  .table-scroll{
    max-height:68vh;
    overflow:auto;
    position:relative;
  }

  table thead{
    position:sticky;
    top:0;
    z-index:4;
    background:#fff;
  }

  table thead th{
    position:sticky;
    top:0;
    z-index:5;
    background:#fff;
    padding-top:10px;
    padding-bottom:10px;
    box-shadow:0 1px 0 var(--line);
  }

  .table-panel .eyebrow:empty{
    display:none;
  }
}

/* Fechas: misma alineación y altura visual que los demás inputs. */
.field input[type="date"]{
  height:54px;
  line-height:54px;
  text-align:left !important;
  justify-content:flex-start !important;
  -webkit-appearance:none;
  appearance:none;
  padding:0 13px;
  display:block;
}

.field input[type="date"]::-webkit-date-and-time-value{
  text-align:left;
}

.field input[type="date"]::-webkit-datetime-edit{
  text-align:left;
  padding:0;
}

@media (max-width:680px){
  .table-panel .eyebrow:empty{
    display:none;
  }

  .field input[type="date"]{
    min-height:54px;
    height:54px;
    line-height:54px;
    padding-top:0;
    padding-bottom:0;
    text-align:left !important;
  }

  .field input[type="date"]::-webkit-date-and-time-value{
    text-align:left;
  }

  .field input[type="date"]::-webkit-datetime-edit{
    text-align:left;
  }
}


/* V21: ID de Tomador siempre en una sola línea. */
td[data-label="ID"],
td:first-child{
  white-space:nowrap;
}

@media (max-width:680px){
  td[data-label="ID"]{
    white-space:nowrap;
  }
}


/* V22: base completa para Asegurados usando el patrón de Tomadores. */
.asegurado-form .tomador-intro{
  background:linear-gradient(135deg,#eef7fc,#ffffff);
}

@media (min-width:681px){
  .table-panel .eyebrow:empty{
    display:none;
  }
}

@media (max-width:680px){
  .table-panel .eyebrow:empty{
    display:none;
  }

  td[data-label="ID"]{
    white-space:nowrap;
  }
}


/* V24: indicador global de carga/espera para consultas y guardados. */
.loading-overlay{
  position:fixed;
  inset:0;
  z-index:80;
  display:none;
  align-items:center;
  justify-content:center;
  padding:22px;
  background:rgba(9,26,38,.38);
  backdrop-filter:blur(5px);
}

.loading-overlay.is-visible{
  display:flex;
}

.loading-card{
  display:flex;
  align-items:center;
  gap:16px;
  max-width:420px;
  width:min(420px,100%);
  padding:20px 22px;
  border-radius:24px;
  background:rgba(255,255,255,.96);
  border:1px solid rgba(210,225,235,.9);
  box-shadow:0 22px 70px rgba(9,26,38,.22);
  color:var(--ink);
}

.loading-card strong{
  display:block;
  color:var(--brand);
  font-size:17px;
  margin-bottom:3px;
}

.loading-card p{
  margin:0;
  color:var(--muted);
  font-size:14px;
  line-height:1.35;
}

.loading-spinner{
  flex:0 0 auto;
  width:42px;
  height:42px;
  border-radius:50%;
  border:4px solid #dceaf2;
  border-top-color:var(--brand);
  animation:asegia-spin .8s linear infinite;
}

@keyframes asegia-spin{
  to{transform:rotate(360deg);}
}

@media (max-width:680px){
  .loading-overlay{
    align-items:flex-end;
    padding:18px;
  }

  .loading-card{
    border-radius:22px;
    padding:18px;
  }

  .loading-spinner{
    width:36px;
    height:36px;
    border-width:3px;
  }
}


/* V25: Bienes separados por tipo y base para Bienes Autos. */
.auto-form .auto-intro{
  background:linear-gradient(135deg,#eef7fc,#ffffff);
}

td[data-label="ID"],
td:first-child{
  white-space:nowrap;
}

@media (max-width:680px){
  td[data-label="ID"]{
    white-space:nowrap;
  }
}


/* V26: primera fase Pólizas Autos. */
.poliza-auto-form .poliza-auto-intro{
  background:linear-gradient(135deg,#eef7fc,#ffffff);
}

.policy-type-switch{
  margin-bottom:12px;
}

.master-note{
  color:var(--muted);
  font-size:13px;
  margin-top:10px;
  line-height:1.35;
}

.insured-draft-card{
  border:1px solid var(--line);
  background:#f8fbfd;
  border-radius:20px;
  padding:16px;
  margin-top:12px;
}

.insured-draft-card strong{
  color:var(--brand);
  display:block;
  margin-bottom:12px;
}

.compact-grid{
  gap:12px;
}

td[data-label="ID"],
td:first-child{
  white-space:nowrap;
}


/* V28: Pólizas Autos - selección visual más clara y maestros HTTP. */
.policy-choice-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
  margin-bottom:16px;
}

.policy-choice-block{
  border:1px solid var(--line);
  background:#f8fbfd;
  border-radius:20px;
  padding:14px;
}

.choice-title{
  display:block;
  margin:0 0 10px;
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--muted);
  font-weight:900;
}

.policy-type-switch.compact{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.policy-type-switch.compact .type-option{
  min-height:38px;
  padding:9px 13px;
  border-radius:999px;
  font-size:14px;
  flex:0 0 auto;
}

.master-input{
  cursor:pointer;
  background-image:linear-gradient(90deg,rgba(5,118,178,.04),rgba(255,255,255,0));
}

.master-note{
  border:1px dashed rgba(5,118,178,.22);
  background:rgba(5,118,178,.04);
  border-radius:16px;
  padding:10px 12px;
}

.master-picker-backdrop{
  position:fixed;
  inset:0;
  z-index:130;
  display:none;
  align-items:center;
  justify-content:center;
  padding:22px;
  background:rgba(8,24,38,.42);
  backdrop-filter:blur(5px);
}

.master-picker-backdrop.is-open{
  display:flex;
}

.master-picker-card{
  width:min(720px,100%);
  max-height:min(78vh,720px);
  overflow:hidden;
  border-radius:28px;
  background:#fff;
  box-shadow:0 30px 90px rgba(8,24,38,.28);
  border:1px solid rgba(210,225,235,.9);
  display:flex;
  flex-direction:column;
}

.master-picker-head{
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:flex-start;
  padding:22px 24px 14px;
  border-bottom:1px solid var(--line);
}

.master-picker-head h4{
  margin:4px 0 0;
  font-size:22px;
}

.master-picker-search{
  margin:16px 24px 12px;
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 14px;
  border:1px solid var(--line);
  border-radius:18px;
  background:#f8fbfd;
}

.master-picker-search input{
  border:0;
  background:transparent;
  outline:0;
  width:100%;
  min-height:48px;
  font:inherit;
  color:var(--ink);
}

.master-picker-results{
  overflow:auto;
  padding:0 24px 24px;
}

.master-result{
  width:100%;
  border:1px solid var(--line);
  background:#f8fbfd;
  border-radius:18px;
  padding:14px 16px;
  margin-top:10px;
  text-align:left;
  cursor:pointer;
  display:grid;
  gap:4px;
  color:var(--ink);
}

.master-result:hover{
  border-color:rgba(5,118,178,.35);
  box-shadow:0 10px 25px rgba(5,118,178,.08);
}

.master-result strong{
  font-size:16px;
  color:var(--brand);
}

.master-result span{
  color:var(--ink);
}

.master-result small,
.master-empty{
  color:var(--muted);
}

.master-empty{
  padding:18px;
  border:1px dashed var(--line);
  border-radius:18px;
  background:#f8fbfd;
}

.master-empty.error{
  color:#b52222;
  background:#fff2f2;
}

@media (max-width:680px){
  .policy-choice-grid{
    grid-template-columns:1fr;
  }

  .policy-type-switch.compact{
    flex-wrap:nowrap;
    overflow-x:auto;
    padding-bottom:2px;
  }

  .policy-type-switch.compact .type-option{
    white-space:nowrap;
    font-size:13px;
    min-height:36px;
  }

  .master-picker-backdrop{
    align-items:flex-end;
    padding:12px;
  }

  .master-picker-card{
    max-height:82vh;
    border-radius:24px;
  }

  .master-picker-head{
    padding:18px 18px 12px;
  }

  .master-picker-search{
    margin:14px 18px 10px;
  }

  .master-picker-results{
    padding:0 18px 18px;
  }
}


/* V29: Notificaciones Enviadas - tabla automática sin acciones. */
body[data-view="notificaciones"] .table-panel .eyebrow:empty{
  display:none;
}

body[data-view="notificaciones"] td[data-label="Evento"]{
  font-weight:800;
  color:var(--brand);
}

@media (min-width:681px){
  body[data-view="notificaciones"] .table-scroll{
    max-height:70vh;
  }

  body[data-view="notificaciones"] table{
    min-width:1180px;
  }

  body[data-view="notificaciones"] th,
  body[data-view="notificaciones"] td{
    white-space:nowrap;
  }

  body[data-view="notificaciones"] td[data-label="Nombre"],
  body[data-view="notificaciones"] td[data-label="Email"]{
    white-space:normal;
  }
}


/* V30: ajustes visuales de Notificaciones Enviadas. */
body[data-view="notificaciones"] td[data-label="ID"]{
  white-space:nowrap;
}

body[data-view="notificaciones"] td[data-label="Hora"]{
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}

body[data-view="notificaciones"] th:nth-child(9),
body[data-view="notificaciones"] th:nth-child(10){
  white-space:nowrap;
}

body[data-view="notificaciones"] th:nth-child(11){
  white-space:normal;
}

@media (max-width:680px){
  body[data-view="notificaciones"] td[data-label="Póliza #"]:empty,
  body[data-view="notificaciones"] td[data-label="Anexo #"]:empty,
  body[data-view="notificaciones"] td[data-label="Compañía"]:empty{
    display:none;
  }

  body[data-view="notificaciones"] td[data-label="Póliza #"]:empty::before,
  body[data-view="notificaciones"] td[data-label="Anexo #"]:empty::before,
  body[data-view="notificaciones"] td[data-label="Compañía"]:empty::before{
    display:none;
  }
}


/* V31: corrección final encabezados y campos opcionales en móvil para Notificaciones. */
body[data-view="notificaciones"] th:nth-child(9),
body[data-view="notificaciones"] th:nth-child(10),
body[data-view="notificaciones"] td[data-label="Póliza #"],
body[data-view="notificaciones"] td[data-label="Anexo #"]{
  white-space:nowrap !important;
  word-break:keep-all;
}

@media (max-width:680px){
  body[data-view="notificaciones"] td.optional-notification-cell.is-empty{
    display:none !important;
  }

  body[data-view="notificaciones"] td.optional-notification-cell.is-empty::before{
    display:none !important;
    content:none !important;
  }
}


/* V32: Vencimientos automáticos y vistas calendario. */
body[data-view="vencimientos"] .table-panel .eyebrow:empty{
  display:none;
}

body[data-view="vencimientos"] td[data-label="ID"]{
  white-space:nowrap;
}

body[data-view="vencimientos"] td[data-label="Fecha"]{
  white-space:nowrap;
  font-weight:800;
  color:var(--brand);
}

.venc-calendar{
  width:100%;
}

.venc-calendar-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:16px;
}

.venc-calendar-head h3{
  margin:2px 0 0;
  text-transform:capitalize;
}

.venc-calendar-head span{
  background:#eef6fa;
  color:var(--brand);
  border-radius:999px;
  padding:10px 14px;
  font-weight:900;
}

.venc-calendar-grid{
  display:grid;
  grid-template-columns:repeat(7,minmax(150px,1fr));
  gap:10px;
  min-width:1050px;
}

.venc-calendar.month-mode .venc-calendar-grid{
  grid-template-columns:repeat(7,minmax(138px,1fr));
  min-width:980px;
}

.venc-day{
  min-height:170px;
  border:1px solid var(--line);
  border-radius:18px;
  background:#f8fbfd;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

.venc-day.is-outside{
  opacity:.48;
}

.venc-day header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  padding:11px 12px;
  background:linear-gradient(135deg,#0f3d5e,#0576b2);
  color:#fff;
}

.venc-day header strong{
  font-size:13px;
}

.venc-day header span{
  background:rgba(255,255,255,.18);
  border:1px solid rgba(255,255,255,.26);
  border-radius:999px;
  min-width:30px;
  height:30px;
  display:grid;
  place-items:center;
  font-weight:900;
}

.venc-day-items{
  padding:10px;
  display:grid;
  gap:8px;
}

.venc-day-items em{
  color:var(--muted);
  font-style:normal;
  font-size:13px;
}

.venc-item{
  border:1px solid rgba(5,118,178,.14);
  background:#fff;
  border-radius:14px;
  padding:9px 10px;
  display:grid;
  gap:2px;
}

.venc-item b{
  color:var(--brand);
  font-size:13px;
}

.venc-item span{
  color:var(--ink);
  font-size:13px;
  line-height:1.25;
}

.venc-item small{
  color:var(--muted);
  font-weight:800;
}

@media (max-width:680px){
  .venc-calendar-head{
    align-items:flex-start;
    flex-direction:column;
  }

  .venc-calendar-grid,
  .venc-calendar.month-mode .venc-calendar-grid{
    display:grid;
    grid-template-columns:1fr;
    min-width:0;
  }

  .venc-day{
    min-height:auto;
  }

  .venc-day.is-outside{
    display:none;
  }
}


/* V34: calendario de vencimientos ubica registros por fecha real. */
.venc-day:has(.venc-item){
  border-color:rgba(5,118,178,.24);
  box-shadow:0 10px 28px rgba(5,118,178,.08);
}


/* V35: pulido calendario Vencimientos semana/mes. */
body.is-venc-calendar-view #recordCount{
  display:none;
}

.venc-calendar-head .eyebrow{
  display:none;
}

.venc-calendar-head h3{
  text-transform:none;
}

.venc-item b{
  text-transform:none;
}

.venc-mini-month{
  display:none;
  border:1px solid var(--line);
  background:#f8fbfd;
  border-radius:22px;
  padding:14px;
  margin:14px 0 16px;
}

.mini-month-title{
  font-weight:900;
  color:var(--brand);
  margin-bottom:12px;
  text-transform:capitalize;
}

.mini-month-weekdays,
.mini-month-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:6px;
  text-align:center;
}

.mini-month-weekdays span{
  color:var(--muted);
  font-size:12px;
  font-weight:900;
}

.mini-month-grid span{
  position:relative;
  min-height:34px;
  border-radius:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--ink);
}

.mini-month-grid span.is-outside{
  opacity:.32;
}

.mini-month-grid span.is-today{
  background:rgba(5,118,178,.11);
  color:var(--brand);
}

.mini-month-grid span i{
  position:absolute;
  width:6px;
  height:6px;
  border-radius:999px;
  background:var(--accent);
  bottom:4px;
}

@media (max-width:680px){
  .venc-mini-month{
    display:block;
  }
}


/* V36: en Vencimientos de la Semana, el mini calendario resalta solo la semana activa. */
.week-mode .mini-month-grid span.is-outside-selected-range{
  opacity:.34;
  background:transparent;
}

.week-mode .mini-month-grid span.is-outside-selected-range.has-item i{
  opacity:.55;
}

.week-mode .mini-month-grid span:not(.is-outside-selected-range){
  background:rgba(5,118,178,.06);
}

.week-mode .mini-month-grid span.is-today:not(.is-outside-selected-range){
  background:rgba(5,118,178,.16);
}


/* V37: Pólizas Autos - validaciones, encabezados y asegurados por defecto. */
.required-star{
  color:#c73c3c;
  font-weight:900;
}

body[data-view="polizas"] th:nth-child(3),
body[data-view="polizas"] td[data-label="Anexo #"]{
  white-space:nowrap !important;
  word-break:keep-all;
}

.poliza-auto-form .field-error input,
.poliza-auto-form .field-error textarea{
  border-color:#e35b5b !important;
  box-shadow:0 0 0 3px rgba(227,91,91,.12);
}

.policy-add-wrap{
  margin-top:14px;
}

.policy-add-wrap[style*="display: none"]{
  display:none !important;
}

.insured-draft-card{
  position:relative;
}

.insured-draft-card .field input[readonly]{
  cursor:pointer;
}

@media (max-width:680px){
  body[data-view="polizas"] td[data-label="Anexo #"]{
    white-space:normal;
  }
}


/* V38: limpieza modo real y vista de Pólizas Autos. */
.mock-status,
.mock-indicator,
.mode-mock,
.sidebar .mock-status{
  display:none !important;
}

#recordForm[data-mode="view"] .required-star{
  display:none !important;
}

#recordForm[data-mode="view"] .field-error input,
#recordForm[data-mode="view"] .field-error textarea{
  border-color:var(--line) !important;
  box-shadow:none !important;
}

#recordForm[data-mode="view"] .master-note{
  display:none !important;
}


/* V39: plurales reales y retiro definitivo de Modo maqueta. */
.sidebar-footer{
  display:none !important;
}

.policy-related-list article.related-policy-card{
  align-items:flex-start;
}

.related-policy-card{
  display:grid !important;
  grid-template-columns:minmax(220px,1fr) minmax(180px,.8fr);
}

.related-policy-card div{
  display:grid;
  gap:4px;
}

.related-policy-card small{
  color:var(--muted);
}

@media (max-width:680px){
  .related-policy-card{
    grid-template-columns:1fr;
  }
}


/* V40: scroll superior, encabezado sticky en móvil y navegación del mini calendario. */
@media (max-width:680px){
  .topbar{
    position:sticky;
    top:0;
    z-index:45;
    background:rgba(244,250,253,.94);
    backdrop-filter:blur(12px);
  }

  .module-toolbar{
    position:sticky;
    top:118px;
    z-index:40;
    background:rgba(244,250,253,.94);
    backdrop-filter:blur(12px);
    padding-top:8px;
    padding-bottom:8px;
  }

  .mini-month-grid span{
    cursor:pointer;
    transition:transform .16s ease, background .16s ease, opacity .16s ease;
  }

  .mini-month-grid span:active{
    transform:scale(.94);
  }
}

.venc-day{
  scroll-margin-top:150px;
}

.venc-day.is-focused-day{
  outline:3px solid rgba(5,118,178,.22);
  box-shadow:0 14px 32px rgba(5,118,178,.16);
}

@media (min-width:681px){
  .venc-day{
    scroll-margin-top:24px;
  }
}


/* V41: corrección móvil del sticky.
   El bloque cuadrado venía de hacer sticky a todo .module-toolbar.
   Ahora solo se fija el topbar y el carrusel .tabs, sin afectar Actualizar. */
@media (max-width:680px){
  .topbar{
    position:sticky !important;
    top:0 !important;
    z-index:6 !important; /* debajo del menú lateral y del modal */
    background:rgba(255,255,255,.82) !important;
    border:1px solid rgba(255,255,255,.88) !important;
    box-shadow:var(--shadow) !important;
    border-radius:var(--radius) !important;
    backdrop-filter:blur(16px) !important;
  }

  .module-toolbar{
    position:static !important;
    top:auto !important;
    z-index:auto !important;
    background:transparent !important;
    backdrop-filter:none !important;
    box-shadow:none !important;
    border:0 !important;
    padding:0 !important;
  }

  .module-toolbar .tabs:not(.is-hidden){
    position:sticky !important;
    top:150px !important;
    z-index:5 !important; /* debajo del topbar, menú lateral y modal */
    background:rgba(255,255,255,.78) !important;
    backdrop-filter:blur(14px) !important;
    margin-bottom:10px;
  }

  .module-toolbar .toolbar-right{
    position:static !important;
    background:transparent !important;
    backdrop-filter:none !important;
    box-shadow:none !important;
    border:0 !important;
    padding:0 !important;
  }

  /* Evita que el encabezado quede por encima de overlays. */
  .sidebar.open{
    z-index:20 !important;
  }

  #modalBackdrop.is-open,
  .quick-create-backdrop.is-open,
  .master-picker-backdrop.is-open{
    z-index:10000 !important;
  }

  #modalBackdrop.is-open ~ .topbar,
  body:has(.sidebar.open) .topbar,
  body:has(#modalBackdrop.is-open) .topbar{
    z-index:1 !important;
  }
}

/* Gestión documental v42: acceso por consulta y Google Drive */
.document-center{
  overflow:hidden;
}

.document-access-panel{
  border:1px dashed #b8ccd9;
  border-radius:20px;
  padding:18px;
  background:#fff;
  display:grid;
  gap:16px;
}

.document-access-copy strong{
  display:block;
  color:var(--brand);
  font-size:16px;
  font-weight:900;
  margin-bottom:5px;
}

.document-access-copy p,
.document-results-placeholder p{
  margin:0;
  color:var(--muted);
  line-height:1.5;
}

.document-access-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.document-drive-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
}

.document-results-placeholder{
  border-radius:16px;
  background:#f4f8fb;
  padding:14px 16px;
}

.document-results-placeholder span{
  display:block;
  color:var(--brand);
  font-weight:900;
  margin-bottom:4px;
}

@media (max-width:680px){
  .document-access-panel{
    padding:15px;
  }

  .document-access-actions{
    display:grid;
    grid-template-columns:1fr;
  }

  .document-access-actions .mini-btn,
  .document-drive-link{
    width:100%;
  }
}

/* Autenticación Cognito + Juli v43 */
.auth-button{
  max-width:240px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.auth-button.is-authenticated{
  border-color:rgba(15,61,94,.22);
  background:#eef6fb;
  color:var(--brand);
}

.js-process-inbox-documents:disabled{
  opacity:.65;
  cursor:wait;
}

@media (max-width:680px){
  .auth-button{
    max-width:145px;
  }
}


/* V43.4 · Resultados de búsqueda documental */
.document-results-head{display:grid;gap:4px;margin-bottom:12px}.document-results-head span{font-weight:900;color:var(--brand)}.document-results-head p{margin:0;color:var(--muted)}
.document-result-list{display:grid;gap:10px}.document-result-card{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px;border:1px solid var(--line);border-radius:16px;background:#fff}.document-result-main{display:grid;gap:7px;min-width:0}.document-result-main strong{color:var(--ink);overflow-wrap:anywhere}.document-result-meta{display:flex;flex-wrap:wrap;gap:7px}.document-result-meta span{font-size:12px;font-weight:800;color:var(--muted);background:#eef5f9;border-radius:999px;padding:5px 8px}.document-open-link{flex:0 0 auto;text-decoration:none;white-space:nowrap}.document-results-placeholder.has-results{background:#f7fafc}.document-results-placeholder.is-loading{position:relative}.document-results-placeholder.is-loading:before{content:'';display:inline-block;width:14px;height:14px;margin-right:8px;border:2px solid rgba(15,61,94,.2);border-top-color:var(--brand);border-radius:50%;animation:document-spin .8s linear infinite;vertical-align:-2px}.document-results-placeholder.is-error{background:#fff0f0;border-color:#f2caca}.document-results-placeholder.is-error span{color:#a92f2f}@keyframes document-spin{to{transform:rotate(360deg)}}
@media(max-width:720px){.document-result-card{align-items:stretch;flex-direction:column}.document-open-link{width:100%;text-align:center}}


/* V43.5 · Acceso obligatorio, gestión documental y afinación móvil */
:root{--mobile-topbar-height:138px}
.auth-gate{position:fixed;inset:0;z-index:20000;display:none;align-items:center;justify-content:center;background:linear-gradient(145deg,#eaf3f8,#d7e8f2);padding:24px}.auth-pending .auth-gate{display:flex}.auth-pending .app-shell{visibility:hidden}.auth-gate-card{display:flex;align-items:center;gap:14px;background:#fff;border:1px solid var(--line);border-radius:22px;padding:22px 26px;box-shadow:var(--shadow);color:var(--brand)}
.logged-user{max-width:260px;display:flex;align-items:center;gap:8px;padding:10px 13px;border:1px solid var(--line);border-radius:14px;background:#f1f7fa;color:var(--brand);font-weight:800;white-space:nowrap;overflow:hidden}.logged-user span:last-child{overflow:hidden;text-overflow:ellipsis}.logged-user-dot{width:9px;height:9px;flex:0 0 auto;border-radius:50%;background:var(--ok);box-shadow:0 0 0 5px rgba(31,157,115,.12)}
.document-management-page{padding:24px}.document-management-hero h3{font-size:28px;margin:4px 0 8px}.document-management-hero p:last-child{color:var(--muted);margin:0 0 20px;line-height:1.55}.document-management-panel{max-width:920px}.juli-chat-box{display:grid;gap:7px;border-top:1px solid var(--line);padding-top:16px}.juli-chat-input-wrap{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:end}.juli-chat-input-wrap textarea{width:100%;resize:vertical;min-height:56px;border:1px solid var(--line);border-radius:16px;background:#f7fafc;padding:14px;outline:none}.juli-chat-send{height:44px;border:0;border-radius:14px;padding:0 18px;background:var(--brand);color:#fff;font-weight:900}.juli-chat-box.is-preview textarea,.juli-chat-box.is-preview button{opacity:.72;cursor:not-allowed}.juli-chat-box small{color:var(--muted)}
.pull-refresh-indicator{position:fixed;left:50%;top:8px;z-index:12000;transform:translate(-50%,-64px);background:var(--brand);color:#fff;border-radius:999px;padding:9px 15px;font-size:12px;font-weight:900;box-shadow:0 10px 26px rgba(15,61,94,.28);transition:opacity .15s ease,transform .15s ease;opacity:0;pointer-events:none}.pull-refresh-indicator.is-visible{opacity:1}

@media(max-width:680px){
  html,body{overscroll-behavior-y:none}
  .main{padding:12px;padding-top:calc(var(--mobile-topbar-height) + 24px)}
  .topbar{position:fixed !important;top:12px !important;left:12px !important;right:12px !important;width:auto !important;height:auto !important;z-index:45 !important;margin:0 !important}
  .module-toolbar .tabs:not(.is-hidden){top:calc(var(--mobile-topbar-height) + 22px) !important;z-index:40 !important}
  .logged-user{max-width:100%;flex:1;min-width:0}
  .topbar-actions{display:grid;grid-template-columns:minmax(0,1fr) auto;width:100%}
  .topbar-actions .search-box{grid-column:1/-1}
  .topbar-actions .logged-user{grid-column:1}
  .topbar-actions .new-record-wrap{grid-column:2}
  .document-management-page{padding:18px}
  .document-management-hero h3{font-size:24px}
  .juli-chat-input-wrap{grid-template-columns:1fr}
  .juli-chat-send{width:100%}
}


/* V43.6 · Corrección del menú lateral y submenú horizontal fijo en móvil */
@media(max-width:680px){
  /* El menú lateral y su fondo siempre quedan por encima del encabezado y las pestañas. */
  .sidebar.open{
    z-index:110 !important;
  }

  .sidebar-overlay.is-open{
    display:block !important;
    z-index:100 !important;
  }

  /* Las pestañas del módulo permanecen fijas debajo del encabezado principal. */
  .module-toolbar:not(.is-no-tabs){
    padding-top:64px !important;
  }

  .module-toolbar .tabs:not(.is-hidden){
    position:fixed !important;
    top:calc(var(--mobile-topbar-height) + 20px) !important;
    left:12px !important;
    right:12px !important;
    width:auto !important;
    margin:0 !important;
    z-index:40 !important;
    background:rgba(255,255,255,.90) !important;
    border:1px solid rgba(255,255,255,.94) !important;
    box-shadow:0 12px 28px rgba(15,61,94,.13) !important;
    backdrop-filter:blur(16px) !important;
    -webkit-backdrop-filter:blur(16px) !important;
  }

  /* Al abrir el menú lateral, el submenú horizontal desaparece detrás del overlay. */
  body.sidebar-is-open .module-toolbar .tabs,
  body.sidebar-is-open .topbar{
    pointer-events:none !important;
  }

  body.sidebar-is-open .module-toolbar .tabs{
    visibility:hidden !important;
  }
}


/* V43.7 · corrección efectiva con invalidación de caché y capas móviles */
@media(max-width:680px){
  /* El panel lateral debe dominar cualquier elemento fijo del contenido. */
  #sidebar.sidebar{
    z-index:10020 !important;
  }
  #sidebar.sidebar.open{
    z-index:10020 !important;
  }
  #sidebarOverlay.sidebar-overlay.is-open{
    display:block !important;
    z-index:10010 !important;
  }

  /* Carrusel horizontal realmente fijo bajo el encabezado. */
  .active-view .module-toolbar .tabs:not(.is-hidden){
    position:fixed !important;
    top:calc(var(--mobile-topbar-height) + 20px) !important;
    left:12px !important;
    right:12px !important;
    width:auto !important;
    z-index:60 !important;
    margin:0 !important;
    transform:translateZ(0);
  }

  /* Reserva el espacio del carrusel fijo para que no tape el contenido. */
  .active-view .module-toolbar:not(.is-no-tabs){
    padding-top:68px !important;
  }

  /* Mientras el menú lateral esté abierto, el carrusel no se pinta. */
  body.sidebar-is-open .active-view .module-toolbar .tabs:not(.is-hidden){
    display:none !important;
  }
}


/* Identidad visual de Juli v43.8 */
.js-process-inbox-documents{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
}
.js-process-inbox-documents::before{
  content:"";
  flex:0 0 17px;
  width:17px;
  height:17px;
  border-radius:5px;
  background:url("../assets/img/juli-logo.png") center/cover no-repeat;
  box-shadow:0 1px 2px rgba(7,48,70,.14);
}
@media (max-width:720px){
  .js-process-inbox-documents::before{
    flex-basis:16px;
    width:16px;
    height:16px;
  }
}

/* V43.10 · avisos y carga de Juli visibles sobre formularios móviles */
@media (max-width: 680px){
  /* En móvil el formulario usa una capa muy alta; los avisos de Juli deben quedar por encima. */
  #loadingOverlay.loading-overlay{
    z-index: 12050 !important;
  }

  #toast.toast{
    z-index: 12060 !important;
    left: 16px !important;
    right: 16px !important;
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none !important;
  }
}


/* ASEGIA v43.11 - Chat operativo de Juli */
.juli-chat-box{display:grid;gap:12px;border-top:1px solid var(--line);padding-top:16px}
.juli-chat-messages{display:grid;gap:10px;max-height:360px;overflow:auto;padding:4px 2px 4px 0;scroll-behavior:smooth}
.juli-message{display:flex;align-items:flex-start;gap:9px;max-width:92%}
.juli-message img{width:24px;height:24px;object-fit:contain;flex:0 0 24px;border-radius:7px;margin-top:3px}
.juli-message-content,.juli-message>div{min-width:0;background:#f3f7fa;border:1px solid var(--line);border-radius:15px;padding:10px 12px}
.juli-message-user{margin-left:auto;justify-content:flex-end}
.juli-message-user .juli-message-content{background:var(--brand);color:#fff;border-color:var(--brand)}
.juli-message strong{display:block;font-size:12px;margin-bottom:3px}
.juli-message p{margin:0;line-height:1.48;overflow-wrap:anywhere}
.juli-message.is-pending{opacity:.72}
.juli-chat-input-wrap{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:end}
.juli-chat-input-wrap textarea{width:100%;resize:vertical;min-height:56px;max-height:160px;border:1px solid var(--line);border-radius:16px;background:#fff;padding:13px 14px;outline:none;font:inherit}
.juli-chat-input-wrap textarea:focus{border-color:var(--brand);box-shadow:0 0 0 3px rgba(15,61,94,.10)}
.juli-chat-send{height:44px;border:0;border-radius:14px;padding:0 18px;background:var(--brand);color:#fff;font-weight:900;cursor:pointer}
.juli-chat-send:disabled{opacity:.65;cursor:wait}
.juli-chat-box small{color:var(--muted)}
.juli-result-list{display:grid;gap:8px;margin-top:10px}
.juli-result-card{display:flex;align-items:center;justify-content:space-between;gap:12px;background:#fff;border:1px solid var(--line);border-radius:12px;padding:10px}
.juli-result-card>div{min-width:0}
.juli-result-card>div>strong{font-size:14px;margin:0 0 5px}
.juli-result-meta{display:flex;flex-wrap:wrap;gap:5px 10px;color:var(--muted);font-size:12px}
.juli-result-meta span{overflow-wrap:anywhere}
.juli-result-card .mini-btn{flex:0 0 auto}
@media(max-width:680px){
  .juli-chat-messages{max-height:320px}
  .juli-message{max-width:96%}
  .juli-chat-input-wrap{grid-template-columns:1fr}
  .juli-chat-send{width:100%}
  .juli-result-card{align-items:flex-start;flex-direction:column}
  .juli-result-card .mini-btn{width:100%;text-align:center}
}


/* ASEGIA v43.13 · acceso global a Juli y chat habilitado en vistas */
.juli-floating-button{
  position:fixed;right:24px;bottom:24px;z-index:12020;
  display:inline-flex;align-items:center;gap:9px;height:52px;padding:0 17px 0 9px;
  border:0;border-radius:999px;background:var(--brand);color:#fff;font-weight:900;
  box-shadow:0 16px 38px rgba(7,48,70,.30);cursor:pointer;transition:.18s ease;
}
.juli-floating-button:hover{transform:translateY(-2px);box-shadow:0 20px 44px rgba(7,48,70,.34)}
.juli-floating-button img{width:36px;height:36px;border-radius:11px;object-fit:cover}
body.juli-global-open .juli-floating-button{opacity:0;pointer-events:none;transform:scale(.9)}
.juli-global-panel{
  position:fixed;top:18px;right:18px;bottom:18px;width:min(430px,calc(100vw - 36px));
  z-index:12030;background:#fff;border:1px solid var(--line);border-radius:24px;
  box-shadow:0 28px 80px rgba(7,31,48,.28);padding:16px;display:grid;
  grid-template-rows:auto minmax(0,1fr);gap:12px;transform:translateX(calc(100% + 40px));
  opacity:0;pointer-events:none;transition:transform .24s ease,opacity .2s ease;
}
.juli-global-panel.is-open{transform:translateX(0);opacity:1;pointer-events:auto}
.juli-global-panel-header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-bottom:12px;border-bottom:1px solid var(--line)}
.juli-global-title{display:flex;align-items:center;gap:10px}.juli-global-title>img{width:42px;height:42px;border-radius:13px;object-fit:cover}
.juli-global-title strong,.juli-global-title small{display:block}.juli-global-title small{color:var(--muted);margin-top:2px}
.juli-global-chat{min-height:0;border-top:0;padding-top:0;grid-template-rows:minmax(0,1fr) auto auto}
.juli-global-chat .juli-chat-messages{max-height:none;min-height:0}
@media(max-width:680px){
  .juli-floating-button{right:16px;bottom:calc(16px + env(safe-area-inset-bottom));width:52px;padding:0;justify-content:center}
  .juli-floating-button span{display:none}.juli-floating-button img{width:38px;height:38px}
  .juli-global-panel{inset:0;width:100%;border-radius:0;padding:14px;padding-top:calc(14px + env(safe-area-inset-top));padding-bottom:calc(14px + env(safe-area-inset-bottom));transform:translateY(105%)}
  .juli-global-panel.is-open{transform:translateY(0)}
  .juli-global-chat .juli-chat-input-wrap{grid-template-columns:minmax(0,1fr) auto}
  .juli-global-chat .juli-chat-send{width:auto}
}
\n\n/* ASEGIA v43.14 · corrección de Juli global en móvil */
.juli-global-panel[hidden]{display:none!important}
@media(max-width:680px){
  .juli-floating-button{
    position:fixed!important;
    right:14px!important;
    bottom:calc(14px + env(safe-area-inset-bottom))!important;
    left:auto!important;
    top:auto!important;
    width:50px!important;
    min-width:50px!important;
    height:50px!important;
    min-height:50px!important;
    padding:0!important;
    margin:0!important;
    border-radius:50%!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    overflow:hidden!important;
    z-index:12020!important;
  }
  .juli-floating-button span{display:none!important}
  .juli-floating-button img{
    display:block!important;
    width:36px!important;
    height:36px!important;
    max-width:36px!important;
    max-height:36px!important;
    margin:0!important;
    border-radius:11px!important;
    object-fit:cover!important;
  }
  .juli-global-panel{
    position:fixed!important;
    inset:0!important;
    width:100vw!important;
    height:100dvh!important;
    max-width:none!important;
    max-height:100dvh!important;
    margin:0!important;
    border:0!important;
    border-radius:0!important;
    overflow:hidden!important;
    z-index:12030!important;
    background:#fff!important;
    padding:calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom))!important;
    grid-template-rows:auto minmax(0,1fr)!important;
  }
  .juli-global-panel-header{min-height:56px;flex:0 0 auto}
  .juli-global-title>img{
    width:38px!important;height:38px!important;max-width:38px!important;max-height:38px!important
  }
  .juli-global-chat{min-height:0!important;overflow:hidden!important}
  .juli-global-chat .juli-chat-messages{min-height:0!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch}
  body.juli-global-open{overflow:hidden!important;touch-action:none}
}
