/* ===========================================
   KinPatch Families Page Styles
   Matches mobile app family cards
   =========================================== */

/* Page Container */
.families-container {
    min-height: 100vh;
    background: var(--surface);
}

/* Header */
.families-header {
    background: var(--surface);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.families-header-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.logout-btn:hover {
    text-decoration: underline;
}

/* Content */
.families-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Section */
.section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.count-badge {
    background: var(--primary);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-left: 8px;
}

/* Family Card */
.family-card {
    display: flex;
    align-items: center;
    background: white;
    padding: 20px 16px;
    border-radius: 20px;
    margin-bottom: 8px;
    border: 1px solid #E8E0DB;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
}

.family-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Badges */
.badge-container {
    position: absolute;
    top: 8px;
    right: 12px;
}

.badge {
    display: flex;
    align-items: center;
    padding: 5px;
    border-radius: 14px;
}

.badge-primary {
    background: #DBEAFE;
    color: #42A5F5;
}

.badge-origin {
    background: #ccf8dc;
    color: #17A34A;
}

.badge-private {
    background: #F3E5F5;
    color: #9C27B0;
}

.badge .mdi {
    font-size: 14px;
}

/* Inline family type icons (after family name) */
.family-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
    vertical-align: middle;
}

.family-type-icon .mdi {
    font-size: 16px;
}

/* Primary/Current family - blue */
.family-type-primary {
    color: #42A5F5;
}

/* Origin family - green */
.family-type-origin {
    color: #17A34A;
}

/* Private family - purple */
.family-type-private {
    color: #9C27B0;
}

