:root {
    --text: #253048;
    --muted: #5f6f8b;
    --line: #d8e7ff;
    --panel: #ffffff;
    --primary: #2e5bff;
    --danger: #e03d3d;
    --cause: #ffe29a;
    --problem: #ffb180;
    --effect: #bde9a9;
    --mean: #ffd6f8;
    --solution: #ffd8a8;
    --result: #b7f2ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #dcefd3 0%, #eef7e7 36%, #f7f8ef 72%, #f7f5ea 100%);
}

.app {
    max-width: 1450px;
    margin: 0 auto;
    padding: 20px;
}

.header-logos,
.collab-logos {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logos {
    justify-content: center;
    flex: 1;
    min-width: 260px;
}

.collab-logos {
    justify-content: center;
    margin-bottom: 8px;
}

.header-logos img,
.collab-logos img {
    height: 104px;
    max-width: min(36vw, 340px);
    object-fit: contain;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(180, 204, 247, 0.85);
    border-radius: 14px;
    padding: 8px 14px;
    box-shadow: 0 10px 20px rgba(45, 82, 158, 0.2);
}

@media (max-width: 720px) {
    .header-logos img,
    .collab-logos img {
        height: 80px;
        padding: 6px 10px;
    }
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.app-header h1 {
    margin: 0 0 6px;
    font-size: clamp(1.55rem, 2.5vw, 2.3rem);
}

.app-header p {
    margin: 0;
    color: var(--muted);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.theme-switcher {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid rgba(170, 190, 230, 0.55);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
}

.session-info {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#sessionUserLabel {
    font-size: 0.98rem;
    font-weight: 700;
    color: #344e77;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(166, 187, 227, 0.6);
    border-radius: 999px;
    padding: 4px 18px 4px 4px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    color: #344e77;
    font: inherit;
}

.user-chip:hover {
    box-shadow: 0 4px 12px rgba(45, 82, 158, 0.15);
    transform: translateY(-1px);
}

.user-chip--plain {
    cursor: default;
    font-size: 0.84rem;
    font-weight: 700;
    padding: 6px 12px;
}

.user-chip-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7bf3, #275bc8);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.user-chip-avatar.has-image {
    color: transparent;
}

.profile-panel {
    background: linear-gradient(160deg, #f0f6ff 0%, #e7f1ff 60%, #e0ecfb 100%);
    border: 1px solid #bed3ef;
    box-shadow: 0 14px 36px rgba(45, 82, 158, 0.18);
}

.profile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-body {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    margin-top: 10px;
}

.profile-body > .full-width {
    grid-column: 1 / -1;
}

@media (max-width: 760px) {
    .profile-body {
        grid-template-columns: 1fr;
    }
}

.profile-avatar-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile-avatar-wrap {
    margin: 10px 0;
}

.profile-avatar-preview {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7bf3, #275bc8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    font-weight: 800;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 4px solid #fff;
    box-shadow: 0 8px 20px rgba(45, 82, 158, 0.25);
}

.profile-avatar-preview.has-image {
    color: transparent;
}

.btn-danger {
    background: #e03d3d;
    color: #fff;
}

.btn-danger:hover {
    background: #c43535;
}

.responsibles-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border: 1px dashed #bfd3f4;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.6);
}

.responsibles-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px;
}

.responsibles-empty {
    color: var(--muted);
    font-size: 0.84rem;
    font-style: italic;
}

.responsible-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 12px;
    background: #e8f0ff;
    border: 1px solid #bfd3f4;
    border-radius: 999px;
    font-size: 0.84rem;
    color: #1f4776;
}

.responsible-chip .chip-remove {
    background: none;
    border: none;
    color: #1f4776;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    padding: 0 4px;
    border-radius: 50%;
}

.responsible-chip .chip-remove:hover {
    background: rgba(31, 71, 118, 0.1);
}

.responsibles-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.responsibles-controls input[type="text"] {
    flex: 1 1 200px;
    min-width: 180px;
}

.responsibles-list {
    max-height: 260px;
    overflow: auto;
    background: #fff;
    border: 1px solid #dfe8f6;
    border-radius: 8px;
    padding: 4px;
}

.responsible-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.responsible-option:hover {
    background: #f3f7ff;
}

.responsible-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.responsible-option-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7bf3, #275bc8);
    color: #fff;
    font-weight: 800;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.responsible-option-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.responsible-option-text small {
    color: var(--muted);
    font-size: 0.76rem;
}

.admin-table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.admin-filters {
    margin-bottom: 10px;
    align-items: end;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid #e9eff8;
    padding: 8px 10px;
    text-align: left;
    font-size: 0.84rem;
}

.admin-table th {
    background: #f3f7ff;
    color: #35507a;
}

.usage-bars {
    display: grid;
    gap: 8px;
}

.usage-bar-row {
    display: grid;
    gap: 4px;
}

.usage-bar-label {
    font-size: 0.78rem;
    color: #4f6283;
    font-weight: 700;
}

.usage-bar-track {
    height: 12px;
    border-radius: 999px;
    background: #e9f0ff;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(135deg, #2f63af 0%, #4f84d1 100%);
}

body[data-auth="loggedout"] .app-header,
body[data-auth="loggedout"] .toolbar,
body[data-auth="loggedout"] .primary-toolbar,
body[data-auth="loggedout"] .workflow-stepper,
body[data-auth="loggedout"] .settings-panel,
body[data-auth="loggedout"] .workflow-stage,
body[data-auth="loggedout"] .collab-panel,
body[data-auth="loggedout"] .status-msg {
    display: none !important;
}

