/* ══════════════════════════════════════════════════════════
   TOKENS Y BASE (ACTUALIZADO)
══════════════════════════════════════════════════════════ */
:root {
  --parchment:  #f8f4e6; /* Un poco más luminoso y limpio */
  --parchment2: #ede4cc;
  --ink:        #2a1e12;
  --ink2:       #5a4634;
  --ink3:       #8b7355;
  --gold:       #b38b36;
  --gold-l:     #d4ad5e;
  --gold-pale:  #f4ebd0;
  --bark:       #4a2e1b;
  --bark2:      #6b442a;
  --bark3:      #8c5a39;
  --leaf:       #385e2b;
  --red-fam:    #9c2b2b;
  
  --ff-d:       'IM Fell English', serif;
  --ff-b:       'Cormorant Garamond', serif;
  --ff-ui:      'Inter', system-ui, -apple-system, sans-serif; /* Nueva fuente UI */
  --r:          12px; /* Bordes un poco más suaves */
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
  font-family: var(--ff-ui); /* La UI por defecto es moderna y limpia */
  background: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Títulos históricos */
h1, h2, h3, .modal-title { font-family: var(--ff-d); }

/* ══════════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════════ */
#login-screen{
  position:fixed;inset:0;z-index:9999;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(ellipse at 50% 110%, #3c6828 0%, #1e3010 50%, #0e1808 100%);
  overflow:hidden;
}
#login-screen.hidden{display:none}
.l-leaves{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.l-leaf{
  position:absolute;border-radius:50% 5px 50% 5px;opacity:0;
  animation:leaf-fall linear infinite;
}
@keyframes leaf-fall{
  0%{opacity:0;transform:translateY(-40px) rotate(0deg)}
  10%{opacity:.65}90%{opacity:.4}
  100%{opacity:0;transform:translateY(110vh) rotate(560deg) translateX(50px)}
}

.l-card{
  position:relative;background:var(--parchment);border-radius:18px;
  padding:44px 40px 38px;width:100%;max-width:390px;
  box-shadow:0 28px 70px rgba(0,0,0,.52);text-align:center;
  border:1px solid rgba(154,108,16,.22);
}
.l-tree{width:68px;height:68px;margin:0 auto 18px;display:block}
.l-title{font-family:var(--ff-d);font-size:1.8rem;color:var(--bark);line-height:1.18;margin-bottom:4px}
.l-sub{font-size:.95rem;color:var(--ink3);font-style:italic;margin-bottom:28px}
.l-form{display:flex;flex-direction:column;gap:12px}
.l-input-w{position:relative}
.l-input-w svg{position:absolute;left:13px;top:50%;transform:translateY(-50%);color:var(--ink3);pointer-events:none}
.l-input{
  font-family:var(--ff-b);font-size:1rem;width:100%;padding:11px 12px 11px 38px;
  border:1.5px solid rgba(154,108,16,.28);border-radius:var(--r);
  background:#fff;color:var(--ink);outline:none;transition:border-color .2s,box-shadow .2s;
}
.l-input:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(154,108,16,.1)}
.l-btn{
  font-family:var(--ff-d);font-size:1.05rem;padding:12px;
  background:linear-gradient(135deg,var(--bark),var(--bark2));
  color:var(--gold-pale);border:none;border-radius:var(--r);
  cursor:pointer;letter-spacing:.04em;margin-top:4px;transition:opacity .2s,transform .1s;
}
.l-btn:hover{opacity:.87}.l-btn:active{transform:scale(.98)}
.l-err{color:#7a1414;font-size:.88rem;background:#fdeaea;border-radius:6px;padding:8px 12px;display:none}
.l-err.show{display:block}

/* ══════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════ */
#app{display:none;min-height:100vh}
#app.visible{display:block}

header{
  background:linear-gradient(135deg,var(--bark) 0%,#1e1008 100%);
  color:var(--gold-pale);padding:0 1.5rem;
  display:flex;align-items:center;justify-content:space-between;
  height:58px;position:sticky;top:0;z-index:200;
  box-shadow:0 3px 18px rgba(0,0,0,.38);
}
.h-left{display:flex;align-items:center;gap:10px}
header h1{font-family:var(--ff-d);font-size:1.3rem;font-weight:normal;letter-spacing:.02em}

/* NAV DESKTOP */
.h-nav{display:flex;gap:4px}
.nav-btn{
  font-family:var(--ff-b);font-size:.92rem;padding:6px 14px;
  border-radius:16px;border:1px solid transparent;cursor:pointer;
  transition:all .16s;background:transparent;color:rgba(240,223,160,.65);
  display:flex;align-items:center;gap:6px;
}
.nav-icon{font-size:1.1rem;opacity:0.8;}
.nav-btn.active,.nav-btn:hover{
  background:rgba(200,148,56,.2);color:var(--gold-pale);border-color:rgba(200,148,56,.32)
}
.nav-btn.active .nav-icon {opacity:1;}
.btn-logout{
  font-family:var(--ff-b);font-size:.84rem;padding:5px 13px;
  background:transparent;color:rgba(240,223,160,.45);
  border:1px solid rgba(240,223,160,.18);border-radius:13px;cursor:pointer;transition:all .16s;
}
.btn-logout:hover{color:var(--gold-pale);border-color:rgba(240,223,160,.38)}
.view{display:none}.view.active{display:block}

/* ══════════════════════════════════════════════════════════
   TREE TOOLBAR & SUB-NAV
══════════════════════════════════════════════════════════ */
#tree-view {
  background: radial-gradient(circle at 50% 0%, #ffffff 0%, var(--parchment) 70%);
  min-height: calc(100vh - 58px);
}
.tree-toolbar{
  position:sticky;top:0;z-index:20;
  display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 18px;
  background:rgba(246,240,224,.9);backdrop-filter:blur(8px);
  border-bottom:1px solid rgba(154,108,16,.08);
}
.tree-tools-left{display:flex;gap:10px;align-items:center;}
.btn-add{
  font-family:var(--ff-b);font-size:.92rem;padding:6px 16px;
  background:var(--bark);color:var(--gold-pale);border:none;
  border-radius:16px;cursor:pointer;transition:background .16s;
}
.btn-add:hover{background:var(--bark2)}

/* Sub-nav Pestañas Árbol */
.tree-mode-bar {
  display:flex;align-items:center;justify-content:space-between;
  padding:6px 18px;background:rgba(246,240,224,.95);
  border-bottom:1px solid rgba(154,108,16,.16);
  position:sticky;top:51px;z-index:19;
}
.mode-tabs { display:flex; gap:4px; background:rgba(200,148,56,.15); padding:3px; border-radius:20px; }
.mode-tab {
  border:none; background:transparent; padding:4px 14px; border-radius:16px;
  font-family:var(--ff-b); font-size:.85rem; font-weight:600; color:var(--bark3);
  cursor:pointer; transition:all 0.2s;
}
.mode-tab.active { background:#fff; color:var(--bark); box-shadow:0 2px 6px rgba(0,0,0,.1); }
.tree-hint{font-size:.84rem;color:var(--ink3);font-style:italic}

/* Contenedores de árboles */
.tree-container { display:none; overflow:auto; width:100%; min-height:calc(100vh - 160px); position:relative; }
.tree-container.active-container { display:block; }

/* ── Tree search ───────────────────────────────────────── */
.tree-search-wrap{position:relative;flex:1;max-width:280px;}
.tree-search-input{
  font-family:var(--ff-b);font-size:.95rem;width:100%;padding:7px 14px 7px 34px;
  border:1.5px solid rgba(154,108,16,.3);border-radius:18px;background:#fff;color:var(--ink);outline:none;
  transition:border-color .15s,box-shadow .15s;
}
.tree-search-input:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(154,108,16,.1);}
.tree-search-icon{position:absolute;left:11px;top:50%;transform:translateY(-50%);color:var(--ink3);pointer-events:none;}
.tree-search-results{
  position:absolute;top:calc(100% + 6px);left:auto;right:0;width:300px;
  background:#fff;border:1px solid rgba(154,108,16,.22);
  border-radius:12px;box-shadow:0 8px 28px rgba(20,10,0,.18);z-index:500;overflow:hidden;max-height:320px;overflow-y:auto;display:none;
}
.tree-search-results.open{display:block}
.tree-sr-item{display:flex;align-items:center;gap:10px;padding:9px 13px;cursor:pointer;border-bottom:1px solid rgba(154,108,16,.07);transition:background .12s;}
.tree-sr-item:last-child{border-bottom:none}
.tree-sr-item:hover,.tree-sr-item.active-item{background:#fdf5e0}
.tree-sr-photo{width:38px;height:38px;border-radius:50%;border:2px solid var(--gold-l);overflow:hidden;background:var(--gold-pale);flex-shrink:0;display:flex;align-items:center;justify-content:center;}
.tree-sr-photo img{width:100%;height:100%;object-fit:cover}
.tree-sr-photo svg{width:20px;height:20px;opacity:.4}
.tree-sr-name{font-family:var(--ff-d);font-size:.95rem;color:var(--ink);line-height:1.2}
.tree-sr-dates{font-size:.78rem;color:var(--ink3);font-style:italic;margin-top:1px}
.tree-sr-empty{padding:14px;text-align:center;color:var(--ink3);font-style:italic;font-size:.9rem}

/* ══════════════════════════════════════════════════════════
   TREE HTML LAYOUT (CLASSIC)
══════════════════════════════════════════════════════════ */
.tn-wrap {display:flex; flex-direction:column; align-items:center; padding:32px 48px 80px; min-width:max-content; position:relative;}
.tn-back {align-self:flex-start; background:#3a7aaa; color:#fff; padding:6px 14px; border-radius:14px; font-family:var(--ff-b); font-size:.9rem; cursor:pointer; margin-bottom:12px; z-index:2;}
.tn-back:hover{background:#2a6a9a;}

.tn-ancestors-row{display:flex;flex-direction:row;align-items:flex-end;justify-content:center;}
.tn-side-branch{display:flex;flex-direction:column;align-items:center;}
.tn-sides-gap{width:52px;flex-shrink:0;}
.tn-anc-col{display:flex;flex-direction:column;align-items:center;}
.tn-anc-self{padding:14px 0 0;display:flex;justify-content:center;position:relative;z-index:2;}
.tn-par-row{display:flex;flex-direction:row;align-items:flex-end;gap:0;}
.tn-par-gap{width:8px;flex-shrink:0;}
.tn-ghost-col{display:flex;flex-direction:column;align-items:center;}

.tn-root-row{display:flex;justify-content:center;padding:10px 0;position:relative;z-index:2;}
.tn-root-couple{display:flex;align-items:center;gap:4px;}
.tn-root-p1,.tn-root-p2{display:contents;}
.tn-anc-col .tn-par-row{display:flex;flex-direction:row;align-items:flex-end;}
.tn-par-gap{width:20px;flex-shrink:0;}
.tn-par-heart{font-size:10px;color:#8b1a1a;align-self:flex-end;padding:0 4px;padding-bottom:14px;opacity:.7;flex-shrink:0;}
.tn-sides-gap{width:80px;flex-shrink:0;}

.tn-kids-row{display:flex;flex-direction:row;align-items:flex-start;justify-content:center;gap:20px;padding-top:0;}
.tn-kid-branch{display:flex;flex-direction:column;align-items:center;}
.tn-kid-couple,.tn-kid-solo{display:flex;align-items:center;padding:10px 0 0;position:relative;z-index:2;}
.tn-grandkids{display:flex;flex-direction:row;gap:10px;justify-content:center;padding-top:10px;position:relative;z-index:2;}
.tn-grandkid{display:flex;}

.tn-heart{display:flex;flex-direction:column;align-items:center;font-size:13px;color:#8b1a1a;padding:0 4px;min-width:24px;text-align:center;align-self:center;}
.tn-heart small{font-family:var(--ff-b);font-size:7px;color:var(--ink3);font-style:italic;}

/* Ajuste de tn-card para soportar la línea de hermanos y LETRAS FUERTES */
/* Tarjetas del árbol más amplias y legibles */
.tn-card {
  display: flex; flex-direction: column; align-items: center;
  background: #ffffff; /* Blanco para dar máximo contraste */
  border: 1px solid var(--gold-l); 
  border-radius: 12px;
  padding: 12px 8px 10px; 
  cursor: pointer; 
  width: 130px; /* Antes 90px */
  transition: transform .2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow .2s; 
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,.06); 
  z-index: 2;
  min-height: 140px; 
  justify-content: flex-start;
}
.tn-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 10px 20px rgba(179,139,54,.2);
  border-color: var(--gold);
}
.tn-card.tn-dead { background: #faf8f5; border-color: #d0c4b4; filter: grayscale(10%); opacity: 0.95; }
.tn-card.tn-ext { background: #f0f7ff; border: 1px dashed #4a88c8; }
.tn-card.tn-ghost{visibility:hidden;pointer-events:none;}
.tn-ghost-full{visibility:hidden;pointer-events:none;}
.tn-photo {
  width: 64px; /* Antes 50px */
  height: 64px; 
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--gold-l);
  background: var(--gold-pale);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  flex-shrink: 0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.tn-card.tn-ext .tn-photo{border-color:#3a7aaa;}
.tn-photo img{width:100%;height:100%;object-fit:cover;}

/* NOMBRES Y FECHAS EN EL ÁRBOL - FUERTES Y VISIBLES */
.tn-name {
  font-family: var(--ff-b); /* Volvemos al serif elegante para el nombre */
  font-size: 13px; /* Antes 8.5px */
  font-weight: 600; 
  color: var(--ink); 
  text-align: center; 
  line-height: 1.15; 
  max-width: 114px; 
  display: -webkit-box; 
  -webkit-line-clamp: 2; 
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tn-card.tn-ext .tn-name { color:#1a4a7a; }

.tn-dates {
  font-family: var(--ff-ui); /* Sans-serif para los números, se leen perfectos */
  font-size: 10.5px; /* Antes 7.6px */
  color: var(--ink3); 
  font-weight: 500; 
  text-align: center; 
  margin-top: 4px;
}

.tn-ext-badge{position:absolute;top:2px;right:2px;width:13px;height:13px;background:#3a7aaa;border-radius:50%;font-size:8px;color:white;display:flex;align-items:center;justify-content:center;}
.tn-svg-overlay { z-index: 0 !important; }

/* ── Refresh button ── */
.btn-refresh {
  background: none; border: 1.5px solid rgba(154,108,16,.35); border-radius: 50%; width: 32px; height: 32px; font-size: 1.1rem; cursor: pointer; color: var(--bark); display: flex; align-items: center; justify-content: center; transition: background .15s, transform .15s; flex-shrink: 0;
}
.btn-refresh:hover { background: rgba(154,108,16,.1); }
.btn-refresh.spinning { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════
   DIRECTORIO Y TABLAS
══════════════════════════════════════════════════════════ */
.dir-header { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:16px; padding:24px; }
.dir-header h2 { font-family:var(--ff-d); font-size:1.8rem; color:var(--bark); font-weight:normal; }
.search-wrap { position:relative; }
.search-wrap svg { position:absolute; left:12px; top:50%; transform:translateY(-50%); color:var(--ink3); }
.search-wrap input { padding:8px 12px 8px 34px; border:1px solid rgba(154,108,16,.3); border-radius:18px; font-family:var(--ff-b); font-size:.95rem; outline:none; }

.dir-table-wrap { 
  background:#fdf8ee; 
  margin:0 24px 40px; 
  border-radius:12px; 
  border:1px solid rgba(154,108,16,.2); 
  box-shadow:0 4px 16px rgba(20,10,0,.08); 
  overflow-x:auto; 
  max-width: calc(100vw - 48px); 
  box-sizing: border-box;
}

.dir-table { width:100%; border-collapse:collapse; text-align:left; font-size:.95rem; min-width: 600px;}
.dir-table th { background:rgba(200,148,56,.1); padding:12px 16px; font-weight:600; color:var(--bark); font-family:var(--ff-d); font-size:1.05rem; }
.dir-table td { padding:10px 16px; border-bottom:1px solid rgba(154,108,16,.1); vertical-align:middle; }
.dir-table tbody tr:hover { background:rgba(200,148,56,.04); }
.d-thumb { width:40px; height:40px; border-radius:50%; overflow:hidden; border:2px solid var(--gold-l); background:var(--gold-pale); display:flex; align-items:center; justify-content:center; }
.d-thumb img { width:100%; height:100%; object-fit:cover; }
.g-badge { display:inline-block; padding:2px 8px; border-radius:12px; font-size:.75rem; font-weight:bold; letter-spacing:.05em; text-transform:uppercase; }
.g-badge.M { background:#e0ecf8; color:#1a4a7a; }
.g-badge.F { background:#f8e0ec; color:#7a1a4a; }
.action-btns { display:flex; gap:6px; }
.btn-icon { font-family:var(--ff-b); font-size:.85rem; padding:4px 10px; border-radius:12px; border:1px solid; cursor:pointer; background:transparent; transition:all .15s; }
.btn-view { color:var(--bark); border-color:rgba(154,108,16,.3); }
.btn-view:hover { background:rgba(154,108,16,.1); }
.btn-edit { color:#1a4a7a; border-color:rgba(26,74,122,.3); }
.btn-edit:hover { background:rgba(26,74,122,.1); }
.btn-del { color:#8b1a1a; border-color:rgba(139,26,26,.3); }
.btn-del:hover { background:rgba(139,26,26,.1); }
.pagination { display:flex; justify-content:center; gap:6px; padding:16px; }
.pg-btn { padding:4px 12px; border-radius:16px; border:1px solid rgba(154,108,16,.3); background:transparent; cursor:pointer; color:var(--bark); font-family:var(--ff-b); font-size:.9rem; }
.pg-btn.active, .pg-btn:hover { background:var(--gold-l); color:#fff; border-color:var(--gold-l); }
.loading { display:flex; align-items:center; justify-content:center; gap:10px; padding:40px; color:var(--ink3); font-style:italic; }
.spinner { width:20px; height:20px; border:2px solid var(--gold-pale); border-top-color:var(--gold-l); border-radius:50%; animation:spin .8s linear infinite; }

/* ══════════════════════════════════════════════════════════
   MODALES Y FORMULARIOS
══════════════════════════════════════════════════════════ */
.modal-overlay { position:fixed; inset:0; background:rgba(10,5,0,.6); backdrop-filter:blur(3px); z-index:9000; display:flex; align-items:center; justify-content:center; opacity:0; pointer-events:none; transition:opacity .25s; padding:16px; overflow-y:auto; }
.modal-overlay.open { opacity:1; pointer-events:auto; }
.modal { background:#fdf8ee; width:100%; max-width:640px; border-radius:16px; box-shadow:0 20px 60px rgba(0,0,0,.4); display:flex; flex-direction:column; max-height:min(90vh, 90dvh); transform:translateY(20px) scale(.98); transition:transform .25s; border:1.5px solid var(--gold-l); overflow:hidden; }
.modal-overlay.open .modal { transform:translateY(0) scale(1); }
.modal-sm { max-width:440px; }
.modal-header { padding:18px 24px; border-bottom:1px solid rgba(154,108,16,.2); display:flex; justify-content:space-between; align-items:center; }
.modal-title { font-family:var(--ff-d); font-size:1.4rem; color:var(--bark); }
.modal-close { background:none; border:none; font-size:2rem; line-height:1; color:var(--ink3); cursor:pointer; transition:color .15s; }
.modal-close:hover { color:var(--red-fam); }
.modal-body { padding:24px; padding-bottom: 120px; overflow-y:auto; flex:1; min-height:0; }
.modal-footer { padding:16px 24px; border-top:1px solid rgba(154,108,16,.2); display:flex; justify-content:flex-end; gap:10px; background:rgba(200,148,56,.05); border-radius:0 0 16px 16px; }

.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.fg { display:flex; flex-direction:column; gap:6px; }
.fg.full { grid-column:1 / -1; }
.fg label {
  font-family: var(--ff-ui);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink2);
}
.fg input, .fg select, .fg textarea { font-family:var(--ff-b); font-size:.95rem; padding:10px 12px; border:1.5px solid rgba(154,108,16,.3); border-radius:8px; background:#fff; color:var(--ink); outline:none; transition:border-color .15s; width:100%; box-sizing:border-box; }
.fg input:focus, .fg select:focus, .ss-input:focus { 
  background: #fff;
  border-color: var(--gold); 
  box-shadow: 0 0 0 4px rgba(179,139,54,.15); 
}
.photo-row { display:flex; align-items:center; gap:16px; }
.photo-prev { width:64px; height:64px; border-radius:50%; border:2px dashed var(--gold-l); display:flex; align-items:center; justify-content:center; overflow:hidden; flex-shrink:0; background:rgba(200,148,56,.1); }
.photo-lbl { display:inline-block; padding:6px 14px; background:#fff; border:1px solid var(--gold-l); border-radius:16px; font-size:.85rem; cursor:pointer; color:var(--bark); }
.photo-lbl:hover { background:rgba(200,148,56,.1); }
input[type=file] { display:none; }

.btn-s, .btn-p, .btn-d, .btn-green { font-family:var(--ff-b); font-size:1rem; padding:8px 18px; border-radius:18px; cursor:pointer; transition:all .15s; border:none; }
.btn-s { background:transparent; color:var(--ink2); border:1px solid rgba(154,108,16,.4); }
/* Botones secundarios */
.btn-s, .btn-icon, .mode-tab, .pg-btn {
  font-family: var(--ff-ui);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.btn-s:hover { background:rgba(154,108,16,.1); }
.btn-p { background:var(--bark); color:var(--gold-pale); }
.btn-p:hover { background:var(--bark2); }
.btn-d { background:#8b1a1a; color:#fff; }
.btn-d:hover { background:#6a1010; }
.btn-green { background:var(--leaf); color:#fff; }
.btn-green:hover { background:var(--leaf2); }

/* ══════════════════════════════════════════════════════════
   DETALLES DE PERSONA Y TOASTS
══════════════════════════════════════════════════════════ */
.detail-top { display:flex; gap:20px; align-items:center; margin-bottom:20px; }
.det-photo { width:90px; height:90px; border-radius:50%; border:3px solid var(--gold-l); background:var(--gold-pale); overflow:hidden; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.det-photo img { width:100%; height:100%; object-fit:cover; }
.det-name { font-family:var(--ff-d); font-size:1.6rem; color:var(--bark); line-height:1.2; margin-bottom:6px; }
.det-meta { font-size:.95rem; color:var(--ink3); line-height:1.5; font-style:italic; }
.det-section { margin-bottom:16px; padding-top:16px; border-top:1px dashed rgba(154,108,16,.2); }
.det-label { font-size:.85rem; text-transform:uppercase; letter-spacing:.05em; color:var(--gold-l); font-weight:bold; margin-bottom:8px; }
.det-value { font-size:1rem; color:var(--ink); line-height:1.5; }
.union-pill { display:inline-block; padding:4px 12px; border-radius:16px; font-size:.9rem; margin-top:6px; margin-right:6px; border:1px solid; }
.union-status-married { background:rgba(90,136,64,.1); color:var(--leaf); border-color:rgba(90,136,64,.3); }
.union-status-divorced { background:rgba(139,26,26,.1); color:var(--red-fam); border-color:rgba(139,26,26,.3); }
.union-status-widowed { background:rgba(80,56,32,.1); color:var(--ink2); border-color:rgba(80,56,32,.3); }
.union-status-partner { background:rgba(200,148,56,.1); color:var(--bark); border-color:rgba(200,148,56,.3); }

/* Píldora navegable para Hermanos en el Modal */
.sib-pill {
  display:inline-block; padding:3px 10px; border-radius:12px; font-size:.85rem; 
  background:rgba(200,148,56,.1); color:var(--bark); border:1px solid rgba(200,148,56,.3); 
  cursor:pointer; transition:all .15s; margin-bottom:4px;
}
.sib-pill:hover { background:rgba(200,148,56,.25); border-color:var(--gold-l); }

.toast-c { position:fixed; bottom:24px; right:24px; z-index:9999; display:flex; flex-direction:column; gap:10px; pointer-events:none; }
.toast { padding:12px 20px; border-radius:8px; font-family:var(--ff-b); font-size:.95rem; color:#fff; box-shadow:0 8px 24px rgba(0,0,0,.25); animation:toast-in .3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.toast.success { background:#2a5018; }
.toast.error { background:#8b1a1a; }
@keyframes toast-in { from { transform:translateX(100%); opacity:0; } to { transform:translateX(0); opacity:1; } }

/* ══════════════════════════════════════════════════════════
   TIMELINE — vertical
══════════════════════════════════════════════════════════ */
.vtl-wrap { padding: 20px 16px 60px; max-width: 800px; margin: 0 auto; }
.vtl-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 28px; justify-content: center; }
.vtl-leg-item { display: flex; align-items: center; gap: 6px; font-family: var(--ff-b); font-size: .85rem; color: var(--ink3); }
.vtl-leg-dot { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: white; flex-shrink: 0; }
.vtl-list { position: relative; padding: 0 0 40px; }
.vtl-list::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--gold-l), var(--bark), var(--gold-l)); transform: translateX(-50%); border-radius: 2px; }
.vtl-year-marker { position: relative; text-align: center; margin: 24px 0 8px; z-index: 2; }
.vtl-year-marker span { display: inline-block; background: var(--bark); color: var(--gold-pale); font-family: var(--ff-d); font-size: 1rem; padding: 3px 14px; border-radius: 20px; position: relative; z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.vtl-event { position: relative; display: flex; align-items: center; margin: 10px 0; width: 100%; }
.vtl-dot { position: absolute; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: white; border: 2.5px solid white; box-shadow: 0 2px 6px rgba(0,0,0,.25); z-index: 3; flex-shrink: 0; }
.vtl-left .vtl-card { margin-right: calc(50% + 20px); margin-left: 0; }
.vtl-right .vtl-card { margin-left: calc(50% + 20px); margin-right: 0; }
.vtl-card { flex: 1; background: #fdf8ee; border: 1.5px solid var(--gold-l); border-radius: 10px; padding: 10px 12px; box-shadow: 0 2px 8px rgba(20,10,0,.08); transition: transform .14s, box-shadow .14s; }
.vtl-card:hover { transform: translateY(-2px); box-shadow: 0 5px 16px rgba(20,10,0,.15); }
.vtl-card-top { display: flex; align-items: center; gap: 10px; }
.vtl-photo { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold-l); flex-shrink: 0; }
.vtl-icon-circle { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.vtl-card-text { flex: 1; min-width: 0; }
.vtl-card-label { font-family: var(--ff-d); font-size: .92rem; color: var(--ink); line-height: 1.3; word-break: break-word; }
.vtl-card-detail { font-family: var(--ff-b); font-size: .78rem; color: var(--ink3); font-style: italic; margin-top: 3px; }

/* ══════════════════════════════════════════════════════════
   MAPA FAMILIAR (FIX DE OVERFLOW)
══════════════════════════════════════════════════════════ */
#map-view { width: 100%; overflow-x: hidden; }

#family-map { 
  height: calc(100vh - 200px); 
  min-height: 480px; 
  border-radius: 12px; 
  overflow: hidden; 
  width: calc(100% - 56px); 
  margin: 0 auto 16px; 
  box-shadow: 0 4px 20px rgba(0,0,0,.15); 
  border: 1.5px solid rgba(154,108,16,.2); 
  z-index: 1; 
}

#map-filter-bar { display: flex; gap: 20px; padding: 0 28px 14px; flex-wrap: wrap; justify-content: center; }
#map-filter-bar label { display: flex; align-items: center; gap: 6px; font-family: var(--ff-b); font-size: .88rem; color: var(--ink); cursor: pointer; }
#map-filter-bar input[type=checkbox] { accent-color: var(--bark); width: 15px; height: 15px; }
.map-status { text-align: center; padding: 6px 28px; font-family: var(--ff-b); font-size: .8rem; color: var(--ink3); font-style: italic; min-height: 24px; margin-bottom: 20px; }

/* ══════════════════════════════════════════════════════════
   NUEVO MENÚ MÓVIL (BOTTOM TAB BAR)
══════════════════════════════════════════════════════════ */
@media(max-width:700px){
  .btn-logout { display:none; }
  
  header {
    height: 50px;
    padding: 0 16px;
    justify-content: center;
  }
  
  .h-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: #1e1008;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 6px;
    z-index: 999;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    border-top: 1px solid rgba(200,148,56,0.3);
  }
  
  .nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    background: transparent !important;
    border: none !important;
    border-radius: 8px;
    width: 20%;
    min-width: 0;
  }
  
  .nav-icon { font-size: 1.3rem; opacity: 0.5; transition: opacity 0.2s, transform 0.2s; }
  .nav-txt { font-size: 0.65rem; font-family: sans-serif; opacity: 0.5; font-weight: normal; }
  
  .nav-btn.active .nav-icon { opacity: 1; transform: translateY(-2px) scale(1.1); text-shadow: 0 0 10px rgba(240,223,160,0.5); }
  .nav-btn.active .nav-txt { opacity: 1; color: var(--gold-pale); font-weight: bold; }

  body { padding-bottom: 64px; }
  .toast-c { bottom: 80px; }
  
  .tree-mode-bar { padding: 6px 10px; top: 50px; }
  .mode-tab { padding: 4px 10px; font-size: .75rem; }
  
  .tree-toolbar { flex-wrap: wrap; padding: 8px 10px; }
  .tree-tools-left { width: 100%; justify-content: space-between; }
  .tree-search-wrap { width: 100%; max-width: none; margin-top: 4px; }
  .tree-search-results { width: 100%; }
/* Botones primarios */
.btn-add, .btn-p, .btn-green {
  font-family: var(--ff-ui);
  font-size: .9rem;
  font-weight: 500;
  padding: 8px 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
  .tn-card { width: 76px !important; min-height: 88px !important; height: auto !important; padding: 6px 3px 4px; }
  .tn-photo { width: 36px; height: 36px; margin-bottom: 3px; }
  .tn-name { font-size: 7.5px; max-width: 68px; font-weight: bold; }
  .tn-dates { font-size: 6.8px; font-weight: 600; font-style: normal; }
  .tn-par-gap { width: 4px; }
  .tn-sides-gap { width: 18px; }

  #directory-view, #unions-view, #timeline-view, #map-view { padding: 10px 0; }
  .dir-header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px 16px; }
  .dir-header h2 { font-size: 1.2rem; }
  .dir-table-wrap { margin: 0 10px 40px; max-width: calc(100vw - 20px); }

  #family-map { 
    width: calc(100% - 20px); 
    margin: 0 auto 10px; 
    height: 60vh; 
    min-height: 350px; 
  }
  #map-filter-bar { padding: 0 10px 8px; gap: 8px; font-size: .82rem; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: 14px 14px 0 0; max-height: calc(100dvh - 64px); overflow-y: auto; }
  .modal-body { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .fg.full { grid-column: 1; }
.fg input, .fg select, .fg textarea, .ss-input {
  font-family: var(--ff-ui); /* Textos de input limpios y modernos */
  font-size: .95rem; 
  padding: 10px 14px; 
  border: 1px solid rgba(154,108,16,.4); 
  border-radius: 8px; 
  background: #fafaf8; 
  color: var(--ink); 
  transition: all .2s; 
}
  .modal-footer { padding: 10px 14px; }

  .vtl-list::before { left: 18px; }
  .vtl-dot { left: 18px; }
  .vtl-left .vtl-card, .vtl-right .vtl-card { margin-left: 48px; margin-right: 0; }
  .vtl-year-marker { text-align: left; padding-left: 48px; }
  .vtl-year-marker span { font-size: .85rem; }
}

@media(max-width:400px){
  .nav-txt { font-size: 0.6rem; }
  .tn-card { width: 66px !important; min-height: 80px !important; height: auto !important; }
  .tn-photo { width: 30px; height: 30px; }
  .tn-name { font-size: 6.8px; font-weight: bold; }
  .tn-dates { font-size: 6px; font-weight: 600; font-style: normal; }
}

/* ══════════════════════════════════════════════════════════
   PEDIGREE VIEW
══════════════════════════════════════════════════════════ */
.pdg-wrap { padding: 8px 0 40px; }
.pdg-title { font-family: var(--ff-d); font-size: 1.4rem; color: var(--bark); margin-bottom: 20px; }
.pdg-grid { display: flex; flex-direction: column; gap: 0; }

.pdg-gen {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  border-bottom: 1px solid rgba(154,108,16,.1);
  padding: 8px 0;
  gap: 8px;
}
.pdg-gen-label {
  writing-mode: vertical-lr;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-family: var(--ff-b);
  font-size: .72rem;
  color: var(--ink3);
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200,148,56,.07);
  border-radius: 6px;
  flex-shrink: 0;
  letter-spacing: .05em;
}
.pdg-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--gold-l);
  background: #fdf8ee;
  min-width: 90px;
  max-width: 120px;
  flex: 1;
  cursor: pointer;
  transition: transform .14s, box-shadow .14s;
  text-align: center;
}
.pdg-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(20,10,0,.15); }
.pdg-male  { border-color: rgba(42,88,136,.35); background: #f0f4fa; }
.pdg-female{ border-color: rgba(136,40,88,.35); background: #faf0f4; }
.pdg-empty { background: rgba(0,0,0,.03); border: 1.5px dashed rgba(154,108,16,.2); cursor: default; justify-content: center; }
.pdg-unknown { font-size: 1.5rem; opacity: .25; }
.pdg-photo { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; border: 1.5px solid var(--gold-l); background: var(--gold-pale); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; flex-shrink: 0; }
.pdg-photo img { width: 100%; height: 100%; object-fit: cover; }
.pdg-name { font-family: var(--ff-d); font-size: 7px; line-height: 1.3; color: var(--ink); word-break: break-word; }
.pdg-dates { font-family: var(--ff-b); font-size: 6.5px; color: var(--ink3); font-style: italic; margin-top: 2px; }
.pdg-place { font-family: var(--ff-b); font-size: 6px; color: var(--ink3); margin-top: 1px; }

@media(max-width:700px){
  .pdg-card { min-width: 70px; max-width: 90px; }
  .pdg-photo { width: 32px; height: 32px; }
  .pdg-name { font-size: 6px; }
}
/* ══════════════════════════════════════════════════════════
   ESTADÍSTICAS
══════════════════════════════════════════════════════════ */
#stats-container {
  padding: 16px 24px 60px;
  max-width: 1100px;
  margin: 0 auto;
}

/* Grid de 2 columnas para las 4 secciones pequeñas */
.st-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

/* Sección */
.st-section {
  background: var(--parchment);
  border: 1px solid var(--gold-l);
  border-radius: 10px;
  padding: 16px 18px 14px;
}
.st-section-title {
  font-family: var(--ff-d);
  font-size: 1.15rem;
  color: var(--bark);
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gold-l);
}

/* Barras */
.st-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 22px;
}
.st-bar-label {
  width: 140px;
  flex-shrink: 0;
  font-size: .85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.st-bar-extra {
  font-size: .75rem;
  color: var(--ink3);
  font-style: italic;
}
.st-bar-track {
  flex: 1;
  height: 10px;
  background: rgba(154,108,16,.12);
  border-radius: 5px;
  overflow: hidden;
}
.st-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bark2), var(--gold));
  border-radius: 5px;
  transition: width .4s ease;
  min-width: 4px;
}
.st-bar-count {
  width: 26px;
  text-align: right;
  font-size: .82rem;
  font-weight: 700;
  color: var(--bark);
}

/* Notas */
.st-note {
  font-size: .8rem;
  color: var(--ink3);
  font-style: italic;
  margin-top: 10px;
  line-height: 1.4;
}
.st-note strong { color: var(--bark); font-style: normal; }
.st-note-ok { color: #2a7a2a; font-style: normal; font-weight: 600; }

/* Pills */
.st-pill {
  display: inline-block;
  font-size: .76rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin: 2px 2px 2px 0;
  font-family: var(--ff-b);
}
.st-pill-warn {
  background: #fff3cd;
  color: #7a5000;
  border: 1px solid #f0c060;
}
.st-pill-miss {
  background: #fde8e8;
  color: #7a1a1a;
  border: 1px solid #f0a0a0;
}

/* Variantes de apellido */
.st-variant-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gold-l);
}
.st-variant-row:last-of-type { border-bottom: none; }
.st-variant-total {
  font-size: .78rem;
  color: var(--ink3);
  margin-left: 6px;
  font-style: italic;
}

/* Generaciones — span full width */
#stats-container > .st-section {
  margin-bottom: 18px;
}

/* Grid de 2 columnas para antepasado + rama */
.st-grid-2 {
  grid-template-columns: 1fr 1fr;
}

/* Antepasado más antiguo */
.st-oldest-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 8px 0 4px;
}
.st-oldest-photo {
  width: 80px; height: 80px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden;
  border: 2px solid var(--gold-l);
}
.st-oldest-photo img { width: 100%; height: 100%; object-fit: cover; }
.st-oldest-no-photo {
  width: 100%; height: 100%;
  background: var(--gold-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--bark2);
}
.st-oldest-info { flex: 1; }
.st-oldest-name { margin-bottom: 6px; }
.st-oldest-date { font-size: .88rem; color: var(--ink); margin-bottom: 4px; }
.st-oldest-note { font-size: .82rem; color: var(--ink3); margin-bottom: 2px; }

/* Rama más larga */
.st-branch-info {
  font-size: .92rem; color: var(--ink);
  margin-bottom: 14px;
  padding: 8px 12px;
  background: rgba(154,108,16,.08);
  border-radius: 6px;
  border-left: 3px solid var(--gold);
}
.st-branch-chain {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.st-branch-step {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.st-branch-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--gold-l);
  background: #fff;
  width: 100%;
}
.st-branch-num {
  font-size: .7rem; font-weight: 700;
  color: var(--bark2); font-family: sans-serif;
  width: 18px; text-align: right; flex-shrink: 0;
  margin-right: 2px;
}
.st-branch-photo {
  width: 38px; height: 38px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--gold-l); flex-shrink: 0;
}
.st-branch-no-photo {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--gold-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--bark2); flex-shrink: 0;
  border: 1px solid var(--gold-l);
}
.st-branch-name { font-size: .82rem; }
.st-branch-year { font-size: .73rem; color: var(--ink3); }
.st-branch-arrow {
  font-size: .85rem; color: var(--gold);
  padding: 1px 0 1px 28px;
  line-height: 1;
}


/* Enlace a persona */
.st-person-link {
  display: inline-block;
  font-size: .82rem;
  color: var(--bark);
  background: rgba(154,108,16,.1);
  border: 1px solid var(--gold-l);
  border-radius: 14px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background .15s;
}
.st-person-link:hover {
  background: var(--gold-l);
  color: #3a1a00;
}

/* Datos incompletos */
.st-incomplete-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.st-incomplete-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--gold-l);
  border-radius: 6px;
}
.st-missing-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

@media(max-width:700px) {
  .st-grid { grid-template-columns: 1fr; }
  #stats-container { padding: 12px 12px 60px; }
  .st-bar-label { width: 110px; font-size: .78rem; }
}

/* ══════════════════════════════════════════════════════════
   PEDIGREE EXTENSIONS (+) Y GRAFO
══════════════════════════════════════════════════════════ */
.btn-expand-ped {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold-l); color: #fff; border: 2px solid #fff;
  font-size: 16px; font-weight: bold; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  position: absolute; right: -12px; top: 50%; transform: translateY(-50%);
  cursor: pointer; z-index: 10;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: background 0.2s, transform 0.2s;
}
.btn-expand-ped:hover { background: var(--bark); transform: translateY(-50%) scale(1.15); }

/* SVG del Grafo */
.graph-node circle { stroke: #fff; stroke-width: 1.5px; transition: stroke-width 0.2s; cursor: pointer; }
.graph-node circle:hover { stroke: var(--gold); stroke-width: 3px; }
.graph-node text { font-family: var(--ff-b); font-size: 10px; pointer-events: none; fill: var(--ink); text-shadow: 0 1px 2px rgba(255,255,255,0.8); }
.graph-link { stroke-opacity: 0.4; }
.graph-link.parent { stroke: var(--bark); stroke-width: 1.5px; }
.graph-link.spouse { stroke: #8b1a1a; stroke-width: 1px; stroke-dasharray: 3,3; }

.graph-tooltip {
  position: absolute; background: rgba(26,16,8,0.9); color: #fdf8ee;
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--gold-l);
  font-family: var(--ff-b); font-size: 0.85rem; pointer-events: none;
  opacity: 0; transition: opacity 0.2s; z-index: 9999;
}

/* ══════════════════════════════════════════════════════════
   BUSCADOR INTELIGENTE EN FORMULARIOS (AUTOCOMPLETE)
══════════════════════════════════════════════════════════ */
.ss-wrap { position: relative; width: 100%; }
.ss-input {
  width: 100%; padding: 10px 30px 10px 12px; font-family: var(--ff-b); font-size: .95rem;
  border: 1.5px solid rgba(154,108,16,.3); border-radius: 8px; background: #fff;
  color: var(--ink); outline: none; transition: border-color .15s;
}
.ss-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(154,108,16,.1); }
.ss-clear { 
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); 
  cursor: pointer; font-size: 1.2rem; line-height: 1; color: var(--ink3); 
  display: none; background: none; border: none; padding: 4px;
}
.ss-clear:hover { color: var(--red-fam); }
.ss-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff;
  border: 1px solid var(--gold-l); border-radius: 8px; max-height: 220px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(20,10,0,.2); z-index: 9999; display: none;
}
.ss-list.open { display: block; }
.ss-item { padding: 8px 12px; cursor: pointer; font-size: .9rem; border-bottom: 1px solid rgba(154,108,16,.1); }
.ss-item:last-child { border-bottom: none; }
.ss-item:hover { background: rgba(200,148,56,.15); }
.ss-item.selected { background: rgba(200,148,56,.25); font-weight: bold; color: var(--bark); }

/* ══════════════════════════════════════════════════════════
   MEJORAS UX MÓVIL: ZERO SCROLL HORIZONTAL Y DRAG
══════════════════════════════════════════════════════════ */
/* 1. Ocultar barras de scroll en el árbol pero mantenerlo arrastrable */
.tree-container {
  -ms-overflow-style: none;  /* IE y Edge */
  scrollbar-width: none;  /* Firefox */
  cursor: grab; /* Cursor de "mano" en PC */
}
.tree-container::-webkit-scrollbar { display: none; /* Chrome, Safari, iOS */ }
.tree-container:active { cursor: grabbing; }

/* 2. Convertir Tablas en Tarjetas Verticales en Móvil */
@media(max-width: 700px) {
  .dir-table thead { display: none; /* Ocultar cabeceras */ }
  .dir-table, .dir-table tbody, .dir-table tr, .dir-table td { display: block; width: 100%; }
  
  .dir-table tr { 
    margin-bottom: 15px; 
    border: 1px solid var(--gold-l); 
    border-radius: 12px; 
    background: #fff; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.06); 
    padding: 8px 16px; 
  }
  
  .dir-table td { 
    text-align: right; 
    padding: 10px 0; 
    border-bottom: 1px dashed rgba(154,108,16,.2); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    min-height: 40px;
  }
  
  .dir-table td:last-child { 
    border-bottom: none; 
    justify-content: center; 
    padding-top: 14px; 
  }
  
  /* Inyectar las etiquetas de la tabla automáticamente mediante CSS */
  .dir-table td::before { 
    content: attr(data-label); 
    font-family: var(--ff-ui);
    font-weight: 600; 
    color: var(--ink3); 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    margin-right: 15px; 
    text-align: left;
  }
  
  .dir-table td > .action-btns { width: 100%; justify-content: center; }
  .d-thumb { margin: 0; }
}

/* ══════════════════════════════════════════════════════════
   MODAL FOOTER RESPONSIVE
══════════════════════════════════════════════════════════ */
.modal-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 16px; }
.modal-btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-btn-group.left { flex: 1 1 auto; justify-content: flex-start; }
.modal-btn-group.right { flex: 0 0 auto; justify-content: flex-end; }

@media(max-width: 700px) {
  .modal-btn-group.left { justify-content: center; width: 100%; }
  .modal-btn-group.right { justify-content: center; width: 100%; border-top: 1px dashed rgba(154,108,16,.3); padding-top: 12px; }
  /* En móvil, los botones del modal crecen para ser fáciles de pulsar */
  .modal-footer button { flex: 1 1 45%; justify-content: center; padding: 10px 4px; font-size: 0.85rem; }
  
  /* Ajuste de Pestañas del Árbol */
  .tree-mode-bar { flex-direction: column; gap: 10px; align-items: center; padding: 10px; height: auto; }
  .mode-tabs { flex-wrap: wrap; justify-content: center; width: 100%; border-radius: 12px; }
  .mode-tab { flex: 1 1 40%; text-align: center; padding: 8px 6px; }
  .tree-hint { text-align: center; width: 100%; }
}

/* ══════════════════════════════════════════════════════════
   CONVERSIÓN DE TABLAS A TARJETAS EN MÓVIL
══════════════════════════════════════════════════════════ */
@media(max-width: 700px) {
  /* Quitar constraints que causan scroll horizontal */
  .dir-table-wrap { overflow-x: hidden !important; margin: 0 12px 80px !important; background: transparent; border: none; box-shadow: none; }
  .dir-table { min-width: 100% !important; background: transparent; }
  .dir-table thead { display: none; }
  
  /* Cada fila (tr) es ahora una Tarjeta Blanca */
  .dir-table tbody tr {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
    background: #fff; border: 1px solid var(--gold-l); border-radius: 14px;
    padding: 14px; margin-bottom: 16px; box-shadow: 0 4px 12px rgba(20,10,0,0.06);
  }
  
  /* Formato base para todas las celdas (td) */
  .dir-table td {
    width: 100%; display: flex; align-items: center; border: none; padding: 6px 0;
    border-bottom: 1px dashed rgba(154,108,16,.15);
  }
  
  /* Inyectar las etiquetas mediante CSS */
  .dir-table td::before {
    content: attr(data-label);
    font-family: var(--ff-ui); font-size: 0.75rem; font-weight: 600;
    color: var(--ink3); text-transform: uppercase;
    width: 90px; flex-shrink: 0; display: block;
  }
  
  /* Acciones genéricas abajo del todo */
  .dir-table td:last-child { width: 100%; justify-content: center; padding-top: 14px; border-top: 1px solid rgba(154,108,16,.2); border-bottom: none;}
  .dir-table td:last-child::before { display: none; }
  .dir-table td .action-btns { width: 100%; justify-content: center; display: flex; gap: 8px; flex-wrap: wrap; }
  .dir-table td .action-btns button { flex: 1 1 30%; justify-content: center; }

/* --- LAYOUT ESPECÍFICO: DIRECTORIO --- */
  #directory-view .dir-table td:nth-child(1) { width: 50px; border-bottom: none; padding: 0; }
  #directory-view .dir-table td:nth-child(1)::before { display: none; }
  #directory-view .d-thumb { width: 48px; height: 48px; margin: 0; }
  
  #directory-view .dir-table td:nth-child(2), #directory-view .dir-table td:nth-child(3) { width: calc(100% - 60px); border-bottom: none; padding: 2px 0; }
  #directory-view .dir-table td:nth-child(2)::before, #directory-view .dir-table td:nth-child(3)::before { display: none; }
  #directory-view .dir-table td:nth-child(2) { font-size: 1.15rem; color: var(--bark); }
  #directory-view .dir-table td:nth-child(3) { font-size: 0.95rem; color: var(--ink3); padding-bottom: 10px; }
  
  /* Ajuste preciso de Género y Nacimiento */
  #directory-view .dir-table td:nth-child(4) { width: 32%; justify-content: flex-start; }
  #directory-view .dir-table td:nth-child(4)::before { width: auto; margin-right: 8px; }
  
  #directory-view .dir-table td:nth-child(5) { width: 65%; justify-content: flex-end; }
  #directory-view .dir-table td:nth-child(5)::before { width: auto; margin-right: 8px; }
  
  #directory-view .dir-table td:nth-child(6) { flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 0; border-bottom: none; }
  #directory-view .dir-table td:nth-child(6)::before { width: 100%; margin-bottom: 4px; }

  /* --- LAYOUT ESPECÍFICO: MATRIMONIOS --- */
  #unions-view .dir-table td { justify-content: space-between; }
  #unions-view .dir-table td:nth-child(1), #unions-view .dir-table td:nth-child(2) { font-size: 1.05rem; color: var(--bark); }
  
  /* Reordenamos con Flexbox para agrupar inteligentemente */
  #unions-view .dir-table td:nth-child(1) { order: 1; } /* Cónyuge A */
  #unions-view .dir-table td:nth-child(2) { order: 2; } /* Cónyuge B */
  
  /* Línea compartida: Estado e Hijos */
  #unions-view .dir-table td:nth-child(3) { order: 3; width: 55%; justify-content: flex-start; }
  #unions-view .dir-table td:nth-child(3)::before { width: auto; margin-right: 8px; }
  #unions-view .dir-table td:nth-child(6) { order: 4; width: 40%; justify-content: flex-end; border-bottom: 1px dashed rgba(154,108,16,.15); padding: 6px 0; }
  #unions-view .dir-table td:nth-child(6)::before { width: auto; margin-right: 8px; }
  
  /* Líneas completas: Fecha y Lugar */
  #unions-view .dir-table td:nth-child(4) { order: 5; width: 100%; display: flex; }
  #unions-view .dir-table td:nth-child(5) { order: 6; width: 100%; display: flex; border-bottom: none; text-align: right; }
  
  #unions-view .dir-table td:last-child { order: 7; } /* Botones Acción */
}