:root {
    --bg: #0b1220;
    --bg-elevated: #121a2b;
    --panel: #172235;
    --text: #eef3f8;
    --muted: #9aabbd;
    --accent: #2ec4ff;
    --accent-2: #5ddec9;
    --success: #1fd6a4;
    --warning: #f0b429;
    --error: #ff5d6c;
    --staff: #c4a1ff;
    --line: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
    background:
        radial-gradient(1000px 500px at 20% -10%, rgba(46, 196, 255, 0.18), transparent 55%),
        radial-gradient(800px 400px at 100% 0%, rgba(93, 222, 201, 0.12), transparent 50%),
        var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.app-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 16px calc(92px + env(safe-area-inset-bottom));
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
}

.brand-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.brand-logo {
    /* Breites "Greator presents"-Logo bewusst klein halten. */
    height: 22px;
    width: auto;
    max-width: 52vw;
    object-fit: contain;
    display: block;
}

.brand-tag {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.stepper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.staff-stepper {
    grid-template-columns: repeat(2, 1fr);
}

.single-stepper {
    grid-template-columns: 1fr;
}

body.info-mode #info-stepper .step.is-active {
    border-color: rgba(215, 227, 239, 0.7);
    box-shadow:
        inset 0 0 0 1px rgba(215, 227, 239, 0.35),
        0 8px 22px rgba(215, 227, 239, 0.16);
    color: #d7e3ef;
}

body.info-mode #info-stepper .step.is-active strong {
    color: #eef3f8;
}

body.incoming-mode #return-stepper .step.is-active {
    border-color: rgba(31, 214, 164, 0.55);
    box-shadow:
        inset 0 0 0 1px rgba(31, 214, 164, 0.25),
        0 8px 22px rgba(31, 214, 164, 0.18);
    color: var(--success);
}

body.incoming-mode #return-stepper .step.is-active strong {
    color: var(--success);
}

.staff-stepper .step.is-active {
    border-color: rgba(196, 161, 255, 0.55);
    box-shadow:
        inset 0 0 0 1px rgba(196, 161, 255, 0.25),
        0 8px 22px rgba(196, 161, 255, 0.18);
    color: var(--staff);
}

.staff-stepper .step.is-active strong {
    color: var(--staff);
}

body.staff-mode .status-panel[data-tone="info"],
body.staff-mode .status-panel[data-tone="neutral"] {
    background: rgba(196, 161, 255, 0.12);
    border-color: rgba(196, 161, 255, 0.35);
}

.staff-name-form {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.staff-name-label {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.staff-name-input {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 16px;
}

.staff-name-input:focus {
    outline: none;
    border-color: rgba(196, 161, 255, 0.7);
}

.staff-submit {
    background: var(--staff) !important;
    color: #1a1028 !important;
}

.step {
    border: 1px solid var(--line);
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    position: relative;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
    transform: scale(0.97);
}

.step strong {
    display: block;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 2px;
}

.step.is-active {
    border-color: rgba(46, 196, 255, 0.55);
    box-shadow:
        inset 0 0 0 1px rgba(46, 196, 255, 0.25),
        0 8px 22px rgba(46, 196, 255, 0.2);
    color: var(--accent);
    transform: scale(1.06);
    z-index: 1;
}

.step.is-done {
    border-color: rgba(31, 214, 164, 0.45);
    color: var(--success);
}

.scanner-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin: 8px 0 14px;
    width: 100%;
}

#scanner-video {
    width: min(72vw, 280px);
    height: min(72vw, 280px);
    object-fit: cover;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: #000;
}