body[data-auth="loggedout"] {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

body[data-auth="loggedout"] .app {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 26px 16px;
}

body[data-auth="loggedout"] #authPanel {
    display: block !important;
    width: min(94vw, 420px);
    margin: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

body[data-auth="loggedout"] #authPanel .auth-card {
    border: 1px solid rgba(168, 190, 230, 0.38);
    border-radius: 18px;
    background: linear-gradient(165deg, rgba(252, 254, 255, 0.96) 0%, rgba(243, 248, 255, 0.93) 100%);
    box-shadow: 0 18px 34px rgba(16, 43, 82, 0.26);
    padding: 18px 18px 14px;
    text-align: center;
}

.auth-logo-top img {
    width: min(58%, 220px);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #dce6f8;
    padding: 6px 8px;
}

.auth-logo-bottom {
    margin-top: 12px;
}

.auth-logo-bottom img {
    width: min(52%, 200px);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #dce6f8;
    padding: 6px 8px;
}

.auth-fields {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.auth-input-wrap {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 6px;
    border: 1px solid #d6e2f7;
    border-radius: 10px;
    padding: 2px 6px 2px 4px;
    background: #fff;
}

.auth-input-wrap input {
    border: none !important;
    outline: none;
    background: transparent !important;
    padding: 8px 4px !important;
}

.auth-input-icon {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef4ff;
    color: #355c97;
    font-size: 0.78rem;
    font-weight: 800;
}

.auth-toggle-pass {
    border: 1px solid #cfe0ff;
    background: #f5f9ff;
    color: #2f5491;
    border-radius: 8px;
    width: 30px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-toggle-pass:hover {
    transform: translateY(-1px);
    background: #e8f1ff;
    box-shadow: 0 6px 12px rgba(47, 84, 145, 0.18);
}

.auth-toggle-pass svg {
    display: block;
}

.auth-toggle-pass.is-visible .eye-open {
    display: none;
}

.auth-toggle-pass.is-visible .eye-closed {
    display: block !important;
}

body[data-auth="loggedout"] #authPanel h2 {
    margin: 10px 0 4px;
    font-size: 1.45rem;
}

body[data-auth="loggedout"] #authPanel p {
    margin: 0 0 8px;
}

body[data-auth="loggedout"] #authMsg.status-msg {
    display: block !important;
    min-height: 20px;
    margin-top: 8px;
}

.theme-switcher-label {
    font-size: 0.82rem;
    color: #4a5f83;
    font-weight: 700;
    margin-right: 2px;
}

.theme-btn {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(66, 88, 128, 0.25);
}

.theme-btn.active {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #2f4c8b;
}

