:root {
    --bg: #f5efe4;
    --surface: rgba(255, 255, 255, 0.92);
    --ink: #1e2430;
    --muted: #616b7c;
    --border: rgba(30, 36, 48, 0.12);
    --accent: #9a4d14;
    --accent-deep: #5b2605;
    --success: #146c43;
    --danger: #b02a37;
    --shadow: 0 24px 70px rgba(39, 26, 13, 0.14);
    --radius-lg: 28px;
    --radius-md: 18px;
    --font-ui: "Noto Sans Gujarati", "Shruti", "Mukta Vaani", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-ui);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(154, 77, 20, 0.12), transparent 30%),
        radial-gradient(circle at bottom right, rgba(91, 38, 5, 0.1), transparent 25%),
        linear-gradient(180deg, #f9f4ec 0%, #f2e7d8 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(154, 77, 20, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(154, 77, 20, 0.05) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent);
}

.site-shell {
    position: relative;
    z-index: 1;
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 20px 40px;
}

.site-header,
.panel,
.hero-card {
    backdrop-filter: blur(14px);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 22px 26px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.site-kicker,
.section-label,
.eyebrow {
    margin: 0 0 8px;
    font-size: 0.82rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
}

.site-title {
    display: inline-block;
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    font-weight: 800;
    line-height: 1.1;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.site-nav a {
    padding: 11px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.65);
    color: var(--muted);
    transition: 0.2s ease;
}

.site-nav a.active,
.site-nav a:hover {
    color: var(--accent-deep);
    background: #fff7ee;
}

.page-content {
    display: grid;
    gap: 24px;
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
    gap: 24px;
    border-radius: var(--radius-lg);
    padding: 30px;
}

.hero-copy h1,
.page-heading h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.05;
}

.hero-text,
.page-subtitle,
.section-description,
.feature-list p,
.empty-state,
.detail-card dd,
.detail-card dt {
    color: var(--muted);
}

.hero-text {
    margin: 20px 0;
    font-size: 1.04rem;
    line-height: 1.8;
}

.hero-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-points {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.hero-points span,
.count-chip {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(154, 77, 20, 0.08);
    color: var(--accent-deep);
    font-weight: 700;
}

.hero-panel {
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(91, 38, 5, 0.98), rgba(49, 24, 10, 0.97));
    color: #fff;
    padding: 24px;
}

.hero-panel h2,
.panel h2,
.detail-card h2,
.section-heading h2 {
    margin: 0;
    font-size: 1.35rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.stat-card {
    padding: 18px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.stat-card span {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(1.7rem, 3vw, 2.3rem);
}

.stat-card-wide {
    grid-column: span 2;
}

.panel-grid,
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.panel,
.detail-card {
    border-radius: var(--radius-lg);
    padding: 26px;
}

.panel-header,
.section-heading,
.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.page-heading {
    padding: 8px 2px;
}

.feature-list {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

.feature-list article {
    padding: 18px;
    border-radius: var(--radius-md);
    background: rgba(154, 77, 20, 0.05);
    border: 1px solid rgba(154, 77, 20, 0.08);
}

.feature-list h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease;
}

.button {
    padding: 12px 18px;
    font-weight: 700;
}

.button:hover,
.button-link:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
    color: #fff;
}

.button-secondary {
    background: #fff;
    border: 1px solid rgba(154, 77, 20, 0.16);
    color: var(--accent-deep);
}

.button-ghost {
    background: transparent;
    border: 1px solid rgba(30, 36, 48, 0.14);
    color: var(--ink);
}

.button-disabled {
    background: #e6e2db;
    color: #8c8a84;
    cursor: not-allowed;
    padding: 12px 18px;
    border-radius: 999px;
}

.inline-link,
.button-link {
    color: var(--accent);
    font-weight: 700;
}

.danger-link {
    color: var(--danger);
    background: transparent;
    padding: 0;
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}

.search-bar input {
    flex: 1 1 320px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 18px;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(30, 36, 48, 0.08);
    vertical-align: top;
}

.data-table th {
    font-size: 0.92rem;
    background: rgba(30, 36, 48, 0.04);
}

.members-table input,
.members-table select {
    min-width: 120px;
}

.serial-cell {
    font-weight: 700;
    color: var(--accent);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.empty-state,
.empty-row {
    padding: 18px;
    border-radius: var(--radius-md);
    background: rgba(154, 77, 20, 0.05);
}

.family-form {
    display: grid;
    gap: 24px;
}

.form-section {
    padding: 22px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 241, 233, 0.98));
    border: 1px solid rgba(30, 36, 48, 0.08);
}

