/* ========= 征程·财富管理 样式 ========= */
:root {
    --color-bg: #fafaf7;
    --color-surface: #ffffff;
    --color-surface-2: #f5f4ef;
    --color-border: #e6e2d8;
    --color-border-strong: #c9c3b3;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-text-soft: #9aa0a6;

    --color-primary: #0f2c4d;          /* 深海军蓝，财富管理感 */
    --color-primary-hover: #143a64;
    --color-accent: #b48a3d;           /* 暖金 */
    --color-accent-soft: #e8d9b8;
    --color-success: #2f7a3e;
    --color-danger: #b1432f;
    --color-danger-soft: #f3d8d2;

    --shadow-sm: 0 1px 2px rgba(15, 44, 77, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 44, 77, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 44, 77, 0.12);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

input[type="text"], input[type="search"], input[type="number"], input[type="date"],
input[type="email"], input[type="tel"], textarea, select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 44, 77, 0.08);
}

/* ========= 布局 ========= */
.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* LOGO：鎏金香槟晨光版自带渐变底，无需叠加背景 */
.brand-mark {
    width: 38px;
    height: 38px;
    display: block;
    object-fit: contain;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.brand-mark:hover {
    transform: scale(1.06);
    box-shadow: var(--shadow-md);
}

/* ===== 导出报告菜单 ===== */
.export-menu-wrap {
    position: relative;
    display: inline-block;
}

.export-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 5px;
    min-width: 180px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* 关键：display:flex 会盖掉 [hidden] 的 display:none，必须显式声明 */
.export-menu[hidden] {
    display: none;
}

.export-menu button {
    text-align: left;
    background: transparent;
    border: none;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    color: var(--color-text);
    white-space: nowrap;
}

.export-menu button:hover {
    background: var(--color-surface-2);
    color: var(--color-primary);
}

.brand-title h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--color-primary);
}

