/* ==========================================================================
   Bewertung – Oberfläche
   Leitidee: Die Fünf-Gesichter-Skala ist das Herz der App. Ihre Farben
   tragen Bedeutung und kehren in den Auswertungen wieder.
   ========================================================================== */

:root {
    /* Grundpalette */
    --ink:        #232733;
    --ink-soft:   #5c6475;
    --paper:      #f7f8fa;
    --surface:    #ffffff;
    --surface-2:  #f0f2f7;
    --line:       #e4e8f0;

    --bg:        var(--paper);
    --text:      var(--ink);
    --text-mute: var(--ink-soft);

    /* Akzent – wird pro Mandant überschrieben */
    --accent:      #5a4fcf;
    --accent-soft: rgba(90, 79, 207, .10);
    --accent-tx:   #ffffff;

    /* Notenskala: von unzufrieden bis begeistert */
    --note-1: #e5484d;
    --note-2: #ef7a2e;
    --note-3: #96a0b5;
    --note-4: #4cae6c;
    --note-5: #12a08a;

    --ok-bg:   #e6f6ec;  --ok-tx:   #1a6b38;
    --err-bg:  #fdeaea;  --err-tx:  #a92a2f;
    --warn-bg: #fdf3dd;  --warn-tx: #86601a;

    /* Rundungen nach Hierarchie, nicht überall gleich */
    --r-panel: 20px;
    --r-card:  14px;
    --r-ctrl:  10px;
    --r-pill:  999px;

    /* Schatten mit leichtem Blaustich statt neutralem Grau */
    --shadow-sm: 0 1px 2px rgba(35, 39, 51, .05);
    --shadow-md: 0 2px 4px rgba(35, 39, 51, .04), 0 8px 20px rgba(35, 39, 51, .06);
    --shadow-lg: 0 4px 8px rgba(35, 39, 51, .05), 0 18px 44px rgba(35, 39, 51, .10);

    --sans: "Inter", "Segoe UI Variable", "Segoe UI", -apple-system,
            BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
    --bg:        #14161c;
    --surface:   #1c1f28;
    --surface-2: #242833;
    --text:      #e8eaf0;
    --text-mute: #9aa2b4;
    --line:      #2e333f;

    --note-1: #f26a6e;
    --note-2: #f79552;
    --note-3: #8d97ab;
    --note-4: #63c284;
    --note-5: #2bb9a2;

    --ok-bg:   #14301f;  --ok-tx:   #7fd79a;
    --err-bg:  #351a1c;  --err-tx:  #f3a1a4;
    --warn-bg: #332813;  --warn-tx: #e6c377;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .3);
    --shadow-lg: 0 4px 10px rgba(0, 0, 0, .4), 0 18px 44px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        --bg:        #14161c;
        --surface:   #1c1f28;
        --surface-2: #242833;
        --text:      #e8eaf0;
        --text-mute: #9aa2b4;
        --line:      #2e333f;

        --note-1: #f26a6e;
        --note-2: #f79552;
        --note-3: #8d97ab;
        --note-4: #63c284;
        --note-5: #2bb9a2;

        --ok-bg:   #14301f;  --ok-tx:   #7fd79a;
        --err-bg:  #351a1c;  --err-tx:  #f3a1a4;
        --warn-bg: #332813;  --warn-tx: #e6c377;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 2px 4px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .3);
        --shadow-lg: 0 4px 10px rgba(0, 0, 0, .4), 0 18px 44px rgba(0, 0, 0, .45);
    }
}

/* ==========================================================================
   Grundlagen
   ========================================================================== */
* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
    margin: 0 0 .5em;
    font-weight: 640;
    letter-spacing: -.021em;
    line-height: 1.25;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1em; }

a { color: var(--accent); text-underline-offset: 2px; }

.mono, .token { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

code {
    background: var(--surface-2);
    padding: .12em .4em;
    border-radius: 5px;
    font-size: .88em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ==========================================================================
   Kopfleiste
   ========================================================================== */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 14px 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.app-header.is-pinned { position: sticky; top: 0; z-index: 50; }

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

.brand-mark {
    width: 38px; height: 38px;
    flex: 0 0 38px;
    border-radius: 11px;
    background: var(--accent);
    color: var(--accent-tx);
    display: flex; align-items: center; justify-content: center;
    font-weight: 680; font-size: 17px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }

.brand-name {
    font-weight: 620;
    font-size: 1.02rem;
    letter-spacing: -.015em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.theme-controls {
    display: flex; gap: 1px;
    background: var(--surface-2);
    border-radius: var(--r-pill);
    padding: 3px;
}

.theme-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 28px;
    text-decoration: none;
    color: var(--text-mute);
    border-radius: var(--r-pill);
    font-size: 14px; line-height: 1;
}
.theme-btn:hover { color: var(--text); }
.theme-btn.is-active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.pin-btn { font-size: 12px; }
.pin-btn:not(.is-active) { opacity: .5; }

/* ==========================================================================
   Layout
   ========================================================================== */
.container { max-width: 1140px; margin: 0 auto; padding: 30px 26px 48px; }
.container.narrow { max-width: 680px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-sm);
    padding: 24px 26px;
    margin-bottom: 22px;
}

/* Kennzahlen: zusammenhängender Block statt vier gleicher Kärtchen */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    overflow: hidden;
    margin-bottom: 22px;
}

