/* =================================================================
   Platform7 SevenSales — Admin UI
   Notion/Linear-style, Light-only, Sidebar-Layout.
   Strict-CSP: keine @import, keine remote fonts.
   ================================================================= */

/* ----- design tokens ------------------------------------------- */
:root {
    /* surface */
    --bg:           #fbfbfa;
    --bg-elevated:  #ffffff;
    --bg-sunken:    #f5f5f4;
    --bg-hover:     rgba(15, 15, 15, 0.04);
    --bg-active:    rgba(15, 15, 15, 0.06);

    /* lines */
    --line:         #ebebea;
    --line-strong:  #d4d4d2;
    --line-soft:    rgba(15, 15, 15, 0.06);

    /* text */
    --ink:          #1a1a1a;
    --ink-2:        #525252;
    --ink-muted:    #999999;
    --ink-faint:    #b8b8b6;

    /* accent — kept from previous palette but used sparingly */
    --accent:        #1f5965;
    --accent-soft:   #e8f0f1;
    --accent-strong: #154048;

    /* status */
    --ok:        #2e8555;
    --ok-soft:   #e6f3ec;
    --warn:      #b97a1f;
    --warn-soft: #fbf2e2;
    --danger:    #c93b22;
    --danger-soft:#fbe9e6;
    --info:      #2c5e91;
    --info-soft: #e6eef7;

    /* type scale (compact, Notion-density) */
    --fs-xs:    11px;
    --fs-sm:    12.5px;
    --fs-body:  14px;
    --fs-md:    15px;
    --fs-lg:    18px;
    --fs-xl:    22px;
    --fs-xxl:   28px;
    --lh-tight: 1.3;
    --lh-body:  1.5;

    /* spacing rhythm — multiples of 4 */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10:40px;
    --sp-12:48px;
    --sp-16:64px;

    --radius-sm: 4px;
    --radius:    6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    --shadow-sm: 0 1px 0 rgba(15, 15, 15, 0.04);
    --shadow:    0 1px 0 rgba(15, 15, 15, 0.04),
                 0 4px 12px rgba(15, 15, 15, 0.04);
    --shadow-md: 0 1px 0 rgba(15, 15, 15, 0.05),
                 0 8px 28px rgba(15, 15, 15, 0.08);

    --font-sans: "Inter var", "Inter", -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code",
                 Consolas, "Liberation Mono", Menlo, monospace;

    --sidebar-w: 248px;
    --content-max: 1100px;
}