.brand-sub {
    font-size: 11px;
    color: var(--color-text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.app-main {
    flex: 1 1 auto;
    display: flex;
    overflow: hidden;
}

/* ========= 侧边栏 ========= */
.sidebar {
    width: 280px;
    flex: 0 0 280px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-row input {
    width: 100%;
}

.customer-list-wrap {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 8px 0;
}

.customer-list {
    list-style: none;
}

.customer-list li {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.customer-list li:hover {
    background: var(--color-surface-2);
}

.customer-list li.active {
    background: var(--color-surface-2);
    border-color: var(--color-border-strong);
}

.customer-list .cust-name {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.customer-list .cust-name .cust-pin {
    font-size: 10px;
    color: var(--color-accent);
    font-weight: 500;
    background: var(--color-accent-soft);
    padding: 2px 6px;
    border-radius: 3px;
}

.customer-list .cust-tags {
    font-size: 11px;
    color: var(--color-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.customer-list .cust-tag {
    background: var(--color-surface-2);
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid var(--color-border);
}

.sidebar-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px 20px;
    display: none;
}

.sidebar-empty p {
    font-size: 14px;
    margin-bottom: 6px;
}

.sidebar-empty span {
    font-size: 12px;
    color: var(--color-text-soft);
}

.sidebar-empty.visible {
    display: block;
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-top: 1px solid var(--color-border);
}

.storage-status {
    font-size: 11px;
    color: var(--color-text-soft);
    letter-spacing: 0.3px;
}

/* ========= 工作区 ========= */
.workspace {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.empty-state {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    gap: 12px;
}

.empty-mark {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 44px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    overflow: hidden;   /* 圆角裁掉内里 img 的尖角 */
    opacity: 0.95;
}

.empty-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
}

.empty-state h2 {
    font-size: 22px;
    font-weight: 500;
    color: var(--color-text);
}

.empty-state.hidden { display: none; }

/* ========= 客户视图 ========= */
.customer-view {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.customer-header {
    padding: 16px 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.customer-title h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.customer-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tag {
    font-size: 11px;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 500;
}

.updated-at {
    font-size: 11px;
    color: var(--color-text-soft);
}

.customer-actions {
    display: flex;
    gap: 6px;
}

/* ========= Tabs ========= */
.tabs {
    display: flex;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 24px;
}

.tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
    margin-right: 8px;
}

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

.tab.tab-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-accent);
}

.tab-content {
    flex: 1 1 auto;
    overflow: auto;
}

.tab-pane {
    padding: 24px;
}

.tab-pane.tab-pane-active {
    display: block;
}

.tab-pane[hidden] {
    display: none;
}

/* ========= KYC 表单 ========= */
.kyc-form {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.kyc-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.section-header {
    padding: 12px 16px;
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    letter-spacing: 0.3px;
}

.section-header .section-meta {
    font-size: 11px;
    color: var(--color-text-soft);
}

.section-body {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.section-body .full-row {
    grid-column: 1 / -1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    letter-spacing: 0.2px;
}

.field-label em {
    color: var(--color-danger);
    font-style: normal;
    margin-left: 2px;
}

.field-hint {
    font-size: 11px;
    color: var(--color-text-soft);
    margin-top: 2px;
}

.field-age-hint {
    font-size: 11px;
    color: var(--color-accent, #b48a3d);
    margin-top: 2px;
    font-weight: 600;
    min-height: 0;
}

.section-body textarea {
    min-height: 80px;
    resize: vertical;
}

/* ========= 家族树 ========= */
.family-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.family-toolbar .toolbar-info {
    font-size: 12px;
    color: var(--color-text-muted);
}

.family-toolbar .toolbar-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.family-canvas-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: calc(100vh - 280px);
    min-height: 500px;
    position: relative;
}

.family-canvas {
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle, var(--color-border) 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: var(--color-bg);
    position: relative;
    overflow: auto;
}

.family-canvas.dragging {
    cursor: grabbing;
}

/* 缩放结构：sizer 占位（内容尺寸 × zoom），inner 被缩放 */
.family-sizer {
    position: relative;
}

.family-inner {
    position: relative;
    transform-origin: 0 0;
}

.family-toolbar .zoom-label {
    font-size: 12px;
    color: var(--color-text-muted);
    min-width: 38px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.family-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.family-node {
    position: absolute;
    background: var(--color-surface);
    border: 2px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    min-width: 120px;
    min-height: 64px;
    cursor: grab;
    user-select: none;
    box-shadow: var(--shadow-sm);
    z-index: 2;
    transition: box-shadow 0.15s, border-color 0.15s;
}

/* 右下角拉伸手柄 */
.family-node-resize {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.1s;
    background: linear-gradient(135deg, transparent 50%, var(--color-primary) 50%);
    border-bottom-right-radius: 4px;
    z-index: 3;
}

.family-node:hover .family-node-resize {
    opacity: 0.85;
}

.family-node:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.family-node.dragging {
    cursor: grabbing;
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent);
    z-index: 10;
}

.family-node.is-main {
    border-color: var(--color-accent);
    background: linear-gradient(135deg, #fff, var(--color-accent-soft));
}

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

/* 客户本人金色星标 */
.family-node-star {
    color: var(--color-accent);
    margin-left: 4px;
    font-size: 14px;
    text-shadow: 0 0 6px rgba(180, 138, 61, 0.45);
}

/* 备注亮点标签（金底小签，随节点显示） */
.family-node-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 5px;
    max-width: 100%;
}

.family-node-tag {
    display: inline-block;
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent);
    color: #7a5a1e;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 10px;
    line-height: 16px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 编辑弹窗里的快捷标签按钮 */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.quick-tag {
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text-muted);
    border-radius: 10px;
    padding: 2px 9px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.12s;
}

.quick-tag:hover {
    border-color: var(--color-accent);
    color: #7a5a1e;
}

.quick-tag.active {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: #7a5a1e;
    font-weight: 600;
}

.family-node-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.family-node-relation {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    margin-top: 4px;
}

.family-node-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.1s;
}

.family-node:hover .family-node-actions {
    opacity: 1;
}

.family-node-action {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.family-node-action:hover {
    background: var(--color-surface-2);
    border-color: var(--color-border-strong);
}

.family-node-action.delete:hover {
    background: var(--color-danger-soft);
    border-color: var(--color-danger);
    color: var(--color-danger);
}

.family-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.family-empty p {
    font-size: 13px;
}

.family-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 11px;
    color: var(--color-text-muted);
    z-index: 5;
}

.family-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.family-legend .legend-item:last-child { margin-bottom: 0; }

.legend-line {
    display: inline-block;
    width: 24px;
    height: 2px;
}

/* 关系选择器 */
.relation-picker {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 4px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    min-width: 100px;
}

.relation-picker.visible { display: flex; }

.relation-picker-btn {
    padding: 6px 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    border-radius: 3px;
    font-size: 12px;
}

.relation-picker-btn:hover {
    background: var(--color-surface-2);
}

/* ========= 按钮 ========= */
.btn {
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
    background: var(--color-surface);
    color: var(--color-text);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn-ghost {
    background: transparent;
    border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-2); }

.btn-danger {
    background: transparent;
    color: var(--color-danger);
    border-color: var(--color-border);
}
.btn-danger:hover { background: var(--color-danger-soft); border-color: var(--color-danger); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
}

/* ========= 模态框 ========= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 44, 77, 0.4);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 420px;
    max-height: calc(100vh - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.modal-close:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.form-hint {
    font-size: 12px;
    color: var(--color-text-muted);
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--color-surface-2);
}

/* ========= Toast ========= */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    box-shadow: var(--shadow-md);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s;
}

.toast.visible {
    opacity: 1;
}

/* ========= 家族树 - 线条 & 节点增强 ========= */
.family-line {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 2;
    cursor: pointer;
    pointer-events: stroke;
    transition: stroke 0.15s;
}

.family-line:hover {
    stroke: var(--color-accent);
    stroke-width: 3;
}

.family-line.line-solid {
    stroke-dasharray: none;
}

.family-line.line-dashed {
    stroke-dasharray: 6 4;
}

.family-line.line-auto {
    /* 自动生成线 - 默认隐藏鼠标光标，只在hover时交互 */
    pointer-events: stroke;
}

.family-line-label {
    fill: var(--color-text-muted);
    font-size: 10px;
    font-family: var(--font-sans);
    paint-order: stroke;
    stroke: var(--color-bg);
    stroke-width: 3;
    stroke-linejoin: round;
    pointer-events: none;
}

/* 宽幅透明命中区：解决细线点不中 */
.family-line-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 16;
    pointer-events: stroke;
    cursor: pointer;
}

/* 框选选中的连线 */
.family-line.line-selected {
    stroke: var(--color-accent);
    stroke-width: 3;
}

/* 对齐工具条（框选 ≥2 节点时出现于画布底部中央） */
.family-align-bar {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 60;
    max-width: calc(100% - 32px);
    flex-wrap: wrap;
    justify-content: center;
}

.family-align-bar button {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-sans);
    color: var(--color-text);
    white-space: nowrap;
}

.family-align-bar button:hover {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

/* 已故节点样式 */
.family-node.is-deceased {
    border-style: dashed;
    background: linear-gradient(135deg, #fbfaf6, #f0ebe0);
}

.family-node.is-deceased .family-node-name {
    color: var(--color-text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--color-text-soft);
}

/* 画线模式下：选中起始节点 */
.family-node.line-start {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-soft);
    animation: pulse-line-start 1.2s ease-in-out infinite;
}

@keyframes pulse-line-start {
    0%, 100% { box-shadow: 0 0 0 4px var(--color-accent-soft); }
    50% { box-shadow: 0 0 0 8px rgba(180, 138, 61, 0.15); }
}

/* 画线模式画布光标 */
.family-canvas.draw-mode {
    cursor: crosshair;
}

.family-canvas.draw-mode .family-node {
    cursor: crosshair;
}

.family-canvas.draw-mode .family-node-resize {
    cursor: nwse-resize;
}

/* 抓取平移 */
.family-canvas.pan-mode {
    cursor: grab;
}

.family-canvas.pan-mode.panning {
    cursor: grabbing;
}

/* 框选多选 */
.family-node.selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.family-select-box {
    position: absolute;
    border: 1px dashed var(--color-accent);
    background: var(--color-accent-soft);
    opacity: 0.6;
    z-index: 40;
    pointer-events: none;
}

/* 单击节点 → 四边"＋"连线手柄 */
.family-node-port {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    font-size: 15px;
    line-height: 20px;
    text-align: center;
    cursor: crosshair;
    display: none;
    z-index: 5;
    user-select: none;
    box-shadow: var(--shadow-sm);
    font-family: var(--font-sans);
}

.family-node.active .family-node-port {
    display: block;
}

.family-node-port:hover {
    background: var(--color-primary);
    color: #fff;
}

.port-top { top: -12px; left: 50%; margin-left: -11px; }
.port-bottom { bottom: -12px; left: 50%; margin-left: -11px; }
.port-left { left: -12px; top: 50%; margin-top: -11px; }
.port-right { right: -12px; top: 50%; margin-top: -11px; }

/* 画线模式下隐藏手柄，避免干扰 */
.family-canvas.draw-mode .family-node-port {
    display: none;
}

/* 单击激活的节点给个描边提示 */
.family-node.active {
    border-color: var(--color-primary);
}

/* 关系选择器 - 分组分类 */
.relation-categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 280px;
    overflow-y: auto;
    padding: 2px;
}

.relation-category {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.relation-cat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0 4px;
}

.relation-cat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.relation-cat-btn {
    padding: 6px 14px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text);
    transition: all 0.1s;
}

.relation-cat-btn:hover {
    background: var(--color-surface-2);
    border-color: var(--color-border-strong);
}

.relation-cat-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* 人物详情小弹窗（线编辑） */
.line-editor {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
    font-size: 12px;
}

.line-editor-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.line-editor-row button {
    padding: 4px 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.line-editor-row button:hover {
    background: var(--color-surface-2);
}

.line-editor-row button.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.line-editor-row input[type="text"] {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-size: 12px;
}

.line-editor .line-delete-btn {
    background: transparent;
    color: var(--color-danger);
    border-color: var(--color-border);
    width: 100%;
    justify-content: center;
    display: flex;
}

.line-editor .line-delete-btn:hover {
    background: var(--color-danger-soft);
    border-color: var(--color-danger);
}

.line-editor-meta {
    font-size: 11px;
    color: var(--color-text-soft);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--color-border);
}

/* Toggle 按钮组 */
.toggle-group {
    display: inline-flex;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
    width: fit-content;
}

.toggle-btn {
    padding: 6px 14px;
    background: var(--color-surface);
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text);
    transition: background 0.1s;
}

