.graph-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
}

.graph-panel {
    overflow: hidden;
}

.control-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
}

.tool-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    border: 1px solid rgba(18, 33, 25, .11);
    border-radius: 10px;
    background: rgba(255, 255, 255, .58);
    padding: 4px;
}

.tool-label {
    padding: 0 5px 0 7px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: 0;
    white-space: nowrap;
}

.mode-group {
    background: rgba(15, 105, 72, .06);
}

.storage-group {
    margin-left: auto;
}

.chart-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.chart-meta .muted {
    margin: 0;
}

.mode-control {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--panel-soft);
    padding: 2px;
    min-height: 34px;
}

.mode-btn {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    min-height: 28px;
    padding: 0 10px;
    font-weight: 800;
    cursor: pointer;
}

.mode-btn.is-active {
    background: #fff;
    color: var(--accent-strong);
    box-shadow: 0 1px 6px rgba(23, 32, 26, .08);
}

.control-strip .btn:disabled,
.control-strip .icon-btn:disabled,
.mini-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.graph-canvas {
    position: relative;
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, #fff 0%, #f8faf7 100%);
    padding: 12px;
    width: 100%;
    height: var(--graph-canvas-height, calc(100vh - 220px));
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}

.graph-canvas.is-panning {
    cursor: grabbing;
    user-select: none;
}

.graph-pan-space {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.graph-stage {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: top left;
    will-change: transform;
}

.graph-edges,
.graph-cards {
    position: absolute;
    inset: 0;
}

.graph-edges {
    overflow: visible;
    pointer-events: auto;
}

.graph-cards {
    pointer-events: none;
}

.graph-link {
    pointer-events: none;
}

.graph-edge-halo,
.graph-edge {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    transition: stroke .16s ease, stroke-width .16s ease, opacity .16s ease;
}

.graph-edge-halo {
    stroke: rgba(255, 255, 255, .96);
    stroke-width: 8;
}

.graph-edge {
    stroke: #adbbb2;
    stroke-width: 2;
}

.graph-edge-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 18;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: stroke;
    cursor: pointer;
}

.graph-port {
    fill: #fff;
    stroke: #adbbb2;
    stroke-width: 2;
    pointer-events: none;
    transition: fill .16s ease, stroke .16s ease, opacity .16s ease;
}

.graph-link:hover .graph-edge,
.graph-link.is-related .graph-edge,
.graph-link.is-selected .graph-edge {
    stroke: var(--accent);
}

.graph-link:hover .graph-port,
.graph-link.is-related .graph-port,
.graph-link.is-selected .graph-port {
    stroke: var(--accent);
}

.graph-link.is-related .graph-edge,
.graph-link.is-related .graph-port {
    opacity: .82;
}

.graph-link.is-selected .graph-edge {
    stroke-width: 3;
    opacity: 1;
}

.graph-link.is-selected .graph-port-target {
    fill: var(--accent);
}

.graph-link.is-muted .graph-edge,
.graph-link.is-muted .graph-port {
    opacity: .32;
}

.graph-link.is-muted .graph-edge-halo {
    opacity: .62;
}