.theme-btn[data-theme-choice="institucional"] { background: linear-gradient(135deg, #0f315e, #1e5f9d); }
.theme-btn[data-theme-choice="azul-noche"] { background: linear-gradient(135deg, #0b2342, #1b3f73); }
.theme-btn[data-theme-choice="azul-profundo"] { background: linear-gradient(135deg, #0f2e5f, #2f5ea8); }
.theme-btn[data-theme-choice="azul-pizarra"] { background: linear-gradient(135deg, #1f314b, #35557a); }
.theme-btn[data-theme-choice="azul-claro"] { background: linear-gradient(135deg, #315f9e, #6b98d8); }

.btn {
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 9px 18px rgba(46, 91, 255, 0.28);
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--line);
}

.btn-small {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px 12px;
}

.scene-panel,
.builder-card,
.summary-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 12px 22px rgba(40, 84, 152, 0.08);
}

.scene-panel {
    padding: 14px;
    margin-top: 8px;
}

.scene-panel h2 {
    margin: 0 0 10px;
    font-size: 1.15rem;
}

.scene-wrapper {
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(180deg, #9fd0ff 0%, #e6f4ff 45%, #d8f4c6 45%, #9fd176 100%);
    box-shadow: inset 0 -18px 28px rgba(66, 123, 40, 0.15);
    position: relative;
}

.scene-wrapper-guide {
    --guide-branches-offset: 0px;
    --guide-trunk-offset: 0px;
    --guide-roots-offset: 0px;
    background-color: #d9efff;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.scene-wrapper-problem.scene-wrapper-guide {
    background-image: url("../img/arbol-problema-fondo-v2.png");
}

.scene-wrapper-solution.scene-wrapper-guide {
    background-image: url("../img/arbol-problema-fondo.png");
}

.scene-wrapper-guide .cloud {
    display: none;
}

.tree-art {
    display: none !important;
}

.scene-wrapper-solution:not(.scene-wrapper-guide) {
    background: linear-gradient(180deg, #b39cff 0%, #ece6ff 45%, #dff5ff 45%, #9ad2f9 100%);
}

.tree-scene {
    position: relative;
    min-height: 560px;
    padding: 18px;
}

/* Refuerzo para evitar que estilos externos desarmen la escena */
.scene-wrapper .tree-scene {
    position: relative !important;
    min-height: 560px !important;
    display: block !important;
}

.scene-wrapper .drop-zone {
    position: absolute !important;
    display: block !important;
    z-index: 2;
}

.tree-art {
    position: absolute;
    left: 50%;
    bottom: 86px;
    transform: translateX(-50%);
    z-index: 0;
}

.tree-crown {
    width: 220px;
    height: 320px;
    border-radius: 120px 120px 100px 100px;
    background: radial-gradient(circle at 50% 25%, #98d965 0%, #62b236 60%, #4f9931 100%);
    box-shadow: 0 18px 34px rgba(64, 128, 45, 0.24);
}

.tree-trunk-art {
    position: absolute;
    left: 50%;
    bottom: -66px;
    width: 110px;
    height: 215px;
    transform: translateX(-50%);
    border-radius: 44px;
    background: linear-gradient(180deg, #9a663a 0%, #6e4324 100%);
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.06);
}

.tree-roots-art {
    position: absolute;
    left: 50%;
    bottom: -90px;
    width: 200px;
    height: 38px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: radial-gradient(circle at center, rgba(92, 62, 31, 0.45) 0%, rgba(92, 62, 31, 0.2) 60%, rgba(92, 62, 31, 0) 100%);
}

.tree-art-solution .tree-crown {
    background: radial-gradient(circle at 50% 25%, #9cb2ff 0%, #7689f1 60%, #5d6ed8 100%);
    box-shadow: 0 18px 34px rgba(86, 97, 186, 0.24);
}

.tree-art-solution .tree-trunk-art {
    background: linear-gradient(180deg, #845ab0 0%, #66418f 100%);
}

.cloud {
    position: absolute;
    height: 24px;
    border-radius: 40px;
    background: rgba(255, 255, 255, 0.8);
    z-index: 0;
}

.cloud::before,
.cloud::after {
    content: "";
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

.cloud::before {
    width: 26px;
    height: 26px;
    left: 10px;
    top: -12px;
}

.cloud::after {
    width: 34px;
    height: 34px;
    left: 30px;
    top: -16px;
}

.cloud-left {
    width: 80px;
    top: 32px;
    left: 12%;
}

.cloud-right {
    width: 92px;
    top: 42px;
    right: 12%;
}

.drop-zone {
    position: absolute;
    border: 2px dashed rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    padding: 10px;
    z-index: 2;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.drop-zone.drag-over {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.01);
}

.zone-branches .zone-title {
    background: rgba(197, 247, 190, 0.92);
}

.zone-trunk .zone-title {
    background: rgba(255, 219, 183, 0.95);
}

.zone-roots .zone-title {
    background: rgba(219, 201, 255, 0.94);
}

.zone-branches {
    top: 75px;
    left: 7%;
    right: 7%;
    min-height: 190px;
}

.zone-trunk {
    top: 285px;
    left: 36%;
    right: 36%;
    min-height: 145px;
}

.zone-roots {
    bottom: 14px;
    left: 12%;
    right: 12%;
    min-height: 145px;
}

/* Ajuste fino para la imagen guia del arbol de problema */
.scene-wrapper-guide .zone-branches {
    top: calc(56px + var(--guide-branches-offset));
    left: 5%;
    right: 5%;
    min-height: 170px;
}

.scene-wrapper-guide .zone-trunk {
    top: calc(255px + var(--guide-trunk-offset));
    left: 39%;
    right: 39%;
    min-height: 118px;
}

.scene-wrapper-guide .zone-roots {
    bottom: calc(12px + var(--guide-roots-offset));
    left: 8%;
    right: 8%;
    min-height: 150px;
}

.scene-wrapper-guide .drop-zone {
    border-color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.zone-title {
    display: inline-block;
    margin-bottom: 7px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.83rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.8);
}

.card-stack,
.card-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    min-height: 48px;
}

.builder-grid {
    margin-top: 14px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.builder-card {
    padding: 12px;
}

.builder-card h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.builder-input textarea,
.summary-card textarea {
    width: 100%;
    resize: vertical;
    min-height: 56px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    font: inherit;
}

.builder-input {
    display: grid;
    gap: 8px;
}

.pool-dropzone {
    margin-top: 10px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 10px;
    background: #fbfdff;
}

.pool-dropzone.drag-over {
    background: #ecf4ff;
    border-color: #94b5ff;
}

.pool-help {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.86rem;
}

.tree-card {
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 8px 10px;
    min-width: 130px;
    max-width: 280px;
    cursor: grab;
    box-shadow: 0 8px 14px rgba(30, 54, 106, 0.13);
}

.tree-card[data-type="cause"] {
    background: var(--cause);
    border-color: #efc569;
}

.tree-card[data-type="problem"] {
    background: var(--problem);
    border-color: #f08f55;
}

.tree-card[data-type="effect"] {
    background: var(--effect);
    border-color: #91c878;
}

.tree-card[data-type="mean"] {
    background: var(--mean);
    border-color: #d897cf;
}

.tree-card[data-type="solution"] {
    background: var(--solution);
    border-color: #efab62;
}

.tree-card[data-type="result"] {
    background: var(--result);
    border-color: #7cc4d8;
}

.tree-card.dragging {
    opacity: 0.6;
}

.card-label {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    white-space: pre-wrap;
    word-break: break-word;
}

.discussion-tag {
    margin: 6px 0 0;
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #7c3d00;
    background: rgba(255, 235, 168, 0.9);
    border: 1px solid rgba(179, 122, 0, 0.36);
    border-radius: 999px;
    padding: 2px 8px;
}

.card-actions {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}

.icon-btn {
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.76);
    border-radius: 8px;
    padding: 2px 8px;
    cursor: pointer;
    color: #2a3b59;
}

.icon-btn.delete {
    color: var(--danger);
}

.summary-grid {
    margin-top: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(300px, 1fr));
}

.summary-card {
    padding: 12px;
}

.summary-card h3 {
    margin: 0 0 8px;
}

.summary-card textarea {
    background: #f8fbff;
}

.report-logo-preview {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 10px;
    margin: 0 0 10px;
    background: #fbfdff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.report-logo-preview img {
    max-width: 240px;
    max-height: 110px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    padding: 6px;
}

.report-logo-preview p {
    margin: 0;
    font-size: 0.86rem;
    color: var(--muted);
}

.full-width {
    grid-column: 1 / -1;
}

.report-meta-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.report-label {
    display: grid;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
}

.report-label input,
.report-label textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 10px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

.report-label select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 10px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

.collab-panel {
    margin-top: 10px;
    margin-bottom: 14px;
    padding: 16px 18px 18px;
}

.collab-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.collab-panel-head h3 {
    margin: 0 0 4px;
}

.collab-status-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.collab-panel-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.collab-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(240px, 280px) 1fr;
    align-items: start;
}

.collab-qr-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.collab-qr-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbff;
    padding: 12px;
}

.collab-qr-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.collab-qr-card-head h4 {
    margin: 0;
    font-size: 0.92rem;
}

.collab-qr-frame {
    display: flex;
    justify-content: center;
    padding: 8px;
    background: #fff;
    border: 1px solid #d7e4f8;
    border-radius: 12px;
}

#collabQrProblemImg,
#collabQrSolutionImg,
#collabFloatQrImg {
    width: 200px;
    height: 200px;
    display: block;
    object-fit: contain;
    background: #fff;
}

.collab-join-url {
    margin: 8px 0 0;
    font-size: 0.75rem;
    color: var(--muted);
    word-break: break-all;
    line-height: 1.35;
}

.collab-qr-hint {
    margin: 0;
}

.collab-entries-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.collab-entries-block h4 {
    margin: 0 0 8px;
}

.collab-entries-pool {
    min-height: 72px;
    max-height: 360px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

#collabEntriesProblem .tree-card,
#collabEntriesSolution .tree-card {
    max-width: 360px;
}

.collab-attendance {
    margin-top: 14px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.collab-attendance summary {
    cursor: pointer;
    font-weight: 700;
    color: #2a4f86;
    margin-bottom: 10px;
}

.collab-float-qr {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1200;
    width: 168px;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid #c5d8f4;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 30px rgba(18, 42, 84, 0.28);
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.collab-float-qr:not([hidden]) {
    display: flex;
}

.collab-float-qr-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: #1f4776;
}

#collabFloatQrImg {
    width: 140px;
    height: 140px;
}

.mode-select-fallback {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.toolbar-mode {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    position: relative;
}

.toolbar-mode-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #4b648c;
}

.mode-switch {
    display: inline-flex;
    padding: 3px;
    border-radius: 999px;
    background: #e8f0ff;
    border: 1px solid #c9daf5;
    gap: 2px;
}

.mode-switch-btn {
    border: none;
    background: transparent;
    color: #46608a;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.mode-switch-btn.is-active {
    background: linear-gradient(135deg, #4a7bf3, #275bc8);
    color: #fff;
    box-shadow: 0 6px 14px rgba(39, 91, 200, 0.28);
}

.settings-grid--themes {
    grid-template-columns: 1fr;
}

.collab-student-badge {
    display: inline-flex;
    margin: 0 0 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e8f3ff;
    color: #275bc8;
    font-size: 0.78rem;
    font-weight: 700;
}

.collab-student-lead {
    margin: 0 0 14px;
    color: var(--muted);
}

.collab-student-forms {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.collab-student-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbff;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.collab-student-card h3 {
    margin: 0;
    font-size: 1rem;
}

.collab-student-card textarea {
    width: 100%;
    resize: vertical;
    min-height: 72px;
    border: 1px solid #cfdcf2;
    border-radius: 10px;
    padding: 10px;
    font: inherit;
}

@media (max-width: 900px) {
    .collab-layout {
        grid-template-columns: 1fr;
    }
    .collab-student-forms {
        grid-template-columns: 1fr;
    }
}

.collab-entry-meta {
    margin: 0 0 6px;
    font-size: 0.78rem;
    color: var(--muted);
}

.collab-student-group {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    background: #fbfdff;
}

.collab-student-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.collab-student-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.collab-filter-btn {
    border: 1px solid #cfd7ff;
    background: #f5f7ff;
    color: #3653c8;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.76rem;
    cursor: pointer;
}

.collab-filter-btn:hover {
    background: #edf1ff;
}

.collab-filter-btn.active {
    border-color: #3653c8;
    background: #3653c8;
    color: #fff;
}

.collab-student-name {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f3ca8;
}

.collab-student-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.collab-student-items .tree-card.is-hidden {
    display: none;
}

.zone-tuner {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    margin: 8px 0 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f7fbff;
}

.zone-tuner label {
    display: grid;
    gap: 4px;
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 700;
}

.zone-tuner input[type="range"] {
    width: 100%;
}

#metaRecordNumber {
    background: #eef3ff;
    color: #1f3ca8;
    font-weight: 700;
}

.status-msg {
    margin: 10px 0 0;
    min-height: 20px;
    font-weight: 700;
    color: #2b56f5;
}

.workflow-actions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.workspace-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-evidence {
    display: none;
}

.problem-workspace {
    margin-top: 10px;
}

.problem-workspace-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
}

.problem-workspace-head h2 {
    margin: 0;
}

.problem-workspace-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(520px, 1fr) minmax(240px, 320px);
    gap: 12px;
    align-items: start;
}

.problem-side {
    max-height: min(78vh, 860px);
    overflow: auto;
}

.problem-center-panel {
    margin: 0;
    padding: 10px;
}

.problem-center-input {
    margin-top: 10px;
}

.solution-workspace {
    margin-top: 10px;
}

.solution-workspace-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
}

.solution-workspace-head h2 {
    margin: 0;
}

.solution-workspace-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(520px, 1fr) minmax(240px, 320px);
    gap: 12px;
    align-items: start;
}

.solution-side {
    max-height: min(78vh, 860px);
    overflow: auto;
}

.solution-center-panel {
    margin: 0;
    padding: 10px;
}

.solution-center-input {
    margin-top: 10px;
}

/* Capa visual moderna 3D + movimiento suave */
body {
    background:
        radial-gradient(circle at 10% 8%, rgba(147, 219, 152, 0.42) 0%, rgba(147, 219, 152, 0) 35%),
        radial-gradient(circle at 88% 12%, rgba(215, 233, 162, 0.32) 0%, rgba(215, 233, 162, 0) 36%),
        linear-gradient(160deg, #edf7e5 0%, #f8fbf1 44%, #f6f4e8 100%);
    background-attachment: fixed;
}

.app-header,
.toolbar,
.scene-panel,
.builder-card,
.summary-card {
    backdrop-filter: blur(8px);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.95) 0%, rgba(247, 252, 255, 0.9) 100%);
    border-color: rgba(165, 196, 255, 0.6);
    box-shadow:
        0 16px 34px rgba(57, 96, 185, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.app-header {
    padding: 16px 18px;
    border-radius: 20px;
}

.toolbar {
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(165, 196, 255, 0.6);
}

.btn {
    border-radius: 14px;
    transform-style: preserve-3d;
}

.btn-primary {
    background: linear-gradient(135deg, #2f7bff 0%, #4f59ff 45%, #8254ff 100%);
    box-shadow:
        0 12px 24px rgba(66, 98, 255, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-secondary,
.btn-small {
    background: linear-gradient(180deg, #ffffff 0%, #f1f6ff 100%);
    border-color: rgba(163, 191, 255, 0.65);
    box-shadow: 0 6px 14px rgba(46, 78, 145, 0.1);
}

.scene-wrapper {
    border-color: rgba(150, 189, 255, 0.72);
    box-shadow:
        0 16px 28px rgba(39, 78, 155, 0.16),
        inset 0 -32px 34px rgba(83, 140, 63, 0.18);
}

.scene-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 35%);
    pointer-events: none;
    z-index: 0;
}

.scene-wrapper::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.18;
    mix-blend-mode: soft-light;
    background:
        repeating-conic-gradient(
            from 0deg at 50% 50%,
            rgba(255, 255, 255, 0.5) 0deg,
            rgba(255, 255, 255, 0.08) 18deg,
            rgba(96, 145, 255, 0.34) 30deg,
            rgba(255, 255, 255, 0.04) 45deg
        ),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 58%);
}

.scene-wrapper-guide {
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
    background-size: contain !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
}

.scene-wrapper-problem.scene-wrapper-guide {
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%),
        url("../img/arbol-problema-fondo-v2.png") !important;
}

.scene-wrapper-solution.scene-wrapper-guide {
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%),
        url("../img/arbol-problema-fondo.png") !important;
}

.scene-wrapper .tree-scene {
    position: relative;
    z-index: 1;
}

.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.14);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.34),
        0 8px 16px rgba(37, 71, 139, 0.16);
}

.drop-zone.drag-over {
    background: rgba(255, 255, 255, 0.32);
    transform: translateY(-2px) scale(1.01);
}

.tree-card {
    border-radius: 14px;
    box-shadow:
        0 10px 18px rgba(28, 50, 99, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tree-card:hover {
    transform: translateY(-2px);
    box-shadow:
        0 14px 24px rgba(28, 50, 99, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.zone-title {
    box-shadow: 0 5px 10px rgba(35, 64, 122, 0.14);
}

#collabQrProblemImg,
#collabQrSolutionImg {
    box-shadow: 0 10px 18px rgba(41, 72, 139, 0.2);
}

@keyframes floatingPanel {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
    100% { transform: translateY(0px); }
}

.scene-panel {
    animation: floatingPanel 5.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .scene-panel {
        animation: none;
    }
}

/* Flujo por etapas: acta -> problema -> soluciones -> informe */
body[data-workflow-stage="problem"] .app,
body[data-workflow-stage="solution"] .app {
    max-width: min(98vw, 1750px);
    padding: 10px 14px 18px;
}

body[data-workflow-stage="problem"] .scene-panel,
body[data-workflow-stage="solution"] .scene-panel {
    padding: 10px;
}

body[data-workflow-stage="problem"] .scene-wrapper,
body[data-workflow-stage="solution"] .scene-wrapper {
    min-height: calc(100vh - 210px);
}

body[data-workflow-stage="problem"] .tree-scene,
body[data-workflow-stage="solution"] .tree-scene {
    min-height: calc(100vh - 230px) !important;
}

body[data-problem-focus="on"] {
    overflow: hidden;
}

body[data-problem-focus="on"] .app-header,
body[data-problem-focus="on"] .toolbar,
body[data-problem-focus="on"] .primary-toolbar,
body[data-problem-focus="on"] .workflow-stepper,
body[data-problem-focus="on"] .settings-panel,
body[data-problem-focus="on"] #collabPanel,
body[data-problem-focus="on"] #stageProblemActions,
body[data-problem-focus="on"] .problem-center-input,
body[data-problem-focus="on"] .zone-tuner {
    display: none !important;
}

body[data-problem-focus="on"] .collab-float-qr:not([hidden]) {
    display: flex !important;
}

body[data-problem-focus="on"] #stageProblemWorkspace .btn-evidence {
    display: inline-flex;
}

body[data-problem-focus="on"] #stageProblemWorkspace {
    position: fixed;
    inset: 0;
    z-index: 999;
    margin: 0;
    padding: 10px 10px 12px;
    background: var(--theme-bg, linear-gradient(160deg, #edf7e5 0%, #f8fbf1 44%, #f6f4e8 100%));
    overflow: auto;
}

body[data-problem-focus="on"] #stageProblemWorkspace .problem-workspace-layout {
    grid-template-columns: minmax(280px, 360px) minmax(640px, 1fr) minmax(280px, 360px);
}

body[data-problem-focus="on"] #stageProblemWorkspace .problem-side {
    max-height: calc(100vh - 92px);
}

body[data-problem-focus="on"] #stageProblemWorkspace .scene-wrapper {
    min-height: calc(100vh - 104px);
}

body[data-problem-focus="on"] #stageProblemWorkspace .tree-scene {
    min-height: calc(100vh - 124px) !important;
}

body[data-solution-focus="on"] {
    overflow: hidden;
}

body[data-solution-focus="on"] .app-header,
body[data-solution-focus="on"] .toolbar,
body[data-solution-focus="on"] .primary-toolbar,
body[data-solution-focus="on"] .workflow-stepper,
body[data-solution-focus="on"] .settings-panel,
body[data-solution-focus="on"] #collabPanel,
body[data-solution-focus="on"] #stageSolutionActions,
body[data-solution-focus="on"] .solution-center-input,
body[data-solution-focus="on"] .zone-tuner {
    display: none !important;
}

body[data-solution-focus="on"] .collab-float-qr:not([hidden]) {
    display: flex !important;
}

body[data-solution-focus="on"] #stageSolutionWorkspace .btn-evidence {
    display: inline-flex;
}