/* Avatar */
.family-avatar {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.family-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.family-avatar .mdi {
    font-size: 28px;
    color: var(--primary);
}

/* Avatar Stack (for member composites) */
.avatar-stack {
    display: flex;
    margin-right: 14px;
}

.avatar-stack-item {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: var(--primary-soft);
    border: 2px solid white;
    margin-left: -12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-stack-item:first-child {
    margin-left: 0;
}

.avatar-stack-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-stack-item .initials {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

/* Card Content */
.family-card-content {
    flex: 1;
    min-width: 0;
    margin-right: 8px;
}

.family-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.family-members {
    font-size: 14px;
    color: #7A7A7A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.family-card-chevron {
    color: var(--text-light);
    font-size: 24px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
}

.empty-state .mdi {
    font-size: 48px;
    color: var(--text-light);
}

.empty-state-title {
    margin-top: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.empty-state-subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
}

.loading-state .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
}

.loading-state-text {
    margin-top: 16px;
    font-size: 16px;
    color: var(--text-secondary);
}

/* Error State */
.error-state {
    text-align: center;
    padding: 40px 24px;
}

.error-state .mdi {
    font-size: 48px;
    color: var(--error);
}

.error-state-text {
    margin-top: 12px;
    font-size: 16px;
    color: var(--error);
}

.retry-btn {
    margin-top: 16px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.retry-btn:hover {
    background: var(--primary-dark);
}

/* Family Card Name (to differentiate from show page) */
.family-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge icons (for family card) */
.badge-primary-icon {
    background: #DBEAFE;
    color: #42A5F5;
}

.badge-origin-icon {
    background: #ccf8dc;
    color: #17A34A;
}

.badge-private-icon {
    background: #F3E5F5;
    color: #9C27B0;
}

/* Section Count */
.section-count {
    background: var(--primary);
    color: white;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-left: 8px;
    padding: 0 6px;
}

/* Navigation Back Button */
.nav-back {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.nav-back:hover {
    opacity: 0.8;
}

/* ========================================
   FAMILY DETAIL PAGE (SHOW)
   ======================================== */

.family-detail-container {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
    width: 100%;
}

/* Family Header */
.family-header {
    text-align: center;
    padding-bottom: 32px;
}

/* Large Family Avatar */
.family-avatar-large {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    border-radius: 60px;
    overflow: hidden;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.family-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.family-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.family-avatar-placeholder .mdi {
    font-size: 48px;
    color: var(--primary);
}

/* Composite Avatar - Overlapping layout like mobile app */
.family-avatar-composite {
    width: 100%;
    height: 100%;
    position: relative;
}

.composite-avatar {
    width: 48%;
    height: 48%;
    border-radius: 50%;
    overflow: hidden;
    position: absolute;
    border: 2px solid white;
    box-sizing: border-box;
}

/* Position avatars in overlapping 2x2 pattern */
.composite-avatar-0 {
    top: 5%;
    left: 10%;
    z-index: 4;
}

.composite-avatar-1 {
    top: 5%;
    right: 10%;
    z-index: 3;
}

.composite-avatar-2 {
    bottom: 5%;
    left: 10%;
    z-index: 2;
}

.composite-avatar-3 {
    bottom: 5%;
    right: 10%;
    z-index: 1;
}

.composite-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.composite-avatar.avatar-placeholder {
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.composite-avatar.avatar-placeholder .mdi {
    font-size: 20px;
    color: var(--primary);
}

.composite-avatar.avatar-placeholder .avatar-initials-small {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}

/* Family Name on Show Page */
.family-header .family-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

/* Family Badges */
.family-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.family-badges .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.badge-extended {
    background: #FEF3C7;
    color: #92400E;
}

/* ========================================
   MEMBER CARDS (Horizontal Scroll)
   ======================================== */

.members-scroll {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.members-scroll::-webkit-scrollbar {
    display: none;
}

.member-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 16px 12px;
    border-radius: 16px;
    min-width: 100px;
    max-width: 100px;
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.member-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.member-avatar {
    width: 64px;
    height: 64px;
    border-radius: 32px;
    overflow: hidden;
    margin-bottom: 10px;
    background: var(--primary-soft);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.member-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.member-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
}

.member-initials {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.member-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin-bottom: 4px;
}

.member-role {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ========================================
   INVITATION CARDS
   ======================================== */

.invitations-scroll {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
}

/* Invitation cards on families index page - full width with inline actions */
.invitations-scroll .invitation-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border-radius: 16px;
    padding: 16px;
    width: 100%;
    max-width: none;
    border: 1px solid var(--border);
    box-shadow: none;
    text-align: left;
}

.invitations-scroll .invitation-info {
    flex: 1;
    min-width: 0;
}

.invitations-scroll .invitation-actions {
    display: flex;
    gap: 8px;
    margin: 0;
    flex-shrink: 0;
}

.invitations-scroll .invitation-actions .btn-accept,
.invitations-scroll .invitation-actions .btn-decline {
    padding: 8px 16px;
    font-size: 14px;
}

.invitation-header {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.invitation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    overflow: hidden;
    background: var(--primary-soft);
    flex-shrink: 0;
}

.invitation-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.invitation-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.invitation-avatar-placeholder .mdi {
    font-size: 24px;
    color: var(--primary);
}

.invitation-info {
    flex: 1;
    min-width: 0;
}

.invitation-family-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.invitation-from,
.invitation-role {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.invitation-from .mdi,
.invitation-role .mdi {
    font-size: 14px;
}

.invitation-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.btn-accept {
    flex: 1;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-accept:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-decline {
    flex: 1;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-decline:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.invitation-note {
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
}

/* ========================================
   PENDING INVITATIONS (Admin View)
   ======================================== */

.pending-invites-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pending-invite-card {
    display: flex;
    align-items: center;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.pending-invite-card:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.pending-invite-avatar {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--surface);
    margin-right: 12px;
    flex-shrink: 0;
}

.pending-invite-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pending-invite-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pending-invite-avatar-placeholder .mdi {
    font-size: 20px;
    color: var(--text-light);
}

.pending-invite-info {
    flex: 1;
    min-width: 0;
}

.pending-invite-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: block;
}

.pending-invite-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.pending-invite-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #F59E0B;
    font-weight: 500;
}

.pending-invite-status .mdi {
    font-size: 14px;
}

.pending-invite-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.pending-invite-action .mdi {
    font-size: 18px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .family-detail-container {
        padding: 16px;
    }

    .family-avatar-large {
        width: 100px;
        height: 100px;
    }

    .family-header .family-name {
        font-size: 24px;
    }

    .member-card {
        min-width: 90px;
        max-width: 90px;
        padding: 12px 8px;
    }

    .member-avatar {
        width: 56px;
        height: 56px;
    }
}

/* ========================================
   CREATE FAMILY PAGE
   ======================================== */

.create-family-container {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px;
    width: 100%;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 32px;
}

/* Avatar Section */
.avatar-section {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.avatar-upload {
    position: relative;
    display: inline-block;
}

.avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 60px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.avatar-preview .mdi {
    font-size: 48px;
    color: var(--primary);
}

.avatar-preview>img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-edit-badge {
    position: absolute;
    z-index: 10;
    bottom: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid white;
    transition: background-color 0.2s;
}

.avatar-edit-badge:hover {
    background: var(--primary-dark);
}

.avatar-edit-badge .mdi {
    font-size: 16px;
    color: white;
}

.avatar-input-hidden {
    display: none;
}

.create-family-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Form Cards */
.form-card {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.form-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.form-card-header .mdi {
    font-size: 20px;
    color: var(--primary);
}

.form-card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.form-card-body {
    padding: 20px;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(219, 104, 14, 0.1);
}

.form-input::placeholder {
    color: var(--text-light);
}

/* Select Wrapper */
.select-wrapper {
    position: relative;
}

.form-select {
    width: 100%;
    padding: 14px 44px 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(219, 104, 14, 0.1);
}

.select-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: var(--text-secondary);
    pointer-events: none;
}

/* Toggle Rows */
.toggle-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.toggle-row-last {
    border-bottom: none;
    padding-bottom: 0;
}

.toggle-content {
    flex: 1;
    margin-right: 16px;
}

.toggle-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.toggle-subtitle {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

/* Create Button */
.btn-create-family {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 8px;
}

.btn-create-family:hover {
    background: var(--primary-dark);
}

.btn-create-family:active {
    transform: scale(0.98);
}

.btn-create-family .mdi {
    font-size: 22px;
}

/* Add Family Button on Index */
.add-family-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: white;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 16px;
    border: 2px dashed var(--primary);
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    gap: 8px;
}

.add-family-card:hover {
    background: var(--primary-soft);
    border-color: var(--primary-dark);
}

.add-family-card .mdi {
    font-size: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .create-family-container {
        padding: 16px;
    }

    .page-title {
        font-size: 24px;
    }
}

/* ========================================
   ADD MEMBER PAGE
   ======================================== */

/* Tab Toggle */
.tab-toggle {
    display: flex;
    background: var(--surface);
    border-radius: 25px;
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--primary);
}

.tab-active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Invite Section */
.invite-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Search Container */
.search-container {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 25px;
    padding: 12px 16px;
    border: 1px solid var(--border);
}

.search-icon {
    font-size: 22px;
    color: var(--text-secondary);
    margin-right: 10px;
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 16px;
    color: var(--text);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-light);
}

/* Suggested Users */
.suggested-users-section {
    margin-bottom: 8px;
}

.suggested-users-section .section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.suggested-users-section .section-header .mdi {
    font-size: 20px;
    color: var(--primary);
}

.suggested-users-section .section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.suggested-users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggested-user-card {
    display: flex;
    align-items: center;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.suggested-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    overflow: hidden;
}

.suggested-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.suggested-user-info {
    flex: 1;
}

.suggested-user-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.suggested-user-relation {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-invite {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-invite:hover {
    background: var(--primary-dark);
}

.btn-invite:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-invited {
    background: var(--success);
}

.invite-status-badge {
    padding: 6px 12px;
    background: var(--success-soft);
    color: var(--success);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.empty-state-text {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* Invite Link Card */
.invite-link-card {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.invite-link-icon {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.invite-link-icon .mdi {
    font-size: 28px;
    color: var(--primary);
}

.invite-link-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}

.invite-link-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 20px;
}

.btn-generate-invite {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-generate-invite:hover {
    background: var(--primary-dark);
}

.btn-generate-invite:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: calc(100% - 32px);
    z-index: 1001;
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text);
}

.modal-content p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 16px;
}

.invite-link-display {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.invite-link-display input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
}

.btn-copy {
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-copy:hover {
    background: var(--primary-dark);
}

.btn-close-modal {
    width: 100%;
    padding: 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-close-modal:hover {
    background: var(--border);
}

/* Add Member Card on Show Page */
.add-member-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    max-width: 100px;
    padding: 16px 8px;
    background: white;
    border: 2px dashed var(--primary);
    border-radius: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.add-member-card:hover {
    background: var(--primary-soft);
}

.add-member-card .add-icon {
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.add-member-card .add-icon .mdi {
    font-size: 28px;
    color: var(--primary);
}

.add-member-card .add-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

.add-member-card .add-sublabel {
    font-size: 12px;
    color: var(--primary);
}

/* ========================================
   INVITATION PAGE
   ======================================== */

.invitation-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px;
    width: 100%;
}

.invitation-card {
    background: white;
    border-radius: 24px;
    padding: 40px 32px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.invitation-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    overflow: hidden;
}

.invitation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.invitation-avatar .mdi {
    font-size: 48px;
    color: var(--primary);
}

.invitation-composite {
    width: 100px;
    height: 100px;
}

.invitation-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}

.invitation-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0 0 8px;
}

.invitation-family-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 16px;
}

.invitation-members {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 24px;
}

.invitation-members .mdi {
    font-size: 18px;
}

.invitation-expired {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--error-soft);
    color: var(--error);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 24px;
}

.invitation-expires {
    font-size: 13px;
    color: var(--text-light);
    margin: 0 0 24px;
}

.invitation-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--success-soft);
    color: var(--success);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}

.invitation-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-accept {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-accept:hover {
    background: var(--primary-dark);
}

.btn-decline {
    width: 100%;
    padding: 14px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-decline:hover {
    background: var(--surface);
    color: var(--text);
}

.decline-form {
    margin: 0;
}

.invitation-login-prompt {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.invitation-login-prompt p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 8px;
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--primary-soft);
}

/* ========================================
   MEMBER PROFILE PAGE
   ======================================== */

.member-profile-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px;
}

.member-profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 60px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    overflow: hidden;
}

.member-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials-large {
    font-size: 42px;
    font-weight: 700;
    color: white;
}

.avatar-initials-preview {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
}

.member-profile-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 12px;
    text-align: center;
}

.member-role-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}

.member-relationship {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0 0 24px;
}

.member-relationship .mdi {
    font-size: 20px;
}

.member-section {
    width: 100%;
    max-width: 400px;
    margin-top: 32px;
}

.card-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
    width: 100%;
    max-width: 400px;
    text-align: left;
}

.member-detail-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-row:first-child {
    padding-top: 0;
}

.detail-row .mdi {
    font-size: 20px;
    color: var(--primary);
}

.detail-row span:last-child {
    font-size: 15px;
    color: var(--text);
}

/* Nav Edit Button */
.nav-edit-btn {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    margin-right: 8px;
}

.nav-edit-btn .mdi {
    font-size: 20px;
    color: var(--primary);
}

.nav-edit-btn:hover {
    background: var(--primary);
}

.nav-edit-btn:hover .mdi {
    color: white;
}

.nav-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

/* Family Name Row with Edit Button */
.family-name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Family Edit Container */
.family-edit-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
}