/* ----- reset --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
code {
    font-family: var(--font-mono);
    font-size: 0.92em;
    color: var(--ink-2);
    background: var(--bg-sunken);
    padding: 0.05em 0.35em;
    border-radius: 3px;
}
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-2); }
.muted { color: var(--ink-muted); }
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0; padding: 0; margin: -1px;
}

/* ===== APP SHELL =============================================== */
.app-body {
    background: var(--bg);
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ----- sidebar ------------------------------------------------- */
.app-sidebar {
    grid-row: 1;
    grid-column: 1;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: var(--sp-4) var(--sp-3);
    background: var(--bg);
    border-right: 1px solid var(--line);
    overflow-y: auto;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
    padding: var(--sp-2);
    border-radius: var(--radius);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
    margin-bottom: var(--sp-4);
}
.brand:hover { background: var(--bg-hover); text-decoration: none; }

.brand-logo {
    width: 160px;
    height: auto;
    flex: 0 0 auto;
}

.brand-product {
    font-size: var(--fs-xs);
    color: var(--ink-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav-primary {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px var(--sp-2);
    border-radius: var(--radius);
    color: var(--ink-2);
    font-size: var(--fs-body);
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.08s ease, color 0.08s ease;
}
.nav-item:hover { background: var(--bg-hover); color: var(--ink); text-decoration: none; }
.nav-item.is-active {
    background: var(--bg-active);
    color: var(--ink);
    font-weight: 600;
}

.nav-item__bullet {
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: var(--ink-faint);
    flex: 0 0 auto;
    transition: background-color 0.08s ease;
}
.nav-item:hover .nav-item__bullet { background: var(--ink-muted); }
.nav-item.is-active .nav-item__bullet { background: var(--accent); }

/* push a count badge to the far right of the nav row */
.nav-item__label { flex: 1 1 auto; min-width: 0; }
.nav-item__badge {
    flex: 0 0 auto;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--warn-soft);
    color: var(--warn);
    font-size: var(--fs-sm);
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* user area at bottom of sidebar */
.nav-user {
    margin-top: auto;
    padding-top: var(--sp-4);
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.who {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px var(--sp-2);
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
}
.who:hover { background: var(--bg-hover); text-decoration: none; }
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--fs-sm);
    flex: 0 0 auto;
}
.who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who-name {
    font-size: var(--fs-body);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.who-email {
    font-size: var(--fs-xs);
    color: var(--ink-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-form { margin: 0; padding: 0 var(--sp-2); }

/* ----- main + content ------------------------------------------ */
.app-main {
    grid-row: 1;
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}
.app-content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-8) var(--sp-6) var(--sp-12);
}
.site-footer {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-4) var(--sp-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-2);
    color: var(--ink-muted);
    font-size: var(--fs-sm);
    border-top: 1px solid var(--line);
}

/* ===== TYPOGRAPHY ============================================== */
h1, h2, h3, h4 {
    margin: 0 0 var(--sp-2);
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: var(--lh-tight);
}
h1 { font-size: var(--fs-xxl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--sp-3); }

.eyebrow {
    display: inline-block;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    margin-bottom: var(--sp-1);
}

.subtitle {
    color: var(--ink-2);
    font-size: var(--fs-md);
    margin: var(--sp-1) 0 0;
}

/* page header band */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    padding-bottom: var(--sp-5);
    margin-bottom: var(--sp-6);
    border-bottom: 1px solid var(--line);
}
.page-header > div:first-child { flex: 1; min-width: 0; }

.divider {
    height: 1px;
    background: var(--line);
    border: 0;
    margin: var(--sp-6) 0;
}

/* ===== CARDS =================================================== */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    margin-bottom: var(--sp-4);
    overflow: hidden;
}
.card-header {
    padding: var(--sp-3) var(--sp-5);
    border-bottom: 1px solid var(--line);
    background: var(--bg-elevated);
}
.card-header h3 { margin: 0; font-size: var(--fs-md); }
.card-body { padding: var(--sp-5); }
.card--alert {
    border-color: #e6c887;
    background: var(--warn-soft);
}

.empty-state {
    padding: var(--sp-10) var(--sp-6);
    text-align: center;
    color: var(--ink-muted);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
}
.empty-state h3 { color: var(--ink); margin-bottom: var(--sp-2); }
.empty-state p { margin: 0; font-size: var(--fs-sm); }