.graph-card {
    position: absolute;
    z-index: 2;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 8px;
    box-shadow: 0 8px 18px rgba(23,32,26,.06);
    cursor: grab;
    width: 176px;
    height: 66px;
    display: grid;
    align-content: center;
    overflow: hidden;
    pointer-events: auto;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.graph-card:hover,
.graph-card.is-selected,
.graph-card.is-connected,
.graph-card.is-over {
    border-color: var(--accent);
    box-shadow: 0 10px 22px rgba(23,32,26,.1);
}

.graph-card.is-connected {
    background: #fbfdfb;
}

.graph-card.is-over {
    background: var(--accent-soft);
}

.graph-card.is-dragging {
    opacity: .45;
    cursor: grabbing;
}

.graph-card-title {
    min-width: 0;
    text-align: center;
}

.graph-card-title h3,
.graph-card-title p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.graph-card-title p {
    margin-top: 2px;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.15;
}

.graph-card-meta {
    position: absolute;
    top: 5px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .68rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.graph-empty {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(360px, calc(100vw - 80px));
    min-height: 180px;
    transform: translate(-50%, -50%);
    border: 2px dashed var(--line-strong);
    border-radius: 12px;
    background: rgba(255,255,255,.78);
    color: var(--muted);
    display: grid;
    place-items: center;
    text-align: center;
    padding: 20px;
    font-weight: 800;
    pointer-events: none;
}

.graph-side .form-actions {
    align-items: stretch;
}

.layout-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.layout-actions .btn {
    min-width: 0;
}

.relation-panel {
    margin-top: 16px;
}

.inline-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.section-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.search-field {
    display: block;
    margin: 8px 0 8px;
}

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

select {
    font: inherit;
    min-width: 0;
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 7px 9px;
    background: #fff;
    color: var(--ink);
}

.relation-list,
.selected-link {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.relation-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.person-row-lite {
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    color: inherit;
    cursor: pointer;
}

.relation-row strong,
.relation-row span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.relation-row span {
    margin-top: 2px;
    color: var(--muted);
    font-size: .78rem;
}

.relation-empty {
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--muted);
    padding: 10px;
    text-align: center;
    font-size: .86rem;
}

.mini-btn {
    border: 1px solid var(--line-strong);
    background: var(--panel-soft);
    color: var(--ink);
    border-radius: 8px;
    min-height: 28px;
    padding: 0 9px;
    font-weight: 800;
    cursor: pointer;
}

.mini-btn.danger {
    color: var(--danger);
    border-color: #f0b8b1;
    background: var(--danger-soft);
}

@media (max-width: 1100px) {
    .graph-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .control-strip {
        display: grid;
        grid-template-columns: 1fr;
    }

    .tool-group {
        width: 100%;
        justify-content: flex-start;
    }

    .mode-control {
        width: 100%;
    }

    .mode-btn {
        flex: 1 1 50%;
    }

    .graph-canvas {
        min-height: 680px;
        max-height: none;
    }
}

/* V2 premium visual layer */
:root {
    --bg: #f3f5f2;
    --panel: #fbfcfa;
    --panel-soft: #f4f7f3;
    --ink: #111915;
    --muted: #647167;
    --line: #d9e0d8;
    --line-strong: #b7c4ba;
    --accent: #16724f;
    --accent-strong: #075b3d;
    --accent-soft: #e8f4ef;
    --danger: #b42318;
    --danger-soft: #fff1ef;
    --shadow: 0 22px 70px rgba(27, 39, 32, .11), 0 1px 0 rgba(255, 255, 255, .9) inset;
}

body {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .72) 0%, rgba(243, 245, 242, .88) 38%, #edf1ed 100%),
        #f3f5f2;
}

.topbar {
    padding: 22px 22px 14px;
    max-width: 1720px;
    margin: 0 auto;
}

.brand-block {
    gap: 2px;
}

.brand-home {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    width: max-content;
    color: inherit;
    text-decoration: none;
}

.brand-home img {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    filter: drop-shadow(0 8px 14px rgba(15, 95, 66, .16));
}

.product-name {
    color: var(--accent-strong);
    font-size: .72rem;
    letter-spacing: .14em;
}

.title-field input {
    color: #0d1612;
    font-size: 1.58rem;
    letter-spacing: 0;
}

.title-field input:focus {
    background: rgba(255, 255, 255, .72);
    border-color: rgba(7, 91, 61, .22);
    box-shadow: 0 12px 32px rgba(27, 39, 32, .1);
}

.top-actions {
    gap: 9px;
}

.file-actions .btn {
    min-width: 0;
}

.btn,
.icon-btn,
.mode-btn,
select,
input {
    border-radius: 9px;
}

.btn,
.icon-btn {
    min-height: 36px;
    border-color: rgba(18, 33, 25, .15);
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .92) inset, 0 8px 18px rgba(27, 39, 32, .04);
    font-weight: 760;
}

.btn:hover,
.icon-btn:hover {
    border-color: rgba(7, 91, 61, .42);
    background: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .96) inset, 0 13px 28px rgba(27, 39, 32, .1);
}

