:root {
    --bg: #f4f1ea;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: rgba(255, 255, 255, 0.96);
    --text: #1d2128;
    --muted: #5c6470;
    --accent: #0b6efd;
    --shadow: 0 16px 40px rgba(33, 37, 41, 0.08);
    --lp-light: #a8bad3;
    --lp-mid: #6281a7;
    --lp-blue: #2b4c7e;
    --lp-deep: #1d3557;
    --lp-night: #0b1626;
}

body {
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(8, 117, 163, 0.10), transparent 30%),
        radial-gradient(circle at top right, rgba(186, 135, 56, 0.16), transparent 28%),
        linear-gradient(180deg, #f9f6ef 0%, #f3efe8 100%);
}

.welcome-page {
    min-height: 100vh;
    color: #17202b;
    background: url("../img/LP%20Fondo.jpg");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.welcome-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 92px 1fr;
}

.welcome-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.15rem clamp(1.25rem, 3vw, 3rem);
    background: var(--lp-night);
    border-bottom: 1px solid rgba(168, 186, 211, 0.24);
    box-shadow: 0 18px 50px rgba(11, 22, 38, 0.28);
    backdrop-filter: blur(12px);
}

.welcome-kicker {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--lp-light);
}

.welcome-brand {
    font-size: clamp(1.1rem, 2vw, 1.65rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: #f4f8ff;
}

.welcome-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: clamp(2rem, 5vw, 4.8rem);
    text-align: center;
}

.welcome-content-panel {
    width: min(1180px, 100%);
    padding: clamp(2rem, 5vw, 4.8rem);
    border: 1px solid rgba(168, 186, 211, 0.34);
    border-radius: 1.6rem;
    background: rgba(11, 22, 38, 0.73);
    box-shadow: 0 28px 80px rgba(11, 22, 38, 0.34);
    backdrop-filter: blur(12px);
}

.welcome-place {
    width: fit-content;
    margin: 0 auto 1.25rem;
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(168, 186, 211, 0.72);
    color: var(--lp-blue);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
}

.welcome-title {
    max-width: 1500px;
    margin: 0 auto;
    color: #f4f8ff;
    font-size: clamp(2.3716rem, 7.4536vw, 8.3006rem);
    line-height: 0.9;
    font-weight: 900;
    letter-spacing: -0.065em;
    text-align: center;
    text-transform: uppercase;
    text-wrap: balance;
    text-shadow: 0 14px 36px rgba(11, 22, 38, 0.42);
}

.welcome-title span {
    display: block;
    font-size: 0.476em;
    letter-spacing: -0.06em;
}

.welcome-description {
    max-width: 820px;
    margin: 2rem auto 0;
    font-size: clamp(1rem, 1.35vw, 1.35rem);
    line-height: 1.45;
    color: rgba(232, 240, 251, 0.86);
    text-shadow: 0 8px 26px rgba(11, 22, 38, 0.35);
}

.welcome-start-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2rem;
}

.welcome-button {
    min-width: 240px;
    padding: 1rem 2.4rem;
    border: 1px solid rgba(168, 186, 211, 0.44);
    border-radius: 999px;
    background: var(--lp-blue);
    color: #f4f8ff;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    box-shadow: 0 18px 42px rgba(11, 22, 38, 0.34);
}

.welcome-button:hover {
    background: var(--lp-mid);
    color: #fff;
    transform: translateY(-1px);
}

.welcome-button-secondary {
    background: rgba(255, 255, 255, 0.16);
}

.welcome-button-secondary:hover {
    background: rgba(255, 255, 255, 0.24);
}

.logout-button {
    border-color: #b4232d;
    background: #b4232d;
    color: #fff;
}

.logout-button:hover {
    border-color: #8f1b24;
    background: #8f1b24;
    color: #fff;
}

.hero-panel {
    padding: 2rem;
    border-radius: 1.75rem;
    background:
        linear-gradient(135deg, rgba(9, 57, 107, 0.92), rgba(26, 110, 153, 0.88)),
        linear-gradient(135deg, #0b6efd, #23a6d5);
    color: #fff;
    box-shadow: var(--shadow);
}

.soft-card {
    background: var(--panel);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    border-radius: 1.25rem;
}

.stat-card {
    background: var(--panel-strong);
    box-shadow: var(--shadow);
    border-radius: 1.25rem;
}

.scenario-preset-box {
    padding: 1rem;
    border: 1px solid rgba(43, 76, 126, 0.12);
    border-radius: 1rem;
    background: rgba(168, 186, 211, 0.18);
}

.stat-label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.stat-value {
    margin-top: 0.4rem;
    font-size: 1.85rem;
    font-weight: 700;
}

.section-tabs .nav-link {
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow);
}