.family-edit-container .form-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 32px;
}

.family-edit-container .avatar-section {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

/* Danger Section for Delete */
.danger-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.btn-delete-family {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: white;
    border: 1px solid #DC2626;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #DC2626;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-family:hover {
    background: #FEE2E2;
}

.btn-delete-family .mdi {
    font-size: 20px;
}

/* Connection Card */
.connection-card {
    margin-top: 24px;
    padding: 24px;
}

.connection-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text);
}

.connection-path {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.connection-step {
    display: flex;
    gap: 16px;
    position: relative;
    padding-bottom: 24px;
}

.connection-step:last-child {
    padding-bottom: 0;
}

.connection-line {
    position: absolute;
    left: 24px;
    /* Center of 48px avatar */
    top: 0;
    bottom: 0;
    width: 2px;
    background: #E5E7EB;
    transform: translateX(-50%);
    z-index: 0;
}

.connection-step:first-child .connection-line {
    top: 24px;
    /* Start from center of avatar */
}

.connection-step:last-child .connection-line {
    bottom: auto;
    height: 24px;
    /* End at center of avatar */
}

.connection-avatar-wrapper {
    position: relative;
    z-index: 1;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.connection-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-secondary);
}

.connection-avatar.connection-avatar-placeholder {
    font-size: 20px;
    color: var(--primary);
    background: var(--primary-soft);
    border: 2px solid var(--primary);
}