.form-grid {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.form-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
    display: grid;
    gap: 8px;
}

.field span,
.field legend {
    font-weight: 700;
}

.field-hint {
    display: block;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--muted);
}

.fieldset-card {
    margin: 0;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(30, 36, 48, 0.1);
    background: #fff;
}

input,
textarea,
select {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid rgba(30, 36, 48, 0.14);
    background: #fff;
    color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(154, 77, 20, 0.55);
    box-shadow: 0 0 0 4px rgba(154, 77, 20, 0.12);
}

.radio-group {
    display: flex;
    gap: 18px;
    margin-top: 10px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert {
    padding: 16px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
}

.alert-success {
    background: rgba(20, 108, 67, 0.12);
    border: 1px solid rgba(20, 108, 67, 0.16);
    color: var(--success);
}

.alert-error {
    background: rgba(176, 42, 55, 0.08);
    border: 1px solid rgba(176, 42, 55, 0.14);
    color: #6f1020;
}

.alert-error h3 {
    margin: 0 0 10px;
}

.alert-error ul {
    margin: 0;
    padding-left: 20px;
}

.member-count-grid {
    align-items: flex-start;
}

.member-heading {
    align-items: center;
}

.member-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.member-status {
    margin: 0;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(30, 36, 48, 0.06);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
}

.member-status.is-neutral {
    background: rgba(30, 36, 48, 0.06);
    color: var(--muted);
}

.member-status.is-valid {
    background: rgba(20, 108, 67, 0.12);
    color: var(--success);
}

.member-status.is-invalid {
    background: rgba(176, 42, 55, 0.08);
    color: var(--danger);
}

.relationship-help {
    display: grid;
    gap: 6px;
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(154, 77, 20, 0.06);
    border: 1px solid rgba(154, 77, 20, 0.08);
    color: var(--muted);
}

.relationship-help strong {
    color: var(--accent-deep);
}

.family-tree-panel {
    display: grid;
    gap: 24px;
}

.tree-root-card {
    position: relative;
    overflow: hidden;
    padding: 28px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(91, 38, 5, 0.98), rgba(154, 77, 20, 0.94));
    color: #fff;
}

.tree-root-card::after {
    content: '';
    position: absolute;
    right: -40px;
    bottom: -60px;
    width: 180px;
    height: 180px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.tree-root-label,
.tree-root-subtitle {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
}

.tree-root-card h2 {
    margin: 10px 0 6px;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.tree-root-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.tree-root-meta .count-chip {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.tree-info-card {
    display: grid;
    gap: 8px;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    background: rgba(154, 77, 20, 0.06);
    border: 1px solid rgba(154, 77, 20, 0.08);
    color: var(--muted);
}

.tree-info-card strong {
    color: var(--accent-deep);
}

.tree-branch-list {
    display: grid;
    gap: 18px;
}

.tree-branch {
    position: relative;
    padding-left: 28px;
}

.tree-branch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 11px;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, rgba(154, 77, 20, 0.28), rgba(154, 77, 20, 0.08));
}

.tree-branch::after {
    content: '';
    position: absolute;
    top: 28px;
    left: 11px;
    width: 18px;
    height: 2px;
    background: rgba(154, 77, 20, 0.28);
}

.tree-member-card {
    position: relative;
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(154, 77, 20, 0.1);
    background: #fff;
    box-shadow: 0 10px 24px rgba(39, 26, 13, 0.06);
}

.tree-member-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.tree-member-link {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.tree-branch-children {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.tree-branch.depth-1,
.tree-branch.depth-2,
.tree-branch.depth-3,
.tree-branch.depth-4 {
    margin-left: 14px;
}

.tree-branch.depth-1 .tree-member-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 245, 239, 0.98));
}