.toggle-btn + .toggle-btn {
    border-left: 1px solid var(--color-border);
}

.toggle-btn:hover {
    background: var(--color-surface-2);
}

.toggle-btn.active {
    background: var(--color-primary);
    color: white;
}

/* 提示条 */
.hint-banner {
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent);
    color: #6b5320;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hint-banner .hint-close {
    margin-left: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #6b5320;
}

/* Modal 大尺寸 */
.modal-content.modal-lg {
    max-width: 540px;
}

/* ========= Scrollbar ========= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-soft); }

/* ========= 响应式 ========= */
@media (max-width: 720px) {
    .app-main { flex-direction: column; }
    .sidebar { width: 100%; flex: 0 0 auto; max-height: 40vh; }
    .section-body { grid-template-columns: 1fr; }
    .relation-categories { max-height: 200px; }
}
/* ========= v1.1 家庭三张报表 + 指标 + 配置设计 ========= */
.ledger-table { display: flex; flex-direction: column; gap: 4px; }

.ledger-row {
    display: grid;
    grid-template-columns: 52px 110px 1fr 130px 1fr;
    gap: 8px;
    align-items: center;
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.ledger-row .lg-group {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-primary);
    background: var(--color-primary-soft, rgba(28, 43, 74, 0.08));
    border-radius: 4px;
    padding: 4px 2px;
    text-align: center;
}

