/* =====================================================================
   Belastungs-Coach – eigenständige, in sich geschlossene Styles.
   Mobile-first.
   ===================================================================== */

/* ===================== Design-Tokens ===================== */

:root {
    --bg: #000000;
    --panel: #ffffff;
    --ink: #242424;
    --ink-soft: #6b6b76;
    --line: #ececf1;
    --blue: #704cff;
    --blue-2: #21c8df;
    --blue-soft: rgba(117, 88, 255, .14);
    --orange: #ff836b;
    --orange-2: #f08a3c;
    --orange-soft: #fce8d2;
    --radius: 13px;
    --grad: linear-gradient(135deg, #7558ff, #21c8df);
    --grad-2: linear-gradient(135deg, #24c7df, #a94cff);
    --grad-3: linear-gradient(135deg, #ff836b, #754dff);
    --purple-bg: #e2ddf9;
    --rose-bg: #f7d9df;
    --blue-bg: #d9eafa;
    --orange-bg: #fce8d2;
}

/* ===================== Reset ===================== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    direction: ltr;
    text-align: left;
}

body {
    background: linear-gradient(
        90deg,
        #000000 0%,
        #000000 30%,
        #071525 60%,
        var(--blue) 100%
    );
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% -12%, rgba(255, 255, 255, .06), transparent 55%);
}

/* ===================== App / Header ===================== */

.app {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.header {
    flex: 0 0 auto;
    padding: 19px 28px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 9px;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, .55);
}

.logo {
    width: 200px;
    height: auto;
    max-height: 64px;
    object-fit: contain;
    display: block;
}

.connection {
    display: flex;
    align-items: center;
    gap: 9px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c9ccd6;
    transition: background .3s, box-shadow .3s;
}

.connection.online .connection-dot {
    background: var(--blue);
    box-shadow: 0 0 12px rgba(117, 88, 255, .55);
}

.status {
    font-size: 10px;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, .7);
}

/* ===================== Titelleiste ===================== */

.panel-title {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--line);
}

.panel-title-text {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: .5px;
    line-height: 1.1;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--blue);
}

.login-button {
    flex: 0 0 auto;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e6e0ff;
    border-radius: 8px;
    background: transparent;
    color: var(--blue);
    cursor: pointer;
}

.login-button:hover {
    background: var(--purple-bg);
    filter: none;
    transform: none;
    box-shadow: none;
}

.login-button svg {
    width: 16px;
    height: 16px;
}

.login-button[hidden],
.user-name[hidden] {
    display: none;
}

.user-name {
    flex: 0 0 auto;
    margin-left: auto;
    max-width: 150px;
    padding: 7px 12px;
    border-radius: 8px;
    background: var(--purple-bg);
    color: var(--blue);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.user-name:hover {
    background: #d6cdf7;
}

.usage-badge {
    flex: 0 0 auto;
    padding: 4px 9px;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--ink-soft);
    background: #f1f2f7;
    border-radius: 999px;
    white-space: nowrap;
}

.usage-badge.unlocked {
    color: #0f7a3d;
    background: #d6f5e3;
}

/* ===================== Buttons ===================== */

button {
    appearance: none;
    border: none;
    background: var(--grad);
    color: #ffffff;
    padding: 11px 21px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 1.5px;
    border-radius: 9px;
    cursor: pointer;
    transition: filter .2s, box-shadow .15s, transform .15s, background .2s;
    white-space: nowrap;
}

button:hover {
    filter: brightness(1.06);
    box-shadow: 0 5px 16px rgba(0, 0, 0, .12);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

button.ghost {
    padding: 10px 16px;
    letter-spacing: 1.5px;
    color: var(--blue);
    background: #ffffff;
    border: 1px solid #e6e0ff;
}

button.ghost:hover {
    background: var(--purple-bg);
    color: var(--blue);
    filter: none;
}

button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ===================== Statuszeile ===================== */

.status-bar {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0 28px 13px;
}

.debug {
    color: #8a8f9e;
    font-size: 7px;
    letter-spacing: 1px;
}

.disclaimer {
    color: #8a8f9e;
    font-size: 8px;
    letter-spacing: .3px;
    text-align: right;
}

/* ===================== Auth-/Konto-Overlays ===================== */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, .7);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.overlay.open {
    display: flex;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 26px 24px 22px;
    background: #ffffff;
    color: var(--ink);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

.login-card h2 {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: .5px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-card label {
    margin-top: 6px;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 2.5px;
    color: var(--ink-soft);
}

.login-card input {
    width: 100%;
    padding: 11px 13px;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink);
    background: #f7f8fc;
    border: 1px solid var(--line);
    border-radius: 9px;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.login-card input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-soft);
    background: #ffffff;
}

.login-card form button {
    width: 100%;
    margin-top: 14px;
}

.login-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    color: var(--ink-soft);
    background: transparent;
    border-radius: 8px;
}

.login-close:hover {
    color: var(--ink);
    background: #f0f0f5;
    filter: none;
    transform: none;
    box-shadow: none;
}

