.tree-page {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: calc(100vh - 120px);
}

.tree-top-panel {
    position: sticky;
    z-index: 1000;
    top: 72px;
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    padding: 10px 16px;
    background: rgba(251, 251, 253, .94);
    border-radius: 8px;
    backdrop-filter: blur(6px);
    font-family: Inter, sans-serif;
}

.tree-card {
    background: rgba(255, 255, 255, .96);
    border: 1px solid #e4e2e9;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(29, 38, 67, .08);
    padding: 10px 12px;
}

.tree-search-card,
.tree-filter-card {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-search-card {
    position: relative;
}

.tree-search-card label,
.tree-filter-card label {
    margin: 0;
    color: #1d2643;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.tree-search-card input {
    width: 190px;
    height: 30px;
    border: 1px solid #d9d7e2;
    border-radius: 7px;
    padding: 4px 7px;
    font-size: 12px;
}

.tree-filter-card input {
    width: 86px;
    height: 30px;
    border: 1px solid #d9d7e2;
    border-radius: 7px;
    padding: 4px 7px;
    font-size: 12px;
}

.tree-search-results {
    position: absolute;
    z-index: 1100;
    top: calc(100% + 6px);
    left: 12px;
    right: 12px;
    display: none;
    max-height: 320px;
    overflow-y: auto;
    background: white;
    border: 1px solid #d9d7e2;
    border-radius: 10px;
    box-shadow: 0 16px 34px rgba(29, 38, 67, .18);
}

.tree-search-result-item {
    width: 100%;
    border: 0;
    background: white;
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eeeaf4;
}

.tree-search-result-item:last-child {
    border-bottom: 0;
}

.tree-search-result-item:hover,
.tree-search-result-item.active {
    background: #f4f1fb;
}

.tree-search-result-title {
    color: #1d2643;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-search-result-meta {
    margin-top: 2px;
    color: #716E7B;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-actions-card,
.tree-export-card,
.tree-legend {
    display: flex;
    gap: 6px;
    align-items: center;
    color: #1d2643;
    font-size: 11px;
}

.tree-action-button,
.tree-export-button {
    min-width: 30px;
}

.tree-legend {
    gap: 10px;
}

.tree-legend-item {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    white-space: nowrap;
}

.tree-legend-marker {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 4px;
    border: 1px solid #b9b4c8;
}

.tree-legend-marker.male {
    background: LightCyan;
}

.tree-legend-marker.female {
    background: MistyRose;
}

.tree-legend-marker.marriage {
    background: #fff4cf;
    border-color: #d2a733;
}

.tree-btn {
    text-transform: lowercase;
    font-size: 11px !important;
    border-radius: 7px !important;
    color: white !important;
    padding: 4px 7px !important;
    background-color: #1d2643 !important;
    border: 0;
    cursor: pointer;
    min-height: 30px;
}

.tree-btn.secondary {
    background-color: #51427a !important;
}

.tree-status {
    position: absolute;
    z-index: 1001;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 1px solid #e4e2e9;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(29, 38, 67, .12);
    padding: 14px 18px;
    color: #1d2643;
    font-family: Inter, sans-serif;
    font-size: 13px;
    display: none;
    text-align: center;
    max-width: 420px;
}

.tree-status.error {
    color: #8a1c1c;
    border-color: #e7b4b4;
}

.chart-container {
    min-height: 900px;
    height: calc(100vh - 230px);
    background: #fbfbfd;
    border-radius: 8px;
    overflow: hidden;
}

.tree-expand-button {
    color: #716E7B;
    border-radius: 5px;
    padding: 4px;
    font-size: 10px;
    margin: auto;
    background: white;
    border: 1px solid #E4E2E9;
}

.tree-node {
    font-family: Inter, sans-serif;
    position: absolute;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
}

.tree-node-root {
    background: #1d2643;
    color: white;
}

.tree-node-start {
    background: #ffffff;
    color: #1d2643;
    border: 1px solid #51427a;
    box-shadow: 0 10px 22px rgba(29, 38, 67, .08);
}

.tree-start-button {
    margin-top: 8px;
    padding: 3px 8px;
    border: 0;
    border-radius: 6px;
    background: #51427a;
    color: #ffffff;
    font-size: 10px;
    cursor: pointer;
}

.tree-node-marriage {
    background: #fff4cf;
    border: 1px solid #d2a733;
    color: #1d2643;
    box-shadow: 0 8px 18px rgba(122, 98, 0, .10);
    flex-direction: column;
    gap: 5px;
}

.tree-family-header {
    font-size: 10px;
    font-weight: 700;
    color: #7a6200;
    text-transform: lowercase;
}

.tree-family-partners {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
}

.tree-family-partner {
    background: rgba(255, 255, 255, .62);
    border: 1px solid rgba(210, 167, 51, .45);
    border-radius: 7px;
    padding: 5px 6px;
    min-width: 0;
}

.tree-family-partner-name {
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-family-partner-name a {
    color: #1d2643;
    text-decoration: none;
}

.tree-family-partner-name a:hover {
    text-decoration: underline;
}

.tree-family-line {
    margin-top: 2px;
    font-size: 8px;
    color: #7a6200;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-family-subtitle {
    font-size: 9px;
    color: #716E7B;
}

.tree-family-actions {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

.tree-family-button {
    padding: 3px 7px;
    border: 0;
    border-radius: 6px;
    background: #51427a;
    color: white;
    font-size: 9px;
    cursor: pointer;
}

.tree-family-button.secondary {
    background: #7a6200;
}

.tree-node-person {
    margin-top: -1px;
    margin-left: -1px;
    border: 1px solid indigo;
    padding: 0;
}

.tree-node-clickable {
    cursor: pointer;
    transition: box-shadow .15s ease, transform .15s ease;
}

.tree-node-clickable:hover {
    box-shadow: 0 10px 22px rgba(29, 38, 67, .16);
    transform: translateY(-1px);
}

.tree-node-male {
    background: LightCyan;
}

.tree-node-female {
    background: MistyRose;
}

.tree-node-unknown {
    background: #ffffff;
}

.tree-node-title {
    font-size: 14px;
    font-weight: 600;
}

.tree-node-subtitle {
    font-size: 10px;
    opacity: .85;
    margin-top: 4px;
}

.tree-person-image {
    position: absolute;
    margin-top: -18px;
    max-width: 45px;
    max-height: 45px;
    border: 1px solid #E4E2E9;
    background: white;
}

.tree-node-edit {
    color: #08011E;
    position: absolute;
    right: 18px;
    top: 14px;
    font-size: 12px;
    z-index: 2;
}

.tree-node-edit a,
.tree-node-edit i {
    color: #08011E;
}

.tree-person-title {
    font-size: 14px;
    color: #08011E;
    margin-top: 27px;
    position: absolute;
    text-align: center;
    width: 212px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-person-dates {
    color: #716E7B;
    margin-top: 49px;
    font-size: 10px;
    position: absolute;
    text-align: center;
    width: 212px;
}

.tree-person-place {
    color: #51427a;
    margin-top: 65px;
    font-size: 9px;
    position: absolute;
    text-align: center;
    width: 212px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-person-badges {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
}

.tree-badge {
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 9px;
    line-height: 1.2;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, .68);
}

.tree-badge-line {
    color: #1d2643;
    border-color: #c9c3dc;
}

.tree-badge-proof {
    color: #51427a;
    border-color: #d6c9ef;
}
