:root{--ink:#24362e;--green:#166342;--lime:#c9a657;--cream:#f8f7f1;--line:#e4e7df;--muted:#6d7c71}*{box-sizing:border-box}body{margin:0;background:var(--cream);font-family:Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;color:var(--ink);line-height:1.55}a{color:var(--green);text-decoration:none}a:hover{text-decoration:underline}.wrap{max-width:1120px;margin:0 auto;padding:0 24px}header{background:#fff;border-bottom:1px solid var(--line)}.nav{display:flex;align-items:center;gap:24px;min-height:80px}.brand{display:flex;align-items:center;gap:11px;color:var(--ink);line-height:1.08;font-size:18px;letter-spacing:.065em;white-space:nowrap}.brand small{display:block;color:var(--muted);font-size:10px;letter-spacing:.07em;margin-top:5px}.brandmark{display:grid;place-items:center;width:44px;height:44px;background:var(--green);color:#fff;font-family:Georgia,serif;font-weight:bold;font-size:27px;border-radius:50%}nav{display:flex;gap:20px;align-items:center;margin-left:auto;flex-wrap:wrap;font-size:13px;font-weight:650}nav a{color:#435449}.logout{margin-left:10px}button,.btn{font:inherit;cursor:pointer;border:0;border-radius:9px;padding:12px 19px;display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;transition:opacity .2s}.primary{background:var(--green);color:white}.primary:hover{opacity:.9;text-decoration:none}.secondary{background:#fff;color:var(--green);border:1px solid #b9c9bb}.secondary:hover{background:#f3f7f1;text-decoration:none}.tiny{padding:8px 10px}.small{padding:9px 12px}.full{width:100%}.dangerbutton{background:#a23232;color:#fff}.danger{border-color:#ecc2c2!important}.hero{padding:80px 0 64px;max-width:770px}.eyebrow{color:#8a6f35;font-weight:750;letter-spacing:.18em;font-size:11px}h1{font-size:clamp(32px,5vw,56px);line-height:1.15;letter-spacing:-.045em;margin:16px 0 22px}h1 em{color:var(--green);font-family:Georgia,serif;font-weight:400}h2{font-size:22px;letter-spacing:-.025em}h3{font-size:16px}.hero p{color:var(--muted);font-size:17px;max-width:620px}.actions{display:flex;gap:12px;flex-wrap:wrap;margin:28px 0 0}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:18px;margin-bottom:20px}.metrics strong{display:block;font-size:38px;color:var(--green);font-weight:750;line-height:1.1}.metrics span{display:block;margin-top:9px;font-size:13px;color:var(--muted)}.metrics a{display:block;font-size:13px;margin-top:5px}.panel{background:white;border:1px solid var(--line);border-radius:15px;padding:26px;box-shadow:0 8px 30px rgba(35,56,42,.025)}.intro{margin:18px 0 50px}.muted,.heading p{color:var(--muted)}.heading{padding:48px 0 26px}.heading h1{font-size:clamp(28px,4vw,43px);margin:12px 0}.heading p{max-width:730px}.auth{max-width:520px;margin:80px auto 100px}.auth h1{font-size:35px}.auth p{color:var(--muted)}form label{display:flex;flex-direction:column;gap:8px;font-size:13px;font-weight:650;margin:15px 0}input,select{font:inherit;font-size:15px;color:var(--ink);border:1px solid #cbd7cc;border-radius:9px;padding:11px 12px;width:100%;background:white;min-width:0}input:focus,select:focus{outline:2px solid #a1c6a2;outline-offset:1px}input[type=file]{font-size:12px}.auth form button{margin-top:14px}.rule{height:1px;background:var(--line);margin:30px 0}.alert{margin:20px 0 0;border-radius:9px;padding:12px 17px;background:#e9f6e9;color:#236a43;font-size:14px}.alert.error{background:#ffeaea;color:#923535}.enroll{display:grid;gap:18px}.step{font-size:13px;color:#a47b2f;letter-spacing:.1em;font-weight:800;display:flex;gap:14px;align-items:center;margin-bottom:20px}.step span{color:var(--ink);letter-spacing:0}.fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 22px}.subsection{background:#f8faf7;padding:16px;border-radius:10px}.subsection h3{margin:0 0 12px}.submitbar{padding:16px 0 50px;display:flex;align-items:center;justify-content:space-between;gap:20px}.submitbar p{color:var(--muted);font-size:13px;max-width:600px}.preview img{max-height:90px;border-radius:9px;max-width:120px;object-fit:cover}.toolbar{display:flex;gap:12px;margin-bottom:20px}.toolbar input{max-width:400px}.tree-viewport{position:relative;background:#fefefd;border:1px solid var(--line);border-radius:16px;overflow:auto;min-height:330px;padding:25px;margin-bottom:60px}.tree-viewport svg{position:absolute;top:0;left:0;pointer-events:none;overflow:visible;z-index:0}.tree-columns{position:relative;display:flex;align-items:stretch;gap:72px;width:max-content;min-width:100%;z-index:1}.generation{min-width:190px;display:flex;flex-direction:column;gap:18px}.generation h3{margin:0 0 6px;color:#9c763a;font-size:12px;text-transform:uppercase;letter-spacing:.08em}.tree-person{display:flex;align-items:center;gap:10px;background:#fff;padding:13px;border-radius:13px;border:1px solid #dce6dc;width:190px;min-height:78px;box-shadow:0 5px 16px #1a3b2420}.tree-person.hidden{opacity:.22}.tree-person img,.tree-person .avatar{width:47px;height:47px;border-radius:50%;object-fit:cover;flex-shrink:0}.avatar{display:grid;place-items:center;background:#e6efe8;color:var(--green);font-size:22px;font-weight:750}.tree-person strong{display:block;font-size:12px;line-height:1.3}.tree-person small{color:var(--muted);font-size:11px}.enrollment{border-top:1px solid var(--line);padding:20px 0}.inline{display:flex;flex-wrap:wrap;gap:12px;align-items:center}.people-mini{display:flex;gap:12px;flex-wrap:wrap;margin:12px 0}.people-mini a{background:#f2f6f0;padding:7px 10px;border-radius:7px;font-size:13px}.tag{font-size:11px;background:#eee9da;border-radius:999px;padding:4px 9px}.tag.approved{background:#daf2df;color:#17653c}.tag.rejected{background:#ffe2e2;color:#a43232}.table-scroll{overflow-x:auto}table{border-collapse:collapse;width:100%}th,td{text-align:left;border-bottom:1px solid var(--line);padding:12px;font-size:13px}th{color:var(--muted);font-size:11px;text-transform:uppercase}.thumbnail{width:46px;height:46px;border-radius:50%;object-fit:cover}footer{color:var(--muted);font-size:12px;padding-top:40px!important;padding-bottom:45px!important}@media(max-width:760px){.nav{flex-wrap:wrap;padding-top:12px;padding-bottom:12px;gap:12px}.brand{margin-right:auto}nav{order:3;width:100%;gap:13px;justify-content:center}.logout{margin:0}.metrics{grid-template-columns:1fr}.hero{padding:50px 0}.fields{grid-template-columns:1fr}.submitbar{flex-direction:column;align-items:stretch}.wrap{padding-left:15px;padding-right:15px}.panel{padding:19px}.heading{padding-top:34px}}@media print{header,footer,.toolbar,.actions{display:none!important}.tree-viewport{overflow:visible;border:none}.tree-columns{gap:60px}body{background:white}}

/* FAMILLE TOH V3 */

#family-shell {
  background: #f5f7f2;
  padding: 16px;
  border: 1px solid #dce5db;
  border-radius: 18px;
}

