/* ===================================================================
   الدبلان من الفرده — Family Registry Stylesheet
   Mobile-first responsive design
   =================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --parchment:    #F5EFE0;
    --parchment-dk: #E8DFD0;
    --green:        #1B4D3E;
    --green-light:  #2A6F5A;
    --green-pale:   #E8F5E9;
    --gold:         #B8860B;
    --gold-light:   #D4A843;
    --gold-pale:    #FFF8E7;
    --red:          #C62828;
    --red-pale:     #FFEBEE;
    --text:         #2C2417;
    --text-light:   #6B5D4F;
    --white:        #FFFFFF;
    --shadow:       0 2px 8px rgba(44,36,23,.10);
    --shadow-lg:    0 8px 32px rgba(44,36,23,.18);
    --radius:       10px;
    --radius-sm:    6px;
    --font-head:    'Geeza Pro', 'Traditional Arabic', 'Noto Naskh Arabic', Tahoma, sans-serif;
    --font-body:    'Segoe UI', 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
    --nav-h:        56px;
}

[hidden] { display: none !important; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    background: var(--parchment);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-light); }

/* --- Ornament Band --- */
.ornament-band {
    height: 4px;
    background: linear-gradient(90deg, var(--gold), var(--green), var(--gold));
}

/* ===================================================================
   Navigation
   =================================================================== */
.nav {
    background: var(--green);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: 100%;
    gap: 12px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--white);
    flex-shrink: 0;
}
.nav-logo { width: 28px; height: 28px; color: var(--gold); }
.nav-title {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Hamburger */
.nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    margin-right: auto;
    border-radius: var(--radius-sm);
}
.nav-toggle:active { background: rgba(255,255,255,.12); }

/* Nav links - mobile: vertical dropdown */
.nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--green);
    flex-direction: column;
    padding: 8px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 99;
}
.nav-links.open { display: flex; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    color: rgba(255,255,255,.85);
    font-size: .93rem;
    font-weight: 600;
    min-height: 44px;
    transition: background .15s;
}
.nav-link:hover, .nav-link.active { color: var(--white); background: rgba(255,255,255,.08); }
.nav-link-admin { color: var(--gold-light); }
.nav-link-admin:hover { color: var(--gold); }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: var(--white);
    font-size: .7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
}

/* Desktop nav */
@media (min-width: 641px) {
    .nav-toggle { display: none; }
    .nav-links {
        display: flex !important;
        position: static;
        flex-direction: row;
        padding: 0;
        box-shadow: none;
        margin-right: auto;
        gap: 2px;
    }
    .nav-link { padding: 8px 14px; border-radius: var(--radius-sm); }
    .nav-dropdown:hover .nav-dropdown-menu { display: block; }
}

/* ===================================================================
   Nav Dropdown
   =================================================================== */
.nav-dropdown { position: relative; }
.nav-dd-arrow { margin-right: 4px; vertical-align: middle; }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 6px 0;
    z-index: 150;
}
/* Mobile: inline */
@media (max-width: 640px) {
    .nav-dropdown-menu {
        position: static;
        background: rgba(255,255,255,.06);
        box-shadow: none;
        border-radius: 0;
        min-width: 0;
    }
    .nav-dropdown-item { color: rgba(255,255,255,.8) !important; }
    .nav-dropdown-item:hover { background: rgba(255,255,255,.08) !important; }
    .nav-dropdown-divider { border-color: rgba(255,255,255,.1) !important; }
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-item {
    display: block;
    padding: 10px 18px;
    color: var(--text);
    font-size: .85rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.nav-dropdown-item:hover { background: var(--parchment); color: var(--green); }
.nav-dropdown-all { color: var(--gold) !important; font-weight: 600; }
.nav-dropdown-divider { border-top: 1px solid var(--parchment-dk); margin: 4px 0; }

/* ===================================================================
   Header
   =================================================================== */
.site-header {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
    color: var(--white);
    padding: 24px 16px;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.brand-title {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}
.brand-sub {
    font-size: .85rem;
    opacity: .8;
    margin: 0;
}
@media (min-width: 641px) {
    .site-header { padding: 32px 24px; }
    .brand-title { font-size: 2rem; }
}

/* ===================================================================
   Buttons
   =================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: all .15s;
    white-space: nowrap;
    text-decoration: none;
}
.btn-primary { background: var(--gold); color: var(--white); }
.btn-primary:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #D32F2F; }
.btn-success { background: var(--green); color: var(--white); }
.btn-success:hover { background: var(--green-light); }
.btn-sm { padding: 6px 12px; font-size: .8rem; min-height: 36px; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--green);
    color: var(--green);
}
.btn-outline:hover { background: var(--green); color: var(--white); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    color: var(--text-light);
    transition: all .15s;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.icon-btn-edit:hover { color: var(--green); }
.icon-btn-delete:hover { color: var(--red); }

/* ===================================================================
   Stats
   =================================================================== */
.stats {
    max-width: 1200px;
    margin: 16px auto;
    padding: 0 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.stat-card {
    background: var(--white);
    padding: 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    border-top: 3px solid var(--gold);
}
.stat-value {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--green);
}
.stat-label { font-size: .78rem; color: var(--text-light); margin-top: 2px; }

@media (min-width: 481px) {
    .stats { grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 0 24px; }
}

/* ===================================================================
   Search
   =================================================================== */
.search-section {
    max-width: 1200px;
    margin: 16px auto;
    padding: 0 16px;
}
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    right: 14px;
    color: var(--text-light);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 12px 44px 12px 44px;
    border: 2px solid var(--parchment-dk);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .95rem;
    background: var(--white);
    transition: border-color .15s;
}
.search-input:focus {
    outline: none;
    border-color: var(--green);
}
.search-clear {
    position: absolute;
    left: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.search-clear:hover { background: rgba(0,0,0,.06); }
.search-meta {
    font-size: .82rem;
    color: var(--text-light);
    margin-top: 8px;
    text-align: center;
}

@media (min-width: 641px) {
    .search-section { padding: 0 24px; }
}

/* ===================================================================
   Records Grid
   =================================================================== */
.records {
    max-width: 1200px;
    margin: 16px auto;
    padding: 0 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 481px) {
    .records { grid-template-columns: repeat(2, 1fr); padding: 0 24px; }
}
@media (min-width: 900px) {
    .records { grid-template-columns: repeat(3, 1fr); }
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    border-right: 4px solid var(--gold);
    transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.card-id {
    font-family: var(--font-head);
    font-size: .85rem;
    color: var(--gold);
    font-weight: 700;
}
.card-actions { display: flex; gap: 2px; }
.card-name {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--green);
    margin-bottom: 10px;
    line-height: 1.4;
}
.card-fields { display: flex; flex-direction: column; gap: 6px; }
.field {
    display: flex;
    gap: 8px;
    font-size: .85rem;
    align-items: baseline;
}
.field dt {
    color: var(--text-light);
    font-weight: 600;
    min-width: 50px;
    flex-shrink: 0;
}
.field dd { color: var(--text); word-break: break-word; }
.field a { color: var(--green); }
.muted { color: var(--parchment-dk); }

/* ===================================================================
   Empty State
   =================================================================== */
.empty-state {
    max-width: 1200px;
    margin: 40px auto;
    padding: 40px 16px;
    text-align: center;
    color: var(--text-light);
}
.empty-state svg { margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 4px; }
.empty-state p { font-size: .85rem; }

/* ===================================================================
   Modal
   =================================================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
}
.modal-panel {
    position: relative;
    background: var(--white);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.modal-panel-sm { max-width: 420px; }

@media (min-width: 641px) {
    .modal { align-items: center; }
    .modal-panel {
        border-radius: var(--radius);
        max-width: 520px;
        max-height: 85vh;
        animation: fadeScale .2s ease;
    }
    @keyframes fadeScale {
        from { transform: scale(.95); opacity: 0; }
        to   { transform: scale(1); opacity: 1; }
    }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--parchment-dk);
}
.modal-head h2 {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--green);
}
.modal-close { color: var(--text-light); }
.modal-body { padding: 20px; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--parchment-dk);
}

/* Form */
.form-row { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.req { color: var(--red); }
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--parchment-dk);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: .9rem;
    transition: border-color .15s;
    min-height: 44px;
}
.form-input:focus { outline: none; border-color: var(--green); }
.form-readonly {
    padding: 10px 14px;
    background: var(--parchment);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    color: var(--text-light);
}
.form-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: var(--gold-pale);
    border-radius: var(--radius-sm);
    font-size: .82rem;
    color: var(--gold);
    line-height: 1.5;
}
.form-notice svg { flex-shrink: 0; margin-top: 2px; }
.form-error {
    padding: 10px 14px;
    background: var(--red-pale);
    color: var(--red);
    border-radius: var(--radius-sm);
    font-size: .85rem;
    margin-top: 12px;
}
.confirm-name {
    font-family: var(--font-head);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--green);
    text-align: center;
    padding: 8px;
}

/* ===================================================================
   Toast
   =================================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    animation: toastIn .3s ease;
    max-width: calc(100% - 32px);
    text-align: center;
}
.toast.toast-error { background: var(--red); }
@keyframes toastIn {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ===================================================================
   Footer
   =================================================================== */
.site-footer {
    margin-top: 40px;
    padding: 24px 16px;
    text-align: center;
    font-size: .82rem;
    color: var(--text-light);
}
.ornament-divider {
    height: 2px;
    max-width: 200px;
    margin: 0 auto 16px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ===================================================================
   Login Page
   =================================================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-h) - 4px);
    padding: 24px 16px;
}
.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-card h1 {
    font-family: var(--font-head);
    font-size: 1.3rem;
    color: var(--green);
    margin-bottom: 24px;
}
.login-card .form-input { margin-bottom: 16px; }
.login-card .btn { width: 100%; justify-content: center; }
.login-error {
    color: var(--red);
    font-size: .85rem;
    margin-bottom: 12px;
}

/* ===================================================================
   Admin Panel
   =================================================================== */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.admin-header h1 {
    font-family: var(--font-head);
    font-size: 1.3rem;
    color: var(--green);
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--parchment-dk);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.admin-tab {
    padding: 10px 16px;
    border: none;
    background: none;
    font-family: var(--font-body);
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
    color: var(--green);
    border-bottom-color: var(--green);
}
.admin-panel { display: none; }
.admin-panel.active { display: block; }

/* Pending Request Cards */
.pending-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: .9rem;
}
.pending-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}
.pending-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--parchment);
    border-bottom: 1px solid var(--parchment-dk);
    flex-wrap: wrap;
    gap: 8px;
}
.pending-type {
    font-weight: 700;
    font-size: .85rem;
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--white);
}
.pending-type.type-add { background: var(--green); }
.pending-type.type-update { background: var(--gold); }
.pending-type.type-delete { background: var(--red); }
.pending-date { font-size: .78rem; color: var(--text-light); }
.pending-card-body { padding: 16px; }

/* Diff View */
.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.diff-table th {
    text-align: right;
    padding: 6px 10px;
    background: var(--parchment);
    color: var(--text-light);
    font-weight: 600;
    border-bottom: 1px solid var(--parchment-dk);
    white-space: nowrap;
    width: 60px;
}
.diff-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--parchment-dk);
    word-break: break-word;
}
.diff-old { color: var(--red); text-decoration: line-through; opacity: .7; }
.diff-new { color: var(--green); font-weight: 600; }
.diff-arrow { color: var(--text-light); padding: 0 4px; font-size: .8rem; }

.pending-card-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--parchment-dk);
}

/* Password Section */
.settings-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    max-width: 400px;
}
.settings-section h3 {
    font-family: var(--font-head);
    font-size: 1.05rem;
    color: var(--green);
    margin-bottom: 16px;
}

