
:root {
    --blue: #004793;
    --gray: #706f6f;
    --border-gray: #706f6f;
    --bg: #ffffff;
    --line-color: #706f6f;
    --border-width: 2px;
    --line-width: 1px;
}


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


.organigramm {
    max-width: 1100px;
    margin: 0 auto;
}

.organigramm .card {
    background: var(--bg);
    border: var(--border-width) solid var(--blue);
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.card--primary {
    border-color: var(--blue);
}

.card__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 0.35rem;
}

.card__name {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 0.25rem;
}

.card__desc {
    font-size: 0.75rem;
    color: var(--gray);
    line-height: 1.4;
    font-weight: bold;
}

.card__note {
    font-size: 0.7rem;
    color: var(--gray);
    font-style: italic;
}

/* --- Top Level --- */
.level-top {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    position: relative;
}

.stabsstelle {
    flex: 0 0 220px;
}

.connector-h {
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.connector-h::after {
    content: '';
    display: block;
    width: 100%;
    height: var(--line-width);
    background: var(--line-color);
}

.geschaeftsfuehrer {
    flex: 0 0 250px;
}

/* --- Vertical Connector from GF to horizontal bar --- */
.connector-v {
    display: flex;
    justify-content: center;
    height: 50px;
}

.connector-v::after {
    content: '';
    display: block;
    width: var(--line-width);
    height: 100%;
    background: var(--line-color);
}

/* --- Horizontal Bar + Vertical drops --- */
.level-mid-connector {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 0 calc(112px - 1px);
}

.level-mid-connector::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(112px);
    right: calc(112px);
    height: var(--line-width);
    background: var(--line-color);
}

.drop {
    width: var(--line-width);
    height: 40px;
    background: var(--line-color);
}

/* --- Departments Row --- */
.level-departments {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

/* --- Sub note --- */
.sub-note {
    text-align: right;
    padding: 0.5rem 0;
    font-size: 0.7rem;
    color: var(--gray);
    font-style: italic;
}

/* --- Bottom Level (no connection lines) --- */
.level-bottom-wrapper {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.level-bottom-wrapper .card {
    flex: 0 0 calc(25% - 0.5rem);
}

/* Hide bottom connectors globally */
.bottom-connectors {
    display: none;
}

/* ======= RESPONSIVE ======= */

/* Tablet & Mobile: Tree-line approach
   All elements branch off a single vertical trunk from GF.
   This correctly shows: L1, L2, GB1–GB4 all directly under GF. */
@media (max-width: 960px) {
    /* Hide desktop connectors */
    .connector-h,
    .connector-v,
    .level-mid-connector,
    .bottom-connectors {
        display: none;
    }

    /* === TOP LEVEL: GF + Stabsstellen === */
    .level-top {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin-left: 2.5rem;
        padding-left: 2rem;
        border-left: 2px solid var(--line-color);
    }

    .geschaeftsfuehrer {
        width: calc(100% + 2rem + 2px);
        max-width: none;
        margin-left: calc(-2rem - 2px);
        order: -1;
        position: relative;
        flex: none;
    }

    .stabsstelle {
        flex: none;
        width: 100%;
        max-width: none;
        position: relative;
        margin-top: 0.5rem;
    }

    /* Horizontal branch from trunk to each Stabsstelle */
    .stabsstelle::before {
        content: '';
        position: absolute;
        left: -2rem;
        top: 50%;
        transform: translateY(-50%);
        width: 2rem;
        height: 2px;
        background: var(--line-color);
    }

    /* === BRIDGE: trunk continues between top and departments === */
    .mobile-connector {
        display: block;
        margin-left: 2.5rem;
        border-left: 2px solid var(--line-color);
        height: 0.75rem;
    }
    .mobile-connector::after {
        display: none;
    }

    /* === DEPARTMENTS: trunk continues with branches === */
    .level-departments {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        margin-left: 2.5rem;
        padding-left: 2rem;
        border-left: 2px solid var(--line-color);
    }

    .level-departments .card {
        position: relative;
    }

    /* Horizontal branch from trunk to each department */
    .level-departments .card::before {
        content: '';
        position: absolute;
        left: -2rem;
        top: 50%;
        transform: translateY(-50%);
        width: 2rem;
        height: 2px;
        background: var(--line-color);
    }

    /* === NOTE: no trunk line === */
    .sub-note {
        text-align: left;
        margin-left: 2.5rem;
        padding-left: calc(2rem + 2px);
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    /* Hide trunk below last department */
    .level-departments .card:last-child::after {
        content: '';
        position: absolute;
        left: calc(-2rem - 2px);
        top: 50%;
        bottom: -0.5rem;
        width: 2px;
        background: #f5f5f5;
    }

    /* === BOTTOM BOXES: no connection lines, just stacked === */
    .level-bottom-wrapper {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        margin-top: 1.5rem;
        gap: 0.5rem;
    }

    .level-bottom-wrapper .card {
        flex: none;
        width: 100%;
    }
}

/* Mobile: tighter spacing */
@media (max-width: 640px) {
    body {
        padding: 1rem 0.5rem;
    }

    .level-top {
        margin-left: 1rem;
        padding-left: 1.5rem;
    }

    .geschaeftsfuehrer {
        width: calc(100% + 1.5rem + 2px);
        margin-left: calc(-1.5rem - 2px);
    }

    .stabsstelle::before {
        left: -1.5rem;
        width: 1.5rem;
    }

    .mobile-connector {
        margin-left: 1rem;
    }

    .level-departments {
        margin-left: 1rem;
        padding-left: 1.5rem;
    }

    .level-departments .card::before {
        left: -1.5rem;
        width: 1.5rem;
    }

    .sub-note {
        margin-left: 1rem;
        padding-left: calc(1.5rem + 2px);
    }

    .level-departments .card:last-child::after {
        left: calc(-1.5rem - 2px);
    }
}

/* Desktop: horizontal layout */
@media (min-width: 961px) {
    .mobile-connector {
        display: none;
    }

    .level-top {
        display: grid;
        grid-template-columns: 220px 60px 250px 60px 220px;
        align-items: stretch;
        justify-content: center;
    }

    .level-top > .geschaeftsfuehrer {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .stabsstelle {
        flex: none;
    }

    .connector-h {
        flex: none;
    }
}