#family-stats {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.family-stat {
  padding: 15px;
  background: white;
  border-radius: 12px;
  border: 1px solid #e0e8de;
}

.family-stat strong {
  display: block;
  color: #166342;
  font-size: 28px;
}

.family-stat span {
  display: block;
  color: #68786d;
  font-size: 12px;
}

.family-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.family-toolbar input {
  flex: 1 1 230px;
}

.family-toolbar button {
  padding: 9px 12px;
}

#family-message {
  font-size: 13px;
  color: #166342;
}

#family-viewport {
  overflow: auto;
  height: 65vh;
  min-height: 380px;
  background-color: #fafbf8;
  background-image:
    radial-gradient(#d8e2d6 1px,transparent 1px);
  background-size: 20px 20px;
  border: 1px solid #dce5db;
  border-radius: 14px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#family-canvas {
  width: max-content;
  min-width: 100%;
  padding: 35px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.family-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

.family-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 174px;
  min-height: 145px;
  padding: 13px;
  background: #fff;
  border: 1px solid #dce5db;
  border-top: 5px solid var(--branch,#166342);
  border-radius: 12px;
  box-shadow: 0 4px 12px #0000000c;
  color: #24362e;
  text-align: center;
}

.family-card-info strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.family-card-info small {
  display: block;
  font-size: 11px;
  color: #6d7c71;
}

.family-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #edf2eb;
  transition: transform .2s;
}

.family-initial {
  display: grid;
  place-items: center;
  background: #e3efe6;
  color: #166342;
  font-size: 26px;
  font-weight: 750;
}

@media(hover:hover) {
  .family-card:hover {
    z-index: 20;
  }

  .family-card img:hover {
    transform: scale(2.3);
    border-radius: 10px;
    box-shadow: 0 8px 25px #0004;
  }
}

.family-toggle {
  font-size: 11px;
  color: var(--branch,#166342);
  background: white;
  border: 1px solid #dce5db;
  border-radius: 20px;
  padding: 6px 12px;
  margin: 8px 0;
  position: relative;
  z-index: 1;
}

.family-unions,
.family-children {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  padding-top: 26px;
  gap: 0;
}

.family-unions::before,
.family-children::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  height: 13px;
  border-left: 2px solid var(--branch);
}

.family-unions > .family-union,
.family-children > .family-node {
  position: relative;
  margin: 0;
}