/* ===================================================================
   Family Tree Page
   =================================================================== */
.tree-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}
.tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.tree-header h1 {
    font-family: var(--font-head);
    font-size: 1.3rem;
    color: var(--green);
}
.tree-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Tree wrapper - scrollable */
.tree-viewport {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px;
    min-height: 300px;
    position: relative;
}
.tree-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* Tree layout - vertical top-down */
.tree-root {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Each tree node */
.tree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.tree-node-label {
    background: var(--green);
    color: var(--white);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: default;
    text-align: center;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 2;
    transition: background .15s;
}
.tree-node-label.is-root {
    background: var(--gold);
    font-family: var(--font-head);
    font-size: 1rem;
    padding: 10px 20px;
}
.tree-node-label.has-record {
    background: var(--green);
}
.tree-node-label.no-record {
    background: var(--green-light);
    opacity: .85;
}
.tree-node-label .admin-node-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.2);
    color: var(--white);
    cursor: pointer;
    font-size: .7rem;
    line-height: 1;
    padding: 0;
}
.tree-node-label .admin-node-btn:hover {
    background: rgba(255,255,255,.35);
}

/* Children container */
.tree-children {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    margin-top: 0;
    padding-top: 28px;
    position: relative;
}

/* Vertical line from parent down */
.tree-children::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 28px;
    background: var(--gold);
}

/* Horizontal bar connecting siblings */
.tree-children.multi::after {
    content: '';
    position: absolute;
    top: 28px;
    height: 2px;
    background: var(--gold);
    left: var(--bar-left, 25%);
    right: var(--bar-right, 25%);
}

/* Vertical line from horizontal bar down to each child */
.tree-children > .tree-node::before {
    content: '';
    position: absolute;
    top: -28px;
    left: 50%;
    width: 2px;
    height: 28px;
    background: var(--gold);
    z-index: 1;
}

/* Hide unnecessary connector for single child */
.tree-children:not(.multi) > .tree-node::before {
    display: none;
}

/* Tree node context menu */
.tree-context-menu {
    position: fixed;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    z-index: 250;
    min-width: 160px;
}
.tree-context-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    font-family: var(--font-body);
    font-size: .85rem;
    text-align: right;
    cursor: pointer;
    color: var(--text);
    min-height: 40px;
}
.tree-context-item:hover { background: var(--parchment); }
.tree-context-item.danger { color: var(--red); }

/* Tree empty state */
.tree-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}
.tree-empty p { margin-bottom: 16px; }

/* ===================================================================
   Page Layout
   =================================================================== */
.page-wrap {
    min-height: calc(100vh - var(--nav-h) - 4px);
    display: flex;
    flex-direction: column;
}
.page-wrap > .site-footer { margin-top: auto; }

/* ===================================================================
   Fathers Page
   =================================================================== */
.father-hero {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
    color: var(--white);
    padding: 40px 16px;
    text-align: center;
}
.father-hero-inner { max-width: 600px; margin: 0 auto; }
.father-photo-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 16px;
}
.father-photo, .father-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--gold);
}
.father-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.5);
}
.father-photo-upload {
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 32px;
    height: 32px;
    background: var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--white);
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.father-photo-upload:hover { background: var(--gold-light); }
.father-name {
    font-family: var(--font-head);
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
}
.father-children-count {
    font-size: .9rem;
    opacity: .8;
    margin-top: 4px;
}

.father-children-section {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
}
.father-children-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
@media (min-width: 481px) { .father-children-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .father-children-grid { grid-template-columns: repeat(3, 1fr); } }

.child-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    border-right: 4px solid var(--gold);
    transition: box-shadow .15s;
}
.child-card:hover { box-shadow: var(--shadow-lg); }
.child-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.child-actions { display: flex; gap: 2px; }
.father-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.father-section-head h2 {
    font-family: var(--font-head);
    font-size: 1.15rem;
    color: var(--green);
}
.child-id {
    font-family: var(--font-head);
    font-size: .85rem;
    color: var(--gold);
    font-weight: 700;
}
.child-name {
    font-family: var(--font-head);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--green);
    margin-bottom: 10px;
}
.child-fields { display: flex; flex-direction: column; gap: 6px; }

/* Fathers grid (listing page) */
.fathers-grid {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
@media (min-width: 641px) { .fathers-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .fathers-grid { grid-template-columns: repeat(4, 1fr); } }

.father-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 16px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow .15s, transform .15s;
    position: relative;
}
.father-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.father-card-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--parchment);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 12px;
    border: 3px solid var(--gold);
    color: var(--text-light);
}
.father-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.father-card h3 {
    font-family: var(--font-head);
    font-size: .95rem;
    color: var(--green);
    margin: 0 0 4px;
}
.father-card-count { font-size: .78rem; color: var(--text-light); }
.father-card-delete {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--red-pale);
    color: var(--red);
    cursor: pointer;
    font-size: .7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.father-card-delete:hover { background: var(--red); color: var(--white); }

/* ===================================================================
   Utility
   =================================================================== */
.text-center { text-align: center; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }

/* ===================================================================
   Print
   =================================================================== */
