:root {
  --peach-light: #FBE7CC;
  --peach-mid: #F0C594;
  --peach-deep: #E2A467;
  --brown-dark: #4E2F1D;
  --brown-mid: #7A4A2B;
  --gold: #B9832F;
  --cream: #FFF8EE;
}
* { box-sizing: border-box; }
body { margin:0; font-family:'Source Sans 3','Work Sans', sans-serif; color:var(--brown-dark); min-height:100vh; background:#FBEEDC; }
.ui-ico { flex:0 0 auto; vertical-align:middle; }
.font-serif { font-family:'Fraunces', serif; }
a { color: inherit; }
.app-shell { width:100%; min-height:100vh; margin:0; position:relative; z-index:1; }


/* ===== header aplikasi ===== */
.app-header { position:relative; background:#452618 url(app-hdr-art.jpg) right center/auto 100% no-repeat; color:#FFF3E0; height:68px; overflow:hidden; box-shadow:0 2px 8px rgba(40,20,10,.35); }
.app-header::before { content:""; position:absolute; inset:0; background:linear-gradient(90deg,#452618 0,#452618 45%,rgba(69,38,24,0) 75%); }
.ah-in { position:relative; z-index:1; height:100%; display:flex; align-items:center; gap:18px; padding:0 20px 0 28px; }
.ah-brand { display:flex; align-items:center; gap:12px; text-decoration:none; color:#FFF3E0; }
.ah-brand img { height:50px; width:auto; display:block; }
.ah-brand span { font-family:'Fraunces',Georgia,serif; font-weight:800; font-size:31px; letter-spacing:.01em; line-height:1; }
.ah-sep { width:2px; height:34px; background:rgba(255,243,224,.35); margin:0 4px; }
.ah-user { display:flex; align-items:center; gap:10px; font-size:16px; font-weight:500; min-width:0; }
.ah-out { margin-left:auto; display:inline-flex; align-items:center; gap:8px; padding:9px 20px; border:1.5px solid rgba(255,243,224,.85); border-radius:12px; color:#FFF3E0; text-decoration:none; font-weight:600; font-size:16px; background:rgba(60,32,18,.55); }
.ah-out:hover { background:rgba(255,243,224,.18); }

.layout { display:flex; align-items:stretch; gap:0; min-height:calc(100vh - 68px); }
.sidebar { position:relative; overflow:hidden; width:clamp(230px,17vw,300px); flex-shrink:0; background:linear-gradient(180deg,#FFF4E3,#FBE5C8); border-right:1px solid #EAD0A8; padding:26px 14px 260px; }
.sidebar::after { content:""; position:absolute; left:0; right:0; bottom:0; height:250px; background:url(side-art.jpg) center bottom/cover no-repeat; -webkit-mask-image:linear-gradient(180deg,transparent,#000 40%); mask-image:linear-gradient(180deg,transparent,#000 40%); pointer-events:none; }
.side-group { margin-bottom:0; position:relative; z-index:1; }
.side-group + .side-group { border-top:1px solid #E4C99D; margin-top:16px; padding-top:20px; }
.side-title { margin:0 0 10px; padding:0 10px; font-size:17px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; color:#B06F25; }
.side-link { display:flex; align-items:center; gap:14px; padding:12px 14px; border-radius:14px; font-size:18px; font-weight:500; color:#4E2F1D; text-decoration:none; margin-bottom:4px; }
.side-link .ui-ico { color:#9A5A25; }
.side-link:hover { background:rgba(185,131,47,.14); }
.side-link.active { background:linear-gradient(180deg,#7A4527,#5A3520); color:#FFF8EE; font-weight:600; box-shadow:0 4px 10px rgba(78,47,29,.35); }
.side-link.active .ui-ico { color:#FFF3E0; }
.panel-body { flex:1; min-width:0; background:linear-gradient(180deg,#FFF9F0,#FBEEDC); padding:22px 26px 30px; }
.nav-toggle{display:none}
@media (max-width:760px){
  .layout{flex-direction:column}
  .nav-toggle{display:inline-flex;flex-direction:column;justify-content:center;gap:5px;width:44px;height:44px;flex:0 0 44px;padding:0 10px;border:1px solid rgba(255,243,224,.45);border-radius:10px;background:transparent;cursor:pointer}
  .nav-toggle span{display:block;height:3px;border-radius:2px;background:#FFF3E0}
  .ah-in{gap:10px;padding:0 12px}
  .sidebar{position:fixed;left:0;top:60px;bottom:0;z-index:950;width:min(86vw,320px);overflow-y:auto;-webkit-overflow-scrolling:touch;transform:translateX(-102%);transition:transform .22s ease;box-shadow:none;border-right:1px solid #EAD0A8;padding:16px 12px 40px}
  .sidebar.open{transform:none;box-shadow:6px 0 24px rgba(40,20,10,.35)}
  .sidebar::after{display:none}
  .nav-backdrop{position:fixed;inset:60px 0 0 0;z-index:940;background:rgba(30,15,8,.45)}
  .nav-backdrop[hidden]{display:none}
  body.nav-open{overflow:hidden}
  .panel-body{padding:14px}
  .ah-brand span{font-size:22px}.ah-user,.ah-sep{display:none}
  .app-header{height:60px}.ah-brand img{height:38px}
  .ah-out{padding:8px 12px}
  input,select,textarea{font-size:16px !important}
  .side-link{min-height:44px}
}
@media (max-width:350px){ .ah-brand span{display:none} }


.card { position:relative; background:linear-gradient(180deg,#FFFDF8,#FBF1E0); border:1px solid #EBD3AE; border-radius:22px; padding:18px 24px; box-shadow:0 3px 10px rgba(78,47,29,.10); margin-bottom:16px; }
.card.has-ico { display:flex; gap:14px; align-items:center; }
.card.has-ico > .ui-ico { color:#9A5A25; }
.card-lace { overflow:hidden; }
.card-lace::after { content:""; position:absolute; top:0; right:0; width:150px; height:130px; background:url(lace.png) right top/contain no-repeat; opacity:.9; pointer-events:none; mix-blend-mode:multiply; }
.card-title { display:flex; align-items:center; gap:12px; font-family:'Fraunces',Georgia,serif; font-weight:800; font-size:24px; margin:0 0 12px; }
.card-title .ui-ico { color:#9A5A25; }
.info-line { display:flex; align-items:center; gap:12px; margin:0 0 14px; font-size:16px; color:#4E2F1D; }
.info-line .ui-ico { color:#9A5A25; }
.btn-primary { display:inline-flex; align-items:center; justify-content:center; gap:10px; background:linear-gradient(180deg,#7A4527,#4E2F1D); color:#fff; border:none; padding:11px 22px; border-radius:12px; font-size:16px; font-weight:600; cursor:pointer; text-decoration:none; box-shadow:0 4px 10px rgba(78,47,29,.3); font-family:inherit; }
.btn-primary:disabled { background:#C9B8A5; }
.btn-ghost { display:inline-flex; align-items:center; justify-content:center; gap:5px; background:linear-gradient(180deg,#FFFDF8,#FBEFD9); border:1.5px solid #D9B889; color:#5A3520; padding:5px 10px; border-radius:10px; font-size:12.5px; font-weight:600; cursor:pointer; text-decoration:none; font-family:inherit; white-space:nowrap; }
.btn-ghost:hover { background:#F7E4C6; }
.btn-ghost.danger { color:#B3261E; border-color:#E0A59E; }
.row-search { display:flex; gap:12px; align-items:center; }
.row-search .search-box { flex:1; position:relative; min-width:200px; }
.row-search .search-box .ui-ico { position:absolute; left:14px; top:50%; transform:translateY(-50%); color:#7A4A2B; }
.row-search .search-box input { width:100%; padding:12px 14px 12px 46px; border-radius:12px; border:1.5px solid #E2C9A2; font-size:16px; background:#fff; font-family:inherit; color:#4E2F1D; }
.status-pill { display:inline-flex; align-items:center; gap:6px; }

.field { display:block; margin-bottom:12px; }
.field > span:first-child, .field label { display:block; font-size:12px; font-weight:600; color:var(--brown-mid); margin-bottom:4px; }
.field { min-width:0; }
.field textarea, .field input[type=file] { width:100%; max-width:100%; }
input, select, textarea, button { max-width:100%; font-family:inherit; }
.field input, .field select { min-width:0; width:100%; padding:8px 10px; border-radius:8px; border:1px solid var(--peach-deep); font-size:14px; background:#fff; }
.field .hint { display:block; font-size:11px; color:#78716c; margin-top:3px; }

.badge { display:inline-block; padding:2px 10px; border-radius:999px; font-size:11px; font-weight:500; }
.badge-aktif { background:#DDEFD8; color:#2F6B3A; font-size:16px; padding:4px 14px; font-weight:600; }
.badge-pasif { background:#F6E3B4; color:#8A6110; }
.badge-terkunci { background:#F8D9E1; color:#A22A4A; }
.badge-peach { background:var(--peach-mid); color:var(--brown-dark); }

.tabs { display:flex; gap:4px; margin-bottom:16px; flex-wrap:wrap; border-bottom:1px solid var(--peach-mid); }
.tab-btn { padding:8px 16px; border-radius:12px 12px 0 0; font-size:14px; font-weight:500; border:none; background:transparent; color:var(--brown-mid); text-decoration:none; display:inline-block; }
.tab-btn.active { background:var(--peach-mid); color:var(--brown-dark); font-weight:600; }

.chart-scroll { overflow:auto; max-height:75vh; padding:44px 16px 32px; overscroll-behavior:contain; }
.chart, .chart ul { display:flex; list-style:none; margin:0; padding:0; justify-content:center; }
.chart { position:relative; gap:28px; }
.chart li.cn[data-side=R] { margin-left:20px; } .chart li.cn[data-side=L] { margin-right:20px; }
.chart-scroll > .chart { justify-content:flex-start; width:max-content; margin:0 auto; }
.chart ul.kids { gap:28px; align-items:flex-start; }
.chart li.cn { display:flex; flex-direction:column; align-items:center; list-style:none; position:relative; }
.chart > li.cn { padding:0; }
/* baris pasangan: kartu utama + semua pasangan berdampingan; jarak 28px memuat garis pasangan */
.couple-row { display:flex; align-items:flex-start; gap:28px; position:relative; z-index:1; }
.cr-item { position:relative; z-index:1; }
.cr-item > .spouse-chip { min-height:84px; }
/* garis pasangan & keturunan digambar oleh skrip (SVG) dari posisi kartu yang sebenarnya */
svg.chart-lines { position:absolute; left:0; top:0; z-index:0; pointer-events:none; overflow:visible; }
svg.chart-lines path { fill:none; stroke:#C28B2E; stroke-width:2; stroke-linecap:square; stroke-linejoin:miter; }
svg.chart-lines path.mk { stroke:#2E8B3D; stroke-width:4; stroke-dasharray:10 6; stroke-linecap:butt; }
.badge-malakok { background:#E3F4E4; color:#1F6B2B; border:1px solid #8CCB92; }
.btn-malakok { color:#1F6B2B !important; border-color:#8CCB92 !important; }
.mk-legend { display:inline-flex; align-items:center; gap:8px; font-size:12px; color:#1F6B2B; }
.mk-legend i { display:inline-block; width:38px; height:0; border-top:4px dashed #2E8B3D; }
.member-card { border-radius:18px; border:2.5px solid #D9A84E; padding:10px; background:linear-gradient(180deg,#FFFEFB,#FFF8EC); box-shadow:0 5px 12px rgba(78,47,29,.18); width:200px; box-sizing:border-box; }
.member-card.male { border-color:#8FB2D6; }
.mc-top { display:flex; gap:8px; }
.mc-info { min-width:0; text-align:left; }
.mc-name { display:flex; align-items:flex-start; gap:5px; }
.mc-title { overflow-wrap:break-word; margin:0; font-size:12.5px; font-weight:800; text-transform:uppercase; line-height:1.15; color:#3B2415; }
.mc-gen { margin:2px 0 0; font-size:11.5px; color:#6B5A4E; }
.mc-badges { display:flex; gap:4px; margin-top:4px; flex-wrap:wrap; }
.node-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; margin-top:8px; }
.node-actions .btn-ghost { padding:5px 3px; font-size:11.5px; gap:4px; min-width:0; overflow:hidden; }
.spouse-chip { border-radius:12px; border:1px solid var(--peach-mid); padding:10px; background:#fff; display:flex; flex-direction:column; align-items:flex-start; gap:2px; font-size:12px; color:var(--brown-mid); width:200px; box-sizing:border-box; }

.photo-box { width:42px; height:63px; border-radius:10px; overflow:hidden; background:#f5f5f4; border:1px solid var(--peach-mid); flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:9px; color:#d6d3d1; }
.photo-box img { width:100%; height:100%; object-fit:cover; }
a.photo-box { text-decoration:none; }
.photo-box.placeholder { background:#FFFDF8; border:1.5px dashed #D9B889; color:#B09670; font-size:11px; font-weight:600; }
.photo-box.placeholder::before { content:"4 x 6"; }

.lightbox-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.82); align-items:center; justify-content:center; z-index:200; padding:24px; }
.lightbox-overlay:target { display:flex; }
.lightbox-overlay img { max-width:90vw; max-height:88vh; border-radius:10px; box-shadow:0 8px 30px rgba(0,0,0,.4); }
.lightbox-close { position:absolute; top:18px; right:24px; color:#fff; font-size:36px; line-height:1; text-decoration:none; font-weight:300; }
.lightbox-close:hover { color:var(--peach-light); }
.gender-icon { display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; border-radius:999px; font-size:13px; font-weight:700; flex-shrink:0; }
.gender-icon.P { background:#F6C6D6; color:#B02C5A; }
.gender-icon.L { background:#A9C6E0; color:#254B7A; }

.toast { font-size:12px; padding:8px 12px; border-radius:10px; background:var(--peach-light); color:var(--brown-dark); margin-bottom:16px; }
.error-text { font-size:12px; color:#b91c1c; margin-bottom:8px; }
table.list { width:100%; border-collapse:collapse; font-size:13px; }
table.list th, table.list td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--peach-mid); }

@media print {
  @page { margin: 10mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background:#fff !important; }
  .panel-body { padding:0 !important; background:#fff !important; }
  .layout { display:block !important; min-height:0 !important; }
  .chart-scroll { overflow:visible !important; max-height:none !important; padding:14px 0 0 !important; }
  .no-print { display:none !important; }
  .node-actions { display:none !important; }
}
.paper-pick { display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--brown-mid); }
.paper-pick select { padding:6px 8px; border-radius:8px; border:1px solid var(--peach-deep); font-size:12.5px; background:#fff; }
.ranji-motto { text-align:center; margin:14px 0 4px; font-family:'Fraunces',Georgia,serif; font-style:italic; font-size:17px; color:var(--brown-mid); letter-spacing:.3px; }
.ranji-motto::before, .ranji-motto::after { content:"\2766"; font-style:normal; color:#C28B2E; margin:0 10px; font-size:14px; }

.name-P { color:#C62828 !important; font-weight:800 !important; }
.name-L { color:#1D4ED8 !important; font-weight:800 !important; }
.mc-name .gender-icon { width:18px; height:18px; font-size:11px; }

.name-click { cursor:pointer; }
.name-click:hover { text-decoration:underline; }
.detail-ov { display:none; position:fixed; inset:0; background:rgba(40,20,10,.55); z-index:300; align-items:center; justify-content:center; padding:16px; }
.detail-ov.open { display:flex; }
.detail-box { width:100%; max-width:420px; max-height:90vh; overflow:auto; background:linear-gradient(180deg,#FFFDF8,#FBF1E0); border:1px solid #EBD3AE; border-radius:22px; padding:20px 22px; box-shadow:0 14px 40px rgba(40,20,10,.4); }
.detail-head { display:flex; gap:14px; align-items:center; margin-bottom:12px; }
.detail-head img, .detail-head .ph { width:64px; height:96px; object-fit:cover; border-radius:10px; flex-shrink:0; }
.detail-head .ph { display:flex; align-items:center; justify-content:center; border:1.5px dashed #D9B889; color:#B09670; font-size:12px; font-weight:600; background:#FFFDF8; }
.detail-head h3 { margin:0; font-family:'Fraunces',Georgia,serif; font-size:20px; line-height:1.2; text-transform:uppercase; overflow-wrap:break-word; }
.detail-head small { color:#6B5A4E; font-size:13px; }
.detail-row { display:flex; gap:12px; padding:7px 0; border-top:1px solid #EFDDBF; font-size:14px; }
.detail-row b { flex:0 0 130px; color:#8A5A2B; font-weight:600; }
.detail-empty { font-size:13px; color:#78716c; margin:6px 0 0; }
.detail-close { float:right; background:none; border:0; font-size:26px; line-height:1; cursor:pointer; color:#6B5A4E; }

/* Alamat berjenjang (Indonesia / Luar Negeri) */
.addr-box{border:1px solid #E2C9A2;border-radius:12px;padding:10px 12px 12px;margin:0 0 12px;min-width:0}
.addr-box legend{font-size:13px;font-weight:700;padding:0 6px}
.addr-dom{display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin:0 0 10px;font-size:13.5px}
.addr-dom>span{font-weight:700}
.addr-dom label{display:inline-flex;align-items:center;gap:6px;cursor:pointer}
.addr-dom input{width:auto;margin:0}
.addr-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:0 10px}
.addr-grid .field,.addr-pane>.field{min-width:0}
.addr-box select,.addr-box input:not([type=radio]){width:100%}
.addr-box select:disabled{opacity:.6;cursor:not-allowed}
.addr-pos{max-width:220px}

/* Dashboard sebaran (Super Admin) */
.dash-stats{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));margin-bottom:16px}
.dash-stats .card{text-align:center}
.dash-stats p{margin:0;font-size:12px;color:#78716c}
.dash-stats b{display:block;margin-top:4px;font-size:28px;color:var(--brown-dark)}
.dash-stats small{font-size:11px;color:#78716c}
.dash-grid{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}
.dash-grid .card{min-width:0}
.dash-grid h3{margin:0 0 10px}
.dash-bars{display:grid;gap:8px}
.dash-row{display:grid;grid-template-columns:minmax(90px,38%) 1fr 34px;gap:8px;align-items:center;font-size:13px}
.dash-lbl{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dash-lbl small{display:block;font-size:10.5px;color:#78716c;overflow:hidden;text-overflow:ellipsis}
.dash-bar{height:10px;border-radius:99px;background:#F3E3C8;overflow:hidden}
.dash-bar i{display:block;height:100%;border-radius:99px;background:linear-gradient(90deg,#B7791F,#8B5A2B)}
.dash-row b{text-align:right;color:var(--brown-dark)}
.dash-empty,.dash-more,.dash-note{margin:0;font-size:12px;color:#78716c}
.dash-note{margin-bottom:10px}

/* Asisten AI adat Minangkabau */
@keyframes aiPulse{0%,100%{box-shadow:0 10px 26px rgba(29,78,216,.45),0 0 0 0 rgba(29,78,216,.45)}50%{box-shadow:0 10px 26px rgba(29,78,216,.45),0 0 0 12px rgba(29,78,216,0)}}

.doc-thumbs { display:flex; gap:6px; flex-wrap:wrap; }
.doc-thumb { width:44px; height:44px; object-fit:cover; border-radius:8px; border:1.5px solid #D9B889; display:block; background:#fff; }
.doc-existing { display:flex; flex-direction:column; align-items:center; gap:2px; font-size:11px; color:#78716c; }
.doc-existing .doc-thumb { width:64px; height:64px; }

@keyframes aiIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.dots{display:inline-flex;gap:4px;align-items:center}
.dots i{width:7px;height:7px;border-radius:50%;background:#1D4ED8;opacity:.35;animation:aiDot 1s infinite}
.dots i:nth-child(2){animation-delay:.15s}.dots i:nth-child(3){animation-delay:.3s}
@keyframes aiDot{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}
.caret{display:inline-block;width:7px;height:14px;margin-left:2px;vertical-align:-2px;background:#1D4ED8;animation:aiBlink .8s steps(1) infinite}
@keyframes aiBlink{50%{opacity:0}}

/* ===== e-book (panel) ===== */
.btn-access{display:inline-block;margin:0 0 0 8px;padding:7px 16px;border-radius:10px;background:#1D4ED8;color:#fff!important;font-weight:700;font-size:14px;text-decoration:none}
.btn-access.alt{background:#fff;color:#1D4ED8!important;border:2px solid #1D4ED8}
.eb-st{display:inline-block;padding:3px 12px;border-radius:99px;font-weight:700;font-size:12.5px}
.eb-st.ok{background:#DCFCE7;color:#166534}.eb-st.wait{background:#FEF3C7;color:#92400E}.eb-st.bad{background:#FEE2E2;color:#991B1B}
.eb-tabs{display:flex;flex-wrap:wrap;gap:8px}.eb-tabs a{padding:8px 16px;border-radius:10px;background:#FBE0CB;color:#8A3B1F;font-weight:700;text-decoration:none}.eb-tabs a.on{background:#1D4ED8;color:#fff}
.eb-f{display:inline-block;padding:5px 12px;border-radius:99px;background:#FBE0CB;color:#8A3B1F;font-size:13px;text-decoration:none;margin:0 4px 4px 0}.eb-f.on{background:#1D4ED8;color:#fff}
.eb-tbl td{vertical-align:top}
@media (max-width:760px){ .dms-row input[type=number]{width:20% !important;min-width:0;padding-left:6px;padding-right:6px} .dms-row select{width:22% !important;min-width:0;padding-left:4px;padding-right:4px} }