.card.stat {
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 20px 22px;
}

.stat .label {
    font-size: .82rem;
    color: var(--text-mute);
    margin-bottom: 4px;
}
.stat .value {
    font-size: 2rem;
    font-weight: 660;
    letter-spacing: -.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.grid .card.stat:first-child .value { color: var(--accent); }

/* ==========================================================================
   Navigation und Schaltflächen
   ========================================================================== */
.menu { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--accent);
    color: var(--accent-tx);
    text-decoration: none;
    border: 1px solid transparent;
    padding: 10px 17px;
    border-radius: var(--r-ctrl);
    font-size: .93rem;
    font-weight: 560;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: filter .14s ease, background .14s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
    box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); filter: none; }

.btn-danger { background: var(--note-1); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }

/* ==========================================================================
   Formulare
   ========================================================================== */
label { display: block; margin: 18px 0 6px; font-weight: 560; font-size: .9rem; }
label.inline {
    display: inline-flex; align-items: center; gap: 9px;
    font-weight: 400; margin: 0; cursor: pointer;
}

input[type=text], input[type=password], input[type=email],
input[type=number], select, textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r-ctrl);
    font-family: inherit;
    font-size: .95rem;
    transition: border-color .14s ease, box-shadow .14s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-mute); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; }
input[type=color] {
    width: 100%; height: 44px; padding: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-ctrl);
    cursor: pointer;
}
input[type=file] { font-size: .9rem; color: var(--text-mute); }
input[type=file]::file-selector-button {
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--r-ctrl);
    padding: 7px 13px; margin-right: 11px; cursor: pointer; font-family: inherit;
}
textarea { min-height: 120px; resize: vertical; }

.hint { color: var(--text-mute); font-size: .87rem; margin: 5px 0 0; }

fieldset {
    border: none;
    border-top: 1px solid var(--line);
    padding: 6px 0 0;
    margin: 30px 0 0;
}
legend { font-weight: 620; font-size: 1.02rem; padding: 0; }

/* ==========================================================================
   Meldungen
   ========================================================================== */
.notice {
    padding: 12px 15px;
    border-radius: var(--r-ctrl);
    margin-bottom: 18px;
    font-size: .92rem;
}
.notice-ok   { background: var(--ok-bg);   color: var(--ok-tx); }
.notice-err  { background: var(--err-bg);  color: var(--err-tx); }
.notice-warn { background: var(--warn-bg); color: var(--warn-tx); }
.notice a { color: inherit; }

/* ==========================================================================
   Tabellen
   ========================================================================== */
.table-wrap { overflow-x: auto; margin: 0 -26px; padding: 0 26px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 12px 14px; text-align: left; vertical-align: middle; }
th {
    font-size: .82rem;
    font-weight: 560;
    color: var(--text-mute);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: .79rem;
    font-weight: 560;
}
.tag-open { background: var(--ok-bg); color: var(--ok-tx); }
.tag-used { background: var(--surface-2); color: var(--text-mute); }
.tag-sent { background: var(--accent-soft); color: var(--accent); }

/* --- Verteilungsbalken: Farbe je Note ---------------------------------- */
.bar-row { display: flex; align-items: center; gap: 14px; margin: 11px 0; }
.bar-row .face { font-size: 1.35rem; width: 30px; text-align: center; }
.bar {
    flex: 1;
    height: 10px;
    background: var(--surface-2);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.bar span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: var(--r-pill);
}
.bar-row .num {
    font-size: .88rem; min-width: 32px; text-align: right;
    color: var(--text-mute); font-variant-numeric: tabular-nums;
}

.r1 .bar span { background: var(--note-1); }
.r2 .bar span { background: var(--note-2); }
.r3 .bar span { background: var(--note-3); }
.r4 .bar span { background: var(--note-4); }
.r5 .bar span { background: var(--note-5); }

/* ==========================================================================
   Fußzeile
   ========================================================================== */
.app-footer {
    text-align: center;
    color: var(--text-mute);
    font-size: .8rem;
    padding: 28px 20px 38px;
}