@media print {
    .nav, .nav-toggle, .search-section, .icon-btn, .btn, .modal, .toast, .site-footer { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

/* ===================================================================
   v3 — Family portal, generational pages, person profiles and heritage tree
   =================================================================== */

:root {
    --navy: #172a55;
    --navy-deep: #0f1d3f;
    --heritage-blue: #192c70;
    --brown: #7a481f;
    --leaf: #2f6f31;
    --leaf-dark: #1d5027;
    --cream: #fbf7ea;
    --line: rgba(95, 74, 43, .16);
}

body { background-image: radial-gradient(circle at 20% 5%, rgba(184,134,11,.055), transparent 24rem); }
.page-wrap.family-portal,
.records-page-new,
.person-page,
.tree-page-new,
.admin-page-new { width: 100%; }

.eyebrow {
    display: inline-block;
    color: var(--gold);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .03em;
    margin-bottom: 5px;
}
.eyebrow-light { color: #f2cf7a; }
.btn-large { min-height: 48px; padding-inline: 22px; font-size: .94rem; }
.btn-outline-light { border: 1px solid rgba(255,255,255,.55); color: var(--white); background: rgba(255,255,255,.04); }
.btn-outline-light:hover { background: rgba(255,255,255,.12); color: var(--white); }
.btn-outline { border: 1px solid var(--green); color: var(--green); background: transparent; }
.btn-outline:hover { background: var(--green-pale); }
.card-arrow { color: var(--gold); font-size: 1.25rem; font-weight: 700; flex: 0 0 auto; }

.breadcrumbs {
    width: min(1200px, calc(100% - 32px));
    margin: 18px auto 12px;
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    color: var(--text-light);
    font-size: .8rem;
}
.breadcrumbs a { color: var(--green); font-weight: 600; }
.breadcrumbs span:last-child { color: var(--text); }

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}
.section-heading h2 { font-family: var(--font-head); color: var(--green); font-size: 1.42rem; line-height: 1.25; }
.section-heading > p { max-width: 560px; color: var(--text-light); font-size: .86rem; }
.section-heading-actions { align-items: center; }

.empty-panel {
    background: rgba(255,255,255,.75);
    border: 1px dashed rgba(27,77,62,.25);
    border-radius: 18px;
    padding: 44px 20px;
    text-align: center;
    color: var(--text-light);
}
.empty-panel h3 { font-family: var(--font-head); color: var(--green); margin-bottom: 5px; }
.empty-panel p { margin-bottom: 16px; }
.empty-icon { font-size: 2rem; margin-bottom: 8px; }
.compact-empty { padding: 28px 18px; }
.not-found-panel { width: min(700px, calc(100% - 32px)); margin: 60px auto; }

/* Portal homepage --------------------------------------------------- */
.portal-hero {
    width: min(1200px, calc(100% - 32px));
    margin: 24px auto 0;
    min-height: 410px;
    padding: 52px clamp(22px, 5vw, 72px);
    border-radius: 26px;
    background:
        linear-gradient(115deg, rgba(12,42,35,.98), rgba(35,103,81,.95)),
        radial-gradient(circle at 80% 20%, rgba(212,168,67,.35), transparent 22rem);
    color: var(--white);
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
    align-items: center;
    gap: 38px;
    box-shadow: 0 18px 50px rgba(27,77,62,.2);
}
.portal-hero::after {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(235,205,125,.35);
    border-radius: 19px;
    pointer-events: none;
}
.portal-hero-ornament {
    position: absolute;
    inset: 0;
    opacity: .12;
    background-image:
        linear-gradient(45deg, transparent 43%, rgba(255,255,255,.55) 44%, rgba(255,255,255,.55) 46%, transparent 47%),
        linear-gradient(-45deg, transparent 43%, rgba(255,255,255,.55) 44%, rgba(255,255,255,.55) 46%, transparent 47%);
    background-size: 34px 34px;
    mask-image: linear-gradient(90deg, transparent, #000 50%, #000);
}
.portal-hero-copy { position: relative; z-index: 2; }
.portal-hero h1 { font-family: var(--font-head); font-size: clamp(2.3rem, 6vw, 4.35rem); line-height: 1.15; margin-bottom: 10px; }
.portal-hero-copy > p { max-width: 680px; color: rgba(255,255,255,.82); font-size: 1rem; line-height: 1.9; }
.portal-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.portal-search {
    max-width: 650px;
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    color: var(--text-light);
    border-radius: 13px;
    padding: 0 15px;
    position: relative;
    box-shadow: 0 12px 28px rgba(0,0,0,.16);
}
.portal-search input { flex: 1; border: 0; min-width: 0; height: 54px; font-family: var(--font-body); font-size: .94rem; outline: 0; color: var(--text); }
.portal-search > button { border: 0; background: none; color: var(--text-light); font-size: 1.45rem; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; }
.portal-search > button:hover { background: var(--parchment); }
.portal-search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    background: var(--white);
    border-radius: 13px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 30;
    color: var(--text);
    max-height: 390px;
    overflow-y: auto;
}
.portal-search-results a { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 11px 13px; border-bottom: 1px solid var(--parchment-dk); }
.portal-search-results a:last-child { border-bottom: 0; }
.portal-search-results a:hover { background: var(--gold-pale); }
.portal-search-results strong { display: block; color: var(--green); font-size: .87rem; }
.portal-search-results small { display: block; color: var(--text-light); font-size: .74rem; }
.portal-result-empty { padding: 18px; text-align: center; color: var(--text-light); }
.result-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--green-pale); color: var(--green); font-size: .72rem; font-weight: 700; }
.portal-hero-tree { position: relative; z-index: 2; min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: end; filter: drop-shadow(0 12px 14px rgba(0,0,0,.18)); }
.mini-tree-crown { width: 285px; height: 210px; position: relative; }
.mini-tree-crown span { position: absolute; width: 112px; height: 76px; border-radius: 58% 42% 54% 46%; background: linear-gradient(135deg,#4e9a52,#245e35); border: 2px solid rgba(255,255,255,.15); }
.mini-tree-crown span:nth-child(1){right:87px;top:0}.mini-tree-crown span:nth-child(2){right:15px;top:55px;transform:rotate(18deg)}.mini-tree-crown span:nth-child(3){right:155px;top:55px;transform:rotate(-18deg)}.mini-tree-crown span:nth-child(4){right:58px;top:118px;transform:rotate(8deg)}.mini-tree-crown span:nth-child(5){right:132px;top:118px;transform:rotate(-8deg)}
.mini-tree-trunk { width: 58px; height: 92px; margin-top: -58px; background: linear-gradient(90deg,#74441f,#bd8341,#6a3d1d); clip-path: polygon(30% 0,70% 0,88% 100%,12% 100%); }
.mini-tree-base { margin-top: -4px; background: #b88723; color: #fff; font-family: var(--font-head); font-weight: 700; border-radius: 10px; padding: 8px 25px; border: 2px solid rgba(255,255,255,.3); }

.portal-stats {
    width: min(1100px, calc(100% - 48px));
    margin: -26px auto 34px;
    position: relative;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 10px 32px rgba(44,36,23,.14);
    overflow: hidden;
}
.portal-stats article { padding: 20px 16px; text-align: center; border-left: 1px solid var(--parchment-dk); }
.portal-stats article:last-child { border-left: 0; }
.portal-stats strong { display: block; color: var(--green); font-family: var(--font-head); font-size: 1.55rem; }
.portal-stats span { color: var(--text-light); font-size: .78rem; }
.portal-links { width: min(1200px, calc(100% - 32px)); margin: 0 auto 42px; display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.portal-link-card { display: grid; grid-template-columns: 58px 1fr auto; gap: 15px; align-items: center; background: var(--white); border-radius: 17px; padding: 24px; box-shadow: var(--shadow); border: 1px solid rgba(184,134,11,.12); transition: transform .16s, box-shadow .16s; }
.portal-link-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.portal-link-card h2 { font-family: var(--font-head); color: var(--green); font-size: 1.15rem; }
.portal-link-card p { color: var(--text-light); font-size: .8rem; }
.portal-link-icon { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; background: var(--gold-pale); font-size: 1.55rem; }
.portal-link-tree { background: linear-gradient(135deg,#fff,#f2f8f1); }
.portal-link-arrow { color: var(--gold); font-size: 1.2rem; }
.branches-section { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }
.branches-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.branch-card { background: var(--white); border-radius: 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; transition: transform .16s,box-shadow .16s; }
.branch-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.branch-card-main { display: grid; grid-template-columns: 70px minmax(0,1fr) auto; align-items: center; gap: 13px; padding: 18px; color: var(--text); }
.branch-card-photo { width: 68px; height: 68px; border-radius: 50%; overflow: hidden; background: var(--green-pale); border: 3px solid rgba(184,134,11,.7); display: grid; place-items: center; color: var(--green); font-weight: 800; font-size: .76rem; text-align: center; }
.branch-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.branch-card h3 { font-family: var(--font-head); color: var(--green); font-size: 1.03rem; margin-bottom: 3px; }
.branch-card p { color: var(--text-light); font-size: .76rem; }
.branch-preview { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.branch-preview span { padding: 2px 7px; border-radius: 10px; background: var(--parchment); color: var(--text-light); font-size: .68rem; }
.branch-delete-btn { position: absolute; top: 7px; left: 7px; z-index: 2; width: 27px; height: 27px; border: 0; border-radius: 50%; background: var(--red-pale); color: var(--red); cursor: pointer; font-size: 1rem; }
.branch-delete-btn:hover { background: var(--red); color: #fff; }

/* Branch generations ------------------------------------------------ */
.branch-hero {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto 34px;
    padding: 34px clamp(20px,4vw,52px);
    border-radius: 22px;
    background: linear-gradient(125deg,var(--green),#276b55);
    color: #fff;
    display: grid;
    grid-template-columns: 145px minmax(0,1fr) auto;
    gap: 26px;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 14px 36px rgba(27,77,62,.2);
}
.branch-hero-pattern { position: absolute; inset: 0; opacity: .12; background: radial-gradient(circle at 12px 12px,rgba(255,255,255,.8) 1px,transparent 1.5px); background-size: 24px 24px; }
.branch-photo-shell,.branch-hero-copy,.branch-hero-actions { position: relative; z-index: 2; }
.branch-photo-shell { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.branch-photo { width: 124px; height: 124px; border-radius: 50%; object-fit: cover; border: 5px solid #e0b856; box-shadow: 0 10px 25px rgba(0,0,0,.18); }
.branch-photo-placeholder { display: grid; place-items: center; background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); }
.photo-proposal-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 11px; border-radius: 18px; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.3); color: #fff; cursor: pointer; font-size: .74rem; font-weight: 600; }
.photo-proposal-btn:hover { background: rgba(255,255,255,.22); }
.branch-hero-copy h1 { font-family: var(--font-head); font-size: clamp(1.8rem,4vw,3rem); margin-bottom: 6px; }
.branch-hero-copy > p { color: rgba(255,255,255,.78); max-width: 650px; }
.branch-metrics { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.branch-metrics span { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); border-radius: 9px; padding: 8px 11px; font-size: .76rem; }
.branch-metrics strong { font-family: var(--font-head); font-size: 1.05rem; color: #f5cf70; margin-left: 4px; }
.branch-hero-actions { display: flex; flex-direction: column; gap: 9px; min-width: 175px; }
.generation-stack { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }
.generation-level { position: relative; background: rgba(255,255,255,.42); border-radius: 18px; padding: 22px; margin-bottom: 24px; border: 1px solid rgba(184,134,11,.1); }
.generation-head { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.generation-head h3 { font-family: var(--font-head); color: var(--green); font-size: 1.12rem; }
.generation-head span { color: var(--text-light); font-size: .74rem; }
.generation-number { width: 39px; height: 39px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; font-family: var(--font-head); font-weight: 700; box-shadow: 0 0 0 5px var(--green-pale); }
.generation-line { position: absolute; right: 41px; top: 60px; bottom: -25px; width: 2px; background: linear-gradient(var(--gold),rgba(184,134,11,.05)); }
.generation-level:last-child .generation-line { display: none; }
.generation-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding-right: 16px; }
.generation-card { display: grid; grid-template-columns: 54px minmax(0,1fr) auto; gap: 12px; align-items: center; background: var(--white); border-radius: 13px; padding: 13px; color: var(--text); box-shadow: var(--shadow); border-right: 3px solid var(--gold); transition: transform .15s,box-shadow .15s; }
.generation-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.generation-card-avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--green-pale); color: var(--green); font-size: .68rem; font-weight: 700; text-align: center; }
.generation-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.generation-card h4 { font-family: var(--font-head); color: var(--green); font-size: .94rem; }
.generation-card p { color: var(--text-light); font-size: .71rem; }
.person-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.person-tags span,.record-mini-tags span { display: inline-flex; align-items: center; background: var(--parchment); color: var(--text-light); border-radius: 10px; padding: 2px 7px; font-size: .65rem; }
.person-tags .tag-warning,.record-mini-tags .tag-warning,.tag-warning { background: #fff3cd; color: #856404; }
.person-tags .tag-success,.tag-success { background: #e7f6ec; color: #196b3c; }

/* Forms ------------------------------------------------------------- */
@media (min-width: 641px) { .modal-panel.modal-panel-wide { max-width: 760px; } }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 14px; }
.form-span-2 { grid-column: 1 / -1; }
.form-help { display: block; color: var(--text-light); font-size: .72rem; margin-top: 5px; }
.relationship-form select.form-input { background: #fff; }
.success-message { background: var(--green-pale); color: var(--green); }

/* Person page ------------------------------------------------------- */
.person-hero { width: min(1200px, calc(100% - 32px)); margin: 0 auto 24px; background: var(--white); border-radius: 20px; padding: 28px; display: grid; grid-template-columns: 145px minmax(0,1fr) auto; align-items: center; gap: 24px; box-shadow: var(--shadow); border-top: 4px solid var(--gold); }
.person-photo-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.person-photo { width: 118px; height: 118px; border-radius: 50%; object-fit: cover; border: 4px solid var(--gold); box-shadow: var(--shadow); }
.person-photo-placeholder { display: grid; place-items: center; background: var(--green-pale); color: var(--green); font-family: var(--font-head); font-weight: 700; text-align: center; }
.person-photo-btn { background: var(--green); border-color: var(--green); }
.person-hero-copy h1 { font-family: var(--font-head); color: var(--green); font-size: clamp(1.65rem,4vw,2.7rem); line-height: 1.25; }
.person-hero-copy > p { color: var(--text-light); margin-top: 10px; max-width: 700px; }
.person-hero-tags { margin-top: 10px; }
.person-hero-actions { display: flex; flex-direction: column; gap: 8px; min-width: 180px; }
.person-layout { width: min(1200px, calc(100% - 32px)); margin: 0 auto 25px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.person-panel { background: var(--white); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.person-panel-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.person-panel-head h2 { font-family: var(--font-head); color: var(--green); font-size: 1.2rem; }
.record-number { background: var(--gold-pale); color: var(--gold); border-radius: 12px; padding: 4px 9px; font-family: var(--font-head); font-size: .76rem; }
.person-details { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.person-details > div { background: var(--parchment); padding: 11px 12px; border-radius: 10px; }
.person-details dt { color: var(--text-light); font-size: .71rem; font-weight: 600; }
.person-details dd { color: var(--text); font-size: .88rem; font-weight: 600; margin-top: 2px; word-break: break-word; }
.relationship-summary { display: grid; gap: 9px; }
.relationship-row { display: grid; grid-template-columns: 42px 1fr; gap: 11px; align-items: center; padding: 10px; border: 1px solid var(--parchment-dk); border-radius: 11px; }
.relationship-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--green-pale); }
.relationship-row small { display: block; color: var(--text-light); font-size: .69rem; }
.relationship-row strong { display: block; color: var(--green); font-size: .84rem; }
.person-children-section,.descendant-summary { width: min(1200px, calc(100% - 32px)); margin: 0 auto 26px; }
.person-children-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.person-child-card { background: var(--white); border-radius: 14px; padding: 14px; display: grid; grid-template-columns: 52px minmax(0,1fr) auto; gap: 12px; align-items: center; color: var(--text); box-shadow: var(--shadow); }
.person-child-card:hover { box-shadow: var(--shadow-lg); }
.person-child-avatar { width: 50px; height: 50px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--green-pale); color: var(--green); font-size: .68rem; font-weight: 700; }
.person-child-avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-child-card h3 { font-family: var(--font-head); color: var(--green); font-size: .91rem; }
.person-child-card p { color: var(--text-light); font-size: .7rem; }
.descendant-summary-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.descendant-summary-grid article { background: var(--white); padding: 18px; border-radius: 13px; text-align: center; box-shadow: var(--shadow); }
.descendant-summary-grid strong { display: block; font-family: var(--font-head); color: var(--green); font-size: 1.5rem; }
.descendant-summary-grid span { color: var(--text-light); font-size: .75rem; }

/* Modern records ---------------------------------------------------- */
.records-hero { width: min(1200px, calc(100% - 32px)); margin: 24px auto 0; border-radius: 20px; padding: 30px clamp(20px,4vw,45px); background: linear-gradient(125deg,var(--green),#276b55); color: #fff; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.records-hero h1 { font-family: var(--font-head); font-size: clamp(1.6rem,4vw,2.65rem); }
.records-hero p { color: rgba(255,255,255,.78); }
.records-stats { margin-top: -18px; margin-bottom: 24px; }
.records-search-panel { width: min(1000px, calc(100% - 32px)); margin: 0 auto 18px; }
.records-search-box { display: flex; align-items: center; gap: 10px; background: var(--white); border: 1px solid var(--parchment-dk); border-radius: 13px; padding: 0 14px; box-shadow: var(--shadow); }
.records-search-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(27,77,62,.08); }
.records-search-box input { border: 0; outline: 0; flex: 1; min-width: 0; height: 52px; font-family: var(--font-body); font-size: .92rem; }
.records-search-box button { border: 0; background: none; color: var(--text-light); font-size: 1.4rem; cursor: pointer; }
.records-search-meta { text-align: center; color: var(--text-light); font-size: .77rem; margin-top: 8px; }
.records.records-modern { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 0; }
.records-modern.is-loading { opacity: .48; pointer-events: none; }
.record-card-modern { background: var(--white); border-radius: 15px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid rgba(184,134,11,.1); transition: box-shadow .15s,transform .15s; }
.record-card-modern:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.record-card-link { display: grid; grid-template-columns: 58px minmax(0,1fr) auto; gap: 12px; align-items: center; color: var(--text); padding: 15px; }
.record-avatar { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--green-pale); color: var(--green); font-weight: 700; font-size: .7rem; text-align: center; }
.record-avatar img { width: 100%; height: 100%; object-fit: cover; }
.record-title-line { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.record-title-line h2 { font-family: var(--font-head); color: var(--green); font-size: .93rem; line-height: 1.45; }
.record-title-line > span { color: var(--gold); font-family: var(--font-head); font-size: .69rem; flex: 0 0 auto; }
.record-main > p { color: var(--text-light); font-size: .7rem; margin-top: 2px; }
.record-mini-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.record-card-actions { display: flex; justify-content: flex-end; gap: 7px; padding: 8px 14px; border-top: 1px solid var(--parchment-dk); background: #fdfcf9; }
.record-card-actions button { border: 0; background: none; color: var(--green); cursor: pointer; font-family: var(--font-body); font-size: .72rem; font-weight: 600; padding: 4px 7px; border-radius: 6px; }
.record-card-actions button:hover { background: var(--green-pale); }
.record-card-actions .danger-link { color: var(--red); }
.record-card-actions .danger-link:hover { background: var(--red-pale); }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; margin: 24px auto 0; padding: 0 16px; }
.pagination button { min-width: 38px; min-height: 38px; border: 1px solid var(--parchment-dk); border-radius: 8px; background: var(--white); color: var(--text); cursor: pointer; font-family: var(--font-body); }
.pagination button:hover:not(:disabled),.pagination button.active { background: var(--green); border-color: var(--green); color: #fff; }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination span { color: var(--text-light); padding: 0 3px; }

/* Heritage tree ----------------------------------------------------- */
.tree-page-intro { width: min(1200px, calc(100% - 32px)); margin: 24px auto 18px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.tree-page-intro h1 { font-family: var(--font-head); color: var(--green); font-size: clamp(1.7rem,4vw,2.7rem); }
.tree-page-intro > div:first-child > p { color: var(--text-light); max-width: 700px; }
.tree-page-note { max-width: 390px; display: grid; grid-template-columns: 40px 1fr; gap: 9px; align-items: center; background: var(--gold-pale); color: #70560f; border-radius: 12px; padding: 12px 14px; font-size: .75rem; }
.tree-page-note > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #fff; }
.heritage-tree-shell { width: min(1500px, calc(100% - 24px)); margin: 0 auto; background: var(--cream); border: 9px solid var(--heritage-blue); outline: 4px solid #d2a93e; border-radius: 8px; position: relative; overflow: hidden; box-shadow: 0 18px 45px rgba(24,35,68,.22); }
.heritage-tree-shell::before { content:''; position:absolute; inset:4px; border:2px solid #d2a93e; pointer-events:none; z-index:5; }
.heritage-frame-corner { position:absolute; width:90px; height:90px; z-index:6; pointer-events:none; background: repeating-conic-gradient(from 22.5deg,#d4ab3d 0 12deg,#243a87 12deg 24deg); clip-path: polygon(0 0,100% 0,100% 22%,22% 22%,22% 100%,0 100%); opacity:.9; }
.corner-tr { top:0; right:0 }.corner-tl { top:0; left:0; transform:scaleX(-1) }.corner-br { bottom:0; right:0; transform:scaleY(-1) }.corner-bl { bottom:0; left:0; transform:scale(-1) }
.heritage-tree-title { padding: 28px 110px 16px; text-align: center; background: linear-gradient(#fffdf5,#f9f1d9); border-bottom: 1px solid rgba(184,134,11,.22); }
.heritage-tree-title span { color: var(--gold); font-family: var(--font-head); font-size: .82rem; }
.heritage-tree-title h2 { font-family: var(--font-head); color: var(--text); font-size: clamp(1.45rem,4vw,2.6rem); text-shadow: 0 2px #fff; }
.heritage-tree-title p { color: var(--text-light); font-size: .75rem; }
.tree-control-panel { display: grid; grid-template-columns: minmax(240px,1.4fr) minmax(190px,.8fr) minmax(150px,.65fr) auto; gap: 10px; align-items: end; padding: 14px 24px; background: rgba(255,255,255,.72); border-bottom: 1px solid var(--parchment-dk); }
.tree-control-field label { display: block; color: var(--text-light); font-size: .69rem; font-weight: 700; margin-bottom: 3px; }
.tree-control-field input,.tree-control-field select { width: 100%; height: 42px; border: 1px solid var(--parchment-dk); border-radius: 8px; background: #fff; font-family: var(--font-body); padding: 0 10px; outline: 0; }
.tree-control-field input:focus,.tree-control-field select:focus { border-color: var(--green); }
.tree-search-control > div { display: flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--parchment-dk); border-radius: 8px; padding: 0 10px; }
.tree-search-control > div input { border: 0; padding: 0; }
.tree-zoom-controls { display: flex; gap: 4px; }
.tree-zoom-controls button { height: 42px; min-width: 42px; border: 1px solid var(--parchment-dk); border-radius: 8px; background: #fff; color: var(--green); cursor: pointer; font-family: var(--font-body); font-weight: 700; }
.tree-zoom-controls button:nth-child(2) { min-width: 68px; }
.tree-zoom-controls button:hover { background: var(--green); color: #fff; }
.tree-result-meta { display: flex; justify-content: space-between; gap: 10px; padding: 8px 24px; color: var(--text-light); font-size: .7rem; background: #fbf7ea; }
.heritage-tree-viewport { height: min(66vh,720px); min-height: 560px; overflow: auto; direction: ltr; background: #fbf7e9; cursor: grab; overscroll-behavior: contain; }
.heritage-tree-viewport.is-dragging { cursor: grabbing; user-select: none; }
.heritage-tree-svg { display: block; max-width: none; transform-origin: top left; font-family: var(--font-body); }
.tree-paper-marks circle { fill:none; stroke:#c1af81; stroke-width:1; opacity:.07; }
.tree-branches path { fill:none; stroke:url(#trunkGradient); stroke-linecap:round; stroke-width:12; }
.tree-branches path[data-depth="1"] { stroke-width:20; }
.tree-branches path[data-depth="2"] { stroke-width:14; }
.tree-branches path[data-depth="3"] { stroke-width:10; }
.tree-branches path[data-depth="4"] { stroke-width:7; }
.tree-branches path[data-depth="5"],.tree-branches path[data-depth="6"] { stroke-width:5; }
.tree-main-trunk { fill:url(#trunkGradient); stroke:#5f3518; stroke-width:2; }
.heritage-node { cursor:pointer; outline:none; }
.heritage-node .leaf-shape { fill:var(--leaf); stroke:#e9f4d9; stroke-width:2; transition:fill .15s,stroke .15s,transform .15s; }
.heritage-node:hover .leaf-shape,.heritage-node:focus .leaf-shape { fill:#438d3f; stroke:#d4ab3d; stroke-width:4; transform:scale(1.04); }
.heritage-node.node-father .leaf-shape { fill:#265d2d; }
.heritage-node.node-unlinked .leaf-shape { fill:#6b7253; }
.heritage-node.node-inferred .leaf-shape { stroke:#e6bd49; stroke-dasharray:5 3; }
.leaf-vein { fill:none; stroke:rgba(255,255,255,.35); stroke-width:1.5; pointer-events:none; }
.leaf-label { fill:#fff; font-size:13px; font-weight:700; pointer-events:none; direction:rtl; unicode-bidi:plaintext; }
.root-plaque { fill:#b18422; stroke:#6d5010; stroke-width:3; filter:url(#leafShadow); }
.root-label { fill:#fff; font-family:var(--font-head); font-size:22px; font-weight:700; }
.hidden-count circle { fill:#d4ab3d; stroke:#fff; stroke-width:2; }
.hidden-count text { fill:#fff; font-size:9px; font-weight:700; }
.heritage-node.tree-search-hit .leaf-shape,.heritage-node.tree-search-hit .root-plaque { stroke:#ffcf32; stroke-width:7; filter:drop-shadow(0 0 8px rgba(255,207,50,.8)); }
.tree-loading-card { min-height: 520px; display:flex; flex-direction:column; gap:12px; align-items:center; justify-content:center; color:var(--text-light); direction:rtl; }
.tree-loader { width:38px; height:38px; border-radius:50%; border:4px solid var(--parchment-dk); border-top-color:var(--green); animation:treeSpin .9s linear infinite; }
@keyframes treeSpin { to { transform:rotate(360deg); } }
.heritage-tree-footer { text-align:center; padding:15px 20px 22px; background:linear-gradient(#f9f1d9,#f4e7c4); border-top:1px solid rgba(184,134,11,.22); }
.heritage-tree-footer span { display:block; color:var(--brown); font-family:var(--font-head); font-weight:700; }
.heritage-tree-footer p { color:var(--text-light); font-size:.7rem; }
.tree-help-grid { width:min(1200px,calc(100% - 32px)); margin:28px auto 0; display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.tree-help-grid article { background:var(--white); border-radius:13px; padding:16px; display:grid; grid-template-columns:38px 1fr; gap:10px; align-items:start; box-shadow:var(--shadow); }
.tree-help-grid article > span { width:36px; height:36px; border-radius:50%; display:grid; place-items:center; background:var(--green); color:#fff; font-family:var(--font-head); }
.tree-help-grid h3 { color:var(--green); font-family:var(--font-head); font-size:.9rem; }
.tree-help-grid p { color:var(--text-light); font-size:.72rem; }

/* Admin ------------------------------------------------------------- */
.admin-hero { width:min(1100px,calc(100% - 32px)); margin:24px auto 0; padding:28px 34px; border-radius:18px; background:linear-gradient(125deg,var(--green),#276b55); color:#fff; display:flex; justify-content:space-between; align-items:center; gap:20px; }
.admin-hero h1 { font-family:var(--font-head); font-size:2rem; }
.admin-hero p { color:rgba(255,255,255,.77); }
.admin-hero-count { min-width:175px; padding:13px 18px; border-radius:12px; background:rgba(255,255,255,.1); text-align:center; }
.admin-hero-count strong { display:block; font-family:var(--font-head); color:#f2cf7a; font-size:1.7rem; }
.admin-hero-count span { font-size:.7rem; }
.admin-page-new .admin-tabs,.admin-page-new .admin-panel { width:min(1100px,calc(100% - 32px)); margin-inline:auto; }
.admin-page-new .admin-tabs { margin-top:18px; }
.pending-toolbar { display:flex; align-items:center; justify-content:space-between; gap:15px; margin-bottom:15px; }
.pending-toolbar h2,.settings-section h2 { font-family:var(--font-head); color:var(--green); }
.pending-toolbar p { color:var(--text-light); font-size:.76rem; }
.pending-card-photo { border-color:#9b6fb3; }
.pending-type.type-photo { background:#72508a; }
.pending-photo-review { display:grid; grid-template-columns:130px 1fr; gap:16px; align-items:center; }
.pending-photo-review img { width:130px; height:130px; object-fit:cover; border-radius:12px; border:3px solid var(--gold); }
.pending-photo-review h3 { font-family:var(--font-head); color:var(--green); }
.pending-photo-review p { color:var(--text-light); font-size:.75rem; }
.pending-target-type { display:inline-block; padding:3px 8px; border-radius:10px; background:#efe6f5; color:#72508a; font-size:.67rem; }
.admin-page-new .pending-empty { background:var(--white); border-radius:15px; box-shadow:var(--shadow); }

/* Responsive -------------------------------------------------------- */
@media (max-width: 900px) {
    .portal-hero { grid-template-columns: 1fr; min-height: 0; }
    .portal-hero-tree { display:none; }
    .portal-stats { grid-template-columns:repeat(2,1fr); }
    .portal-stats article:nth-child(2) { border-left:0; }
    .portal-stats article:nth-child(-n+2) { border-bottom:1px solid var(--parchment-dk); }
    .portal-links { grid-template-columns:1fr; }
    .branch-hero,.person-hero { grid-template-columns:125px minmax(0,1fr); }
    .branch-hero-actions,.person-hero-actions { grid-column:1/-1; flex-direction:row; flex-wrap:wrap; }
    .branch-hero-actions .btn,.person-hero-actions .btn { flex:1; }
    .tree-control-panel { grid-template-columns:1fr 1fr; }
    .tree-zoom-controls { align-self:end; }
    .heritage-tree-title { padding-inline:80px; }
}

@media (max-width: 700px) {
    .section-heading { align-items:start; flex-direction:column; }
    .portal-hero { width:calc(100% - 20px); margin-top:10px; border-radius:18px; padding:35px 20px; }
    .portal-hero h1 { font-size:2.45rem; }
    .portal-hero-actions .btn { width:100%; justify-content:center; }
    .portal-stats { width:calc(100% - 30px); margin-top:-15px; }
    .portal-links,.branches-section,.generation-stack,.person-layout,.person-children-section,.descendant-summary,.tree-page-intro { width:calc(100% - 24px); }
    .branches-grid,.generation-grid,.person-children-grid,.records.records-modern { grid-template-columns:1fr; }
    .branch-hero,.person-hero { width:calc(100% - 24px); grid-template-columns:1fr; text-align:center; padding:25px 18px; }
    .branch-photo-shell,.person-photo-wrap { justify-self:center; }
    .branch-metrics,.person-tags { justify-content:center; }
    .branch-hero-actions,.person-hero-actions { grid-column:auto; flex-direction:column; width:100%; }
    .branch-hero-actions .btn,.person-hero-actions .btn { width:100%; justify-content:center; }
    .generation-grid { padding-right:0; }
    .generation-line { right:41px; opacity:.45; }
    .person-layout { grid-template-columns:1fr; }
    .person-details { grid-template-columns:1fr; }
    .descendant-summary-grid { grid-template-columns:1fr; }
    .records-hero { width:calc(100% - 24px); flex-direction:column; align-items:stretch; text-align:center; }
    .records-hero .btn { justify-content:center; }
    .records-stats { width:calc(100% - 30px); }
    .records-search-panel { width:calc(100% - 24px); }
    .tree-page-intro { flex-direction:column; align-items:stretch; }
    .tree-page-note { max-width:none; }
    .heritage-tree-shell { width:calc(100% - 12px); border-width:6px; outline-width:2px; }
    .heritage-frame-corner { width:58px; height:58px; }
    .heritage-tree-title { padding:20px 55px 13px; }
    .tree-control-panel { grid-template-columns:1fr; padding:12px; }
    .tree-zoom-controls button { flex:1; }
    .tree-result-meta { padding-inline:12px; }
    #treeHint { display:none; }
    .heritage-tree-viewport { min-height:480px; height:65vh; }
    .tree-help-grid { width:calc(100% - 24px); grid-template-columns:1fr; }
    .admin-hero { width:calc(100% - 24px); flex-direction:column; text-align:center; padding:24px 18px; }
    .admin-hero-count { width:100%; }
    .admin-page-new .admin-tabs,.admin-page-new .admin-panel { width:calc(100% - 24px); }
    .pending-toolbar { align-items:stretch; flex-direction:column; }
    .pending-photo-review { grid-template-columns:1fr; text-align:center; }
    .pending-photo-review img { margin:auto; }
}

@media (max-width: 520px) {
    .form-grid { grid-template-columns:1fr; }
    .form-span-2 { grid-column:auto; }
    .portal-stats article { padding:15px 8px; }
    .portal-stats strong { font-size:1.28rem; }
    .portal-link-card { grid-template-columns:48px 1fr; padding:17px; }
    .portal-link-arrow { display:none; }
    .portal-link-icon { width:46px; height:46px; }
    .branches-grid { grid-template-columns:1fr; }
    .branch-card-main { grid-template-columns:58px minmax(0,1fr) auto; padding:14px; }
    .branch-card-photo { width:56px; height:56px; }
    .generation-level { padding:16px 12px; }
    .generation-card { grid-template-columns:46px minmax(0,1fr) auto; padding:11px; }
    .generation-card-avatar { width:44px; height:44px; }
    .record-card-link { grid-template-columns:48px minmax(0,1fr) auto; padding:12px; }
    .record-avatar { width:46px; height:46px; }
    .record-title-line { display:block; }
    .record-title-line > span { display:block; margin-top:2px; }
    .person-child-card { grid-template-columns:44px minmax(0,1fr) auto; }
    .person-child-avatar { width:42px; height:42px; }
}

/* ===================================================================
   Professional refinement — July 2026
   =================================================================== */
:root {
    --parchment: #f6f3eb;
    --parchment-dk: #e8e1d2;
    --green: #123f35;
    --green-light: #1f6654;
    --green-deep: #0b3028;
    --gold: #b3862e;
    --gold-light: #d2ae62;
    --gold-pale: #fbf5e8;
    --text: #202821;
    --text-light: #667069;
    --shadow: 0 6px 22px rgba(25, 45, 37, .08);
    --shadow-lg: 0 18px 48px rgba(25, 45, 37, .14);
    --radius: 14px;
    --radius-sm: 9px;
    --font-head: "DIN Next Arabic", "Noto Kufi Arabic", "Geeza Pro", Tahoma, sans-serif;
    --font-body: "DIN Next Arabic", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
    --nav-h: 66px;
}
html { font-size: 16px; }
body {
    background:
        radial-gradient(circle at 10% 0%, rgba(179,134,46,.06), transparent 28rem),
        var(--parchment);
    letter-spacing: 0;
}
.ornament-band { height: 3px; background: linear-gradient(90deg, transparent, var(--gold), var(--green-light), var(--gold), transparent); }
.nav { background: rgba(14,57,47,.98); backdrop-filter: blur(10px); box-shadow: 0 5px 18px rgba(7,31,26,.18); }
.nav-inner { max-width: 1320px; padding-inline: 28px; }
.nav-brand { gap: 11px; }
.nav-logo { width: 38px; height: 38px; object-fit: contain; }
.nav-title { font-size: 1.08rem; letter-spacing: -.01em; }
.nav-link { font-size: .86rem; padding-inline: 17px; border-radius: 10px; }
.nav-link.active { background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.btn { border-radius: 10px; padding-inline: 20px; box-shadow: none; }
.btn-primary { background: linear-gradient(135deg,#c49a42,#a67620); }
.btn-primary:hover { background: linear-gradient(135deg,#d3ad5c,#b3862e); transform: translateY(-1px); }
.btn-outline { border-color: rgba(18,63,53,.35); }
.btn-approve-link { background: #eaf4ef; color: var(--green); border: 1px solid #b9d7ca; }
.btn-approve-link:hover { background: var(--green); color: #fff; }
.eyebrow { letter-spacing: 0; font-size: .72rem; }
.section-heading h2 { font-size: 1.35rem; }

/* Brand seal and homepage */
.portal-hero.portal-hero-refined {
    width: min(1320px, calc(100% - 48px));
    min-height: 360px;
    grid-template-columns: 220px minmax(0,1fr);
    padding: 54px clamp(34px,6vw,84px);
    border-radius: 24px;
    background:
        radial-gradient(circle at 15% 15%, rgba(216,181,103,.18), transparent 24rem),
        linear-gradient(115deg,#0c332b 0%,#174f42 58%,#216653 100%);
    box-shadow: 0 24px 60px rgba(14,57,47,.20);
}
.portal-hero.portal-hero-refined::after { inset: 14px; border-radius: 17px; border-color: rgba(232,207,142,.28); }
.portal-hero-refined .portal-hero-ornament {
    opacity: .08;
    background-size: 42px 42px;
    mask-image: linear-gradient(90deg,#000,transparent 75%);
}
.family-seal {
    position: relative;
    z-index: 2;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    justify-self: center;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(232,207,142,.25);
    box-shadow: inset 0 0 0 10px rgba(255,255,255,.025);
}
.family-seal img { width: 112px; height: 112px; }
.family-seal span {
    position: absolute;
    bottom: 18px;
    color: #f0d797;
    font-family: var(--font-head);
    font-size: .92rem;
    font-weight: 700;
}
.portal-hero-refined .portal-hero-copy { max-width: 820px; }
.portal-hero-refined h1 { font-size: clamp(2.7rem,5.5vw,4.8rem); margin-bottom: 14px; }
.portal-hero-refined .portal-hero-copy > p { font-size: 1.04rem; line-height: 2; max-width: 780px; }
.portal-stats { width: min(1120px,calc(100% - 72px)); margin-top: -34px; border: 1px solid rgba(18,63,53,.06); }
.portal-stats article { padding: 22px 16px; }
.portal-stats strong { font-size: 1.6rem; }
.portal-links { width: min(1320px,calc(100% - 48px)); gap: 20px; }
.portal-link-card { border-radius: 18px; padding: 26px 28px; border: 1px solid rgba(18,63,53,.08); box-shadow: 0 10px 32px rgba(31,58,48,.07); }
.portal-link-card:hover { transform: translateY(-4px); box-shadow: 0 18px 42px rgba(31,58,48,.12); border-color: rgba(179,134,46,.28); }
.portal-link-icon { border-radius: 14px; background: linear-gradient(145deg,#fff9ec,#f3e5bd); color: var(--green); }
.portal-link-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.portal-link-tree { background: #fff; }
.branches-section { width: min(1320px,calc(100% - 48px)); }
.branch-card { border: 1px solid rgba(18,63,53,.07); border-radius: 18px; }
.branch-card-photo { border-color: rgba(179,134,46,.65); }

/* Branch and person pages */
.branch-hero,.person-hero,.records-hero,.admin-hero { border-radius: 22px; box-shadow: 0 18px 46px rgba(18,63,53,.14); }
.generation-level,.person-panel,.record-card-modern,.person-child-card { border: 1px solid rgba(18,63,53,.07); }
.generation-card,.person-child-card { border-radius: 14px; }
.relationship-icon-svg svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.selected-parent-preview {
    margin-top: 9px;
    padding: 9px 12px;
    border-radius: 9px;
    background: #eef5f1;
    color: var(--green);
    font-size: .77rem;
    font-weight: 700;
    border: 1px solid #d7e6df;
}
.form-input { border-radius: 10px; border-color: #ddd8cc; }
.form-input:focus { border-color: var(--green-light); box-shadow: 0 0 0 3px rgba(31,102,84,.10); }
.modal-panel { border: 1px solid rgba(18,63,53,.08); }

/* Tree page — clean professional frame */
.tree-page-intro-refined {
    width: min(1320px,calc(100% - 48px));
    margin: 28px auto 18px;
    padding: 0 4px;
}
.tree-page-intro-refined h1 { font-size: clamp(2rem,4vw,3rem); }
.tree-intro-mark { width: 74px; height: 74px; filter: drop-shadow(0 8px 14px rgba(18,63,53,.12)); }
.heritage-tree-shell {
    width: min(1580px,calc(100% - 32px));
    background: #fff;
    border: 1px solid rgba(18,63,53,.14);
    outline: 0;
    border-radius: 22px;
    box-shadow: 0 22px 58px rgba(18,63,53,.14);
}
.heritage-tree-shell::before { display: none; }
.heritage-tree-title {
    min-height: 118px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 22px 28px;
    text-align: right;
    background: linear-gradient(135deg,#fff,#fbf8ef);
    border-bottom: 1px solid #ece6d9;
}
.heritage-tree-title img { width: 68px; height: 68px; }
.heritage-tree-title span { font-family: var(--font-body); font-size: .7rem; font-weight: 800; }
.heritage-tree-title h2 { color: var(--green-deep); font-size: clamp(1.55rem,3vw,2.35rem); text-shadow: none; line-height: 1.25; }
.heritage-tree-title p { margin-top: 2px; }
.tree-control-panel { padding: 16px 22px; background: #fff; border-bottom: 1px solid #ece8df; }
.tree-control-field input,.tree-control-field select,.tree-search-control > div,.tree-zoom-controls button { border-radius: 10px; border-color: #ded9cf; }
.tree-result-meta { padding: 10px 24px; background: #f8f7f3; border-bottom: 1px solid #ece8df; }
.heritage-tree-viewport {
    height: min(70vh,780px);
    min-height: 590px;
    background:
        radial-gradient(circle at center, rgba(179,134,46,.035), transparent 38rem),
        #fbfaf6;
}
.tree-paper-marks circle { opacity: .035; }
.tree-main-trunk { fill: url(#trunkGradient); stroke: #6b421e; stroke-width: 1.4; }
.tree-branches path { stroke-width: 8; filter: drop-shadow(0 2px 1px rgba(75,45,20,.12)); }
.tree-branches path[data-depth="1"] { stroke-width: 14; }
.tree-branches path[data-depth="2"] { stroke-width: 10; }
.tree-branches path[data-depth="3"] { stroke-width: 7; }
.tree-branches path[data-depth="4"] { stroke-width: 5; }
.tree-branches path[data-depth="5"],.tree-branches path[data-depth="6"] { stroke-width: 4; }
.tree-branches path[data-source="inferred"] { stroke-dasharray: 12 7; opacity: .75; }
.heritage-node .leaf-shape { fill: #2e7742; stroke: #f4f0df; stroke-width: 2.2; }
.heritage-node.node-father .leaf-shape { fill: #205c35; stroke: #d6b45f; stroke-width: 2.6; }
.heritage-node.node-inferred .leaf-shape { stroke: #d6a83f; stroke-dasharray: 6 4; }
.heritage-node:hover .leaf-shape,.heritage-node:focus .leaf-shape { fill: #3f8c51; stroke: #d6b45f; stroke-width: 3.5; }
.leaf-label { font-size: 13.5px; font-family: var(--font-body); }
.root-plaque { fill: #b3862e; stroke: #7c5b18; stroke-width: 2; rx: 12px; }
.heritage-tree-footer { padding: 13px 20px 16px; background: #f8f5ed; border-top: 1px solid #ece6d9; }
.heritage-tree-footer span { color: var(--green); }

/* Records/admin refinement */
.records-hero,.admin-hero { width: min(1220px,calc(100% - 48px)); background: linear-gradient(120deg,#103c32,#236552); }
.records-search-panel,.records.records-modern,.admin-page-new .admin-tabs,.admin-page-new .admin-panel { max-width: 1220px; }
.record-card-modern { border-radius: 16px; }
.pending-card { border-radius: 16px; }

@media (max-width: 900px) {
    .portal-hero.portal-hero-refined { grid-template-columns: 150px 1fr; min-height: 330px; padding: 42px 34px; }
    .family-seal { width: 140px; height: 140px; }
    .family-seal img { width: 88px; height: 88px; }
    .family-seal span { bottom: 12px; }
}
@media (max-width: 700px) {
    .nav-inner { padding-inline: 14px; }
    .portal-hero.portal-hero-refined { width: calc(100% - 20px); grid-template-columns: 1fr; text-align: center; padding: 34px 22px 42px; border-radius: 18px; }
    .family-seal { width: 118px; height: 118px; }
    .family-seal img { width: 74px; height: 74px; }
    .family-seal span { font-size: .76rem; bottom: 9px; }
    .portal-hero-refined .portal-hero-copy { text-align: center; }
    .portal-hero-refined .portal-hero-copy > p { font-size: .92rem; }
    .portal-stats { width: calc(100% - 30px); }
    .portal-links,.branches-section,.tree-page-intro-refined { width: calc(100% - 24px); }
    .tree-page-intro-refined { flex-direction: row; align-items: center; }
    .tree-intro-mark { width: 54px; height: 54px; }
    .heritage-tree-shell { width: calc(100% - 12px); border-radius: 15px; border-width: 1px; }
    .heritage-tree-title { padding: 18px 15px; min-height: 96px; }
    .heritage-tree-title img { width: 52px; height: 52px; }
    .heritage-tree-viewport { min-height: 500px; height: 66vh; }
}

/* Final professional polish */
:root {
    --font-head: 'Noto Naskh Arabic', 'Amiri', 'Geeza Pro', 'Traditional Arabic', serif;
    --font-body: 'Noto Kufi Arabic', 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
}
.nav { height: 64px; --nav-h: 64px; }
.nav-inner { max-width: 1320px; padding-inline: 24px; }
.nav-logo { width: 38px; height: 38px; }
.nav-title { font-size: 1.08rem; letter-spacing: 0; }
.nav-link { font-size: .88rem; }
.portal-hero-refined h1,
.branch-hero h1,
.person-hero h1,
.heritage-tree-title h2 { font-family: var(--font-head); font-weight: 700; }

.link-approval-panel {
    width: min(1180px, calc(100% - 48px));
    margin: 18px auto 24px;
    display: grid;
    grid-template-columns: 52px minmax(0,1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 20px 22px;
    background: linear-gradient(135deg,#fffaf0,#f4f8f5);
    border: 1px solid rgba(179,134,46,.28);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(18,63,53,.07);
}
.link-approval-panel h2 { color: var(--green-deep); font-size: 1.15rem; margin: 1px 0 3px; }
.link-approval-panel p { color: var(--text-light); font-size: .85rem; line-height: 1.85; }
.link-approval-icon { width: 48px; height: 48px; border-radius: 14px; display:grid; place-items:center; background:#eaf4ef; color:var(--green); }
.link-approval-icon svg { width: 27px; height: 27px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

.heritage-tree-shell-primary { margin-top: 30px; }
.heritage-tree-title { justify-content: flex-start; padding-inline: clamp(24px,5vw,64px); }
.heritage-tree-title > div { text-align: right; }
.heritage-tree-footer { min-height: 48px; display:flex; align-items:center; justify-content:center; }

@media (max-width:700px) {
    .nav { height: 58px; --nav-h: 58px; }
    .nav-inner { padding-inline: 12px; }
    .nav-logo { width: 32px; height: 32px; }
    .link-approval-panel { width: calc(100% - 24px); grid-template-columns: 44px 1fr; padding: 16px; }
    .link-approval-panel .btn { grid-column: 1 / -1; width: 100%; }
    .heritage-tree-shell-primary { margin-top: 16px; }
}
.empty-icon-svg { display:grid; place-items:center; margin-inline:auto; }
.empty-icon-svg svg { width:38px; height:38px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }

/* Relationship review and request context */
.tree-branches path[data-source="inferred"] { stroke-dasharray: none; opacity: 1; }
.heritage-node.node-inferred .leaf-shape { stroke: #f4f0df; stroke-dasharray: none; }
.inline-admin-link { display:inline-flex; margin-top:6px; color:var(--green); font-weight:800; font-size:.78rem; text-decoration:underline; text-underline-offset:3px; }

.badge-gold { background:#b78320; }
.pending-card-head > div { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.pending-card-head h3 { margin:0; color:var(--green-deep); font-size:1.02rem; }
.request-context {
    margin: 0 28px;
    padding: 14px 16px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    background:#f0f7f3;
    border:1px solid #d7e7df;
    border-radius:12px;
}
.request-context > div { display:grid; gap:2px; }
.request-context span { color:var(--text-light); font-size:.7rem; font-weight:700; }
.request-context strong { color:var(--green-deep); font-size:.9rem; }
.request-context a,.review-links a,.relationship-review-copy > a { color:var(--green); font-size:.76rem; font-weight:800; text-decoration:underline; text-underline-offset:3px; white-space:nowrap; }
.pending-parent-correction { margin-top:18px; padding:16px; border-radius:12px; background:#fffaf0; border:1px solid #ead8aa; display:grid; gap:7px; }
.pending-parent-correction label { color:var(--green-deep); font-weight:800; font-size:.82rem; }
.pending-parent-correction select,.relationship-assign-control select {
    width:100%; height:46px; border:1px solid #d9d4c9; border-radius:10px; background:#fff; padding:0 12px; font-family:var(--font-body); color:var(--text);
}
.pending-parent-correction small { color:#7b6b4c; font-size:.7rem; }

.relationship-review-summary { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-bottom:18px; }
.relationship-review-summary article { background:#fff; border:1px solid #ebe7de; border-radius:14px; padding:16px 18px; display:flex; align-items:baseline; gap:10px; box-shadow:0 8px 22px rgba(18,63,53,.05); }
.relationship-review-summary strong { color:var(--green); font-size:1.5rem; }
.relationship-review-summary span { color:var(--text-light); font-size:.78rem; }
#relationshipReviewList { display:grid; gap:14px; }
.relationship-review-card { background:#fff; border:1px solid #e8e3d9; border-radius:16px; padding:20px; display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:22px; box-shadow:0 10px 26px rgba(18,63,53,.06); }
.relationship-review-card.unlinked { border-right:4px solid #c98b1d; }
.relationship-review-card.inferred { border-right:4px solid var(--green); }
.relationship-review-copy { min-width:0; }
.relationship-review-copy .review-state { display:inline-flex; margin-bottom:5px; color:#9a6b15; font-size:.7rem; font-weight:900; }
.relationship-review-card.inferred .review-state { color:var(--green); }
.relationship-review-copy h3 { color:var(--green-deep); margin:0 0 5px; font-size:1.02rem; }
.relationship-review-copy p { color:var(--text-light); margin:0 0 7px; font-size:.8rem; }
.review-links { display:flex; flex-wrap:wrap; gap:14px; }
.relationship-assign-control { min-width:min(420px,42vw); display:grid; grid-template-columns:minmax(220px,1fr) auto; gap:10px; align-items:center; }

@media (max-width:760px) {
    .request-context { margin-inline:16px; align-items:flex-start; flex-direction:column; }
    .relationship-review-summary { grid-template-columns:1fr; }
    .relationship-review-card { grid-template-columns:1fr; padding:17px; }
    .relationship-review-card .btn { width:100%; }
    .relationship-assign-control { min-width:0; width:100%; grid-template-columns:1fr; }
}
.relationship-review-search { margin: 0 0 16px; }
.relationship-review-search input { width:100%; height:48px; border:1px solid #ded9cf; border-radius:12px; background:#fff; padding:0 16px; font-family:var(--font-body); color:var(--text); outline:0; }
.relationship-review-search input:focus { border-color:var(--green); box-shadow:0 0 0 3px rgba(27,77,62,.08); }

/* Relationship review v5: auto detection, bulk approval and deletion */
.relationship-toolbar-actions { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.relationship-bulk-bar {
    margin: 0 0 16px;
    min-height: 58px;
    padding: 10px 14px;
    display:flex;
    align-items:center;
    gap:14px;
    background:linear-gradient(135deg,#f2f7f4,#fffaf0);
    border:1px solid #ddd9cf;
    border-radius:14px;
}
.relationship-bulk-bar > strong { margin-inline-start:auto; color:var(--green-deep); font-size:.82rem; }
.relationship-select-all { display:inline-flex; align-items:center; gap:9px; color:var(--green-deep); font-weight:800; font-size:.78rem; cursor:pointer; }
.relationship-select-all input,.relationship-card-check input { accent-color:var(--green); width:18px; height:18px; cursor:pointer; }
.relationship-review-card { position:relative; grid-template-columns:minmax(0,1fr) minmax(390px,auto); padding-inline-start:58px; }
.relationship-card-check { position:absolute; inset-inline-start:20px; top:22px; display:grid; place-items:center; }
.relationship-assign-control { min-width:min(500px,46vw); grid-template-columns:1fr; align-items:stretch; }
.relationship-parent-field { display:grid; gap:7px; }
.relationship-card-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; }
.auto-detect-note { display:flex; flex-wrap:wrap; align-items:center; gap:5px 8px; color:#567066; font-size:.68rem; line-height:1.6; }
.auto-detect-note strong { color:var(--green); }
.auto-detect-note span { flex-basis:100%; color:var(--text-light); }
.auto-detect-note.no-suggestion { color:#8a7660; }
.relationship-parent-field select.auto-filled { border-color:var(--gold); box-shadow:0 0 0 4px rgba(179,134,46,.14); }
.relationship-review-card.unlinked { border-right-color:#c98b1d; }
.relationship-review-card.inferred { border-right-color:var(--green); }

@media (max-width:900px) {
    .relationship-review-card { grid-template-columns:1fr; }
    .relationship-assign-control { min-width:0; width:100%; }
}
@media (max-width:700px) {
    .relationship-toolbar-actions { width:100%; }
    .relationship-toolbar-actions .btn { flex:1; }
    .relationship-bulk-bar { align-items:stretch; flex-wrap:wrap; }
    .relationship-bulk-bar > strong { margin-inline-start:0; display:flex; align-items:center; }
    .relationship-bulk-bar .btn { width:100%; }
    .relationship-review-card { padding-inline-start:46px; }
    .relationship-card-check { inset-inline-start:15px; top:19px; }
    .relationship-card-actions { display:grid; grid-template-columns:1fr 1fr; }
    .relationship-card-actions .btn { width:100%; }
    .relationship-card-actions .btn-danger { grid-column:1 / -1; }
}


/* Supplied family identity and admin-only tree visibility — V6 */
.nav-logo {
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 0 0 1px rgba(211,174,98,.55), 0 4px 12px rgba(0,0,0,.14);
}
.family-seal {
    width: 196px;
    height: 250px;
    border-radius: 20px;
    padding: 12px;
    background: #fff;
    border: 1px solid rgba(232,207,142,.52);
    box-shadow: 0 18px 36px rgba(4,25,20,.22);
}
.family-seal img { width: 100%; height: 100%; object-fit: contain; }
.portal-links.portal-links-single { grid-template-columns: minmax(0, 780px); justify-content: center; }
.heritage-tree-title img {
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 0 0 1px rgba(179,134,46,.25);
}
@media (max-width: 900px) {
    .family-seal { width: 160px; height: 205px; }
}
@media (max-width: 700px) {
    .family-seal { width: 142px; height: 182px; }
    .portal-links.portal-links-single { grid-template-columns: 1fr; }
}

/* Secure site access ------------------------------------------------ */
.site-access-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 12%, rgba(184,134,11,.08), transparent 30%),
        radial-gradient(circle at 82% 88%, rgba(27,77,62,.09), transparent 34%),
        var(--cream);
}
.site-access-page {
    min-height: calc(100vh - 5px);
    display: grid;
    place-items: center;
    padding: 32px 18px;
}
.site-access-card {
    width: min(440px, 100%);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(184,134,11,.22);
    border-radius: 24px;
    padding: 34px;
    text-align: center;
    box-shadow: 0 24px 70px rgba(27,77,62,.15);
    position: relative;
    overflow: hidden;
}
.site-access-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg,var(--green),var(--gold),var(--green));
}
.site-access-logo {
    width: 138px;
    max-height: 150px;
    object-fit: contain;
    margin: 0 auto 10px;
}
.site-access-copy span { color: var(--gold); font-size: .78rem; font-weight: 700; }
.site-access-copy h1 { font-family: var(--font-head); color: var(--green); font-size: 1.75rem; margin: 3px 0 22px; }
.site-access-form { display: grid; gap: 12px; }
.site-access-input { height: 56px; text-align: center; font-size: 1rem; }
.site-access-form .btn { justify-content: center; width: 100%; }
.sr-only { position: absolute!important; width: 1px!important; height: 1px!important; padding: 0!important; margin: -1px!important; overflow: hidden!important; clip: rect(0,0,0,0)!important; white-space: nowrap!important; border: 0!important; }

/* Security settings ------------------------------------------------- */
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.settings-description { color: var(--text-light); font-size: .78rem; margin: 4px 0 18px; }
.site-access-toggle { display: flex; align-items: center; gap: 11px; cursor: pointer; margin: 8px 0 15px; }
.site-access-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.site-access-toggle-control { width: 48px; height: 27px; border-radius: 16px; background: #c9cec9; position: relative; transition: .2s; flex: 0 0 auto; }
.site-access-toggle-control::after { content: ''; position: absolute; width: 21px; height: 21px; border-radius: 50%; top: 3px; right: 3px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: .2s; }
.site-access-toggle input:checked + .site-access-toggle-control { background: var(--green); }
.site-access-toggle input:checked + .site-access-toggle-control::after { transform: translateX(-21px); }
.site-access-toggle input:focus-visible + .site-access-toggle-control { outline: 3px solid rgba(184,134,11,.28); outline-offset: 2px; }
.site-password-status { border-radius: 10px; padding: 10px 12px; margin-bottom: 15px; font-size: .74rem; }
.site-password-status.ready { background: #e8f5ec; color: #17643a; }
.site-password-status.warning { background: #fff5d8; color: #765b0d; }

@media (max-width: 760px) {
    .settings-grid { grid-template-columns: 1fr; }
    .site-access-card { padding: 28px 20px; border-radius: 19px; }
}
.settings-grid .settings-section { max-width: none; }

/* Visitor analytics ------------------------------------------------- */
.visitor-live-tab { display:inline-flex; align-items:center; gap:5px; margin-inline-start:5px; font-size:.68rem; }
.visitor-live-tab i,.visitor-kpi-live span i,.visitor-live-pulse i { width:7px; height:7px; border-radius:50%; background:#2fb66d; box-shadow:0 0 0 4px rgba(47,182,109,.13); flex:0 0 auto; }
.visitor-live-tab b { font-size:.68rem; }
.visitor-stats-toolbar { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; margin-bottom:18px; }
.visitor-stats-toolbar h2 { font-family:var(--font-head); color:var(--green); margin:2px 0; }
.visitor-stats-toolbar p { color:var(--text-light); font-size:.76rem; max-width:690px; }
.visitor-stats-actions { display:flex; align-items:center; gap:9px; flex:0 0 auto; }
.visitor-stats-actions label { font-size:.72rem; font-weight:800; color:var(--text-light); }
.visitor-stats-actions select { width:125px; height:42px; padding-block:5px; }
.visitor-setup-warning { background:#fff4d6; color:#76580c; border:1px solid #e7cf8d; border-radius:12px; padding:12px 15px; margin-bottom:16px; font-size:.76rem; }
.visitor-setup-warning code { direction:ltr; unicode-bidi:embed; }
.visitor-kpi-grid { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:11px; margin-bottom:16px; }
.visitor-kpi { min-width:0; background:linear-gradient(180deg,#fff,#fbfaf6); border:1px solid rgba(18,63,53,.09); border-radius:14px; padding:16px 15px; box-shadow:0 5px 16px rgba(18,63,53,.055); }
.visitor-kpi span { display:flex; align-items:center; gap:7px; color:var(--text-light); font-size:.7rem; font-weight:800; white-space:nowrap; }
.visitor-kpi strong { display:block; color:var(--green); font-family:var(--font-head); font-size:1.75rem; line-height:1.2; margin:5px 0 1px; }
.visitor-kpi small { color:#929a94; font-size:.62rem; }
.visitor-kpi-live { background:linear-gradient(145deg,#123f35,#1e6552); border-color:transparent; }
.visitor-kpi-live span,.visitor-kpi-live strong,.visitor-kpi-live small { color:#fff; }
.visitor-kpi-live span i { background:#62e298; box-shadow:0 0 0 4px rgba(98,226,152,.16); animation:visitorPulse 1.8s infinite; }
@keyframes visitorPulse { 50% { box-shadow:0 0 0 8px rgba(98,226,152,0); } }
.visitor-dashboard-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.visitor-widget { min-width:0; background:#fff; border:1px solid rgba(18,63,53,.09); border-radius:15px; padding:17px; box-shadow:0 5px 18px rgba(18,63,53,.055); }
.visitor-widget-wide { grid-column:1/-1; }
.visitor-widget-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; }
.visitor-widget-head h3 { font-family:var(--font-head); color:var(--green); font-size:1rem; }
.visitor-widget-head p,.visitor-last-update { color:var(--text-light); font-size:.66rem; }
.visitor-daily-chart { height:245px; display:flex; align-items:stretch; gap:7px; overflow-x:auto; padding:10px 4px 0; border-bottom:1px solid var(--parchment-dk); }
.visitor-day { flex:1 0 34px; min-width:34px; display:grid; grid-template-rows:22px 1fr 24px; text-align:center; align-items:end; }
.visitor-day-value { color:var(--green); font-size:.64rem; font-weight:900; }
.visitor-day-bar-wrap { height:100%; display:flex; align-items:flex-end; justify-content:center; }
.visitor-day-bar-wrap i { display:block; width:min(24px,72%); min-height:2px; border-radius:7px 7px 2px 2px; background:linear-gradient(180deg,var(--gold-light),var(--gold)); box-shadow:0 -4px 12px rgba(179,134,46,.13); transition:height .25s ease; }
.visitor-day > span { color:var(--text-light); font-size:.59rem; padding-top:5px; }
.visitor-breakdown { display:grid; gap:12px; }
.visitor-breakdown-row { display:grid; grid-template-columns:minmax(0,1fr) 38px; gap:5px 10px; align-items:center; }
.visitor-breakdown-row > div:first-child { display:flex; justify-content:space-between; gap:10px; grid-column:1/-1; }
.visitor-breakdown-row span { color:var(--text); font-size:.73rem; }
.visitor-breakdown-row strong { color:var(--green); font-size:.73rem; }
.visitor-breakdown-row small { color:var(--text-light); font-size:.62rem; text-align:left; }
.visitor-progress { height:7px; border-radius:8px; background:#eef1ed; overflow:hidden; }
.visitor-progress i { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--green-light),var(--gold)); }
.visitor-ranked-list { display:grid; gap:4px; }
.visitor-ranked-row { display:grid; grid-template-columns:27px minmax(0,1fr) auto; align-items:center; gap:9px; min-height:38px; padding:5px 7px; border-bottom:1px solid #f1eee7; }
.visitor-ranked-row:last-child { border-bottom:0; }
.visitor-ranked-row b { width:25px; height:25px; display:grid; place-items:center; border-radius:8px; background:var(--gold-pale); color:var(--gold); font-size:.66rem; }
.visitor-ranked-row span,.visitor-ranked-row a { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text); font-size:.73rem; text-decoration:none; }
.visitor-ranked-row a:hover { color:var(--green); text-decoration:underline; }
.visitor-ranked-row strong { color:var(--green); font-size:.72rem; }
.visitor-live-list { display:grid; }
.visitor-live-row { display:grid; grid-template-columns:135px minmax(0,1fr) 55px; align-items:center; gap:12px; padding:11px 5px; border-bottom:1px solid #f0eee8; }
.visitor-live-row:last-child { border-bottom:0; }
.visitor-live-pulse { display:flex; align-items:center; gap:8px; color:#237449; font-size:.7rem; font-weight:900; }
.visitor-live-page { min-width:0; }
.visitor-live-page > a,.visitor-live-page > span { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--green); font-size:.75rem; font-weight:800; text-decoration:none; }
.visitor-live-page > a:hover { text-decoration:underline; }
.visitor-live-page small { display:block; color:var(--text-light); font-size:.61rem; margin-top:2px; }
.visitor-live-row time { direction:ltr; color:var(--text-light); font-size:.67rem; text-align:left; }
.visitor-empty { min-height:90px; display:grid; place-items:center; color:var(--text-light); font-size:.73rem; text-align:center; }

@media (max-width:1100px) {
    .visitor-kpi-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width:700px) {
    .visitor-stats-toolbar { align-items:stretch; flex-direction:column; }
    .visitor-stats-actions { width:100%; display:grid; grid-template-columns:auto 1fr auto; }
    .visitor-stats-actions select { width:100%; }
    .visitor-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .visitor-dashboard-grid { grid-template-columns:1fr; }
    .visitor-widget-wide { grid-column:auto; }
    .visitor-live-row { grid-template-columns:1fr auto; }
    .visitor-live-pulse { grid-column:1/-1; }
}
@media (max-width:430px) {
    .visitor-kpi-grid { grid-template-columns:1fr 1fr; gap:8px; }
    .visitor-kpi { padding:13px 11px; }
    .visitor-kpi strong { font-size:1.42rem; }
}


/* Person request status and delete controls -------------------------- */
.person-request-status {
    margin: 18px 0;
    background: linear-gradient(180deg,#fff,#fcfbf7);
    border: 1px solid rgba(18,63,53,.11);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(18,63,53,.055);
}
.person-request-status-head {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    margin-bottom:13px;
}
.person-request-status-head h2 {
    margin:2px 0 0;
    color:var(--green);
    font-family:var(--font-head);
    font-size:1.05rem;
}
.request-summary-badge {
    flex:0 0 auto;
    display:inline-flex;
    align-items:center;
    min-height:32px;
    padding:6px 11px;
    border-radius:999px;
    background:#fff4d8;
    color:#8b6411;
    border:1px solid #ecd69d;
    font-size:.68rem;
    font-weight:900;
}
.request-summary-complete { background:#eaf6ef; color:#246947; border-color:#cbe4d5; }
.person-request-list { display:grid; gap:8px; }
.person-request-item {
    display:grid;
    grid-template-columns:10px minmax(0,1fr) auto;
    align-items:center;
    gap:11px;
    min-height:58px;
    padding:10px 12px;
    border:1px solid #eeeae0;
    border-radius:13px;
    background:#fff;
}
.request-status-dot { width:9px; height:9px; border-radius:50%; background:#c38a20; box-shadow:0 0 0 4px rgba(195,138,32,.10); }
.person-request-copy { min-width:0; }
.person-request-copy strong { display:block; color:var(--text); font-size:.78rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.person-request-copy small { display:block; color:var(--text-light); font-size:.62rem; margin-top:3px; }
.request-status-label { min-width:94px; text-align:center; border-radius:999px; padding:6px 9px; font-size:.64rem; font-weight:900; background:#fff4d8; color:#8b6411; }
.request-status-approved .request-status-dot { background:#2f8a58; box-shadow:0 0 0 4px rgba(47,138,88,.10); }
.request-status-approved .request-status-label { background:#e8f5ed; color:#247046; }
.request-status-rejected .request-status-dot { background:#c93b3b; box-shadow:0 0 0 4px rgba(201,59,59,.10); }
.request-status-rejected .request-status-label { background:#fdeaea; color:#a62d2d; }
.request-status-cancelled .request-status-dot { background:#8b918d; box-shadow:0 0 0 4px rgba(139,145,141,.10); }
.request-status-cancelled .request-status-label { background:#eef0ef; color:#626864; }
.person-request-admin-link { display:inline-flex; margin-top:12px; color:var(--green); font-size:.7rem; font-weight:900; text-decoration:underline; text-underline-offset:3px; }
.person-modal-foot { justify-content:space-between; gap:12px; }
.person-modal-main-actions { display:flex; align-items:center; gap:9px; margin-inline-start:auto; }
.delete-person-confirm {
    margin-top:14px;
    padding:14px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    border:1px solid #efc8c8;
    border-radius:14px;
    background:#fff3f3;
}
.delete-person-confirm[hidden] { display:none; }
.delete-person-confirm strong { display:block; color:#9e2d2d; font-size:.8rem; }
.delete-person-confirm p { margin:4px 0 0; color:#765b5b; font-size:.68rem; line-height:1.7; }
.delete-person-confirm-actions { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
#btnDeletePerson:disabled { opacity:.62; cursor:not-allowed; }

@media (max-width:700px) {
    .person-request-status-head { align-items:flex-start; flex-direction:column; gap:9px; }
    .person-request-item { grid-template-columns:10px minmax(0,1fr); }
    .request-status-label { grid-column:2; justify-self:start; min-width:0; }
    .person-modal-foot { align-items:stretch; flex-direction:column-reverse; }
    .person-modal-main-actions { width:100%; margin:0; display:grid; grid-template-columns:1fr 1fr; }
    #btnDeletePerson { width:100%; }
    .delete-person-confirm { align-items:stretch; flex-direction:column; }
    .delete-person-confirm-actions { width:100%; display:grid; grid-template-columns:1fr 1fr; }
}


/* Latest request status inside the edit modal */
.latest-request-details {
    margin-top: 18px;
    border: 1px solid #ded8c9;
    border-radius: 16px;
    background: #fbfaf6;
    overflow: hidden;
}
.latest-request-details[hidden] { display: none !important; }
.latest-request-details summary {
    list-style: none;
    cursor: pointer;
    min-height: 70px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    user-select: none;
}
.latest-request-details summary::-webkit-details-marker { display: none; }
.latest-request-details summary::after {
    content: '⌄';
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #f0ecdf;
    color: #174f43;
    font-size: 1rem;
    font-weight: 900;
    transition: transform .2s ease;
}
.latest-request-details[open] summary::after { transform: rotate(180deg); }
.latest-request-summary-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-inline-end: auto;
}
.latest-request-summary-title { color: #153f36; font-weight: 900; }
.latest-request-summary-subtitle { color: #777c78; font-size: .76rem; }
.latest-request-details .request-status-label {
    min-width: auto;
    white-space: nowrap;
}
.latest-request-details .request-status-label.request-status-pending { background:#fff4d8; color:#8b6411; }
.latest-request-details .request-status-label.request-status-approved { background:#e8f5ed; color:#247046; }
.latest-request-details .request-status-label.request-status-rejected { background:#fdeaea; color:#a62d2d; }
.latest-request-details .request-status-label.request-status-cancelled { background:#eef0ef; color:#626864; }
.latest-request-content {
    border-top: 1px solid #e6e0d2;
    padding: 15px 16px 17px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    background: #fff;
}
.latest-request-content > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.latest-request-content small { color: #7d817e; font-size: .72rem; }
.latest-request-content strong { color: #173f36; font-size: .86rem; overflow-wrap: anywhere; }
.latest-request-admin-link {
    grid-column: 1 / -1;
    justify-self: start;
    color: #174f43;
    font-weight: 900;
    font-size: .78rem;
    text-decoration: underline;
    text-underline-offset: 4px;
}
@media (max-width: 640px) {
    .latest-request-details summary { align-items: flex-start; flex-wrap: wrap; }
    .latest-request-details summary::after { order: 3; margin-inline-start: auto; }
    .latest-request-content { grid-template-columns: 1fr; }
}

/* Detailed descendant generations — V12 */
.descendant-details {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto 30px;
}
.descendant-details-heading {
    margin-bottom: 16px;
}
.descendant-generation-list {
    display: grid;
    gap: 18px;
}
.descendant-generation-group {
    background: rgba(255,255,255,.52);
    border: 1px solid rgba(18,63,53,.08);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(18,63,53,.045);
}
.descendant-generation-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 13px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(18,63,53,.08);
}
.descendant-generation-order {
    display: block;
    color: var(--gold);
    font-size: .68rem;
    font-weight: 800;
    margin-bottom: 2px;
}
.descendant-generation-head h3 {
    color: var(--green);
    font-family: var(--font-head);
    font-size: 1.12rem;
}
.descendant-generation-count {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--gold-pale);
    color: var(--gold);
    font-size: .7rem;
    font-weight: 800;
}
.descendant-person-grid {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 12px;
}
.descendant-person-card {
    min-width: 0;
    background: var(--white);
    border: 1px solid rgba(18,63,53,.08);
    border-radius: 14px;
    padding: 14px;
    display: grid;
    grid-template-columns: 52px minmax(0,1fr) auto;
    gap: 12px;
    align-items: center;
    color: var(--text);
    box-shadow: 0 7px 20px rgba(18,63,53,.055);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.descendant-person-card:hover,
.descendant-person-card:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(179,134,46,.34);
    box-shadow: 0 13px 28px rgba(18,63,53,.105);
}
.descendant-person-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: var(--green-pale);
    color: var(--green);
    border: 2px solid rgba(179,134,46,.25);
    font-size: .68rem;
    font-weight: 800;
    text-align: center;
}
.descendant-person-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.descendant-person-copy {
    min-width: 0;
}
.descendant-person-title-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 8px;
}
.descendant-person-title-row h4 {
    min-width: 0;
    color: var(--green);
    font-family: var(--font-head);
    font-size: .9rem;
    line-height: 1.5;
}
.descendant-person-title-row > span {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 999px;
    background: #eef5f1;
    color: var(--green-light);
    font-size: .62rem;
    font-weight: 800;
}
.descendant-parent-line {
    margin-top: 2px;
    color: var(--text-light);
    font-size: .69rem;
}
.descendant-person-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}
.descendant-person-meta span {
    max-width: 100%;
    padding: 3px 7px;
    border-radius: 7px;
    background: var(--parchment);
    color: var(--text-light);
    font-size: .63rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 700px) {
    .descendant-details { width: calc(100% - 24px); }
    .descendant-details-heading p { max-width: none; }
    .descendant-generation-group { padding: 14px 12px; border-radius: 15px; }
    .descendant-person-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .descendant-generation-head { align-items: flex-start; }
    .descendant-person-card { grid-template-columns: 44px minmax(0,1fr) auto; padding: 12px; gap: 10px; }
    .descendant-person-avatar { width: 42px; height: 42px; }
    .descendant-person-title-row { display: block; }
    .descendant-person-title-row > span { display: inline-flex; margin-top: 4px; }
}

/* V13 — compact statistics and alphabetical controls */
.portal-stats.portal-stats-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(760px, calc(100% - 72px));
}
.portal-stats.portal-stats-two article:nth-child(n) {
    border-bottom: 0;
}
.portal-stats.portal-stats-two article:first-child {
    border-left: 1px solid var(--parchment-dk);
}
.portal-stats.portal-stats-two article:last-child {
    border-left: 0;
}
.section-heading-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}
.alpha-sort-control {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 6px 10px 6px 7px;
    border: 1px solid rgba(18, 63, 53, .16);
    border-radius: 11px;
    background: rgba(255,255,255,.82);
    color: var(--green);
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}
.alpha-sort-control select {
    min-width: 92px;
    height: 32px;
    padding: 3px 9px;
    border: 1px solid var(--parchment-dk);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.generation-stack .section-heading > div > p {
    margin-top: 5px;
    color: var(--text-light);
    font-size: .8rem;
}
@media (max-width: 700px) {
    .portal-stats.portal-stats-two {
        width: calc(100% - 30px);
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .section-heading-controls {
        width: 100%;
        justify-content: stretch;
    }
    .alpha-sort-control {
        flex: 1;
        justify-content: space-between;
    }
}
@media (max-width: 420px) {
    .portal-stats.portal-stats-two {
        grid-template-columns: 1fr;
    }
    .portal-stats.portal-stats-two article:first-child {
        border-left: 0;
        border-bottom: 1px solid var(--parchment-dk);
    }
}
