* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f5f2;
    color: #1f2933;
    font-size: 16px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #deded8;
}

.brand {
    font-weight: 700;
    text-decoration: none;
    color: #111827;
    font-size: 20px;
}

.topbar nav a {
    color: #344054;
    text-decoration: none;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
    margin: 0;
}

.link-button {
    appearance: none;
    border: 0;
    background: transparent;
    color: #344054;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.link-button:hover,
.topbar nav a:hover {
    text-decoration: underline;
}

h2 {
    margin: 28px 0 12px;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 32px auto;
}

.card {
    background: #ffffff;
    border: 1px solid #deded8;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.card.narrow {
    max-width: 560px;
    margin: 0 auto;
}

.card.wide {
    max-width: 1100px;
    margin: 0 auto;
}

h1 {
    margin: 0 0 12px;
    line-height: 1.2;
}

p {
    line-height: 1.5;
}

.muted {
    color: #667085;
}

.messages {
    max-width: 780px;
    margin: 0 auto 16px;
}

.message {
    background: #fff7d6;
    border: 1px solid #f0d779;
    border-radius: 12px;
    padding: 12px 14px;
}

.form {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #c9c9c4;
    border-radius: 10px;
    font-size: 16px;
    background: #ffffff;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    color: #667085;
}

.progress-bar {
    height: 10px;
    border-radius: 999px;
    background: #ececea;
    overflow: hidden;
    margin-bottom: 28px;
}

.progress-bar > div {
    height: 100%;
    background: #344054;
}

.question-form {
    display: grid;
    gap: 22px;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #667085;
}

.scale-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    font-size: 13px;
    color: #475467;
}

.scale-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.score-option {
    cursor: pointer;
    border: 1px solid #c9c9c4;
    border-radius: 14px;
    padding: 14px 10px;
    text-align: center;
    min-height: 118px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    font-weight: 400;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.score-option:hover {
    transform: translateY(-1px);
    border-color: #667085;
}

.score-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.score-option.is-selected,
.score-option:has(input:checked) {
    border-color: #0f172a;
    background: #e6edf8;
    box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.28);
}

.score-option.is-selected .score-dot,
.score-option:has(input:checked) .score-dot {
    background: #111827;
    color: #ffffff;
    border-color: #111827;
}

.score-option.is-selected .score-label,
.score-option:has(input:checked) .score-label {
    color: #0f172a;
    font-weight: 700;
}

.score-dot {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 2px solid #111827;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 18px;
}

.score-label {
    min-height: 34px;
    display: block;
    font-size: 13px;
    color: #475467;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
}

.actions.vertical {
    display: grid;
    justify-content: stretch;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    padding: 12px 16px;
    text-decoration: none;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 15px;
}

.button.primary {
    color: #ffffff;
    background: #111827;
}

.button.secondary {
    color: #111827;
    background: #ffffff;
    border-color: #c9c9c4;
}

.button.danger {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.button.danger:hover {
    background: #fee2e2;
}

.person-form {
    display: grid;
    gap: 8px;
    max-width: 280px;
}

.person-form .inline-field {
    display: grid;
    gap: 4px;
    margin: 0;
}

.person-form .inline-field span {
    font-size: 12px;
    font-weight: 600;
    color: #667085;
}

.person-form input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #c9c9c4;
    border-radius: 8px;
    font-size: 14px;
}

.person-form .button {
    width: 100%;
}

.delete-form {
    margin: 0;
}

.label-form {
    display: grid;
    gap: 8px;
}

.label-form .button {
    width: 100%;
}

.ai-report {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f7f7f4;
    border: 1px solid #deded8;
    border-radius: 8px;
    padding: 10px;
    margin-top: 8px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

.summary-meta {
    margin: 18px 0;
    padding: 12px 14px;
    background: #f7f7f4;
    border-radius: 12px;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid #deded8;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

.summary-table,
.list-table {
    border-collapse: collapse;
    width: 100%;
    background: #ffffff;
}

.summary-table th,
.summary-table td,
.list-table th,
.list-table td {
    border: 1px solid #deded8;
    padding: 8px;
    text-align: left;
}

.summary-table th {
    font-size: 13px;
    vertical-align: bottom;
}

.summary-table td:first-child,
.summary-table th:first-child {
    min-width: 240px;
    white-space: nowrap;
}

.mark-cell {
    width: 70px;
    text-align: center !important;
}

.selected-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #111827;
}

.edit-col {
    width: 80px;
    font-size: 13px;
}

.overview-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: #ffffff;
    padding-top: 12px;
    border-top: 1px solid #deded8;
}