/* ===== STATS GRID ============================================= */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-6); }
@media (max-width: 800px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.stat {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}
.stat-label {
    font-size: var(--fs-sm);
    color: var(--ink-muted);
    font-weight: 500;
}
.stat-value {
    font-size: var(--fs-xxl);
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.stat-meta {
    font-size: var(--fs-sm);
    color: var(--ink-muted);
}

/* ===== TABLES ================================================== */
.table-wrap {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    margin-bottom: var(--sp-4);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-body);
}
.table th, .table td {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line-soft);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table thead th {
    background: var(--bg-elevated);
    color: var(--ink-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--line);
    padding-top: var(--sp-3);
    padding-bottom: var(--sp-3);
}
.table tbody tr { transition: background-color 0.08s ease; }
.table tbody tr:hover { background: var(--bg-hover); }
.table strong { font-weight: 600; }

/* ===== BADGES ================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: var(--fs-xs);
    font-weight: 500;
    line-height: 1.5;
    background: var(--bg-sunken);
    color: var(--ink-2);
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.75;
    flex: 0 0 auto;
}
.badge--ok      { background: var(--ok-soft);     color: var(--ok); }
.badge--warn    { background: var(--warn-soft);   color: var(--warn); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); }
.badge--info    { background: var(--info-soft);   color: var(--info); }
.badge--muted   { background: var(--bg-sunken);   color: var(--ink-muted); }

/* ===== BUTTONS ================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: var(--fs-body);
    font-weight: 500;
    color: #fff;
    background: var(--ink);
    text-decoration: none;
    transition: background-color 0.08s ease, border-color 0.08s ease, color 0.08s ease, transform 0.05s ease;
    cursor: pointer;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { background: #000; text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-strong); }

.btn--secondary {
    background: var(--bg-elevated);
    color: var(--ink);
    border-color: var(--line-strong);
}
.btn--secondary:hover { background: var(--bg-sunken); }

.btn--ghost {
    background: transparent;
    color: var(--ink-2);
    border-color: transparent;
}
.btn--ghost:hover { background: var(--bg-hover); color: var(--ink); }

.btn--danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn--danger:hover { background: #a02e1a; }

.btn--sm { font-size: var(--fs-sm); padding: 4px 10px; }
.btn--lg { font-size: var(--fs-md); padding: 9px 16px; }
.btn--block { width: 100%; }

/* ===== FORMS =================================================== */
.field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    margin-bottom: var(--sp-4);
    min-width: 0;
}
.field label {
    font-size: var(--fs-sm);
    color: var(--ink-2);
    font-weight: 500;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="search"],
.field input[type="url"],
.field input[type="date"],
.field textarea,
.field select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="date"],
textarea,
select {
    font: inherit;
    font-size: var(--fs-body);
    color: var(--ink);
    background: var(--bg-elevated);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 7px 10px;
    width: 100%;
    line-height: 1.4;
    transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
.field textarea, textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}
.field input:focus,
.field textarea:focus,
.field select:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder, .field textarea::placeholder {
    color: var(--ink-faint);
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: flex-end;
}
.row > .field { flex: 1; min-width: 160px; }

.form-error {
    color: var(--danger);
    font-size: var(--fs-sm);
    margin: var(--sp-1) 0 0;
}
.help-text {
    color: var(--ink-muted);
    font-size: var(--fs-sm);
    margin: var(--sp-1) 0 0;
}
.form-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    margin-top: var(--sp-5);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--line);
}

label.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: var(--sp-3);
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
}
label.check input[type="checkbox"],
label.check input[type="radio"] {
    width: auto;
    accent-color: var(--accent);
}

/* ===== FLASH ==================================================== */
.flash {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    margin-bottom: var(--sp-3);
    font-size: var(--fs-body);
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
}
.flash--info    { background: var(--info-soft);   border-color: #c6daed; color: var(--info); }
.flash--success { background: var(--ok-soft);     border-color: #b9dec8; color: var(--ok); }
.flash--warning { background: var(--warn-soft);   border-color: #e6c887; color: var(--warn); }
.flash--error   { background: var(--danger-soft); border-color: #ecbcb1; color: var(--danger); }

/* ===== PAGINATION =============================================== */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: var(--sp-5) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius);
    color: var(--ink-2);
    text-decoration: none;
    border: 1px solid transparent;
}
.pagination a:hover { background: var(--bg-hover); color: var(--ink); text-decoration: none; }
.pagination .current {
    background: var(--bg-elevated);
    border-color: var(--line-strong);
    color: var(--ink);
    font-weight: 500;
}
.pagination .disabled { color: var(--ink-faint); cursor: not-allowed; }

/* ===== TOP-LIST (Dashboard) ===================================== */
.top-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: top;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.top-list li {
    counter-increment: top;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--line-soft);
}
.top-list li:last-child { border-bottom: 0; }
.top-list li::before {
    content: counter(top);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-sunken);
    color: var(--ink-2);
    font-size: var(--fs-xs);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* ===== KNOWLEDGE GAPS ========================================== */
.kg-content {
    line-height: 1.5;
    max-width: 56ch;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ink-2);
}
.kg-actions,
.inbox-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.inbox-actions form { display: inline; margin: 0; }