.section-tabs .nav-link.active {
    background: linear-gradient(135deg, #0b6efd, #198754);
    color: #fff;
}

.plot-block {
    width: 100%;
    min-height: 420px;
}

.plot-tall {
    min-height: 560px;
}

.plot-hero {
    min-height: 680px;
}

.plot-compact {
    min-height: 420px;
}

.leaflet-result-map {
    width: 100%;
    min-height: 640px;
    overflow: hidden;
    border: 1px solid rgba(43, 76, 126, 0.16);
    border-radius: 1.25rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.leaflet-control-layers {
    border: 0 !important;
    border-radius: 0.9rem !important;
    box-shadow: 0 12px 32px rgba(11, 22, 38, 0.18) !important;
}

.flood-depth-overlay {
    image-rendering: pixelated;
}

#refreshResultsButton {
    display: none;
}

.leaflet-error {
    display: flex;
    min-height: 640px;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #f4f8ff;
    text-align: center;
    background: #0b1626;
}

.reference-modal {
    border: 1px solid rgba(43, 76, 126, 0.16);
    border-radius: 0.8rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 60px rgba(11, 22, 38, 0.22);
    backdrop-filter: blur(10px);
}

#referencePanelModal .modal-header {
    align-items: flex-start;
    border-bottom: 1px solid rgba(43, 76, 126, 0.1);
}

#referencePanelModal .modal-body {
    padding: 1rem;
}

.reference-results-list {
    display: grid;
    gap: 0.75rem;
    max-height: 46vh;
    overflow: auto;
    padding-right: 0.15rem;
}

.reference-result-card {
    padding: 0.85rem;
    border: 1px solid rgba(43, 76, 126, 0.12);
    border-radius: 0.6rem;
    background: rgba(168, 186, 211, 0.1);
}

.reference-result-meta {
    display: grid;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.reference-empty {
    padding: 0.85rem;
    border: 1px dashed rgba(43, 76, 126, 0.2);
    border-radius: 0.6rem;
    color: var(--muted);
    background: rgba(168, 186, 211, 0.08);
}

.auth-form-stack {
    display: block;
}

.auth-switch-link {
    font-size: 0.9rem;
    text-decoration: none;
}

.auth-readonly-note {
    padding: 0.85rem 1rem;
    border: 1px solid rgba(43, 76, 126, 0.12);
    border-radius: 0.75rem;
    background: rgba(168, 186, 211, 0.12);
    color: var(--muted);
}

.progress-lg {
    height: 1.2rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
}

.table > :not(caption) > * > * {
    padding: 0.65rem 0.75rem;
}

.form-control,
.form-select {
    border-radius: 0.85rem;
    border-color: rgba(15, 23, 42, 0.12);
}

.cross-section-list {
    min-height: 100%;
    color: var(--text);
    background-color: rgba(255, 255, 255, 0.72);
    opacity: 1;
}

.cross-section-list:disabled {
    color: var(--text);
    background-color: rgba(255, 255, 255, 0.72);
    opacity: 1;
}

.cross-section-info-plot {
    min-height: 430px;
}

#crossSectionInfoTable th {
    width: 34%;
}

.btn {
    border-radius: 999px;
    font-weight: 600;
}

code {
    background: rgba(15, 23, 42, 0.06);
    padding: 0.15rem 0.4rem;
    border-radius: 0.4rem;
}

