:root {
    --primary-organic: #38B2AC;
    --primary-dark: #2C9E98;
    --secondary-branch: #D69E2E;
    --bg-natural: #FDFCFB;
    --surface: #f7f9f8;
    --surface-strong: #edf0ee;
    --text-root: #2D3748;
    --text-muted: #5f6a78;
    --shadow-soft: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 12px 24px rgba(0, 0, 0, 0.08);
    --radius-xl: 20px;
    --radius-lg: 16px;
    --transition-fluid: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background:
        radial-gradient(circle at 10% 10%, rgba(56, 178, 172, 0.08), transparent 35%),
        radial-gradient(circle at 85% 20%, rgba(214, 158, 46, 0.06), transparent 32%),
        linear-gradient(180deg, #FDFCFB 0%, #f7f9f8 100%);
    color: var(--text-root);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    min-height: 100vh;
}

.bg-primary-custom {
    background: linear-gradient(120deg, #2C9E98 0%, #38B2AC 100%) !important;
}

.text-primary-custom {
    color: var(--primary-organic) !important;
}

.navbar-brand {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand img {
    height: 28px;
    width: auto;
}

.icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.bg-success-light {
    background-color: #d4edda;
}

.bg-primary-light {
    background-color: rgba(56, 178, 172, 0.1);
}

.card {
    transition: var(--transition-fluid);
    border-radius: var(--radius-lg);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.photo-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    overflow: hidden;
}

.photo-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.employee-card {
    transition: box-shadow 0.2s;
}

.employee-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.config-panel {
    position: sticky;
    top: 70px;
}

.form-range::-webkit-slider-thumb {
    background: var(--primary-organic);
}

.btn-primary {
    background-color: var(--primary-organic);
    border-color: var(--primary-organic);
    border-radius: var(--radius-xl);
}

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

.btn-outline-primary {
    color: var(--primary-organic);
    border-color: var(--primary-organic);
    border-radius: var(--radius-xl);
}

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

.preview-v2 {
    position: relative;
    min-height: calc(100vh - 95px);
    padding-bottom: 72px;
}

.toolbar-shell {
    position: sticky;
    top: 12px;
    z-index: 60;
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(260px, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(45, 55, 72, 0.08);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    animation: toolbar-enter 0.35s ease;
}

@keyframes toolbar-enter {
    from {
        transform: translateY(-8px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #38B2AC 0%, #D69E2E 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 8px 14px rgba(56, 178, 172, 0.28);
}

.toolbar-brand h1 {
    margin: 0;
    font: 700 1rem/1.1 'Inter', sans-serif;
    color: var(--text-root);
}

.toolbar-brand p {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.toolbar-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border: 1px solid rgba(45, 55, 72, 0.14);
    border-radius: 12px;
    background: #fff;
}

.toolbar-search i {
    color: #6f7c8b;
}

.toolbar-search input {
    width: 100%;
    height: 42px;
    border: 0;
    outline: 0;
    font-size: 0.92rem;
    background: transparent;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: none;
    border: 1px solid rgba(45, 55, 72, 0.12);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-soft);
    max-height: 360px;
    overflow: auto;
    z-index: 80;
}

.search-results.is-open {
    display: block;
}

.search-results button {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #eef2f0;
    background: #fff;
    text-align: left;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-results button:hover {
    background: #f5f9f8;
}

.search-results button strong {
    font-size: 0.87rem;
    color: var(--text-root);
}

.search-results button small {
    font-size: 0.76rem;
    color: #637285;
}

.search-empty {
    padding: 12px;
    color: #7e8a99;
    font-size: 0.84rem;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-shell,
.btn-primary-shell,
.btn-success-shell,
.btn-secondary-shell {
    border-radius: var(--radius-xl);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fluid);
}

.btn-shell {
    background: #fff;
    border-color: rgba(45, 55, 72, 0.16);
    color: var(--text-root);
}

.btn-shell:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.btn-shell.is-active-toggle {
    background: var(--primary-organic);
    color: #fff;
    border-color: var(--primary-organic);
}

.org-node-card.span-alert-high {
    box-shadow: 0 0 0 2.5px rgba(229, 62, 62, 0.5), 0 5px 10px rgba(0, 0, 0, 0.08) !important;
}

.org-node-card.span-alert-low {
    box-shadow: 0 0 0 2.5px rgba(214, 158, 46, 0.5), 0 5px 10px rgba(0, 0, 0, 0.08) !important;
}

.btn-primary-shell {
    background: linear-gradient(130deg, #2C9E98 0%, #38B2AC 100%);
    color: #fff;
    box-shadow: 0 10px 20px rgba(56, 178, 172, 0.24);
}

.btn-primary-shell:hover,
.btn-success-shell:hover,
.btn-secondary-shell:hover {
    transform: translateY(-1px);
}

.btn-success-shell {
    background: linear-gradient(130deg, #2C9E98 0%, #38B2AC 100%);
    color: #fff;
    box-shadow: 0 10px 18px rgba(56, 178, 172, 0.24);
}

.btn-outline-shell {
    background: transparent;
    color: #5a6f86;
    border: 1px solid #d4dce5;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition-fluid);
}
.btn-outline-shell:hover {
    background: var(--surface);
    border-color: var(--primary-organic);
    color: var(--primary-organic);
}

.btn-secondary-shell {
    width: 100%;
    justify-content: flex-start;
    color: var(--text-root);
    border: 1px solid rgba(45, 55, 72, 0.16);
    background: #fff;
}

.org-chart-stage {
    height: calc(100vh - 205px);
    margin-top: 12px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(45, 55, 72, 0.08);
    background: linear-gradient(180deg, #FDFCFB 0%, #f5f7f6 100%);
    box-shadow: inset 0 1px 0 #fff, var(--shadow-soft);
    overflow: hidden;
}

.org-chart-stage,
.org-chart-stage * {
    -webkit-user-select: none;
    user-select: none;
}

.chart-error {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: #637286;
}

.chart-error i {
    font-size: 2rem;
}

.stats-bar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 12px;
    z-index: 65;
    width: min(1180px, calc(100vw - 24px));
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(45, 55, 72, 0.9);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.stats-item {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #d6e2f1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stats-item span {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stats-item strong {
    font-size: 1rem;
    color: #fff;
}

.config-drawer {
    position: fixed;
    right: -360px;
    top: 0;
    width: 340px;
    height: 100vh;
    z-index: 90;
    padding: 22px 18px;
    border-left: 1px solid rgba(45, 55, 72, 0.12);
    background: var(--bg-natural);
    box-shadow: -14px 0 28px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    overflow-y: auto;
}

.config-drawer.is-open {
    right: 0;
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(45, 55, 72, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.drawer-overlay.is-open {
    opacity: 1;
    pointer-events: all;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.drawer-header h2 {
    margin: 0;
    font: 700 1.05rem/1.2 'Inter', sans-serif;
}

.btn-close-shell {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: var(--surface-strong);
    color: var(--text-root);
}

.config-drawer section {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(45, 55, 72, 0.11);
    background: #fff;
    margin-bottom: 12px;
}

.config-drawer h3 {
    margin: 0 0 10px;
    font: 700 0.86rem/1.2 'Inter', sans-serif;
    text-transform: uppercase;
    color: var(--text-root);
}

.segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.segmented button {
    border: 1px solid rgba(56, 178, 172, 0.18);
    background: #f3f7f6;
    border-radius: 9px;
    padding: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-root);
}

.segmented button.is-active {
    background: var(--primary-organic);
    border-color: var(--primary-organic);
    color: #fff;
}

.palette-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.palette-option {
    border: 1px solid rgba(45, 55, 72, 0.16);
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-root);
}

.palette-option.is-active {
    border-color: var(--primary-organic);
    box-shadow: 0 0 0 2px rgba(56, 178, 172, 0.12);
}

.palette-swatches {
    display: inline-flex;
    gap: 4px;
}

.palette-swatches i {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.label-shell {
    display: block;
    margin-bottom: 5px;
    font-size: 0.79rem;
    font-weight: 700;
    color: var(--text-root);
}

.field-shell,
.range-shell {
    width: 100%;
    margin-bottom: 10px;
}

.field-shell {
    height: 37px;
    border-radius: 9px;
    border: 1px solid rgba(45, 55, 72, 0.16);
    padding: 0 10px;
    font-size: 0.84rem;
    background: #fff;
}

.org-node-card {
    height: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(45, 55, 72, 0.14);
    background: #fff;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    transition: none;
    user-select: none;
    cursor: grab;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

.org-node-card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.org-node-card.is-highlighted {
    box-shadow: 0 0 0 3px rgba(214, 158, 46, 0.3), 0 10px 20px rgba(0, 0, 0, 0.12);
}

.org-node-card.is-dragging {
    opacity: 0.6;
    cursor: grabbing;
}

.org-node-card.drop-target {
    box-shadow: 0 0 0 3px rgba(56, 178, 172, 0.24), 0 12px 24px rgba(0, 0, 0, 0.12);
}

.node-accent {
    height: 6px;
    background: var(--node-color, #38B2AC);
}

.node-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 7px;
}

.node-action-reassign {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(45, 55, 72, 0.2);
    border-radius: 8px;
    background: #f4f8f7;
    color: var(--text-root);
    flex-shrink: 0;
}

.node-action-reassign:hover {
    background: rgba(56, 178, 172, 0.1);
}

.node-photo {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--node-color, #38B2AC);
    background: #ecf1f6;
    flex-shrink: 0;
    -webkit-user-drag: none;
    user-drag: none;
}

.node-photo-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #8a97a8;
}

.node-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.node-main strong,
.node-main small,
.node-main em {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.node-main strong {
    font-size: 0.83rem;
    color: var(--text-root);
}

.node-main small {
    font-size: 0.73rem;
    color: #5f6f81;
}

.node-main em {
    font-size: 0.69rem;
    color: #8a96a5;
    font-style: normal;
}

.node-badges {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    padding: 0 10px 10px;
}

.node-badges span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(56, 178, 172, 0.08);
    color: var(--text-root);
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
}

body.is-reassigning,
body.is-reassigning * {
    cursor: grabbing !important;
}

body.is-reassigning {
    touch-action: none;
}

.drag-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 140;
    pointer-events: none;
    border-radius: 10px;
    border: 1px solid rgba(45, 55, 72, 0.2);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 170px;
    will-change: transform;
    transform: translate3d(-9999px, -9999px, 0);
}

.drag-ghost strong {
    font-size: 0.8rem;
    color: var(--text-root);
}

.drag-ghost span {
    font-size: 0.72rem;
    color: #5a6f86;
}

.modal-search-results {
    position: static;
    display: block;
    max-height: 220px;
    margin-bottom: 4px;
    box-shadow: none;
    overflow-y: auto;
}

.custom-palette-editor {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.custom-color-item {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 8px;
    align-items: center;
    border: 1px solid rgba(45, 55, 72, 0.12);
    border-radius: 10px;
    padding: 8px 10px;
    background: #f7f9f8;
}

.custom-color-item span {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-root);
}

.custom-color-item input[type='color'] {
    width: 100%;
    height: 30px;
    border: 1px solid rgba(45, 55, 72, 0.2);
    border-radius: 8px;
    background: #fff;
}

.custom-color-item code {
    font-size: 0.72rem;
    color: var(--text-muted);
}

@media (max-width: 1280px) {
    .toolbar-shell {
        grid-template-columns: 1fr;
    }

    .toolbar-actions {
        justify-content: flex-start;
    }

    .org-chart-stage {
        height: calc(100vh - 285px);
    }
}

@media (max-width: 900px) {
    .stats-bar {
        grid-template-columns: repeat(2, minmax(110px, 1fr));
        width: calc(100vw - 18px);
    }

    .org-chart-stage {
        height: calc(100vh - 320px);
    }

    .config-drawer {
        width: min(340px, 100vw);
        right: calc(-1 * min(340px, 100vw));
    }
}