.connection-check {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #F97316;
    /* Orange-500 */
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.connection-check .mdi {
    font-size: 14px;
    font-weight: bold;
}

.connection-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 2px;
}

.connection-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.connection-name {
    font-weight: 600;
    color: var(--text);
    font-size: 16px;
}

.connection-name.you {
    font-weight: 700;
}

.connection-badge {
    background: #DBEAFE;
    /* Blue-100 */
    color: #1D4ED8;
    /* Blue-700 */
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

.connection-subtext {
    color: var(--text-secondary);
    font-size: 14px;
}

.connection-info {
    margin-top: 24px;
    background: #FFF7ED;
    /* Orange-50 */
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.connection-info .mdi {
    color: #F97316;
    /* Orange-500 */
    font-size: 20px;
    margin-top: -2px;
}

.connection-info p {
    color: #9A3412;
    /* Orange-900 */
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

/* ===========================================
   Mobile App Prompt (Invitation Page)
   =========================================== */

.invitation-app-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.app-prompt-text {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

.btn-open-app {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-open-app:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-open-app .mdi {
    font-size: 20px;
}

.app-store-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.store-button {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #000;
    color: white;
    border-radius: 12px;
    text-decoration: none;
    transition: opacity 0.2s;
}

.store-button:hover {
    opacity: 0.85;
    color: white;
}

.store-button .mdi {
    font-size: 28px;
}

.store-text {
    display: flex;
    flex-direction: column;
}

.store-label {
    font-size: 10px;
    opacity: 0.9;
    line-height: 1.2;
}

.store-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.web-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 16px;
}

.divider-text {
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    padding: 0 16px;
}

.divider-text::before,
.divider-text::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 60px;
    height: 1px;
    background: var(--border);
}

.divider-text::before {
    right: 100%;
}

.divider-text::after {
    left: 100%;
}

.btn-web-continue {
    display: inline-block;
    padding: 12px 24px;
    background: transparent;
    color: var(--primary);
    border: none;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-web-continue:hover {
    text-decoration: underline;
    color: var(--primary);
}

/* ========================================
   TAKEOVER PAGE (Claim Account)
   ======================================== */

.takeover-form {
    width: 100%;
    margin-top: 24px;
}

.takeover-form-group {
    margin-bottom: 16px;
    text-align: left;
}

.takeover-form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.takeover-form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.takeover-form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(219, 104, 14, 0.1);
}

.takeover-form-input::placeholder {
    color: var(--text-light);
}

.takeover-email-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    color: var(--text);
    font-size: 15px;
}

.takeover-email-display .mdi {
    font-size: 20px;
    color: var(--primary);
}

.takeover-merge-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 12px;
    margin: 24px 0;
    text-align: center;
}

.takeover-merge-icon {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background: #DBEAFE;
    display: flex;
    align-items: center;
    justify-content: center;
}

.takeover-merge-icon .mdi {
    font-size: 24px;
    color: #2563EB;
}

.takeover-merge-info p {
    font-size: 14px;
    color: #1E40AF;
    line-height: 1.5;
    margin: 0;
}

.takeover-login-link {
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.takeover-login-link a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.takeover-login-link a:hover {
    text-decoration: underline;
}

.takeover-form-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #FEE2E2;
    border: 1px solid #FECACA;
    border-radius: 8px;
    color: #DC2626;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: left;
}

.takeover-form-error .mdi {
    font-size: 18px;
    flex-shrink: 0;
}

/* ========================================
   SHADOW ACCOUNT BANNER
   ======================================== */

.shadow-banner {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border: 1px solid #F59E0B;
    border-radius: 16px;
    padding: 20px;
    margin-top: 24px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 400px;
}

.shadow-banner-content {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.shadow-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background: #FEF3C7;
    border: 2px solid #F59E0B;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shadow-banner-icon .mdi {
    font-size: 24px;
    color: #B45309;
}

.shadow-banner-text {
    flex: 1;
}

.shadow-banner-title {
    font-size: 16px;
    font-weight: 700;
    color: #92400E;
    margin: 0 0 4px;
}

.shadow-banner-description {
    font-size: 14px;
    color: #B45309;
    margin: 0 0 16px;
    line-height: 1.4;
}

.btn-convert-account {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #F59E0B;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
}

.btn-convert-account:hover {
    background: #D97706;
}

.btn-convert-account .mdi {
    font-size: 18px;
}

/* ========================================
   TAKEOVER MODAL
   ======================================== */

.takeover-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.takeover-modal.show {
    display: flex;
}

.takeover-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.takeover-modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 28px;
    max-width: 420px;
    width: 100%;
    z-index: 1001;
    max-height: 90vh;
    overflow-y: auto;
}