/* ===== BULK BAR / SAVED FILTERS ================================ */
.bulk-bar-form { margin-bottom: var(--sp-3); }
.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg-elevated);
}

.saved-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin: 0 0 var(--sp-3);
}
.saved-filters .badge { text-decoration: none; transition: background-color 0.08s ease; }
.saved-filters .badge:hover { filter: brightness(0.95); }
.saved-filter-del { display: inline-block; margin: 0; }
.save-filter-details { margin-top: var(--sp-3); }
.save-filter-details summary { cursor: pointer; }

/* ===== HEALTH LIST / LOW-RATED ================================== */
.health-list, .lowrate-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.health-list li, .lowrate-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--sp-2);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--line-soft);
}
.health-list li:last-child, .lowrate-list li:last-child { border-bottom: 0; }
.lowrate-note {
    flex-basis: 100%;
    font-size: var(--fs-sm);
    color: var(--ink-muted);
    margin-left: var(--sp-1);
    white-space: pre-wrap;
}

/* ===== CONVERSATION DETAIL ===================================== */
.conv-stream {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
}
.conv-msg {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--bg-elevated);
    max-width: 80ch;
}
.conv-msg--user {
    align-self: flex-end;
    background: var(--accent-soft);
    border-color: #c6dde0;
}
.conv-msg--assistant { align-self: flex-start; }
.conv-msg--system {
    align-self: stretch;
    background: var(--bg-sunken);
    border-style: dashed;
    color: var(--ink-2);
}
/* Assistant-Antwort, die zurückgehalten wurde (Übergabe/Wissenslücke) —
   nie an den Empfänger gegangen, nur intern. Gestrichelter Rahmen +
   dezenter Danger-Ton, damit man sie nicht für die echte Antwort hält. */
.conv-msg--undelivered {
    border-style: dashed;
    border-color: var(--danger);
    background: var(--danger-soft);
}
.conv-msg--undelivered .conv-msg__body { opacity: 0.85; }
.conv-msg__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--ink-muted);
}
.conv-msg__meta .role {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-2);
}
.conv-msg__body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.55;
    color: var(--ink);
}

dl.meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--sp-1) var(--sp-4);
    margin: 0;
}
dl.meta dt { color: var(--ink-muted); font-size: var(--fs-sm); }
dl.meta dd { margin: 0; font-size: var(--fs-sm); }

/* ===== RATINGS =================================================== */
.conv-msg__rate {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
    padding-top: var(--sp-2);
    border-top: 1px dashed var(--line);
}
.conv-msg__rate form {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--sp-2);
    align-items: start;
}
.conv-msg__rate textarea {
    min-height: 36px;
    padding: 6px 10px;
    font-size: var(--fs-sm);
}

fieldset.rate-radio {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 1px;
    border: 0;
    margin: 0;
    padding: 0;
}
.rate-radio__star {
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    color: var(--ink-faint);
    border-radius: var(--radius-sm);
    transition: color 0.08s ease, background 0.08s ease;
    font-size: var(--fs-md);
}
.rate-radio__star:hover { color: var(--warn); background: var(--warn-soft); }
.rate-radio__star input { position: absolute; opacity: 0; pointer-events: none; }
.rate-radio__star:has(input:checked) {
    color: var(--warn);
    background: var(--warn-soft);
}

.rate-list {
    list-style: none;
    margin: var(--sp-2) 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}
.rate-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
}
.rate-list .stars, .stars { color: var(--warn); letter-spacing: 0.05em; }
.rate-note {
    flex-basis: 100%;
    color: var(--ink-muted);
    margin-left: var(--sp-1);
    white-space: pre-wrap;
}