.sc-register-only[hidden] {
    display: none;
}

.sc-account {
    max-width: 420px;
}

.sc-account-panel[hidden] {
    display: none;
}

.sc-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.sc-tab {
    flex: 1 1 0;
    padding: 9px 10px;
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--ink-soft);
    background: #f1f2f7;
    border-radius: 8px;
    box-shadow: none;
}

.sc-tab:hover {
    transform: none;
    box-shadow: none;
    filter: none;
    background: #e9eaf2;
}

.sc-tab.active {
    color: #ffffff;
    background: var(--grad);
}

.sc-message {
    min-height: 14px;
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--ink-soft);
}

.sc-message.error {
    color: #b42318;
}

.sc-auth-note {
    margin: 0 0 14px;
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.5;
    color: #1d4ed8;
    background: var(--blue-bg);
    border-radius: 9px;
}

.sc-auth-note[hidden] {
    display: none;
}

.sc-balance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: #f7f8fc;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.sc-balance-label {
    display: block;
    font-size: 7px;
    letter-spacing: 2.5px;
    color: var(--ink-soft);
}

.sc-balance-value {
    display: block;
    margin-top: 3px;
    font-size: 18px;
    font-weight: 750;
    color: var(--ink);
}

.sc-badge {
    flex: 0 0 auto;
    padding: 5px 9px;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #b42318;
    background: var(--rose-bg);
    border-radius: 999px;
    white-space: nowrap;
}

.sc-badge.unlocked {
    color: #0f7a3d;
    background: #d6f5e3;
}

.sc-payment {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.sc-pay-btn {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 1.5px;
    text-align: center;
    color: #ffffff;
    background: var(--grad);
    border: none;
    border-radius: 9px;
}

.sc-qr {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    padding: 8px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.sc-qr[hidden] {
    display: none;
}

.sc-bank {
    margin: 0;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--ink);
    background: #f7f8fc;
    border: 1px solid var(--line);
    border-radius: 9px;
}

.sc-hint {
    margin: 0;
    font-size: 10px;
    color: var(--ink-soft);
}

.sc-logout-btn {
    width: 100%;
    margin-top: 12px;
    color: #b42318;
    border-color: #f3c9c4;
}

.sc-logout-btn:hover {
    background: var(--rose-bg);
    color: #b42318;
}

/* ===================== Layout ===================== */

.coach-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    width: 100%;
    padding: 8px 28px 16px;
}

.coach-panel {
    flex: 1 1 auto;
    max-width: none;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 5px solid var(--blue);
    border-radius: var(--radius);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
    overflow: hidden;
    color: var(--ink);
}

.coach-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
}

.screen {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.screen.active {
    display: flex;
}

.coach-card {
    padding: 18px;
    background: #f7f8fc;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.coach-card.center {
    text-align: center;
}

.screen h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .3px;
}

.screen h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.4;
}

.muted {
    color: var(--ink-soft);
    font-size: 12px;
    line-height: 1.6;
}

.duration {
    display: inline-block;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--blue);
    background: var(--purple-bg);
    border-radius: 999px;
}

/* ===================== Consent ===================== */

.consent {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}

.consent input {
    width: 20px;
    height: 20px;
    margin: 0;
    flex: 0 0 auto;
}

/* ===================== Progress ===================== */

.coach-progress {
    height: 8px;
    border-radius: 999px;
    background: #eceef6;
    overflow: hidden;
}

.coach-progress-bar {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: var(--grad);
    transition: width .25s;
}

.coach-progress-label {
    margin-top: -8px;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--ink-soft);
    text-transform: uppercase;
}

/* ===================== Fragebogen ===================== */

.q-dim {
    display: block;
    margin-bottom: 8px;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: var(--blue);
    text-transform: uppercase;
}

.q-options {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 16px;
}

.q-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 15px 16px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-align: left;
    white-space: normal;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.q-option:hover {
    transform: none;
    filter: none;
    box-shadow: none;
    border-color: var(--blue);
    background: #ffffff;
}

.q-option .q-num {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
    background: var(--purple-bg);
    border-radius: 50%;
}

.q-option.selected {
    border-color: var(--blue);
    background: var(--blue-soft);
    box-shadow: 0 0 0 2px var(--blue-soft);
}

.q-option.selected .q-num {
    color: #ffffff;
    background: var(--grad);
}

.q-nav {
    display: flex;
    gap: 10px;
}

.q-nav button {
    flex: 1 1 0;
}

/* ===================== Dialog ===================== */

.dialog-log {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 120px;
}

.bubble {
    max-width: 88%;
    padding: 11px 13px;
    font-size: 13px;
    line-height: 1.55;
    border: 1px solid var(--line);
    border-radius: 13px;
}

.bubble.assistant {
    align-self: flex-start;
    background: var(--blue-bg);
    border-color: rgba(112, 76, 255, .14);
}

.bubble.user {
    align-self: flex-end;
    background: var(--orange-bg);
    border-color: rgba(240, 138, 60, .22);
}