.ledger-row .lg-label { font-size: 12px; font-weight: 600; color: var(--color-text); }
.ledger-row .lg-detail { font-size: 11px; color: var(--color-text-muted); }
.ledger-row .lg-note { font-size: 11px; }

.ledger-row input.lg-amount {
    font-weight: 600;
    color: var(--color-primary);
    text-align: right;
}

.ledger-total { background: var(--color-accent-soft); border-color: var(--color-accent); }
.ledger-total .lg-label { color: var(--color-primary); }
.ledger-total .lg-amount { font-size: 13px; font-weight: 700; color: var(--color-accent); text-align: right; padding-right: 4px; }
.ledger-total.net { background: rgba(46, 125, 50, 0.08); border-color: rgba(46, 125, 50, 0.4); }
.ledger-total.net .lg-amount { color: #2e7d32; }

/* 收支表占比列 */
.ledger-total .lg-pct { font-weight: 600; color: var(--color-primary); text-align: right; }

/* 现金流量表：横向年份列 */
.cf-table { display: flex; flex-direction: column; gap: 4px; overflow-x: auto; }

.cf-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.cf-row .cf-label {
    flex: 0 0 128px;
    display: flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-primary-soft, rgba(28, 43, 74, 0.08));
    border-radius: 4px;
    padding: 6px 8px;
}

.cf-row .cf-cell {
    flex: 1 1 0;
    min-width: 150px;
}

.cf-row input { width: 100%; }
.cf-head .cf-cell input { font-weight: 700; color: var(--color-accent); }
.cf-net .cf-cell {
    background: var(--color-accent-soft);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
}

/* 财务指标分析 */
.ind-row {
    display: grid;
    grid-template-columns: 170px 90px 1fr;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    align-items: center;
    margin-bottom: 6px;
}

.ind-row.ind-head {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    border: none;
    padding: 8px 12px;
}

/* 资产配置顶层设计四账户表 */
.alloc-table { display: flex; flex-direction: column; gap: 4px; }

.alloc-row {
    display: grid;
    grid-template-columns: 110px 1.1fr 1.3fr 1.1fr 150px;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    font-size: 12px;
    align-items: center;
}

.alloc-row > div { line-height: 1.6; color: var(--color-text); }
.alloc-row.alloc-head {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    border: none;
    padding: 8px 12px;
}
.alloc-row.alloc-head > div { color: #fff; }

.alloc-row.alloc-star {
    border: 2px solid var(--color-accent);
    background: var(--color-accent-soft);
    box-shadow: 0 1px 6px rgba(180, 138, 61, 0.18);
}
.alloc-row.alloc-star > div:first-child { color: var(--color-accent); }

@media (max-width: 760px) {
    .ledger-row { grid-template-columns: 40px 90px 1fr 100px; }
    .ledger-row .lg-detail { display: none; }
    .ind-row { grid-template-columns: 120px 70px 1fr; gap: 8px; }
    .alloc-row { grid-template-columns: 1fr 1fr; }
}
