/* Family ownership tree: Components/Common/FamilyOwnershipTree.razor + wwwroot/js/family-tree.js,
   used by the Family Tree page (Components/Pages/FamilyTree.razor) and the Entity Ownership report.
   Global rather than scoped: the cards are created by JavaScript, which scoped CSS can't reach.
   Every class is "fot-" prefixed so it can't collide with other pages. Colours come from
   forest-design-tokens.css. */
.fot-page, .fot-tree {
    --fot-individual: var(--forest-500, #2D7D32);
    --fot-individual-soft: var(--forest-active-bg, #E8F5E9);
    --fot-business: var(--forest-slate-500, #4E699A);
    --fot-business-soft: var(--forest-view-bg, #E8EDF6);
    --fot-root: var(--forest-900, #1B5E20);
    --fot-sub: var(--forest-600, #2D7D32);
    --fot-ink: var(--forest-ink, #1B241D);
    --fot-muted: var(--forest-ink-soft, #5C655D);
    --fot-faint: var(--forest-ink-faint, #8B9089);
    --fot-line: var(--forest-border, #E1E4DE);
    --fot-edge: #C3CEC5;
    --fot-surface: var(--forest-surface, #FFFFFF);
    --fot-ground: #F6F8F5;
    --fot-dot: #E1E7DF;
    --fot-gold: var(--forest-gold-500, #B8873F);
    --fot-gold-soft: #F6EEDF;
    --fot-neg: #A33A2A;
    color: var(--fot-ink);
    font-family:var(--fw-font-sans);
}

/* ── Family Tree page shell ─────────────────────────────────────────────── */
.fot-page {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 14px;
    height: calc(100vh - 96px);
    min-height: 600px;
    padding: 16px 20px;
    box-sizing: border-box;
}
.fot-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.fot-head h1 { font-family:var(--fw-font-sans); font-weight: 500; font-size: 24px; margin: 0 auto 0 0; letter-spacing: -.01em; }
.fot-back { font-size: 12.5px; font-weight: 600; color: var(--fot-muted); text-decoration: none; white-space: nowrap; }
.fot-back:hover { color: var(--fot-ink); text-decoration: underline; }
.fot-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.fot-field { display: flex; align-items: center; gap: 8px; }
.fot-field label, .fot-lbl { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--fot-muted); }
.fot-lbl { display: block; margin-bottom: 8px; }
.fot-controls select, .fot-controls input[type="date"] {
    font: inherit; font-size: 13px; color: var(--fot-ink); background: var(--fot-surface);
    border: 1px solid var(--fot-line); border-radius: 8px; padding: 6px 10px;
}
.fot-message { padding: 24px; color: var(--fot-muted); background: var(--fot-surface); border: 1px solid var(--fot-line); border-radius: 12px; }
.fot-message.fot-error { color: var(--fot-neg); }

/* ── Tree component ─────────────────────────────────────────────────────── */
.fot-tree { display: grid; grid-template-rows: auto 1fr; gap: 12px; height: 100%; min-height: 0; }

/* One slim bar: figures on the left, view toggles + search on the right. */
.fot-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
    padding: 10px 14px; background: var(--fot-surface); border: 1px solid var(--fot-line); border-radius: 12px;
}
.fot-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 26px; }
.fot-stat { display: flex; flex-direction: column; gap: 1px; }
.fot-stat b { font-family:var(--fw-font-sans); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.fot-stat span { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--fot-muted); font-weight: 600; }
.fot-asof { font-size: 12px; color: var(--fot-muted); align-self: center; }
.fot-warn { color: var(--fot-gold); font-weight: 600; }
.fot-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.fot-chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--fot-muted);
    border: 1px solid var(--fot-line); border-radius: 999px; padding: 4px 11px; cursor: pointer; user-select: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.fot-chip input { position: absolute; opacity: 0; pointer-events: none; }
.fot-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fot-line); transition: background .15s ease; }
.fot-chip:has(input:checked) { background: var(--fot-individual-soft); border-color: var(--fot-individual); color: var(--forest-700, #1B5E20); }
.fot-chip:has(input:checked)::before { background: var(--fot-individual); }
.fot-chip:has(input:focus-visible) { outline: 2px solid var(--fot-individual); outline-offset: 2px; }
.fot-search {
    width: 190px; font: inherit; font-size: 13px; color: var(--fot-ink); background: var(--fot-ground);
    border: 1px solid var(--fot-line); border-radius: 999px; padding: 5px 12px;
}
.fot-search:focus { outline: none; border-color: var(--fot-individual); background: var(--fot-surface); }

.fot-work { display: grid; grid-template-columns: 1fr 300px; gap: 12px; min-height: 0; }
.fot-viewport {
    position: relative; overflow: hidden; min-height: 440px;
    background: radial-gradient(circle at 1px 1px, var(--fot-dot) 1px, transparent 1.3px) 0 0 / 20px 20px, var(--fot-ground);
    border: 1px solid var(--fot-line); border-radius: 12px; cursor: grab; touch-action: none;
}
.fot-viewport:active { cursor: grabbing; }
.fot-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.fot-edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.fot-edges path { fill: none; stroke: var(--fot-edge); stroke-linecap: round; transition: d .35s ease, stroke-width .35s ease, stroke .15s ease; }
.fot-edges path.fot-hl { stroke: var(--fot-individual); }
.fot-edges path.fot-zero { stroke-dasharray: 3 5; }

/* Cards */
.fot-node {
    position: absolute; left: 0; top: 0; width: 232px; box-sizing: border-box;
    background: var(--fot-surface); border: 1px solid var(--fot-line); border-radius: 12px;
    padding: 11px 13px 12px; box-shadow: 0 1px 2px rgba(22,40,30,.05), 0 6px 18px rgba(22,40,30,.06);
    cursor: pointer; display: grid; gap: 5px;
    transition: transform .35s ease, opacity .35s ease, border-color .15s ease, box-shadow .15s ease;
}
.fot-node:hover { border-color: var(--fot-edge); box-shadow: 0 2px 4px rgba(22,40,30,.06), 0 10px 24px rgba(22,40,30,.09); }
.fot-node:focus-visible { outline: 2px solid var(--fot-individual); outline-offset: 3px; }
.fot-node.fot-sel { border-color: var(--fot-individual); box-shadow: 0 0 0 2px var(--fot-individual), 0 10px 24px rgba(22,40,30,.1); }
.fot-node.fot-hit { box-shadow: 0 0 0 3px #EFCB4F, 0 10px 24px rgba(22,40,30,.1); }
.fot-node.fot-dim { opacity: .38; }
.fot-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.fot-icon { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.fot-icon svg { width: 13px; height: 13px; }
.fot-type { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fot-faint); }
.fot-also { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--fot-gold); background: var(--fot-gold-soft); padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.fot-name { font-family:var(--fw-font-sans); font-weight: 500; font-size: 15.5px; line-height: 1.22; overflow-wrap: anywhere; }
.fot-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--fot-muted); }
.fot-mono { font-family:var(--fw-font-sans); font-variant-numeric: tabular-nums; color: var(--fot-ink); font-weight: 500; }
.fot-mono.fot-neg { color: var(--fot-neg); }
.fot-bar-track { height: 3px; border-radius: 999px; background: #EDF1EC; overflow: hidden; margin-top: 2px; }
.fot-bar-track i { display: block; height: 100%; border-radius: 999px; transition: width .35s ease; }

.fot-k-individual .fot-icon { background: var(--fot-individual-soft); color: var(--fot-individual); }
.fot-k-individual .fot-bar-track i { background: var(--fot-individual); }
.fot-k-business .fot-icon { background: var(--fot-business-soft); color: var(--fot-business); }
.fot-k-business .fot-bar-track i { background: var(--fot-business); }

/* Sub-family: soft green card. */
.fot-k-family { background: #F3F8F3; border-color: #CFE0D2; }
.fot-k-family .fot-icon { background: var(--fot-sub); color: #fff; }
.fot-k-family .fot-bar-track i { background: var(--fot-sub); }
.fot-k-family .fot-bar-track { background: #E0EBE1; }

/* The family being viewed: dark forest card that anchors the tree. */
.fot-k-family.fot-root { background: var(--fot-root); border-color: var(--fot-root); color: #fff; box-shadow: 0 8px 22px rgba(22,40,30,.22); }
.fot-root .fot-icon { background: rgba(255,255,255,.14); color: #fff; }
.fot-root .fot-type, .fot-root .fot-meta { color: rgba(255,255,255,.72); }
.fot-root .fot-mono { color: #fff; }
.fot-root .fot-mono.fot-neg { color: #F4A99C; }
.fot-root.fot-sel { box-shadow: 0 0 0 2px #9FD3A8, 0 8px 22px rgba(22,40,30,.22); }

.fot-fold {
    margin-left: auto; font: 600 11px var(--fw-font-sans); color: var(--fot-sub); background: #fff;
    border: 1px solid #CFE0D2; border-radius: 999px; padding: 2px 9px; cursor: pointer;
}
.fot-pill {
    position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
    font: 600 11px var(--fw-font-sans); font-variant-numeric: tabular-nums;
    background: var(--fot-surface); color: var(--fot-muted); border: 1px solid var(--fot-line);
    padding: 2px 8px; border-radius: 999px; white-space: nowrap; pointer-events: none;
    box-shadow: 0 1px 2px rgba(22,40,30,.05);
    transition: left .35s ease, top .35s ease;
}

.fot-zoombar {
    position: absolute; left: 12px; bottom: 12px; display: flex; overflow: hidden;
    background: var(--fot-surface); border: 1px solid var(--fot-line); border-radius: 10px; box-shadow: 0 1px 3px rgba(22,40,30,.06);
}
.fot-zoombar button { font: 600 13px var(--fw-font-sans); color: var(--fot-ink); background: none; border: 0; padding: 6px 12px; cursor: pointer; }
.fot-zoombar button + button { border-left: 1px solid var(--fot-line); }
.fot-zoombar button:hover { background: var(--fot-ground); }
.fot-legend {
    position: absolute; right: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px 14px;
    background: rgba(255,255,255,.92); border: 1px solid var(--fot-line); border-radius: 10px; padding: 6px 11px;
    font-size: 11.5px; color: var(--fot-muted); max-width: calc(100% - 200px);
}
.fot-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fot-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.fot-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--fot-muted); font-size: 14px; padding: 20px; text-align: center; }
.fot-state.fot-error { color: var(--fot-neg); }

/* Details panel */
.fot-panel {
    background: var(--fot-surface); border: 1px solid var(--fot-line); border-radius: 12px;
    padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 16px;
}
.fot-panel h2 { font-family:var(--fw-font-sans); font-weight: 500; font-size: 19px; margin: 2px 0 0; line-height: 1.2; }
.fot-sub { color: var(--fot-muted); font-size: 12.5px; margin-top: 4px; }
.fot-kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 13px; margin: 0; padding: 12px 0; border-top: 1px solid var(--fot-line); border-bottom: 1px solid var(--fot-line); }
.fot-kv dt { color: var(--fot-muted); }
.fot-kv dd { margin: 0; font-family:var(--fw-font-sans); font-variant-numeric: tabular-nums; text-align: right; }
.fot-hist { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fot-hist th { text-align: left; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--fot-muted); font-weight: 600; padding: 0 0 6px; border-bottom: 1px solid var(--fot-line); }
.fot-hist td { padding: 7px 0; border-bottom: 1px solid var(--fot-line); font-family:var(--fw-font-sans); font-variant-numeric: tabular-nums; }
.fot-hist td:last-child, .fot-hist th:last-child { text-align: right; }
.fot-hist tr.fot-now td { color: var(--fot-individual); font-weight: 600; }
.fot-note { font-size: 12px; line-height: 1.5; color: var(--fot-muted); background: var(--fot-ground); border-radius: 8px; padding: 10px 12px; }
.fot-empty { color: var(--fot-muted); font-size: 13px; }
.fot-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 13px; }
.fot-members li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; }
.fot-members li span:nth-child(2) { font-family:var(--fw-font-sans); font-variant-numeric: tabular-nums; color: var(--fot-muted); }
.fot-members li i { grid-column: 1 / -1; height: 3px; border-radius: 999px; background: #EDF1EC; overflow: hidden; }
.fot-members li i b { display: block; height: 100%; background: var(--fot-individual); border-radius: 999px; }
.fot-btn {
    font: 600 13px var(--fw-font-sans); color: #fff; background: var(--forest-600, #2D7D32);
    border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; margin-top: auto;
}
.fot-btn:hover { background: var(--forest-700, #1B5E20); }

/* ── Entity Ownership report: Tree view container + segmented switches ─── */
.fot-report-tree { height: calc(100vh - 222px); min-height: 560px; }
.fot-scope-hint { margin: -6px 2px 12px; font-size: 12.5px; color: #666; }
.fot-viewswitch { display: inline-flex; border: 1px solid #ddd; border-radius: 5px; overflow: hidden; background: #fafafa; }
.fot-viewswitch button {
    font: 600 13px var(--fw-font-sans); padding: 6px 13px; border: 0; cursor: pointer;
    background: transparent; color: #555; line-height: 1.25;
}
.fot-viewswitch button + button { border-left: 1px solid #ddd; }
.fot-viewswitch button.active { background: #e8f5e9; color: #1b5e20; }
.fot-viewswitch button:focus-visible { outline: 2px solid #2d7d32; outline-offset: -2px; }

@media (max-width: 900px) {
    .fot-page, .fot-tree, .fot-report-tree { height: auto; }
    .fot-tools { margin-left: 0; }
    .fot-search { width: 100%; }
    .fot-work { grid-template-columns: 1fr; }
    .fot-viewport { height: 68vh; }
    .fot-legend { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .fot-node, .fot-pill, .fot-edges path, .fot-bar-track i, .fot-chip { transition: none; }
}