/* ==========================================================================
   Öffentliches Bewertungsformular
   ========================================================================== */
.public-wrap { max-width: 34rem; margin: 0 auto; padding: 44px 22px 40px; }

.public-wrap .card {
    border-radius: var(--r-panel);
    box-shadow: var(--shadow-lg);
    padding: 36px 34px;
}

.public-wrap h1 { font-size: 1.65rem; }

.rating-row {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    margin: 26px 0 4px;
    position: relative;
}
.rating-row input[type=radio] {
    position: absolute; opacity: 0; width: 0; height: 0;
}

.rating-btn {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: 34px; line-height: 1;
    padding: 12px 0;
    margin: 0;
    border-radius: var(--r-card);
    border: 2px solid transparent;
    cursor: pointer;
    filter: grayscale(.7);
    opacity: .62;
    transition: transform .16s ease, opacity .16s ease,
                filter .16s ease, background .16s ease;
}
.rating-btn:hover { opacity: 1; filter: none; transform: translateY(-3px); }

.rating-row input[type=radio]:checked + .rating-btn {
    opacity: 1; filter: none; transform: scale(1.1);
}
.rating-row input[type=radio]:focus-visible + .rating-btn {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Jede Note bekommt ihren eigenen Ton, sobald sie gewählt ist */
.rating-row input[type=radio]:checked + .rating-btn:nth-of-type(1) {
    background: color-mix(in srgb, var(--note-1) 14%, transparent);
    border-color: var(--note-1);
}
.rating-row input[type=radio]:checked + .rating-btn:nth-of-type(2) {
    background: color-mix(in srgb, var(--note-2) 14%, transparent);
    border-color: var(--note-2);
}
.rating-row input[type=radio]:checked + .rating-btn:nth-of-type(3) {
    background: color-mix(in srgb, var(--note-3) 14%, transparent);
    border-color: var(--note-3);
}
.rating-row input[type=radio]:checked + .rating-btn:nth-of-type(4) {
    background: color-mix(in srgb, var(--note-4) 14%, transparent);
    border-color: var(--note-4);
}
.rating-row input[type=radio]:checked + .rating-btn:nth-of-type(5) {
    background: color-mix(in srgb, var(--note-5) 14%, transparent);
    border-color: var(--note-5);
}

.reasons { display: none; margin-top: 26px; }
.reasons.is-visible { display: block; }
.reasons h3 { color: var(--text-mute); font-weight: 560; }

.reason-list { display: flex; flex-wrap: wrap; gap: 9px; }
.reason-chip {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 8px 14px;
    border-radius: var(--r-pill);
    cursor: pointer;
    font-size: .9rem;
    transition: border-color .14s ease, background .14s ease;
}
.reason-chip:hover { border-color: var(--accent); }
.reason-chip:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.reason-chip input { margin: 0; }

.state-card { text-align: center; }
.state-icon { font-size: 48px; line-height: 1; margin-bottom: 14px; }

.privacy-note {
    color: var(--text-mute);
    font-size: .83rem;
    line-height: 1.55;
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.privacy-note a { color: var(--text-mute); }

/* ==========================================================================
   Hilfsklassen (statt Inline-Styles, wegen strenger CSP)
   ========================================================================== */
.face-lg { font-size: 1.35rem; }
.label-col { min-width: 190px; }
.mt-md { margin-top: 22px; }
.inline-form { display: inline; }

.w-0{width:0}.w-5{width:5%}.w-10{width:10%}.w-15{width:15%}.w-20{width:20%}
.w-25{width:25%}.w-30{width:30%}.w-35{width:35%}.w-40{width:40%}.w-45{width:45%}
.w-50{width:50%}.w-55{width:55%}.w-60{width:60%}.w-65{width:65%}.w-70{width:70%}
.w-75{width:75%}.w-80{width:80%}.w-85{width:85%}.w-90{width:90%}.w-95{width:95%}
.w-100{width:100%}

/* ==========================================================================
   Klein und barrierefrei
   ========================================================================== */
@media (max-width: 640px) {
    body { font-size: 15px; }
    .app-header { padding: 12px 16px; }
    .container { padding: 20px 16px 34px; }
    .card { padding: 18px 18px; }
    .table-wrap { margin: 0 -18px; padding: 0 18px; }
    .public-wrap { padding: 26px 16px 32px; }
    .public-wrap .card { padding: 26px 20px; border-radius: var(--r-card); }
    .public-wrap h1 { font-size: 1.4rem; }
    .rating-btn { font-size: 27px; padding: 10px 0; }
    .label-col { min-width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    .rating-btn:hover { transform: none; }
}