.tree-branch.depth-2 .tree-member-card,
.tree-branch.depth-3 .tree-member-card,
.tree-branch.depth-4 .tree-member-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 241, 233, 0.96));
}

.tree-node-type {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.tree-node-type.surat {
    background: rgba(20, 108, 67, 0.12);
    color: var(--success);
}

.tree-node-type.vatan {
    background: rgba(154, 77, 20, 0.12);
    color: var(--accent-deep);
}

.tree-node-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.detail-card dl {
    display: grid;
    gap: 16px;
    margin: 20px 0 0;
}

.detail-card dt {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.detail-card dd {
    margin: 0;
    line-height: 1.7;
    color: var(--ink);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
}

.status-badge.success {
    background: rgba(20, 108, 67, 0.12);
    color: var(--success);
}

.status-badge.muted {
    background: rgba(30, 36, 48, 0.08);
    color: var(--muted);
}

.pager {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.pager-info {
    font-weight: 700;
    color: var(--muted);
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 6px 0;
    color: var(--muted);
    font-size: 0.92rem;
}

@media (max-width: 980px) {
    .site-header,
    .hero-card,
    .panel-grid,
    .detail-grid,
    .page-heading,
    .section-heading {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .form-grid-two,
    .form-grid-three,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card-wide {
        grid-column: auto;
    }

    .site-footer {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .site-shell {
        padding: 18px 14px 28px;
    }

    .site-header,
    .panel,
    .hero-card,
    .detail-card,
    .form-section {
        padding: 18px;
    }

    .button,
    .button-disabled {
        width: 100%;
    }

    .hero-actions,
    .form-actions,
    .search-bar,
    .table-actions,
    .member-actions,
    .tree-member-top {
        flex-direction: column;
    }

    .member-status {
        width: 100%;
    }

    .tree-root-meta,
    .tree-node-meta {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 820px) {
    .members-table {
        min-width: 0;
    }

    .members-table thead {
        display: none;
    }

    .members-table,
    .members-table tbody,
    .members-table tr,
    .members-table td {
        display: block;
        width: 100%;
    }

    .members-table tr.member-row {
        padding: 16px;
        margin-bottom: 14px;
        border-radius: var(--radius-md);
        border: 1px solid rgba(30, 36, 48, 0.08);
        background: #fff;
    }

    .members-table td {
        padding: 0 0 14px;
        border: none;
    }

    .members-table td:last-child {
        padding-bottom: 0;
    }

    .members-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        color: var(--muted);
        font-size: 0.86rem;
        font-weight: 700;
    }

    .members-table .serial-cell {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        padding: 6px 10px;
        border-radius: 999px;
        background: rgba(154, 77, 20, 0.1);
    }

    .members-table .serial-cell::before {
        margin: 0 8px 0 0;
    }

    .members-table .danger-link {
        justify-content: flex-start;
        width: 100%;
        padding: 12px 14px;
        border-radius: 14px;
        background: rgba(176, 42, 55, 0.06);
    }
}

@media print {
    body {
        background: #fff;
    }

    .page-bg,
    .print-hidden,
    .site-footer {
        display: none !important;
    }

    .site-shell {
        max-width: none;
        padding: 0;
    }

    .site-header,
    .panel,
    .hero-card,
    .detail-card,
    .form-section {
        box-shadow: none;
        background: #fff;
        border: 1px solid #ddd;
    }
}