.family-unions > .family-union::before,
.family-children > .family-node::before {
  content: '';
  position: absolute;
  top: -13px;
  left: 0;
  right: 0;
  height: 13px;
  border-top: 2px solid var(--branch);
  pointer-events: none;
}

.family-unions > .family-union::after,
.family-children > .family-node::after {
  content: '';
  position: absolute;
  top: -13px;
  left: 50%;
  height: 13px;
  border-left: 2px solid var(--branch);
  pointer-events: none;
}

.family-unions > :first-child::before,
.family-children > :first-child::before {
  left: 50%;
}

.family-unions > :last-child::before,
.family-children > :last-child::before {
  right: 50%;
}

.family-unions > :only-child::before,
.family-children > :only-child::before {
  border-top: 0;
}

.family-union {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  border: 1px solid #dce5db;
  border-radius: 15px;
  background: #ffffff88;
}

.family-children > .family-node {
  padding: 0 12px;
}

.union-label {
  color: var(--branch);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.empty-union {
  padding: 12px;
  color: #788479;
}

.family-highlight {
  outline: 4px solid #e6ad37;
  outline-offset: 4px;
  background: #fff8e5;
}

.other-branches {
  margin-top: 45px;
  padding: 25px;
  border: 1px dashed #aebdaf;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 25px;
}

#person-dialog {
  border: 0;
  border-radius: 20px;
  padding: 20px;
  width: min(440px,92vw);
  max-height: 90vh;
  color: #24362e;
  box-shadow: 0 20px 80px #0005;
}

#person-dialog::backdrop {
  background: #0009;
}

#person-details {
  text-align: center;
  padding-top: 20px;
}

.portrait-large {
  display: block;
  width: 100%;
  max-height: 55vh;
  min-height: 100px;
  object-fit: contain;
  border-radius: 12px;
}

.portrait-large.family-initial {
  display: grid;
  font-size: 70px;
}

.family-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999;
  border-radius: 0!important;
  overflow: auto;
}

.family-fullscreen #family-viewport {
  height: 72vh;
}

body.family-lock {
  overflow: hidden;
}

@media(max-width:760px) {
  #family-shell {
    padding: 8px;
  }

  #family-stats {
    gap: 5px;
  }

  .family-stat {
    padding: 8px;
  }

  .family-stat strong {
    font-size: 22px;
  }

  .family-stat span {
    font-size: 10px;
  }

  .family-toolbar button {
    font-size: 11px;
    padding: 8px;
  }

  #family-viewport {
    height: 65vh;
  }
}

@media print {
  .family-toolbar,
  .family-toggle,
  #person-dialog {
    display: none!important;
  }

  #family-viewport {
    overflow: visible;
    height: auto;
    border: 0;
  }

  #family-shell {
    position: static;
    overflow: visible;
  }

  .family-card {
    box-shadow: none;
    break-inside: avoid;
  }
}


/* PLEIN ECRAN - VUE GLOBALE */

.family-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 8px;
    overflow: hidden;
    box-sizing: border-box;
}

.family-fullscreen #family-stats {
    display: none;
}

.family-fullscreen .family-toolbar {
    flex-shrink: 0;
    padding-bottom: 8px;
}

.family-fullscreen #family-message:empty {
    display: none;
}

.family-fullscreen #family-viewport {
    flex: 1 1 0;
    height: auto !important;
    min-height: 0 !important;
    width: 100%;
}

.family-fullscreen #family-canvas {
    min-width: 0;
    flex-shrink: 0;
}

#fit-tree {
    background: #166342;
    color: white;
    border-color: #166342;
}


/* IMPRESSION EXCLUSIVE DE L'ARBRE TOH */

@page {
    size: A4 landscape;
    margin: 10mm;
}

@media print {

    html, body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body.printing-tree > :not(main) {
        display: none !important;
    }

    body.printing-tree main > :not(#family-shell) {
        display: none !important;
    }

    body.printing-tree main {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.printing-tree #family-shell {
        position: static !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: white !important;
        overflow: visible !important;
    }

    #family-stats,
    .family-toolbar,
    #family-message,
    .family-toggle,
    #person-dialog {
        display: none !important;
    }

    body.printing-tree #family-viewport {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        border: none !important;
        background: white !important;
    }

    body.printing-tree #family-canvas {
        zoom: var(--print-scale, 1) !important;
        width: max-content !important;
        min-width: 0 !important;
        margin: 0 auto !important;
        padding: 10px !important;
        overflow: visible !important;
    }

    .family-card {
        box-shadow: none !important;
        break-inside: avoid !important;
    }

    .family-highlight {
        outline: none !important;
    }

    .family-avatar {
        transform: none !important;
    }
}


/* SIMPLIFICATION FILIATION DIRECTE */

.family-direct {
    padding-top: 26px;
}

.family-direct-union {
    background: transparent;
    border: none;
    padding: 0;
}

.family-direct > .family-node {
    padding-left: 12px;
    padding-right: 12px;
}

.family-direct .family-card {
    margin-bottom: 0;
}

@media print {
    .family-direct {
        padding-top: 26px;
    }
}