@media (max-width: 991.98px) {
    .welcome-shell {
        grid-template-rows: auto 1fr;
    }

    .hero-panel {
        padding: 1.5rem;
    }

    .plot-block,
    .plot-tall,
    .plot-hero,
    .plot-compact {
        min-height: 360px;
    }
}
/* Mobile responsive layer */
@media (max-width: 767.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .welcome-page {
        background-attachment: scroll;
    }

    .welcome-topbar {
        min-width: 0;
        padding: 0.9rem 1rem;
    }

    .welcome-brand {
        font-size: 1rem;
    }

    .welcome-kicker {
        font-size: 0.68rem;
        letter-spacing: 0.12em;
    }

    .welcome-hero {
        justify-content: flex-start;
        padding: 1rem;
    }

    .welcome-content-panel {
        padding: clamp(1.4rem, 7vw, 2rem) 1rem;
        border-radius: 1.15rem;
    }

    .welcome-place {
        margin-bottom: 1rem;
        font-size: 0.7rem;
        letter-spacing: 0.1em;
    }

    .welcome-title {
        font-size: clamp(2rem, 13vw, 3.4rem);
        line-height: 0.96;
        letter-spacing: -0.05em;
    }

    .welcome-title span {
        margin-top: 0.35rem;
        font-size: 0.54em;
        line-height: 1.05;
    }

    .welcome-description {
        margin-top: 1.25rem;
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .welcome-start-panel,
    .welcome-start-panel > div {
        width: 100%;
    }

    .welcome-button {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        padding: 0.85rem 1rem;
    }

    .simulator-shell {
        padding-top: 0.85rem !important;
        padding-right: 0.75rem !important;
        padding-bottom: 1.5rem !important;
        padding-left: 0.75rem !important;
    }

    .simulator-shell .row > * {
        min-width: 0;
    }

    .hero-panel {
        margin-bottom: 1rem !important;
        padding: 1.15rem;
        border-radius: 1.25rem;
    }

    .hero-panel .display-5 {
        font-size: clamp(1.75rem, 9vw, 2.45rem);
        line-height: 1.08;
    }

    .hero-panel .lead {
        font-size: 1rem;
        line-height: 1.5;
    }

    .hero-panel .card-body > .d-flex,
    .simulator-shell .card-body > .d-flex.justify-content-between {
        flex-wrap: wrap;
    }

    .section-tabs {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 0.5rem;
        margin-right: -0.75rem;
        margin-bottom: 1rem !important;
        margin-left: -0.75rem;
        padding: 0.15rem 0.75rem 0.5rem;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .section-tabs::-webkit-scrollbar {
        display: none;
    }

    .section-tabs .nav-item {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    .section-tabs .nav-link {
        min-height: 44px;
        padding: 0.65rem 1rem;
        white-space: nowrap;
    }

    .soft-card,
    .stat-card {
        border-radius: 1rem;
    }

    .soft-card .card-body,
    .stat-card .card-body {
        padding: 1rem;
    }

    #geometry-panel > .row:first-child > [class*="col-"],
    #resultsSummaryGrid > [class*="col-"] {
        width: 50%;
    }

    .stat-label {
        font-size: 0.72rem;
        line-height: 1.3;
    }

    .stat-value,
    #resultsSummaryGrid .stat-value {
        font-size: 1.2rem !important;
        overflow-wrap: anywhere;
    }

    .scenario-preset-box {
        padding: 0.85rem;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    textarea.form-control {
        min-height: 150px;
    }

    .btn:not(.btn-close) {
        min-height: 44px;
    }

    .scenario-actions {
        display: grid !important;
        grid-template-columns: 1fr;
        width: 100%;
    }

    #scenarioManagerButton,
    #saveScenarioButton {
        width: 100%;
    }

    .plot-block,
    .plot-tall,
    .plot-hero,
    .plot-compact,
    .cross-section-info-plot {
        min-height: 320px;
    }

    .leaflet-result-map,
    .leaflet-error {
        min-height: 420px;
        border-radius: 1rem;
    }

    .leaflet-control-layers {
        max-width: calc(100vw - 4.5rem);
        font-size: 0.78rem;
    }

    .table-responsive {
        margin-right: -1rem;
        margin-left: -1rem;
        padding-right: 1rem;
        padding-left: 1rem;
        scrollbar-width: thin;
    }

    .table {
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .modal-dialog {
        margin: 0.65rem;
    }

    .modal-content {
        max-height: calc(100dvh - 1.3rem);
    }

    .modal-header,
    .modal-body {
        padding: 1rem;
    }

    #crossSectionInfoTable th {
        width: 42%;
        white-space: normal;
    }

    #outputFolderText,
    .reference-result-meta,
    dd {
        overflow-wrap: anywhere;
    }
}

@media (max-width: 389.98px) {
    .welcome-topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 0.75rem;
    }

    .welcome-topbar .btn {
        width: 100%;
    }

    #geometry-panel > .row:first-child > [class*="col-"],
    #resultsSummaryGrid > [class*="col-"] {
        width: 100%;
    }

    .plot-block,
    .plot-tall,
    .plot-hero,
    .plot-compact,
    .cross-section-info-plot {
        min-height: 290px;
    }

    .leaflet-result-map,
    .leaflet-error {
        min-height: 360px;
    }
}