/* ===== FORCE-FAIL / MAINTENANCE FORMS ========================== */
.ff-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
    align-items: center;
}
.ff-form input[type="text"],
.ff-form input[type="password"] {
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    font: inherit;
    font-size: var(--fs-sm);
    flex: 1 1 16ch;
    min-width: 14ch;
    background: var(--bg-elevated);
}

/* ===== ANIMATIONS ============================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== RESPONSIVE ============================================== */
@media (max-width: 768px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar {
        position: relative;
        top: auto;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .nav-primary { flex-direction: row; flex-wrap: wrap; }
    .nav-user { margin-top: var(--sp-3); }
    .app-content { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
}

/* ===== PRINT =================================================== */
@media print {
    body { background: white; color: black; }
    .app-sidebar, .site-footer, .form-actions, .nav-form { display: none; }
    .app-shell { grid-template-columns: 1fr; }
    .card, .table-wrap { box-shadow: none; border: 1px solid #ccc; }
    a { color: black; text-decoration: underline; }
}


/* ===== STANDALONE / AUTH ======================================== */

body.standalone {
    background:
        radial-gradient(circle at 20% 0%, rgba(31, 89, 101, 0.06) 0%, transparent 60%),
        radial-gradient(circle at 80% 100%, rgba(185, 122, 31, 0.04) 0%, transparent 60%),
        var(--bg);
    min-height: 100vh;
}

body.standalone main {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--sp-6);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: var(--sp-8) var(--sp-6);
    box-shadow: var(--shadow);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-1);
    margin-bottom: var(--sp-6);
    font-weight: 600;
    color: var(--ink);
}
.auth-brand .brand-logo { width: 180px; }
.auth-brand .brand-product {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
}

.auth-card h1 {
    margin-bottom: var(--sp-2);
    font-size: var(--fs-xl);
}
.auth-card .lede {
    color: var(--ink-muted);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-6);
}

/* ===== APP-ERROR PAGE =========================================== */
body.app-error {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    max-width: 40rem;
    margin: var(--sp-12) auto;
    padding: 0 var(--sp-4);
}
body.app-error h1 {
    font-size: var(--fs-xl);
    margin-bottom: var(--sp-3);
}
body.app-error p { margin: 0 0 var(--sp-2); color: var(--ink-2); }
body.app-error .trace { color: var(--ink-muted); font-size: var(--fs-sm); }

/* ===== LEGACY CONTAINER (for any old include still using .container) */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--sp-6);
}

/* ===== Theme editor (channel edit page, "Erscheinungsbild") ===== */
.theme-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(420px, 480px);
    gap: var(--sp-6);
    align-items: start;
    margin-bottom: var(--sp-6);
}
.theme-editor__form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0;
}
.theme-editor__preview {
    position: sticky;
    top: var(--sp-4);
    background: var(--bg-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.theme-editor__preview iframe {
    width: 100%;
    height: 720px;
    border: 0;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}
@media (max-width: 1100px) {
    .theme-editor { grid-template-columns: 1fr; }
    .theme-editor__preview { position: static; }
    .theme-editor__preview iframe { height: 600px; }
}

/* ===== HELP / DOCS ============================================= */
/* Contextual "?" tip — a small inline link next to a label/header. */
.help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: var(--sp-1);
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    vertical-align: middle;
    transition: background-color 0.08s ease, color 0.08s ease;
}
.help-tip:hover { background: var(--accent); color: #fff; }

/* Help index — grouped topic links on /admin/help. */
.help-index {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.help-index li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--line-soft);
}
.help-index li:last-child { border-bottom: 0; }
.help-index__link { font-weight: 600; }
.help-index__blurb { color: var(--ink-muted); font-size: var(--fs-sm); }

/* Code block inside help pages (curl examples, JSON). */
.code-block {
    display: block;
    background: var(--bg-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--sp-3);
    margin: var(--sp-2) 0;
    font-size: var(--fs-sm);
    line-height: var(--lh-body);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}