.btn.primary {
    border-color: #0d6a48;
    background: linear-gradient(180deg, #21845e 0%, #0f6948 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .23) inset, 0 13px 28px rgba(15, 105, 72, .22);
}

.btn.primary:hover {
    background: linear-gradient(180deg, #2b936b 0%, #075b3d 100%);
}

.btn.secondary {
    background: rgba(255, 255, 255, .78);
}

.btn.danger,
.mini-btn.danger {
    border-color: rgba(180, 35, 24, .2);
    background: rgba(255, 241, 239, .74);
}

.icon-btn {
    width: 36px;
    font-size: 1rem;
}

.app-layout.graph-layout {
    gap: 14px;
    padding-bottom: 22px;
}

.chart-panel,
.people-panel {
    border-color: rgba(18, 33, 25, .12);
    border-radius: 14px;
    background: rgba(255, 255, 255, .74);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.chart-panel {
    padding: 12px;
}

.people-panel {
    padding: 14px;
}

.graph-side .form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.section-actions .mini-btn {
    min-height: 26px;
    padding: 0 8px;
}

.panel-head {
    align-items: center;
}

.graph-panel > .panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.graph-panel > .panel-head .control-strip {
    justify-content: flex-start;
}

.control-strip {
    align-items: center;
}

.tool-group {
    box-shadow: 0 1px 0 rgba(255, 255, 255, .88) inset;
}

.tool-group.export-group .btn,
.tool-group.view-group .btn {
    min-width: 0;
}

.panel-head h1,
.panel-head h2,
.people-list-head h2 {
    color: #152019;
    font-weight: 850;
}

.muted,
.status {
    color: #5b6a61;
}

.storage-badge {
    min-height: 30px;
    border-color: rgba(22, 114, 79, .16);
    background: rgba(232, 244, 239, .72);
    color: #476358;
}

.mode-control {
    min-height: 36px;
    border-color: rgba(18, 33, 25, .14);
    background: rgba(15, 105, 72, .07);
    padding: 3px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset;
}

.mode-btn {
    min-height: 28px;
    padding: 0 12px;
    color: #5f6d64;
}

.mode-btn.is-active {
    color: var(--accent-strong);
    background: #fff;
    box-shadow: 0 9px 20px rgba(27, 39, 32, .1);
}

.zoom-readout {
    min-width: 48px;
    color: var(--accent-strong);
}

.graph-canvas {
    border-color: rgba(18, 33, 25, .12);
    border-radius: 13px;
    background:
        linear-gradient(rgba(21, 32, 25, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(21, 32, 25, .035) 1px, transparent 1px),
        linear-gradient(180deg, #ffffff 0%, #f8faf8 56%, #f2f6f2 100%);
    background-size: 14px 14px, 14px 14px, 100% 100%;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .94) inset, 0 22px 58px rgba(27, 39, 32, .08) inset;
}

.graph-edge-halo {
    stroke: rgba(255, 255, 255, .98);
    stroke-width: 9;
}

.graph-edge {
    stroke: #91a39a;
    stroke-width: 2.15;
}

.graph-link.is-spanning .graph-edge {
    stroke: #9fada5;
    stroke-width: 1.9;
    opacity: .82;
}

.graph-link.is-spanning .graph-port {
    opacity: .72;
}

.graph-port {
    fill: #fbfcfa;
    stroke: #8fa198;
}

.graph-card {
    border-color: rgba(20, 35, 27, .13);
    border-radius: 10px;
    background:
        linear-gradient(180deg, #ffffff 0%, #fbfcfb 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .95) inset, 0 12px 28px rgba(27, 39, 32, .11);
}

.graph-card::before {
    content: "";
    position: absolute;
    left: 9px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, #1f8a63 0%, #c8a24d 100%);
    opacity: .74;
}

.graph-card:hover,
.graph-card.is-selected,
.graph-card.is-connected,
.graph-card.is-over {
    border-color: rgba(7, 91, 61, .42);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .95) inset, 0 18px 36px rgba(27, 39, 32, .16);
}

.graph-card.is-selected {
    background: #fff;
}

.graph-card.is-connected {
    background: linear-gradient(180deg, #ffffff 0%, #f3fbf7 100%);
}

.graph-card.is-over {
    background: #edf8f2;
}

.graph-card-title {
    padding: 0 8px 0 10px;
}

.graph-card-title h3 {
    color: #121a15;
    font-size: .88rem;
    font-weight: 850;
}

.graph-card-title p {
    color: #64736a;
}

.graph-card-meta {
    top: 7px;
    right: 8px;
    background: #e9f6f0;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .88) inset;
}

label {
    color: #5e6b63;
}

input,
select {
    min-height: 38px;
    border-color: rgba(18, 33, 25, .18);
    background: rgba(255, 255, 255, .82);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset;
}

input:focus,
select:focus {
    border-color: rgba(7, 91, 61, .46);
    box-shadow: 0 0 0 4px rgba(22, 114, 79, .11);
    outline: 0;
}

.relation-panel {
    border-top: 1px solid rgba(18, 33, 25, .08);
    padding-top: 13px;
}

.people-list-head {
    color: #65746a;
}

.people-list-head span,
#manager-count {
    color: var(--accent-strong);
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.relation-row,
.person-row,
.relation-empty {
    border-color: rgba(18, 33, 25, .12);
    background: rgba(255, 255, 255, .72);
    border-radius: 10px;
}

.person-row {
    box-shadow: 0 1px 0 rgba(255, 255, 255, .88) inset;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.person-row:hover,
.person-row.is-selected {
    border-color: rgba(7, 91, 61, .34);
    background: #f4fbf7;
    box-shadow: 0 10px 20px rgba(27, 39, 32, .06);
}

.person-row strong,
.relation-row strong {
    color: #111915;
    font-weight: 850;
}

.person-row span,
.relation-row span {
    color: #68766e;
}

.relation-empty {
    background: rgba(247, 250, 247, .68);
    border-style: solid;
}

.mini-btn {
    border-color: rgba(18, 33, 25, .14);
    background: rgba(255, 255, 255, .78);
}

@media (max-width: 760px) {
    .topbar {
        padding-top: 16px;
    }

    .title-field input {
        font-size: 1.34rem;
    }

    .chart-panel,
    .people-panel {
        border-radius: 12px;
    }
}