.status-panel {
    width: 100%;
    min-height: 180px;
    margin-top: 14px;
    border-radius: 24px;
    padding: 18px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.status-panel[data-tone="success"] {
    background: rgba(31, 214, 164, 0.14);
    border-color: rgba(31, 214, 164, 0.4);
}

.status-panel[data-tone="error"] {
    background: rgba(255, 93, 108, 0.14);
    border-color: rgba(255, 93, 108, 0.45);
}

.status-panel.is-error-emphasis .status-title {
    color: #ff7a88;
    font-size: clamp(28px, 7.5vw, 38px);
    line-height: 1.1;
    font-weight: 850;
}

.status-panel.is-error-emphasis .status-meta {
    color: #f4f7fb;
    font-size: 17px;
    line-height: 1.5;
    font-weight: 650;
}

.status-panel[data-tone="warning"] {
    background: rgba(240, 180, 41, 0.16);
    border-color: rgba(240, 180, 41, 0.5);
}

.status-panel[data-tone="info"] {
    background: rgba(46, 196, 255, 0.12);
    border-color: rgba(46, 196, 255, 0.35);
}

.status-panel.is-compact-info {
    min-height: 0;
    padding: 14px;
    gap: 6px;
    background: #123047;
}

.status-panel.is-compact-info .status-title {
    /* CN klar hervorheben. */
    font-size: 26px;
    font-weight: 850;
    letter-spacing: -0.01em;
    color: #f4fbff;
}

.status-panel.is-compact-info .status-meta {
    font-size: 13px;
    line-height: 1.35;
}

.status-panel.is-compact-info .status-remaining {
    margin-top: 2px;
    padding: 8px 10px;
    font-size: 15px;
}

.status-panel.is-compact-info .status-actions {
    position: static;
    margin-top: 2px;
    padding: 0;
    background: none;
}

.status-panel.is-compact-info .status-ok {
    min-height: 46px;
    margin-top: 2px;
    padding: 10px 14px;
}

.status-kicker {
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.status-language {
    margin: 2px 0 4px;
    font-size: clamp(28px, 8vw, 40px);
    line-height: 1.05;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--accent-2);
    text-transform: uppercase;
}

.status-panel.has-language .status-title {
    font-size: 18px;
    font-weight: 650;
}

.status-panel.is-action-prompt .status-language {
    display: none;
}

.status-panel.is-action-prompt .status-title {
    font-size: clamp(28px, 7.5vw, 38px);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #f4fbff;
}

.status-title {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
}

.status-title:empty {
    display: none;
}

.status-meta {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line;
}

.status-returned {
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 2px solid #1fd6a4;
    background: rgba(31, 214, 164, 0.22);
    color: #baffe9;
    font-size: 19px;
    line-height: 1.25;
    font-weight: 800;
    white-space: pre-line;
}

.status-remaining {
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(240, 180, 41, 0.55);
    background: rgba(240, 180, 41, 0.16);
    color: #ffd978;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 800;
    white-space: pre-line;
}

.status-remaining.is-clear {
    border-color: rgba(93, 222, 201, 0.55);
    background: rgba(93, 222, 201, 0.16);
    color: #8df0df;
}

.status-panel[data-tone="warning"] .status-remaining {
    border-color: rgba(255, 93, 108, 0.55);
    background: rgba(255, 93, 108, 0.16);
    color: #ff8f9a;
}

.status-panel[data-tone="warning"] .status-remaining.is-clear {
    border-color: rgba(93, 222, 201, 0.55);
    background: rgba(93, 222, 201, 0.16);
    color: #8df0df;
}

.status-ok {
    margin-top: 10px;
    align-self: stretch;
    border: 0;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    color: #041018;
    background: #d7e3ef;
}

.status-actions {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.status-actions .status-ok {
    margin-top: 0;
}

.status-issue,
.status-replace {
    display: grid;
    gap: 2px;
    text-align: left;
}

.status-issue strong,
.status-replace strong {
    font-size: 16px;
    line-height: 1.15;
}

.status-issue span,
.status-replace span {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 650;
    opacity: 0.72;
}

.status-blocked-reason {
    padding: 8px 10px;
    border: 1px solid rgba(255, 93, 108, 0.55);
    border-radius: 12px;
    background: rgba(255, 93, 108, 0.14);
    color: var(--error);
    font-size: 20px;
    line-height: 1.2;
    font-weight: 800;
    text-align: center;
}

.status-blocked-reason.is-needs-ticket {
    border-color: rgba(255, 176, 32, 0.7);
    background: rgba(255, 176, 32, 0.18);
    color: #ffcf66;
    font-size: 22px;
}

.status-blocked-reason.is-max-devices {
    font-size: 22px;
}

.status-panel[data-tone="warning"] .status-title {
    color: #ffcf66;
}

.status-panel.has-dismiss .status-actions,
.status-panel.has-info-actions .status-actions {
    display: grid;
}

.status-panel.has-dismiss .status-ok {
    display: block;
}

.status-issue:disabled,
.status-issue.is-disabled {
    opacity: 0.38;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

.status-panel[data-tone="info"] .status-issue:not(:disabled) {
    background: rgba(93, 222, 201, 0.55);
    color: #041018;
}

.status-panel[data-tone="info"] .status-replace:not(:disabled),
.status-panel[data-tone="warning"] .status-replace:not(:disabled) {
    background: rgba(240, 180, 41, 0.78);
    color: #201400;
}

.status-panel[data-tone="error"] .status-ok {
    background: rgba(255, 93, 108, 0.35);
    color: #fff;
}

.status-panel[data-tone="info"] .status-ok {
    background: rgba(46, 196, 255, 0.45);
    color: #041018;
}

.fixed-bottom-subnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 9001;
    margin: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    background: rgba(11, 18, 32, 0.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    display: flex;
}

.fixed-bottom-subnav li {
    flex: 1;
    list-style: none;
    padding: 0;
    cursor: pointer;
}

.fixed-bottom-subnav li span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 76px;
    font-weight: 700;
    color: var(--muted);
}

body.outgoing-mode #outgoing-toggle span,
body.incoming-mode #incoming-toggle span,
body.info-mode #info-toggle span,
body.staff-mode #staff-toggle span {
    color: #041018;
}

body.outgoing-mode #outgoing-toggle {
    background: var(--accent);
}

