.structure-chart-widget {
    margin: 1.5rem 0;
    padding: 1.2rem;
    border-radius: 24px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

.scw-toolbar,
.scw-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.scw-tab,
.scw-controls button {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.65rem 1rem;
    background: white;
    color: #334155;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scw-tab:hover,
.scw-controls button:hover {
    transform: translateY(-1px);
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

.scw-tab.active {
    background: #5b5fa8;
    color: white;
    border-color: #5b5fa8;
}

.scw-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
    gap: 1rem;
    align-items: start;
}

.scw-chart-card,
.scw-info-card,
.scw-step-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    padding: 1rem;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
}

.scw-mini-label,
.scw-step-counter {
    margin: 0 0 0.75rem;
    color: #64748b;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
}

.scw-chart {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    grid-template-areas:
        ". main main ."
        "param1 param2 param3 param4"
        "input decision fee output";
    gap: 1rem;
    align-items: stretch;
    padding: 1.25rem;
    min-height: auto;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background:
        radial-gradient(circle at top left, rgba(91, 95, 168, 0.08), transparent 30%),
        radial-gradient(circle at bottom right, rgba(230, 0, 79, 0.06), transparent 35%),
        #ffffff;
}

.scw-lines {
    display: none !important;
}

.scw-branch-row {
    display: contents;
}

.scw-main,
.scw-module,
.scw-decision,
.scw-param {
    position: static !important;
    box-sizing: border-box;
}

.scw-main,
.scw-module,
.scw-decision {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 84px;
    padding: 1rem;
    border-radius: 18px;
    border: 2px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    transition: all 0.2s ease;
    width: 100%;
}

.scw-main {
    grid-area: main;
    justify-self: center;
    width: min(100%, 320px);
    min-height: 88px;
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
    font-size: 1.15rem;
}

.scw-branch-row .scw-module:nth-child(1) {
    grid-area: input;
}

.scw-branch-row .scw-decision {
    grid-area: decision;
}

.scw-branch-row .scw-module:nth-child(3) {
    grid-area: fee;
}

.scw-branch-row .scw-module:nth-child(4) {
    grid-area: output;
}

.scw-decision {
    flex-direction: column;
    gap: 0.35rem;
    transform: none !important;
    width: 100%;
    height: auto;
    background: #fff7ed;
    border-color: #fdba74;
    color: #9a3412;
    font-size: 1rem;
}

.scw-decision::before {
    content: "Decision";
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #c2410c;
    font-weight: 900;
}

.scw-decision::after {
    content: none;
}

.scw-param {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 54px;
    padding: 0.7rem 0.8rem;
    border-radius: 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #7c2d12;
    font-size: 0.82rem;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    transition: all 0.2s ease;
}

.scw-param-1 { grid-area: param1; }
.scw-param-2 { grid-area: param2; }
.scw-param-3 { grid-area: param3; }
.scw-param-4 { grid-area: param4; }

.scw-view-label {
    display: inline-block;
    margin-bottom: 0.7rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(91, 95, 168, 0.10);
    color: #4b4f9c;
    font-size: 0.85rem;
    font-weight: 800;
}

.scw-info-card h3,
.scw-step-card h3 {
    margin-top: 0;
    color: #0f172a;
}

.scw-info-card h3 {
    font-size: clamp(1.5rem, 2.8vw, 2rem);
    line-height: 1.15;
    margin-bottom: 0.8rem;
}

.scw-focus-box {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #14532d;
    font-weight: 700;
}

.scw-step-card {
    margin-top: 1rem;
}

.scw-step-card p:last-child {
    margin-bottom: 0;
}

.scw-main.active,
.scw-module.active,
.scw-decision.active {
    border-color: #e6004f;
    box-shadow:
        0 0 0 4px rgba(230, 0, 79, 0.08),
        0 12px 28px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

/* View behaviour */
.structure-chart-widget[data-view="data"] .scw-decision {
    opacity: 0.65;
}

.structure-chart-widget[data-view="data"] .scw-param {
    opacity: 1;
}

.structure-chart-widget[data-view="control"] .scw-param {
    opacity: 0.35;
}

.structure-chart-widget[data-view="control"] .scw-decision {
    opacity: 1;
    background: #f5f3ff;
    border-color: #c4b5fd;
    color: #5b21b6;
}

.structure-chart-widget[data-view="control"] .scw-decision::before {
    color: #6d28d9;
}

.structure-chart-widget[data-view="exam"] .scw-chart {
    background: #ffffff;
}

.structure-chart-widget[data-view="exam"] .scw-param,
.structure-chart-widget[data-view="exam"] .scw-module,
.structure-chart-widget[data-view="exam"] .scw-decision,
.structure-chart-widget[data-view="exam"] .scw-main {
    box-shadow: none;
}

/* Medium screens */
@media (max-width: 1100px) {
    .scw-layout {
        grid-template-columns: 1fr;
    }
}

/* Tablet */
@media (max-width: 820px) {
    .scw-chart {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
        grid-template-areas:
            "main main"
            "param1 param2"
            "param3 param4"
            "input decision"
            "fee output";
    }

    .scw-main {
        width: 100%;
        max-width: none;
    }
}

/* Mobile */
@media (max-width: 560px) {
    .scw-chart {
        grid-template-columns: 1fr;
        grid-template-areas:
            "main"
            "input"
            "param1"
            "decision"
            "param2"
            "fee"
            "param3"
            "output"
            "param4";
    }

    .scw-toolbar,
    .scw-controls {
        gap: 0.5rem;
    }

    .scw-tab,
    .scw-controls button {
        width: 100%;
        justify-content: center;
    }
}