body[data-solution-focus="on"] #stageSolutionWorkspace {
    position: fixed;
    inset: 0;
    z-index: 999;
    margin: 0;
    padding: 10px 10px 12px;
    background: var(--theme-bg, linear-gradient(160deg, #edf7e5 0%, #f8fbf1 44%, #f6f4e8 100%));
    overflow: auto;
}

body[data-solution-focus="on"] #stageSolutionWorkspace .solution-workspace-layout {
    grid-template-columns: minmax(280px, 360px) minmax(640px, 1fr) minmax(280px, 360px);
}

body[data-solution-focus="on"] #stageSolutionWorkspace .solution-side {
    max-height: calc(100vh - 92px);
}

body[data-solution-focus="on"] #stageSolutionWorkspace .scene-wrapper {
    min-height: calc(100vh - 104px);
}

body[data-solution-focus="on"] #stageSolutionWorkspace .tree-scene {
    min-height: calc(100vh - 124px) !important;
}

/* Fractal de hojas cayendo en toda la app */
.leaf-fall-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1200;
}

.leaf-fall-item {
    position: absolute;
    top: -8%;
    width: var(--leaf-size, 14px);
    height: var(--leaf-size, 14px);
    animation: leaf-fall var(--leaf-duration, 12s) linear infinite;
    animation-delay: var(--leaf-delay, 0s);
    transform: translateX(0) rotate(0deg);
}