.bubble.error {
    align-self: center;
    color: #b42318;
    background: var(--rose-bg);
    border-color: rgba(180, 35, 24, .15);
}

.dialog-input {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: 14px;
}

.dialog-input textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 52px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    color: var(--ink);
    background: #f7f8fc;
    border: 1px solid var(--line);
    border-radius: 10px;
    resize: vertical;
}

.dialog-input textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-soft);
    background: #ffffff;
}

/* ===================== Report ===================== */

.report-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-section-title {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: var(--ink-soft);
    text-transform: uppercase;
}

.report-summary {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
}

.dimension-card {
    padding: 13px 14px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-left: 5px solid var(--ink-soft);
    border-radius: 11px;
}

.dimension-card.status-rot { border-left-color: #e5484d; }
.dimension-card.status-orange { border-left-color: #f08a3c; }
.dimension-card.status-gelb { border-left-color: #e2b93b; }
.dimension-card.status-gruen { border-left-color: #30a46c; }
.dimension-card.status-nicht_auswertbar { border-left-color: #c9ccd6; }

.dimension-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.dimension-name {
    font-size: 13px;
    font-weight: 700;
}

.dimension-score {
    font-size: 13px;
    font-weight: 700;
    color: var(--blue);
    white-space: nowrap;
}

.dimension-status {
    display: inline-block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.status-rot .dimension-status { color: #c62a2f; }
.status-orange .dimension-status { color: #c96a1c; }
.status-gelb .dimension-status { color: #9a7b12; }
.status-gruen .dimension-status { color: #1d7a4d; }
.status-nicht_auswertbar .dimension-status { color: var(--ink-soft); }

.dimension-bar {
    margin-top: 8px;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--blue);
}

.dimension-note {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--ink-soft);
}

.eri-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.eri-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 650;
}

.eri-bar {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--orange-2);
}

.eri-bar.reward {
    color: #30a46c;
}

.eri-badge {
    display: inline-block;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: 999px;
    background: var(--orange-soft);
    color: #b4621c;
}

.eri-badge.equilibrium { background: #d6f5e3; color: #1d7a4d; }
.eri-badge.borderline { background: #fdf0d0; color: #9a7b12; }
.eri-badge.imbalance { background: var(--rose-bg); color: #c62a2f; }

.reflection-list,
.recommendation-list {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink);
}

.reflection-next {
    padding: 12px 14px;
    background: var(--purple-bg);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.report-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.report-locked {
    padding: 16px;
    text-align: center;
    background: var(--orange-soft);
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.coach-message {
    min-height: 14px;
    font-size: 12px;
    color: var(--ink-soft);
}

.coach-message.error {
    color: #b42318;
}

/* ===================== Verlauf ===================== */

.coach-history-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 11px 13px;
    white-space: normal;
    text-align: left;
    color: var(--ink);
    background: #f7f8fc;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.coach-history-item:hover {
    transform: none;
    box-shadow: none;
    filter: none;
    border-color: var(--blue);
    background: #ffffff;
}

.coach-history-item-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

.coach-history-item-meta {
    font-size: 10px;
    color: var(--ink-soft);
    letter-spacing: 0;
}

/* ===================== Spinner / Übergang ===================== */

.spinner {
    width: 28px;
    height: 28px;
    margin: 8px auto 0;
    border: 3px solid var(--line);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: coach-spin 0.9s linear infinite;
}

@keyframes coach-spin {
    to { transform: rotate(360deg); }
}

.thanks {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
}

/* ===================== Mobile ===================== */

@media (max-width: 900px) {
    .header {
        padding: 18px 18px 6px;
    }

    .status-bar {
        padding: 0 18px 12px;
    }
}

@media (max-width: 640px) {
    .logo {
        width: 150px;
        max-height: 48px;
    }

    .coach-stage {
        padding: 6px 12px 12px;
    }

    .coach-panel {
        border-left-width: 4px;
    }

    .coach-body {
        padding: 16px 14px;
    }

    .screen h1 {
        font-size: 20px;
    }

    .q-option {
        padding: 17px 16px;
        font-size: 14px;
    }
}

/* ===================== PDF / Druck ===================== */

@media print {
    html,
    body {
        overflow: visible !important;
        height: auto !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    body::after {
        display: none !important;
    }

    .header,
    .status-bar,
    .report-actions,
    .coach-progress,
    .coach-progress-label {
        display: none !important;
    }

    .coach-stage {
        display: block !important;
        padding: 0 !important;
    }

    .coach-panel {
        max-width: none !important;
        border: none !important;
        border-left: none !important;
        box-shadow: none !important;
    }

    .panel-title {
        border-bottom: 2px solid #000 !important;
    }

    .panel-title .login-button,
    .panel-title .user-name,
    .usage-badge {
        display: none !important;
    }

    .coach-body {
        overflow: visible !important;
        padding: 0 !important;
    }

    .dimension-card,
    .coach-card {
        break-inside: avoid;
        border: 1px solid #cccccc !important;
        box-shadow: none !important;
    }
}