body.incoming-mode #incoming-toggle {
    background: var(--success);
}

body.info-mode #info-toggle {
    background: #d7e3ef;
}

body.staff-mode #staff-toggle {
    background: #d7c7ff;
}

.uk-subnav {
    margin-left: 0;
}

.busy-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 18, 0.35);
    z-index: 8000;
}

body.is-busy .busy-overlay {
    display: block;
}

/* Ergebnis liegt über der Kamerafläche — kein Nach-unten-Schieben. */
body.has-scan-overlay .scanner-stage {
    min-height: min(72vw, 280px);
}

body.has-scan-overlay #scanner-video {
    opacity: 0.22;
    filter: saturate(0.7);
}

body.has-scan-overlay .status-panel {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: min(92vw, 420px);
    min-height: min(72vw, 280px);
    max-height: min(72vw, 280px);
    margin-top: 0;
    z-index: 2;
    justify-content: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(10, 28, 44, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

body.has-scan-overlay .status-panel[data-tone="error"] {
    background: rgba(72, 18, 28, 0.94);
    border-color: rgba(255, 93, 108, 0.55);
}

body.has-scan-overlay .status-panel.is-all-returned {
    justify-content: center;
    background: rgba(7, 58, 48, 0.88);
    border-color: rgba(31, 214, 164, 0.7);
    text-align: center;
}

body.has-scan-overlay .status-panel.is-all-returned .status-title {
    color: #63f0c5;
    font-size: clamp(30px, 8vw, 42px);
    line-height: 1.05;
    font-weight: 900;
    letter-spacing: -0.02em;
}

body.has-scan-overlay .status-panel.is-all-returned .status-meta {
    color: rgba(235, 255, 249, 0.82);
    font-size: 15px;
    line-height: 1.35;
    font-weight: 650;
}

/* Zwischenschritt im Tausch: eindeutig als Etappe erkennbar. */
body.has-scan-overlay .status-panel.is-exchange-step {
    justify-content: center;
    text-align: center;
    background: #0c3550;
    border-color: #2ec4ff;
    border-width: 2px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.has-scan-overlay .status-panel.is-exchange-step .status-title {
    color: #8fe2ff;
    font-size: clamp(24px, 6.4vw, 34px);
    line-height: 1.1;
    font-weight: 900;
    letter-spacing: -0.02em;
}

body.has-scan-overlay .status-panel.is-exchange-step .status-meta {
    color: rgba(226, 246, 255, 0.84);
    font-size: 14px;
    line-height: 1.4;
}

/* Tausch abgeschlossen: klar sichtbar, nicht transparent. */
body.has-scan-overlay .status-panel.is-exchange-done {
    justify-content: center;
    gap: 10px;
    text-align: center;
    background: #06463a;
    border-color: #1fd6a4;
    border-width: 2px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

body.has-scan-overlay .status-panel.is-exchange-done .status-title {
    color: #7dffd4;
    font-size: clamp(28px, 7.6vw, 40px);
    line-height: 1.05;
    font-weight: 900;
    letter-spacing: -0.02em;
}

body.has-scan-overlay .status-panel.is-exchange-done .status-remaining {
    border-color: #1fd6a4;
    background: rgba(31, 214, 164, 0.22);
    color: #d4fff2;
    font-size: 17px;
    line-height: 1.35;
    text-align: center;
}

body.has-scan-overlay .status-panel.is-exchange-done .status-meta {
    color: rgba(228, 255, 248, 0.82);
    font-size: 14px;
}

body.has-scan-overlay .status-panel.is-exchange-done .status-kicker {
    color: rgba(228, 255, 248, 0.72);
}

body.has-scan-overlay .status-panel.is-partial-return {
    justify-content: flex-start;
    gap: 5px;
    padding: 13px;
    overflow: hidden;
    /* Größere CN braucht mehr Höhe als die Kamerafläche — nichts abschneiden. */
    max-height: min(calc(100dvh - 240px - env(safe-area-inset-bottom)), 400px);
}

body.has-scan-overlay .status-panel.is-partial-return .status-returned {
    margin-top: 0;
    padding: 9px 11px;
    font-size: 18px;
    line-height: 1.3;
}

body.has-scan-overlay .status-panel.is-partial-return .status-remaining {
    white-space: pre-line;
    font-size: 16px;
    line-height: 1.35;
}

/* Teilrückgabe: CN groß und klar, Name bewusst klein als Zusatzinfo. */
body.has-scan-overlay .status-panel.is-partial-return .status-title {
    font-size: clamp(23px, 6.2vw, 30px);
    line-height: 1.08;
    font-weight: 900;
    letter-spacing: -0.01em;
    color: #f4fbff;
}

body.has-scan-overlay .status-panel.is-partial-return .status-meta {
    font-size: 13px;
    line-height: 1.3;
}

body.has-scan-overlay .status-panel.is-error-emphasis .status-title {
    font-size: clamp(24px, 6.5vw, 34px);
}

body.has-scan-overlay .status-panel.is-error-emphasis .status-meta {
    font-size: 15px;
    line-height: 1.4;
}

/* Buttonleiste deckend, damit darunterliegender Inhalt nicht durchscheint. */
body.has-scan-overlay .status-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin-top: 6px;
    padding: 10px 0 4px;
    background: rgba(10, 28, 44, 0.99);
    box-shadow: 0 -12px 14px rgba(10, 28, 44, 0.99);
}

body.has-scan-overlay .status-panel[data-tone="error"] .status-actions {
    background: rgba(72, 18, 28, 0.99);
    box-shadow: 0 -12px 14px rgba(72, 18, 28, 0.99);
}

/* Info mit Aktionsbuttons braucht mehr Höhe als die Kamerafläche. */
body.has-info-result .scanner-stage {
    display: flex;
}

body.has-info-result.has-scan-overlay .status-panel {
    min-height: min(72vw, 280px);
    max-height: calc(100dvh - 250px - env(safe-area-inset-bottom));
}

body.has-info-result .status-panel {
    justify-content: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
}

body.has-scan-overlay .status-remaining,
body.has-scan-overlay .status-returned {
    margin-bottom: 2px;
}

/* Kompakte Hinweiszeile, damit die Device-IDs über der Buttonleiste sichtbar bleiben. */
body.has-info-result .status-blocked-reason.is-max-devices,
body.has-info-result .status-blocked-reason.is-needs-ticket {
    font-size: 18px;
}

@media (max-height: 620px) {
    body.has-info-result .brand-bar {
        margin-bottom: 8px;
    }

    .brand-logo {
        height: 18px;
    }

    body.has-info-result #info-stepper {
        display: none;
    }

    body.has-scan-overlay .status-panel,
    body.has-info-result .status-panel {
        padding: 12px;
        border-radius: 18px;
        gap: 5px;
    }

    body.has-info-result .status-language {
        font-size: 25px;
    }

    body.has-info-result .status-meta {
        font-size: 13px;
        line-height: 1.3;
    }

    body.has-info-result .status-ok {
        min-height: 48px;
        padding: 11px 14px;
    }

    body.has-info-result.has-scan-overlay .status-panel {
        max-height: calc(100dvh - 190px - env(safe-area-inset-bottom));
    }
}