.leaf-fall-item::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 80% 0 80% 0;
    transform: rotate(35deg);
    background: linear-gradient(160deg, #f8e683 0%, #93bf58 48%, #4a8f3e 100%);
    filter: hue-rotate(var(--leaf-hue, 40deg));
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.35);
    animation: leaf-spin calc(var(--leaf-duration, 12s) * 0.45) ease-in-out infinite alternate;
}

@keyframes leaf-fall {
    0% {
        transform: translate3d(0, -6vh, 0) rotate(0deg);
    }
    50% {
        transform: translate3d(calc(var(--leaf-drift, 60px) * 0.55), 52vh, 0) rotate(180deg);
    }
    100% {
        transform: translate3d(var(--leaf-drift, 60px), 112vh, 0) rotate(360deg);
    }
}

@keyframes leaf-spin {
    0% {
        transform: rotate(28deg) scale(0.92);
    }
    100% {
        transform: rotate(68deg) scale(1.06);
    }
}

@media (max-width: 980px) {
    .builder-grid,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .report-meta-grid {
        grid-template-columns: 1fr;
    }

    .zone-trunk {
        left: 28%;
        right: 28%;
    }

    .scene-wrapper-guide .zone-trunk {
        left: 35%;
        right: 35%;
        top: calc(264px + var(--guide-trunk-offset));
    }

    .scene-wrapper-guide .zone-roots {
        left: 6%;
        right: 6%;
    }

    .problem-workspace-layout {
        grid-template-columns: 1fr;
    }

    .problem-side {
        max-height: none;
    }

    .solution-workspace-layout {
        grid-template-columns: 1fr;
    }

    .solution-side {
        max-height: none;
    }

    body[data-problem-focus="on"] #stageProblemWorkspace .problem-workspace-layout {
        grid-template-columns: 1fr;
    }

    body[data-solution-focus="on"] #stageSolutionWorkspace .solution-workspace-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .header-logos,
    .collab-logos {
        gap: 8px;
    }

    .header-logos {
        width: 100%;
        justify-content: flex-start;
        margin-top: 6px;
    }

    .header-logos img,
    .collab-logos img {
        height: 52px;
        max-width: 46vw;
        padding: 3px 6px;
    }

    .app {
        padding: 12px;
    }

    .app-header {
        flex-direction: column;
    }

    .tree-scene {
        min-height: 640px;
    }

    .zone-branches {
        left: 3%;
        right: 3%;
    }

    .zone-trunk {
        left: 20%;
        right: 20%;
    }

    .zone-roots {
        left: 5%;
        right: 5%;
    }

    .scene-wrapper-guide .zone-branches {
        top: calc(68px + var(--guide-branches-offset));
        left: 2%;
        right: 2%;
        min-height: 178px;
    }

    .scene-wrapper-guide .zone-trunk {
        left: 30%;
        right: 30%;
        top: calc(288px + var(--guide-trunk-offset));
        min-height: 126px;
    }

    .scene-wrapper-guide .zone-roots {
        left: 3%;
        right: 3%;
        bottom: calc(12px + var(--guide-roots-offset));
        min-height: 165px;
    }

    .zone-tuner {
        grid-template-columns: 1fr;
    }

    .collab-grid {
        grid-template-columns: 1fr;
    }
}