.list-table th {
    background: #f7f7f4;
}


.compact-table th,
.compact-table td {
    font-size: 13px;
    padding: 6px;
    text-align: center;
}

.compact-table th:nth-child(2),
.compact-table td:nth-child(2) {
    text-align: left;
    min-width: 220px;
}

.summary-self-legend {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.45;
}

.selbstbild-star-inline {
    color: #16a34a;
}

.compact-table .selbstbild-star {
    display: inline-block;
    margin-left: 6px;
    color: #16a34a;
    font-size: 1.45rem;
    line-height: 1;
    vertical-align: middle;
    font-weight: 700;
}

.question-page .question-card {
    display: flex;
    flex-direction: column;
}

.question-page .question-form {
    flex: 1;
}

.question-page .actions {
    margin-top: auto;
}

@media (max-width: 760px) {
    /* Erlaubt vertikales Scrollen, falls Legend + Frage + Raster auf sehr kleinen
       Displays nicht mehr ohne Schnitt passt (vorher: overflow:hidden hat Inhalt abgeschnitten). */
    .question-page {
        overflow-x: hidden;
    }

    .container {
        width: min(1120px, calc(100% - 20px));
        margin: 20px auto;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px 14px;
    }

    .topbar nav {
        width: 100%;
        justify-content: flex-start;
    }

    .card {
        padding: 16px;
        border-radius: 12px;
    }

    .scale-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .scale-labels {
        font-size: 12px;
    }

    .score-option {
        min-height: 100px;
        padding: 10px 8px;
    }

    .score-dot {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .score-label {
        font-size: 12px;
        min-height: 28px;
    }

    .progress-info {
        flex-direction: column;
        gap: 4px;
    }

    .actions {
        flex-direction: column-reverse;
    }

    .button {
        width: 100%;
    }

    .question-page .topbar {
        padding: 8px 12px;
        gap: 8px;
    }

    .question-page .brand {
        font-size: 16px;
    }

    .question-page .topbar nav a,
    .question-page .link-button {
        font-size: 14px;
    }

    .question-page .container {
        margin: 8px auto;
        height: calc(100dvh - 78px);
        display: flex;
    }

    .question-page .question-card {
        padding: 12px;
        border-radius: 10px;
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .question-page .progress-info {
        margin-bottom: 4px;
        font-size: 13px;
    }

    .question-page .progress-bar {
        height: 8px;
        margin-bottom: 12px;
    }

    .question-page h1 {
        font-size: 20px;
        margin-bottom: 10px;
        line-height: 1.15;
    }

    .question-page .question-form {
        gap: 10px;
        min-height: 0;
    }

    .question-page .scale-labels {
        font-size: 11px;
    }

    .question-page .scale-legend {
        font-size: 11px;
        gap: 8px;
    }

    .question-page .scale-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        min-height: 0;
    }

    .question-page .score-option {
        min-height: 70px;
        padding: 6px 4px;
        border-radius: 10px;
        gap: 4px;
    }

    .question-page .score-dot {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .question-page .score-label {
        display: none;
    }

    .question-page .actions {
        margin-top: 8px;
        gap: 8px;
    }

    .question-page .button {
        padding: 10px 12px;
        font-size: 14px;
    }
}

@media (max-width: 900px) {
    .list-table thead {
        display: none;
    }

    .list-table,
    .list-table tbody,
    .list-table tr,
    .list-table td {
        display: block;
        width: 100%;
    }

    .list-table tr {
        border-bottom: 1px solid #deded8;
        padding: 8px 0;
    }

    .list-table tr:last-child {
        border-bottom: 0;
    }

    .list-table td {
        border: 0;
        border-bottom: 1px solid #eee;
        padding: 8px 10px;
        text-align: left !important;
        min-width: 0 !important;
    }

    .list-table td:last-child {
        border-bottom: 0;
    }

    .list-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 12px;
        font-weight: 700;
        color: #667085;
        margin-bottom: 4px;
    }

    .mark-cell {
        width: auto;
    }

    .edit-col {
        width: auto;
    }

    .overview-actions {
        padding-top: 10px;
    }
}

@media (max-width: 420px) {
    h1 {
        font-size: 24px;
    }

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

    .question-page .scale-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .question-page .scale-labels {
        display: none;
    }

    .question-page .scale-legend {
        grid-template-columns: 1fr;
        gap: 3px;
        font-size: 10px;
    }
}