.takeover-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    background: var(--surface);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.takeover-modal-close:hover {
    background: var(--border);
}

.takeover-modal-close .mdi {
    font-size: 20px;
    color: var(--text-secondary);
}

.takeover-modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.takeover-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.takeover-modal-icon .mdi {
    font-size: 32px;
    color: var(--primary);
}

.takeover-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}

.takeover-modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Email Section */
.takeover-section {
    margin-bottom: 24px;
}

.takeover-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.takeover-section-title .mdi {
    font-size: 18px;
    color: var(--primary);
}

.takeover-email-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.takeover-email-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.takeover-email-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(219, 104, 14, 0.1);
}

.takeover-email-input::placeholder {
    color: var(--text-light);
}

.btn-send-invite {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-send-invite:hover {
    background: var(--primary-dark);
}

.btn-send-invite:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-send-invite .mdi {
    font-size: 18px;
}

/* Divider */
.takeover-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
}

.takeover-divider-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.takeover-divider-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Link Section */
.btn-generate-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-generate-link:hover {
    background: var(--primary-soft);
}

.btn-generate-link:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-generate-link .mdi {
    font-size: 18px;
}

/* Link Display */
.takeover-link-display {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.takeover-link-display.show {
    display: flex;
}

.takeover-link-row {
    display: flex;
    gap: 8px;
}

.takeover-link-input {
    flex: 1;
    padding: 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
}

.btn-copy-link {
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-copy-link:hover {
    background: var(--primary-dark);
}

.btn-copy-link .mdi {
    font-size: 16px;
}

.takeover-link-expiry {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 4px;
}

/* Loading Spinner */
.takeover-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: takeover-spin 0.8s linear infinite;
}

@keyframes takeover-spin {
    to { transform: rotate(360deg); }
}

/* Error Message */
.takeover-error {
    display: none;
    padding: 12px 16px;
    background: #FEE2E2;
    border: 1px solid #FECACA;
    border-radius: 8px;
    color: #DC2626;
    font-size: 14px;
    margin-bottom: 16px;
}

.takeover-error.show {
    display: block;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #1F2937;
    color: white;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    animation: toast-slide-in 0.3s ease-out;
}

.toast.toast-success {
    background: #059669;
}

.toast.toast-error {
    background: #DC2626;
}

.toast .mdi {
    font-size: 20px;
}

.toast-hide {
    animation: toast-slide-out 0.3s ease-in forwards;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* ========================================
   FAMILY TREE SECTION
   ======================================== */

.family-tree-container {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.family-tree-canvas {
    width: 100%;
    height: 500px;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

/* Zoom Controls */
.family-tree-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.tree-control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tree-control-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.tree-control-btn .mdi {
    font-size: 20px;
    color: var(--text);
}

.tree-control-btn:hover .mdi {
    color: var(--primary);
}

/* Family Tree Empty State */
.family-tree-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.family-tree-empty .mdi {
    font-size: 64px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.family-tree-empty .empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px;
}

.family-tree-empty .empty-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    max-width: 280px;
}

/* Responsive adjustments for family tree */
@media (max-width: 768px) {
    .family-tree-canvas {
        height: 400px;
    }
    
    .family-tree-controls {
        bottom: 12px;
        right: 12px;
    }
    
    .tree-control-btn {
        width: 36px;
        height: 36px;
    }
    
    .tree-control-btn .mdi {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .family-tree-canvas {
        height: 350px;
    }
}