/* Temas visuales (selector de tonos) */
body[data-theme="institucional"] {
    --theme-bg: linear-gradient(160deg, #082646 0%, #0f3b69 48%, #1d5f99 100%);
    --theme-surface: linear-gradient(160deg, rgba(248, 251, 255, 0.95) 0%, rgba(239, 246, 255, 0.92) 100%);
    --theme-primary: linear-gradient(135deg, #0f3766 0%, #1f5b95 55%, #2d77b9 100%);
    --theme-secondary: linear-gradient(180deg, #f4f9ff 0%, #e8f2ff 100%);
}

body[data-theme="azul-noche"] {
    --theme-bg: linear-gradient(160deg, #0a1d38 0%, #132b50 40%, #1b3a69 100%);
    --theme-surface: linear-gradient(160deg, rgba(246, 250, 255, 0.94) 0%, rgba(237, 244, 255, 0.9) 100%);
    --theme-primary: linear-gradient(135deg, #173a74 0%, #2456a3 55%, #2e6bc8 100%);
    --theme-secondary: linear-gradient(180deg, #f6f9ff 0%, #e8f0ff 100%);
}

body[data-theme="azul-profundo"] {
    --theme-bg: linear-gradient(160deg, #061a33 0%, #0f2d58 44%, #18447e 100%);
    --theme-surface: linear-gradient(160deg, rgba(245, 249, 255, 0.95) 0%, rgba(233, 242, 255, 0.91) 100%);
    --theme-primary: linear-gradient(135deg, #154080 0%, #2360bc 55%, #3a79d9 100%);
    --theme-secondary: linear-gradient(180deg, #f3f8ff 0%, #e5efff 100%);
}

body[data-theme="azul-pizarra"] {
    --theme-bg: linear-gradient(160deg, #1a2738 0%, #24384f 45%, #2f4a66 100%);
    --theme-surface: linear-gradient(160deg, rgba(249, 251, 255, 0.95) 0%, rgba(240, 245, 252, 0.92) 100%);
    --theme-primary: linear-gradient(135deg, #2b4769 0%, #3a5f89 55%, #4d769f 100%);
    --theme-secondary: linear-gradient(180deg, #f6f9ff 0%, #ebf1f8 100%);
}

body[data-theme="azul-claro"] {
    --theme-bg: linear-gradient(160deg, #1d3f72 0%, #2b5d9e 45%, #3d78c4 100%);
    --theme-surface: linear-gradient(160deg, rgba(250, 252, 255, 0.96) 0%, rgba(241, 247, 255, 0.92) 100%);
    --theme-primary: linear-gradient(135deg, #2e5fa4 0%, #3e76c4 55%, #5a91da 100%);
    --theme-secondary: linear-gradient(180deg, #f8fbff 0%, #edf4ff 100%);
}

body[data-theme] {
    background: var(--theme-bg) !important;
    background-attachment: fixed !important;
}

body[data-theme] .app-header,
body[data-theme] .toolbar,
body[data-theme] .primary-toolbar,
body[data-theme] .workflow-stepper,
body[data-theme] .scene-panel,
body[data-theme] .builder-card,
body[data-theme] .summary-card {
    background: var(--theme-surface) !important;
}

body[data-theme] .btn-primary {
    background: var(--theme-primary) !important;
}

body[data-theme] .btn-secondary,
body[data-theme] .btn-small {
    background: var(--theme-secondary) !important;
}

/* Refuerzo de contraste para tonos azules */
body[data-theme] .btn-secondary,
body[data-theme] .btn-small {
    color: #0d2f59 !important;
    border-color: rgba(21, 58, 108, 0.42) !important;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

body[data-theme] .btn-secondary:hover,
body[data-theme] .btn-small:hover {
    filter: brightness(1.02);
    box-shadow: 0 8px 18px rgba(19, 52, 99, 0.2);
}

body[data-theme] .theme-switcher-label,
body[data-theme] #sessionUserLabel,
body[data-theme] .pool-help,
body[data-theme] .report-label,
body[data-theme] .collab-entry-meta,
body[data-theme] .report-logo-preview p {
    color: #1f4776 !important;
}

body[data-theme] .problem-workspace-head h2,
body[data-theme] .solution-workspace-head h2 {
    color: #f5f9ff;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        0 0 12px rgba(6, 24, 52, 0.26);
}

/* ====== Diseno reorganizado: header, stepper, menus y pestanas ====== */

/* Forzar que cualquier elemento con atributo hidden quede oculto
   aun cuando tenga reglas como .summary-grid { display: grid } */
[hidden] {
    display: none !important;
}

.app-header {
    align-items: center;
}

.app-header-main {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1 1 auto;
    min-width: 0;
}

.app-header-title h1 {
    margin: 0 0 4px;
    font-size: clamp(1.35rem, 2.2vw, 2rem);
}

.app-header-title p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.app-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-chip {
    padding: 4px 12px 4px 4px;
    gap: 10px;
}

.user-chip-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: left;
}

.user-chip-text small {
    font-size: 0.68rem;
    font-weight: 600;
    color: #6a85b8;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.user-chip-caret {
    margin-left: 4px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #6a85b8;
    transition: transform 0.2s ease;
}

.user-chip[aria-expanded="true"] .user-chip-caret {
    transform: rotate(180deg);
}

.user-menu {
    position: relative;
}

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 260px;
    background: #fff;
    border: 1px solid rgba(166, 187, 227, 0.6);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(28, 58, 120, 0.2);
    padding: 8px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-menu-dropdown::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-top: 1px solid rgba(166, 187, 227, 0.6);
    border-left: 1px solid rgba(166, 187, 227, 0.6);
    transform: rotate(45deg);
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 6px;
}

.user-menu-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7bf3, #275bc8);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    flex: 0 0 auto;
}

.user-menu-avatar.has-image {
    color: transparent;
}

.user-menu-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-menu-info strong {
    color: #1f4776;
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-info small {
    color: #6a85b8;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font: inherit;
    font-size: 0.92rem;
    color: #24406f;
    cursor: pointer;
    text-align: left;
}

.menu-item:hover {
    background: rgba(74, 123, 243, 0.1);
}

.menu-item--danger {
    color: #a83131;
}

.menu-item--danger:hover {
    background: rgba(211, 47, 47, 0.1);
}

.menu-sep {
    height: 1px;
    background: rgba(166, 187, 227, 0.5);
    margin: 4px 6px;
}

/* Stepper */
.workflow-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid rgba(166, 187, 227, 0.6);
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(28, 58, 120, 0.08);
    margin-bottom: 12px;
}

.workflow-stepper .step-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border: 1px solid transparent;
    background: transparent;
    color: #5b7096;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.workflow-stepper .step-btn:hover {
    background: rgba(74, 123, 243, 0.08);
    color: #275bc8;
}

.workflow-stepper .step-btn .step-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(74, 123, 243, 0.12);
    color: #275bc8;
    font-weight: 800;
    font-size: 0.82rem;
}

.workflow-stepper .step-btn.is-done .step-index {
    background: #47ac70;
    color: #fff;
}

.workflow-stepper .step-btn.is-active {
    background: linear-gradient(135deg, #4a7bf3, #275bc8);
    color: #fff;
    box-shadow: 0 8px 18px rgba(39, 91, 200, 0.28);
}

.workflow-stepper .step-btn.is-active .step-index {
    background: #fff;
    color: #275bc8;
}

.workflow-stepper .step-arrow {
    color: #a7b9d9;
    font-weight: 700;
}

/* Primary toolbar */
.primary-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(166, 187, 227, 0.55);
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(28, 58, 120, 0.06);
}

.primary-toolbar .toolbar-main {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn.btn-ghost {
    background: transparent;
    border: 1px solid rgba(74, 123, 243, 0.45);
    color: #275bc8;
}

.btn.btn-ghost:hover {
    background: rgba(74, 123, 243, 0.08);
}

/* Settings panel */
.settings-panel {
    margin-bottom: 14px;
}

.settings-panel .settings-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.settings-panel h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: #1f4776;
}

.settings-panel .theme-switcher {
    background: transparent;
    border: none;
    padding: 0;
    gap: 8px;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: rgba(74, 123, 243, 0.08);
    border-radius: 12px;
    margin: 10px 0 14px;
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: #5b7096;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.6);
    color: #275bc8;
}

.tab-btn.is-active {
    background: #fff;
    color: #275bc8;
    box-shadow: 0 2px 8px rgba(28, 58, 120, 0.1);
}

.tab-panels .tab-panel {
    display: none;
}

.tab-panels .tab-panel.is-active {
    display: block;
}

/* Profile panel refinements */
.profile-head-user {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.profile-avatar-preview--small {
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
}

.profile-photo-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 18px;
    align-items: center;
}

@media (max-width: 640px) {
    .profile-photo-grid {
        grid-template-columns: 1fr;
    }
    .workflow-stepper {
        padding: 8px;
    }
    .workflow-stepper .step-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    .workflow-stepper .step-arrow {
        display: none;
    }
}

/* ======== Donut charts ======== */
.donut-chart {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 18px;
    align-items: center;
}

.donut-svg {
    width: 180px;
    height: 180px;
    display: block;
}

.donut-svg .donut-ring {
    stroke: rgba(166, 187, 227, 0.25);
}

.donut-svg .donut-total {
    font-size: 16px;
    font-weight: 800;
    fill: #1f4776;
}

.donut-svg .donut-sub {
    font-size: 8px;
    font-weight: 600;
    fill: #6a85b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.donut-legend-item {
    display: grid;
    grid-template-columns: 14px 1fr auto;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #24406f;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    box-shadow: 0 1px 2px rgba(28, 58, 120, 0.15);
}

.legend-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.legend-value {
    font-weight: 700;
    color: #1f4776;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .donut-chart {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    .donut-legend {
        width: 100%;
    }
}

/* ======== Profile stats ======== */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat-chip {
    background: linear-gradient(160deg, #fff 0%, #eef5ff 100%);
    border: 1px solid rgba(166, 187, 227, 0.5);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 6px 14px rgba(28, 58, 120, 0.08);
}

.stat-chip-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1f4776;
    line-height: 1.1;
}

.stat-chip-label {
    font-size: 0.78rem;
    color: #5b7096;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.stats-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(166, 187, 227, 0.4);
    border-radius: 14px;
    padding: 14px;
}

.stats-card h4 {
    margin: 0 0 10px;
    font-size: 0.98rem;
    color: #1f4776;
}

/* ======== Modal de estadisticas de usuario ======== */
body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 28, 56, 0.55);
    backdrop-filter: blur(3px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal-dialog {
    background: linear-gradient(160deg, #f6fbff 0%, #eaf3ff 60%, #e2ecfb 100%);
    border: 1px solid #bed3ef;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(12, 28, 56, 0.35);
    max-width: 980px;
    width: 100%;
    padding: 20px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-head h3 {
    margin: 0;
    color: #1f4776;
}

.admin-head-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Cuando el panel "Mi perfil" o el panel admin estan abiertos,
   ocultamos stepper, barra de acciones, ajustes, etapas del flujo
   y la sesion colaborativa. Asi la pantalla muestra solo el panel activo. */
body[data-active-panel="profile"] .workflow-stepper,
body[data-active-panel="profile"] .primary-toolbar,
body[data-active-panel="profile"] .settings-panel,
body[data-active-panel="profile"] .workflow-stage,
body[data-active-panel="profile"] .collab-panel,
body[data-active-panel="profile"] #adminPanel,
body[data-active-panel="admin"] .workflow-stepper,
body[data-active-panel="admin"] .primary-toolbar,
body[data-active-panel="admin"] .settings-panel,
body[data-active-panel="admin"] .workflow-stage,
body[data-active-panel="admin"] .collab-panel,
body[data-active-panel="admin"] #profilePanel {
    display: none !important;
}
