/* ==========================================================================
   Mailbot admin UI
   One calm petrol palette, one typeface (Instrument Sans, served from
   /static/vendor), panels for structure. Everything the model reads with
   every mail (standard instructions, own behaviour, subject format) is an
   "instruction card" (.prompt): the one element with its own look, because
   it is the one text that costs money per mail.

   Order: tokens, base, layout, controls, components, pages, responsive.
   Class names are shared with templates, static/*.js and tests/ui.
   ========================================================================== */

/* 1. Font ----------------------------------------------------------------- */
@font-face {
    font-family: 'Instrument Sans';
    font-style: normal;
    font-display: swap;
    font-weight: 400 700;
    font-stretch: 75% 100%;
    src: url(/static/vendor/instrument-sans/instrument-sans-latin-standard-normal.woff2) format('woff2-variations');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Instrument Sans';
    font-style: normal;
    font-display: swap;
    font-weight: 400 700;
    font-stretch: 75% 100%;
    src: url(/static/vendor/instrument-sans/instrument-sans-latin-ext-standard-normal.woff2) format('woff2-variations');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* 2. Tokens ---------------------------------------------------------------- */
:root {
    /* Petrol: the one brand colour */
    --petrol-900: #0b2a2f;
    --petrol-700: #0a6564;
    --petrol-600: #0e7c7b;
    --petrol-400: #3fa9a3;
    --petrol-300: #7fd0c8;
    --petrol-100: #d6eeec;
    --petrol-50: #ecf6f5;

    /* Neutrals, slightly cool */
    --canvas: #f1f4f5;
    --surface: #ffffff;
    --surface-2: #f7f9fa;
    --line: #e1e6e9;
    --line-strong: #c9d1d6;
    --ink: #15222b;
    --ink-2: #475763;
    --ink-3: #5f6e78;

    /* Status: 700 = text on the 50 tint (WCAG AA), 500 = dots and bars */
    --ok-700: #17703e;
    --ok-500: #22a05a;
    --ok-50: #e8f5ec;
    --warn-700: #9a5b06;
    --warn-500: #e3a008;
    --warn-50: #fdf3e1;
    --err-700: #b42318;
    --err-500: #e0483b;
    --err-50: #fdecea;

    --font: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.875rem;
    --fs-md: 0.9375rem;
    --fs-lg: 1.0625rem;
    --fs-xl: 1.375rem;
    --fs-2xl: 1.625rem;

    --r-lg: 14px;
    --r-md: 10px;
    --r-sm: 7px;
    --r-full: 999px;

    --ring: 0 0 0 3px rgb(14 124 123 / 0.24);
    --ring-err: 0 0 0 3px rgb(224 72 59 / 0.2);
    --sh-panel: 0 1px 2px rgb(21 34 43 / 0.04);
    --sh-float: 0 18px 40px -12px rgb(11 42 47 / 0.35), 0 3px 8px rgb(11 42 47 / 0.08);

    --sidebar-width: 248px;
    --content-max: 1180px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* 3. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.5;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "ss01" 1;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; color: var(--ink); }
p { margin: 0; }
a { color: var(--petrol-700); text-underline-offset: 2px; }
a:hover { color: var(--petrol-900); }
strong { font-weight: 600; }
code, kbd { font-family: var(--mono); font-size: 0.92em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--petrol-600); outline-offset: 2px; }
::selection { background: var(--petrol-100); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* 4. Layout ---------------------------------------------------------------- */
#app { min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar-width);
    display: flex; flex-direction: column;
    background: var(--petrol-900);
    color: #a7bfc1;
    transition: transform 0.25s var(--ease);
}
.sidebar-header { padding: 22px 18px 18px; border-bottom: 1px solid rgb(255 255 255 / 0.07); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(145deg, var(--petrol-400), var(--petrol-600));
    color: #fff; font-size: 15px;
}
.brand-name { font-size: 1.125rem; font-weight: 650; letter-spacing: -0.01em; }
.bot-state {
    margin-top: 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 10px 10px 12px;
    border-radius: var(--r-md);
    background: rgb(255 255 255 / 0.05);
}
.bot-state-label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: #d8e6e6; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.status-dot-running { background: var(--ok-500); box-shadow: 0 0 0 4px rgb(34 160 90 / 0.18); }
.status-dot-stopped { background: #e0716a; box-shadow: 0 0 0 4px rgb(224 113 106 / 0.16); }
.mailbot-control {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border: 0; border-radius: var(--r-sm);
    font: inherit; font-size: var(--fs-xs); font-weight: 600;
    color: var(--petrol-900); background: var(--petrol-300); cursor: pointer;
}
.mailbot-control:hover { background: #a3e0da; }
.mailbot-control.is-running { color: #fff; background: rgb(255 255 255 / 0.12); }
.mailbot-control.is-running:hover { background: rgb(255 255 255 / 0.2); }
/* A customer login's slot for the bot state: this month's mails against its Kontingent */
.usage-nav {
    margin-top: 16px; display: grid; gap: 4px;
    padding: 12px; border-radius: var(--r-md); background: rgb(255 255 255 / 0.05);
}
.usage-nav-label { font-size: var(--fs-xs); color: #a7bfc1; }
.usage-nav-value { font-size: var(--fs-md); font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.usage-nav-rest { font-size: var(--fs-xs); color: #d8e6e6; }
.usage-nav .usage-bar { margin: 4px 0 2px; background: rgb(255 255 255 / 0.12); }
.usage-nav.is-full .usage-nav-rest { color: #ff9b91; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--r-md);
    color: #a7bfc1; text-decoration: none; font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; opacity: 0.85; }
.nav-item:hover { color: #fff; background: rgb(255 255 255 / 0.05); }
.nav-item[aria-current="page"] { color: #fff; background: rgb(127 208 200 / 0.12); }
.nav-item[aria-current="page"]::before {
    content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--petrol-300);
}
.nav-item[aria-current="page"] i { color: var(--petrol-300); opacity: 1; }

.sidebar-footer { padding: 14px 18px 18px; border-top: 1px solid rgb(255 255 255 / 0.07); }
.logout-button {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border: 0; border-radius: var(--r-sm);
    font: inherit; font-size: var(--fs-sm); color: #a7bfc1; background: transparent; cursor: pointer; text-align: left;
}
.logout-button:hover { color: #fff; background: rgb(255 255 255 / 0.05); }
a.logout-button { text-decoration: none; }
.logout-button .user-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-weight: 500; }
.logout-button i { flex: none; }

.main-content { margin-left: var(--sidebar-width); padding: 32px 40px 64px; min-width: 0; }
.page { max-width: var(--content-max); margin: 0 auto; }
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-header h2 { font-size: var(--fs-2xl); font-stretch: 94%; letter-spacing: -0.015em; }
.page-subtitle { margin-top: 6px; color: var(--ink-2); max-width: 70ch; }
.page-header-actions, .header-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back-link {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px;
    font-size: var(--fs-sm); color: var(--ink-2); text-decoration: none;
}
.back-link:hover { color: var(--petrol-700); }

.mobile-menu-toggle {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 50;
    width: 42px; height: 42px; border: 0; border-radius: var(--r-md);
    color: #fff; background: var(--petrol-900); box-shadow: var(--sh-float); cursor: pointer;
}
.mobile-overlay { display: none; }

/* 5. Buttons --------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 38px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--r-md);
    font: inherit; font-size: var(--fs-base); font-weight: 600; line-height: 1;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { color: #fff; background: var(--petrol-600); }
.btn-primary:hover:not(:disabled) { color: #fff; background: var(--petrol-700); }
.btn-secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); border-color: #b3bec5; }
.btn-danger { color: #fff; background: var(--err-700); }
.btn-danger:hover:not(:disabled) { color: #fff; background: #93190f; }
.btn-ghost { color: var(--ink-2); background: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: rgb(21 34 43 / 0.05); }
.btn-ghost-danger:hover:not(:disabled) { color: var(--err-700); background: var(--err-50); }
.btn-small { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-icon { width: 34px; min-height: 34px; padding: 0; border-radius: var(--r-sm); }
.btn-icon-danger:hover:not(:disabled) { color: var(--err-700); background: var(--err-50); }
.btn-block { width: 100%; }
/* Busy: a ring drawn by CSS turns exactly around its own centre - a font glyph
   (fa-circle-notch) turns around its text box and wobbles off centre */
.spin-ring {
    display: inline-block; flex: none; width: 1em; height: 1em;
    border: 0.15em solid currentColor; border-right-color: transparent; border-radius: 50%;
    vertical-align: -0.14em; animation: spin 0.75s linear infinite;
}
.inline-form { display: inline; margin: 0; }

/* 6. Form controls --------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group > label, .field-label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.req { margin-left: 2px; color: var(--petrol-700); font-weight: 600; }
.label-row { display: flex; align-items: center; gap: 4px; }
.label-row > label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.optional-tag { margin-left: 6px; font-weight: 500; color: var(--ink-3); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"],
input[type="date"], input[type="time"], input[type="url"], select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    font: inherit; font-size: var(--fs-md); line-height: 1.45;
    color: var(--ink); background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: #8795a0; }
input:hover, select:hover, textarea:hover { border-color: #b3bec5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--petrol-600); box-shadow: var(--ring); }
[aria-invalid="true"], .is-over-limit { border-color: var(--err-500) !important; }
[aria-invalid="true"]:focus, .is-over-limit:focus { box-shadow: var(--ring-err) !important; }
select {
    appearance: none; -webkit-appearance: none;
    padding-right: 38px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23475763' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
select:disabled { color: var(--ink-3); background-color: var(--surface-2); cursor: wait; }
textarea { resize: vertical; display: block; }
/* Grows with its content: natively where field-sizing exists, else app.js
   autoGrow. No height transition: while it ran, a new line overflowed the old
   height and the text slid up and down by one line. */
textarea.auto-grow { resize: none; overflow-y: hidden; min-height: 76px; max-height: 60vh; field-sizing: content; }
textarea.auto-grow.is-scrolling { overflow-y: auto; }
@supports (field-sizing: content) { textarea.auto-grow { overflow-y: auto; } }
textarea[data-per-mail] { min-height: 180px; max-height: 75vh; }
textarea.routing-hint { min-height: 44px; }
textarea.subject-format { min-height: 48px; }
input[type="search"] { padding-left: 38px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%235f6e78' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center; }

.field-hint { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.5; }
.field-error {
    display: flex; align-items: center; gap: 6px;
    font-size: var(--fs-sm); font-weight: 500; color: var(--err-700);
}
.field-error::before { content: "\f06a"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 12px; }
.field-limit { align-self: flex-end; font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.field-limit.is-near { color: var(--warn-700); }
.field-limit.is-over { color: var(--err-700); font-weight: 600; align-self: stretch; }
.field-limit-banner, .form-errors, .error-message {
    margin-bottom: 20px; padding: 14px 16px;
    border: 1px solid #f5c2bc; border-radius: var(--r-md);
    color: var(--err-700); background: var(--err-50);
}
.form-errors ul { margin: 8px 0 0; padding-left: 20px; }
.form-errors a { color: var(--err-700); }
.error-message i { margin-right: 6px; }


/* Switch: 40 x 22 track (tests/ui measure it) */
.mini-toggle { position: relative; display: inline-flex; flex: none; width: 40px; height: 22px; cursor: pointer; }
.mini-toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.mini-slider {
    position: absolute; inset: 0; overflow: hidden;
    border-radius: var(--r-full); background: #c3ccd2;
    transition: background 0.2s var(--ease);
}
.mini-slider::before {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
    transition: transform 0.2s var(--ease);
}
.mini-toggle input:checked + .mini-slider { background: var(--petrol-600); }
.mini-toggle input:checked + .mini-slider::before { transform: translateX(18px); }
.mini-toggle input:focus-visible + .mini-slider { box-shadow: var(--ring); }

.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-row .toggle-card-title { font-size: var(--fs-sm); color: var(--ink-2); }
.toggle-card-title { font-weight: 600; }

/* 7. Panels and form sections ---------------------------------------------- */
.card, .form-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-panel);
}
.card { padding: 24px; }
.form-content { display: flex; flex-direction: column; gap: 20px; }
.form-section { padding: 24px 28px 28px; }
.form-section-head { margin-bottom: 20px; }
.section-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-section-head h3 { font-size: var(--fs-lg); letter-spacing: -0.005em; }
.form-section-head p { margin-top: 6px; color: var(--ink-2); max-width: 78ch; }
.section-aside { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.form-section-body { display: flex; flex-direction: column; gap: 20px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.field-grid .full-width { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Collapsible panel (Letzte Speicherungen) */
details.form-section > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.form-section > summary::-webkit-details-marker { display: none; }
details.form-section > summary h3::after {
    content: "\f078"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 11px;
    display: inline-block; margin-left: 10px; color: var(--ink-3); transition: transform 0.2s var(--ease);
}
details.form-section[open] > summary { margin-bottom: 20px; }
details.form-section[open] > summary h3::after { transform: rotate(180deg); }

.page-notice {
    display: flex; align-items: flex-start; gap: 10px;
    margin-bottom: 20px; padding: 12px 16px;
    border: 1px solid var(--petrol-100); border-radius: var(--r-md);
    color: var(--petrol-900); background: var(--petrol-50);
}
.page-notice i { margin-top: 3px; color: var(--petrol-600); }
.page-notice.is-warning { border-color: #f3dfb8; color: var(--warn-700); background: var(--warn-50); }
.field-hint.is-warning { color: var(--warn-700); }
.page-notice.is-warning i { color: var(--warn-700); }

/* „Mails im <Monat>“: one bar for sidebar and form, green, amber from 90 %, red when used up */
.usage-bar { position: relative; display: block; height: 6px; border-radius: var(--r-full); overflow: hidden; background: var(--line); }
.usage-bar > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--ok-500); transition: width 0.4s var(--ease); }
.usage-bar.is-large { height: 10px; }
.is-warn .usage-bar > span { background: var(--warn-500); }
.is-full .usage-bar > span { background: var(--err-500); }
.usage-card {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap;
    padding: 20px 28px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-panel);
}
.usage-main { flex: 1 1 320px; display: grid; gap: 6px; max-width: 560px; }
.usage-card h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.usage-headline { font-size: var(--fs-xl); font-weight: 650; font-stretch: 94%; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.usage-detail { font-size: var(--fs-sm); color: var(--ink-2); }
.usage-card.is-full .usage-detail { color: var(--err-700); font-weight: 500; }
.usage-card.is-warn .usage-detail { color: var(--warn-700); }
.usage-sender { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); }

/* Sticky page header of forms: the document scrolls, the header stays */
.sticky-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
    margin: -32px -40px 24px; padding: 18px 40px;
    background: var(--canvas);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sticky-header.is-stuck { border-bottom-color: var(--line); box-shadow: 0 6px 18px -14px rgb(11 42 47 / 0.5); }
.sticky-header h2 { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sticky-header-title { font-size: var(--fs-xl); font-stretch: 94%; letter-spacing: -0.01em; }
.sticky-header-subtitle { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sticky-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dirty-indicator {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 11px; border-radius: var(--r-full);
    font-size: var(--fs-xs); font-weight: 600; color: var(--warn-700); background: var(--warn-50);
}
.dirty-indicator::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn-500); }

/* 8. Help: a small (?) that explains on demand ------------------------------ */
.help { position: relative; display: inline-flex; vertical-align: middle; }
.help-btn {
    width: 20px; height: 20px; padding: 0;
    display: inline-grid; place-items: center;
    border: 0; border-radius: 50%;
    font-size: 13px; color: var(--ink-3); background: transparent; cursor: help;
    transition: color 0.15s, background 0.15s;
}
.help-btn:hover, .help-btn[aria-expanded="true"] { color: var(--petrol-700); background: var(--petrol-50); }
.help-pop {
    /* fixed and placed by app.js: never widens the page, never clipped by a card */
    position: fixed; z-index: 60; top: 0; left: 0;
    width: min(340px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: var(--r-md);
    font-size: var(--fs-sm); font-weight: 400; line-height: 1.55; color: #e7f0f0;
    background: var(--petrol-900); box-shadow: var(--sh-float);
    display: none; white-space: normal; text-align: left;
}
.help-pop strong { color: #fff; }
.help-item { display: block; position: relative; padding-left: 14px; }
.help-item::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: var(--petrol-300); }
.help-item + .help-item { margin-top: 7px; }
.help-pop a { color: var(--petrol-300); }
.help.is-open .help-pop, .help.is-hover .help-pop { display: block; animation: pop-in 0.15s var(--ease); }

/* 9. Instruction card: text that goes to the model with every mail ---------- */
.prompt {
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.prompt.is-open { border-color: var(--petrol-100); box-shadow: 0 0 0 4px var(--petrol-50); }
.prompt-toggle {
    width: 100%; display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border: 0; border-radius: var(--r-md);
    font: inherit; text-align: left; color: var(--ink); background: transparent; cursor: pointer;
}
.prompt-toggle:hover { background: var(--surface-2); }
.prompt.is-open .prompt-toggle { border-radius: var(--r-md) var(--r-md) 0 0; }
.prompt-icon {
    width: 30px; height: 30px; flex: none; border-radius: 8px;
    display: grid; place-items: center;
    font-size: 13px; color: var(--petrol-700); background: var(--petrol-50);
}
.prompt-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.prompt-name { font-weight: 600; }
.prompt-preview { font-size: var(--fs-sm); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-preview.is-set { color: var(--ink-2); }
.prompt.is-open .prompt-preview { display: none; }
.prompt-chevron { color: var(--ink-3); font-size: 12px; transition: transform 0.2s var(--ease); }
.prompt.is-open .prompt-chevron { transform: rotate(180deg); }
/* Height animates through grid rows 0fr -> 1fr: no fixed max-height, no jump */
.prompt-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.24s var(--ease); }
.prompt.is-open .prompt-body { grid-template-rows: 1fr; }
.prompt-inner { overflow: hidden; min-height: 0; }
.prompt-content { display: flex; flex-direction: column; gap: 10px; padding: 4px 14px 14px; }
.prompt-body:not(.is-ready) .prompt-content { visibility: hidden; }
.prompt.is-open .prompt-body .prompt-content { visibility: visible; }
.prompt-lead { display: flex; align-items: flex-start; gap: 6px; color: var(--ink-2); font-size: var(--fs-sm); }
.prompt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.prompt-foot .field-limit { align-self: auto; }
.prompt-link { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
/* Always-open variant (settings, Probelauf drafts): no toggle, same surface */
.prompt.is-static { border-color: var(--line); box-shadow: none; }
.prompt.is-static .prompt-content { padding: 14px; }
.prompt textarea { font-size: var(--fs-md); line-height: 1.55; background: var(--surface); }
/* Read-only variant: the standard instructions a mailbox runs without an own behaviour */
.prompt.is-readonly { background: var(--surface-2); }
.prompt.is-readonly .prompt-icon { color: var(--ink-2); background: var(--surface); }
.standard-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); line-height: 1.6; color: var(--ink-2); }

/* Behaviour of a mailbox: „Standard-Anweisungen“ or „Eigenes Verhalten“ - two
   radios as one segmented control (app.js initBehavior shows the chosen side) */
.behavior-field { display: flex; flex-direction: column; gap: 10px; }
.behavior-choice { min-width: 0; margin: 0; padding: 0; border: 0; }
.behavior-choice legend { display: flex; align-items: center; gap: 6px; padding: 0; margin-bottom: 8px; }
.behavior-choice legend .field-label { margin: 0; }
.choice-segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: #e7ecef; max-width: 100%; }
.choice-option {
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 7px 13px; border-radius: var(--r-sm);
    font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.choice-option input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.choice-option i { font-size: 12px; color: var(--ink-3); }
.choice-option span { min-width: 0; }  /* a long word breaks at its soft hyphen on a phone */
.choice-option:hover { color: var(--ink); }
.choice-option:has(input:checked) { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgb(21 34 43 / 0.12); }
.choice-option:has(input:checked) i { color: var(--petrol-700); }
.choice-option:has(input:focus-visible) { box-shadow: var(--ring); }
.behavior-drop-note { margin: 6px 0 0; }
@media (max-width: 480px) {
    .choice-segmented { display: flex; }
    .choice-option { flex: 1; min-width: 0; padding: 7px 8px; text-align: center; }
    .choice-option i { display: none; }  /* the words need the room: „Tageszusammenfassung“ */
}

.suggestions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.suggestions-label { font-size: var(--fs-sm); color: var(--ink-2); }
.suggestion {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border: 1px dashed var(--line-strong); border-radius: var(--r-full);
    font: inherit; font-size: var(--fs-sm); color: var(--ink-2); background: var(--surface); cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.suggestion:hover { border-style: solid; border-color: var(--petrol-400); color: var(--petrol-700); background: var(--petrol-50); }

/* 10. Mailbox cards (customer form) ----------------------------------------- */
#targets-container { display: flex; flex-direction: column; gap: 12px; }
.target-form-item {
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
    transition: border-color 0.2s, opacity 0.2s;
}
.target-form-item.expanded { border-color: var(--line-strong); }
.target-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 10px 8px 6px; cursor: pointer;
}
.target-header h4 { flex: 1; min-width: 0; font-size: var(--fs-md); }
.target-toggle {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border: 0; border-radius: var(--r-sm);
    font: inherit; font-weight: 600; text-align: left; color: var(--ink); background: transparent; cursor: pointer;
}
.target-chevron { width: 16px; font-size: 11px; color: var(--ink-3); transform: rotate(-90deg); transition: transform 0.2s var(--ease); }
.target-form-item.expanded .target-chevron { transform: none; }
.target-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-form-item .target-state { display: none; }
.target-form-item.is-inactive .target-state { display: inline-flex; }
.target-form-item.is-inactive .target-title { color: var(--ink-3); }
.target-header-controls { display: flex; align-items: center; gap: 8px; flex: none; }
.fallback-choice {
    position: relative; display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--r-full);
    font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.fallback-choice input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.fallback-choice .fa-star { font-size: 10px; }
.fallback-choice:hover { border-color: var(--line-strong); color: var(--ink-2); }
.fallback-choice:has(input:checked) { border-color: var(--petrol-100); color: var(--petrol-700); background: var(--petrol-50); }
.fallback-choice:has(input:focus-visible) { box-shadow: var(--ring); }
.target-remove-x { color: var(--ink-3); }
.target-form-grid {
    display: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px 20px;
    padding: 6px 18px 18px;
}
.target-form-item.expanded .target-form-grid { display: grid; }
.target-form-grid .full-width { grid-column: 1 / -1; }
#section-targets.is-single .routing-only { display: none !important; }
#section-targets.is-single .target-form-grid { grid-template-columns: minmax(0, 1fr); }
.add-target { align-self: flex-start; }
/* What a mailbox gets: single mails or the Tageszusammenfassung (the chip names its time) */
.target-form-item .target-digest { display: none; }
.target-form-item.is-digest .target-digest { display: inline-flex; flex: none; }
.target-form-item.is-digest .target-title { flex: 0 1 auto; }
.kind-warning { display: flex; align-items: baseline; gap: 6px; margin: 4px 0 0; color: var(--warn-700); }
.digest-time { max-width: 10em; font-variant-numeric: tabular-nums; }
.digest-time::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.7; }
.digest-preview-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.digest-frame { display: block; width: 100%; height: min(60vh, 560px); margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }

/* API key field */
.key-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-field input { flex: 1; min-width: 180px; font-family: var(--mono); font-size: var(--fs-base); }
.key-status { min-height: 1.2em; font-size: var(--fs-sm); color: var(--ink-2); }
.key-status.is-ok { color: var(--ok-700); }
.key-status.is-error { color: var(--err-700); }

/* 11. Chips ---------------------------------------------------------------- */
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: var(--r-full);
    font-size: var(--fs-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; text-decoration: none;
    color: var(--ink-2); background: #e9eef1;
}
.chip i { font-size: 10px; }
.chip-success { color: var(--ok-700); background: var(--ok-50); }
.chip-warning { color: var(--warn-700); background: var(--warn-50); }
.chip-error { color: var(--err-700); background: var(--err-50); }
.chip-muted { color: var(--ink-2); background: #e9eef1; }
.chip-info { color: var(--petrol-700); background: var(--petrol-50); }
a.chip:hover { filter: brightness(0.97); }

/* 12. Dialog ---------------------------------------------------------------- */
dialog.modal-dialog {
    width: min(520px, calc(100vw - 32px));
    padding: 0; border: 0; border-radius: var(--r-lg);
    color: var(--ink); background: var(--surface); box-shadow: var(--sh-float);
}
dialog.modal-dialog.is-wide { width: min(720px, calc(100vw - 32px)); }
dialog.modal-dialog::backdrop { background: rgb(11 42 47 / 0.42); backdrop-filter: blur(3px); }
dialog.modal-dialog[open] { animation: dialog-in 0.18s var(--ease); }
dialog.modal-dialog[open]::backdrop { animation: fade-in 0.18s ease; }
.dialog-body { display: flex; gap: 16px; padding: 24px 24px 8px; }
.dialog-icon {
    width: 40px; height: 40px; flex: none; border-radius: 12px;
    display: grid; place-items: center; font-size: 16px;
    color: var(--petrol-700); background: var(--petrol-50);
}
.dialog-icon.is-danger { color: var(--err-700); background: var(--err-50); }
.dialog-icon.is-warning { color: var(--warn-700); background: var(--warn-50); }
.dialog-text h3 { font-size: var(--fs-lg); margin: 8px 0 6px; }
.dialog-text p { color: var(--ink-2); }
.dialog-text p + p { margin-top: 8px; }
.dialog-text { flex: 1; min-width: 0; }
.dialog-fields { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.dialog-fields .field-hint { margin-top: 0; }
.dialog-text .dialog-fields .field-error { color: var(--err-700); }
/* One row: an alternative ("Verwerfen") on the left, cancel and the main action on the right.
   On a phone the buttons stack full width, the main action on top. */
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 20px 24px 24px; }
.dialog-actions .spacer { flex: 1; }
@media (max-width: 480px) {
    .dialog-body { flex-direction: column; gap: 12px; padding: 20px 20px 4px; }
    .dialog-actions { flex-direction: column-reverse; align-items: stretch; gap: 8px; padding: 16px 20px 20px; }
    .dialog-actions .btn { justify-content: center; }
    .dialog-actions .spacer { display: none; }
}
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.dialog-header h3 { font-size: var(--fs-lg); }
.dialog-scroll { max-height: min(70vh, 640px); overflow: auto; padding: 20px; }

/* 13. Toasts --------------------------------------------------------------- */
.notification {
    position: fixed; right: 20px; bottom: 20px; z-index: 100;
    max-width: min(420px, calc(100vw - 40px));
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px; border-radius: var(--r-md);
    font-weight: 500; color: #fff; background: var(--petrol-900); box-shadow: var(--sh-float);
    animation: toast-in 0.24s var(--ease);
    transition: opacity 0.3s, transform 0.3s var(--ease);
}
.notification::before { font-family: "Font Awesome 6 Free"; font-weight: 900; content: "\f05a"; color: var(--petrol-300); }
.notification.success::before { content: "\f058"; color: #7ee2a8; }
.notification.error::before { content: "\f06a"; color: #ff9b91; }
.notification.warning::before { content: "\f071"; color: #f6c86b; }
.notification.is-leaving { opacity: 0; transform: translateY(8px); }

/* 14. Tables ---------------------------------------------------------------- */
.data-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-panel); }
.data-table-toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.data-table-toolbar .search-input { flex: 1 1 260px; max-width: 380px; min-height: 38px; }
.data-table-toolbar select { width: auto; min-height: 38px; font-size: var(--fs-base); }
/* Export and Import belong together: they wrap as one group, never one by one */
.toolbar-actions { display: inline-flex; flex: none; gap: 4px; }
.toolbar-spacer { flex: 1; }
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 11px 16px; text-align: left; white-space: nowrap;
    font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2);
    background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--ink); }
.data-table th.sortable::after { content: "\2195"; margin-left: 5px; opacity: 0.35; }
.data-table th.sort-asc::after { content: "\2191"; opacity: 1; color: var(--petrol-600); }
.data-table th.sort-desc::after { content: "\2193"; opacity: 1; color: var(--petrol-600); }
.th-main, .th-sub { display: block; }
/* A customer with its own login: when it last signed in, under the address */
.login-line { margin-top: 2px; font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
.login-line i { margin-right: 3px; font-size: 10px; }
.login-line.is-recent i { color: var(--petrol-600); }
.data-table th.sortable:has(.th-main)::after { content: none; }
.data-table th.sortable .th-main::after { content: "\2195"; margin-left: 5px; opacity: 0.35; }
.data-table th.sort-asc .th-main::after { content: "\2191"; opacity: 1; color: var(--petrol-600); }
.data-table th.sort-desc .th-main::after { content: "\2193"; opacity: 1; color: var(--petrol-600); }
.th-sub { font-weight: 500; color: var(--ink-3); }
.activity-col { text-align: right !important; }
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
/* Numbers and dates: "anywhere" also lets the table squeeze a column below its
   longest number, so "0,0123" broke into "0,012" / "3". They break only at a space. */
.data-table td.activity { overflow-wrap: normal; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr[onclick] { cursor: pointer; }
.data-table tbody tr:hover { background: #f8fbfb; }
.data-table tr.inactive td:not(.data-table-status) { opacity: 0.55; }
.sender-cell { min-width: 0; }
.data-table-sender { display: block; font-weight: 600; color: inherit; text-decoration: none; }
.data-table-sender:hover, .data-table-sender:focus-visible { color: var(--petrol-700); text-decoration: underline; }

.customer-chips { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.data-table-status-col { width: 64px; }
.status-dot-btn {
    width: 34px; height: 20px; padding: 0; border: 0; border-radius: var(--r-full);
    background: #c3ccd2; cursor: pointer; position: relative; transition: background 0.2s;
}
.status-dot-btn::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
    background: #fff; transition: transform 0.2s var(--ease);
}
.status-dot-btn.active { background: var(--ok-500); }
.status-dot-btn.active::after { transform: translateX(14px); }
.status-dot-btn:focus-visible { box-shadow: var(--ring); outline: none; }
.activity { text-align: right; font-variant-numeric: tabular-nums; }
.activity-now { display: block; font-weight: 600; }
.license .activity-now { white-space: nowrap; }  /* "02.10.2027" never splits into "02.10.20" and "27" */
.activity-avg { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
.activity.is-zero .activity-now { color: var(--ink-3); font-weight: 500; }
.activity.is-spike .activity-now { color: var(--warn-700); }
.activity.is-spike i { margin-right: 4px; }
.quota.is-near .activity-now { color: var(--warn-700); }
.quota.is-full .activity-now { color: var(--err-700); }
.quota.is-none .activity-now { color: var(--ink-3); font-weight: 500; }
.quota-sub.chip { margin-top: 3px; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.data-table-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 24px; text-align: center; color: var(--ink-2); }
.data-table-empty > i { font-size: 26px; color: var(--petrol-400); }
.data-table-footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 4px; font-size: var(--fs-sm); color: var(--ink-3); }

/* Segmented filter (mails page, Probelauf input mode) */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--r-md); background: #e7ecef; }
.segmented a, .segmented button {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 13px; border: 0; border-radius: var(--r-sm);
    font: inherit; font-size: var(--fs-sm); font-weight: 600; text-decoration: none; color: var(--ink-2); background: transparent; cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); }
.segmented [aria-current="page"], .segmented [aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgb(21 34 43 / 0.12); }

/* 15. Dashboard ------------------------------------------------------------ */
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r-lg);
    color: inherit; text-decoration: none; background: var(--surface); box-shadow: var(--sh-panel);
    transition: border-color 0.15s, transform 0.15s var(--ease);
}
.stat-card-link:hover { border-color: var(--line-strong); color: inherit; transform: translateY(-1px); }
.stat-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; font-size: 14px; }
.stat-value { display: block; font-size: 1.75rem; font-weight: 600; font-stretch: 92%; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-content p { margin-top: 4px; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); }
.stat-sub { display: block; margin-top: 6px; font-size: var(--fs-xs); color: var(--ink-3); }
.stat-sub-warn { color: var(--warn-700); }
.stat-primary .stat-icon { color: var(--petrol-700); background: var(--petrol-50); }
.stat-success .stat-icon { color: var(--ok-700); background: var(--ok-50); }
.stat-error .stat-icon { color: var(--err-700); background: var(--err-50); }
.stat-warning .stat-icon { color: var(--warn-700); background: var(--warn-50); }
.stat-neutral .stat-icon { color: var(--ink-2); background: #e9eef1; }

.llm-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--r-full);
    font-size: var(--fs-sm); text-decoration: none; color: var(--ink-2); background: var(--surface);
}
.llm-badge:hover { border-color: var(--line-strong); color: var(--ink); }
.llm-badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-500); }
.llm-badge.is-down .llm-badge-dot { background: var(--err-500); }
.llm-badge-model { font-weight: 600; color: var(--ink); }
.llm-alert {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 20px; padding: 14px 18px;
    border: 1px solid #f5c2bc; border-radius: var(--r-md); color: var(--err-700); background: var(--err-50);
}
.llm-alert-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.llm-alert-text span { color: var(--ink); }

.dashboard-logs { padding: 0; overflow: visible; }
.dashboard-logs-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.dashboard-logs-header h3 { display: flex; align-items: center; gap: 10px; font-size: var(--fs-lg); }
.logs-header-hint { font-size: var(--fs-xs); font-weight: 500; color: var(--ink-3); }
.dashboard-log-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dashboard-log-controls input[type="search"] { width: 220px; min-height: 36px; font-size: var(--fs-base); }
.dashboard-log-controls select { width: auto; min-height: 36px; font-size: var(--fs-base); }
.filter-reset { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); text-decoration: none; }
.recent-logs { display: flex; flex-direction: column; }
.log-item-link { color: inherit; text-decoration: none; }
.log-item {
    display: grid; grid-template-columns: 86px minmax(0, 1fr) auto; align-items: center; gap: 14px;
    padding: 11px 20px; border-bottom: 1px solid var(--line);
    transition: background 0.12s;
}
.log-item-link:last-child .log-item { border-bottom: 0; }
.log-item-link:hover .log-item { background: #f8fbfb; }
.log-level {
    display: inline-flex; align-items: center; gap: 6px; justify-self: start;
    font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.02em; color: var(--ink-2);
}
.log-level::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--petrol-400); }
.log-level.WARNING { color: var(--warn-700); }
.log-level.WARNING::before { background: var(--warn-500); }
.log-level.ERROR, .log-level.CRITICAL { color: var(--err-700); }
.log-level.ERROR::before, .log-level.CRITICAL::before { background: var(--err-500); }
.log-level.DEBUG::before { background: #aab6be; }
.log-message { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-timestamp { font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-detail-grid { display: flex; flex-direction: column; gap: 18px; }
.log-detail-row { display: flex; align-items: center; gap: 12px; }
.log-detail-timestamp { font-size: var(--fs-sm); color: var(--ink-3); }
.log-detail-section-title { margin-bottom: 8px; font-size: var(--fs-xs); font-weight: 650; color: var(--ink-3); }
.log-detail-field { display: flex; gap: 10px; padding: 3px 0; }
.log-detail-label { flex: none; width: 88px; color: var(--ink-3); }
.log-full-message {
    padding: 12px 14px; border-radius: var(--r-sm);
    font-family: var(--mono); font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; background: var(--surface-2);
}
.log-modal-loading, .log-modal-error { color: var(--ink-2); }
.log-modal-error { color: var(--err-700); }

/* Product explainer: three steps from mail to result */
.explainer {
    margin-bottom: 24px; padding: 20px 22px;
    border: 1px solid var(--petrol-100); border-radius: var(--r-lg);
    background: linear-gradient(180deg, var(--petrol-50), var(--surface) 70%);
}
.explainer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.explainer-head h3 { font-size: var(--fs-md); }
.explainer-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 16px 0 0; padding: 0; list-style: none; counter-reset: step; }
.explainer-steps li { position: relative; display: flex; gap: 12px; align-items: flex-start; }
.explainer-steps li::before {
    counter-increment: step; content: counter(step);
    flex: none; width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: var(--fs-xs); font-weight: 700; color: #fff; background: var(--petrol-600);
}
.explainer-steps strong { display: block; margin-bottom: 2px; }
.explainer-steps span { font-size: var(--fs-sm); color: var(--ink-2); }
.explainer-note { margin-top: 14px; font-size: var(--fs-sm); color: var(--ink-2); }
.explainer.is-collapsed .explainer-steps, .explainer.is-collapsed .explainer-note { display: none; }

/* 16. Settings ------------------------------------------------------------- */
.settings-stack { display: flex; flex-direction: column; gap: 20px; }
.llm-current {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px; border-radius: var(--r-md);
    background: var(--surface-2); border: 1px solid var(--line);
}
.llm-current-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--ok-500); box-shadow: 0 0 0 5px rgb(34 160 90 / 0.15); }
.llm-current.is-down .llm-current-dot { background: var(--err-500); box-shadow: 0 0 0 5px rgb(224 72 59 / 0.15); }
.llm-current-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.llm-current-label { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); }
.llm-current-model { font-size: var(--fs-lg); font-weight: 650; }
.llm-current-note { font-size: var(--fs-sm); color: var(--ink-2); }
.llm-current.is-down .llm-current-note { color: var(--err-700); }
.llm-select-row { display: flex; gap: 8px; }
.llm-select-row select { flex: 1; }
.llm-refresh { width: 42px; min-height: 42px; padding: 0; }
.llm-caps { display: flex; flex-wrap: wrap; gap: 6px; }
.llm-check {
    display: flex; flex-direction: column; gap: 4px;
    padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); font-size: var(--fs-sm);
}
.llm-check.is-pending { color: var(--ink-2); background: var(--surface-2); flex-direction: row; align-items: center; gap: 8px; }
.llm-check.is-ok { border-color: #bfe3cc; background: var(--ok-50); }
.llm-check.is-ok strong { color: var(--ok-700); }
.llm-check.is-warning { border-color: #f1d9a8; background: var(--warn-50); }
.llm-check.is-warning strong { color: var(--warn-700); }
.llm-check.is-error { border-color: #f5c2bc; background: var(--err-50); }
.llm-check.is-error strong { color: var(--err-700); }
.llm-actions, .master-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.llm-actions-hint { font-size: var(--fs-sm); color: var(--ink-3); }
.master-active { display: inline-flex; align-self: flex-start; }
.master-status { font-size: var(--fs-sm); color: var(--ink-2); }
.master-status.is-ok { color: var(--ok-700); }
.master-status.is-error { color: var(--err-700); }
.master-pending {
    display: flex; flex-direction: column; gap: 12px;
    padding: 14px 16px; border: 1px solid #f1d9a8; border-radius: var(--r-md); background: var(--warn-50);
}
.master-pending select { width: auto; min-width: 200px; min-height: 36px; font-size: var(--fs-base); }
.master-pending label { font-size: var(--fs-sm); font-weight: 600; }
.master-subtitle { font-size: var(--fs-md); }
.guarantees { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); }
.guarantees li { display: flex; gap: 8px; }
.guarantees li::before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 11px; line-height: 1.9; color: var(--petrol-600); }
.version-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-md); }
.version-list li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.version-list li:last-child { border-bottom: 0; }
.version-name { font-weight: 600; }
.version-meta { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--ink-3); }

/* 17. Probelauf ------------------------------------------------------------ */
.testrun-grid { display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); gap: 20px; align-items: start; }
.testrun-form, .testrun-fields { display: flex; flex-direction: column; gap: 18px; }
.testrun-actions { display: flex; flex-direction: column; gap: 8px; }
.testrun-actions.is-inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; }
.testrun-buttons { display: flex; gap: 10px; }
.testrun-buttons #tr-run { flex: 1; }
.testrun-save-new { align-self: flex-start; }
.werkbank { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.werkbank-title { font-size: var(--fs-base); font-weight: 600; }
.werkbank .prompt { background: var(--surface); }
.werkbank .behavior-choice legend { margin-bottom: 6px; }
/* the narrower panel: both choices on one line, without their icons */
.werkbank .choice-segmented { display: flex; }
.werkbank .choice-option { flex: 1; padding: 7px 8px; }
.werkbank .choice-option i { display: none; }
/* Start and Speichern stay reachable at the bottom of a long form */
.testrun-footer {
    position: sticky; bottom: 0; z-index: 2;
    margin: 0 -24px -24px; padding: 14px 24px 18px;
    border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); background: var(--surface);
}
/* Gespeicherte Probeläufe: one pill per variant, the loaded one filled */
.saved-runs { display: flex; flex-direction: column; gap: 8px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.saved-runs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.saved-run-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.saved-run {
    display: inline-flex; align-items: stretch; max-width: 100%;
    border: 1px solid var(--line-strong); border-radius: var(--r-full); background: var(--surface);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.saved-run:hover { border-color: var(--petrol-400); }
.saved-run-load, .saved-run-delete { border: 0; font: inherit; background: transparent; cursor: pointer; color: var(--ink); }
.saved-run-load {
    display: inline-flex; align-items: center; gap: 7px; min-width: 0; min-height: 32px;
    padding: 0 4px 0 12px; border-radius: var(--r-full) 0 0 var(--r-full); font-size: var(--fs-sm); font-weight: 600;
}
.saved-run-load i { font-size: 11px; color: var(--ink-3); }
.saved-run-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-run-delete {
    width: 30px; display: grid; place-items: center; flex: none;
    border-radius: 0 var(--r-full) var(--r-full) 0; font-size: 12px; color: var(--ink-3);
}
.saved-run-delete:hover { color: var(--err-700); background: var(--err-50); }
.saved-run-load:focus-visible, .saved-run-delete:focus-visible { outline-offset: -2px; }
.saved-run:has([aria-pressed="true"]) { border-color: var(--petrol-600); background: var(--petrol-50); box-shadow: 0 0 0 1px var(--petrol-600); }
.saved-run:has([aria-pressed="true"]) .saved-run-load, .saved-run:has([aria-pressed="true"]) .saved-run-load i { color: var(--petrol-700); }
.saved-run.is-changed .saved-run-name::after { content: " •"; color: var(--warn-500); }
.testrun-status { font-size: var(--fs-sm); color: var(--ink-2); min-height: 1.2em; }
.testrun-status.is-error { color: var(--err-700); }
/* The result stays in view while the form scrolls, never taller than the window:
   the mail window takes the height that is left. */
.testrun-result { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; min-height: 420px; max-height: calc(100vh - 48px); }
.testrun-result h3 { font-size: var(--fs-lg); }
.testrun-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px 20px; text-align: center; color: var(--ink-2); }
.testrun-empty > i { font-size: 28px; color: var(--petrol-400); }
.testrun-empty h3 { color: var(--ink); }
.testrun-empty p { max-width: 42ch; font-size: var(--fs-sm); }
.testrun-loading { display: flex; flex-direction: column; gap: 12px; }
.testrun-result:has(.testrun-output:not([hidden])) { height: calc(100vh - 48px); }
.testrun-output { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; }
.testrun-form .segmented { display: flex; }
.testrun-form .segmented button { flex: 1; justify-content: center; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, #edf1f3 0%, var(--surface-2) 50%, #edf1f3 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton.is-block { height: 260px; border-radius: var(--r-md); }
.testrun-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; font-size: var(--fs-sm); }
.testrun-facts dt { color: var(--ink-3); font-weight: 500; }
.testrun-facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.testrun-facts dd.is-error { color: var(--err-700); font-weight: 600; }
.mail-window { flex: 1; min-height: 320px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.mail-window-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-sm); }
.mail-window-bar strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-window-action { flex: none; margin: -4px -6px -4px 0; }
.mail-window-dots { display: inline-flex; gap: 5px; }
.mail-window-attachment {
    display: flex; align-items: center; gap: 6px; margin: 0; padding: 6px 14px;
    border-bottom: 1px solid var(--line); font-size: var(--fs-xs); color: var(--ink-2); background: var(--surface);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-window-dots span { width: 9px; height: 9px; border-radius: 50%; background: #d3dade; }
#tr-body { min-height: 190px; }
.testrun-preview { display: block; flex: 1; width: 100%; min-height: 280px; border: 0; background: var(--surface); }
pre.testrun-instructions {
    margin: 12px 0 0; padding: 14px;
    border-radius: var(--r-sm); background: var(--surface-2);
    font-family: var(--mono); font-size: var(--fs-xs); white-space: pre-wrap; word-break: break-word;
}

/* File drop zone (Probelauf .eml, import .json) */
.dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 28px 20px; text-align: center;
    border: 1.5px dashed var(--line-strong); border-radius: var(--r-md);
    color: var(--ink-2); background: var(--surface-2); cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--petrol-400); background: var(--petrol-50); }
.dropzone:focus-within { border-color: var(--petrol-600); box-shadow: var(--ring); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dropzone-icon { font-size: 22px; color: var(--petrol-600); }
.dropzone-title { font-weight: 600; color: var(--ink); }
.dropzone-hint { font-size: var(--fs-sm); font-weight: 400; color: var(--ink-3); }
.dropzone-file { display: none; align-items: center; gap: 12px; width: 100%; text-align: left; }
.dropzone.has-file { padding: 14px 16px; border-style: solid; border-color: var(--petrol-100); background: var(--petrol-50); cursor: default; }
.dropzone.has-file .dropzone-empty { display: none; }
.dropzone.has-file .dropzone-file { display: flex; }
.dropzone.has-file input[type="file"] { pointer-events: none; }
.dropzone-file-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 9px; color: var(--petrol-700); background: var(--surface); }
.dropzone-file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dropzone-file-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-file-size { font-size: var(--fs-xs); color: var(--ink-3); }
.dropzone-clear { position: relative; z-index: 1; }
/* Several files (Probelauf): the zone stays empty, the files are listed below it */
.dropzone.is-compact { align-items: stretch; padding: 14px 16px; }
.dropzone.is-compact .dropzone-empty { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 12px; text-align: left; }
.dropzone.is-compact .dropzone-icon { grid-row: span 2; font-size: 18px; }
.file-list { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.file-item {
    display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px;
    border: 1px solid var(--petrol-100); border-radius: var(--r-sm); background: var(--petrol-50);
}
.file-item-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; color: var(--petrol-700); background: var(--surface); }
.file-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-item-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { font-size: var(--fs-xs); color: var(--ink-3); }
.testrun-files .field-hint:empty { display: none; }
.testrun-files .field-hint.is-error { color: var(--err-700); }

/* 18. Import --------------------------------------------------------------- */
.import-facts { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.import-facts li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.import-facts i { color: var(--petrol-600); text-align: center; }

/* 19. Login ---------------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #d8eeeb 0%, transparent 60%), var(--canvas); }
.auth-card { width: min(400px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--sh-float); }
.auth-card .brand { color: var(--ink); margin-bottom: 26px; }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: 4px; }
.auth-card .field-hint { margin-bottom: 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }

/* 20. License, access, „Wissen aus Website“ -------------------------------- */
.page-notice.is-error { border-color: #f5c2bc; color: var(--err-700); background: var(--err-50); }
.page-notice.is-error i { color: var(--err-700); }

/* Two cards on top of the form: today's mails and the license */
.status-cards { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.license-card {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 20px 24px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-panel);
}
.license-icon {
    width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px;
    font-size: 16px; color: var(--ok-700); background: var(--ok-50);
}
.license-main { display: grid; gap: 4px; min-width: 0; }
.license-card h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.license-date { font-size: var(--fs-xl); font-weight: 650; font-stretch: 94%; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.license-pill {
    display: inline-flex; padding: 2px 10px; border-radius: var(--r-full);
    font-size: var(--fs-xs); font-weight: 600; color: var(--ok-700); background: var(--ok-50);
}
.license-detail { font-size: var(--fs-sm); color: var(--ink-2); }
.license-card.is-warn { border-color: #f3dfb8; background: linear-gradient(180deg, var(--warn-50), var(--surface) 75%); }
.license-card.is-warn .license-icon, .license-card.is-warn .license-pill { color: var(--warn-700); background: #fbe7c3; }
.license-card.is-warn .license-detail { color: var(--warn-700); }
.license-card.is-expired { border-color: #f5c2bc; background: linear-gradient(180deg, var(--err-50), var(--surface) 75%); }
.license-card.is-expired .license-icon, .license-card.is-expired .license-pill { color: var(--err-700); background: #fad6d1; }
.license-card.is-expired .license-detail { color: var(--err-700); font-weight: 500; }

/* The customer's sidebar: the license under the Kontingent */
.license-nav {
    margin-top: 8px; display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--r-md); background: rgb(255 255 255 / 0.05); color: #a7e3c0;
}
.license-nav-text { display: grid; gap: 1px; }
.license-nav-rest { font-size: var(--fs-xs); color: #d8e6e6; }
.license-nav.is-warn { color: #f6c86b; background: rgb(246 200 107 / 0.12); }
.license-nav.is-warn .license-nav-rest { color: #f6c86b; font-weight: 600; }
.license-nav.is-expired { color: #ff9b91; background: rgb(255 155 145 / 0.12); }
.license-nav.is-expired .license-nav-rest { color: #ff9b91; font-weight: 600; }

/* Customer table: the license column */
.license .activity-now i { margin-right: 5px; }
.license.is-warn .activity-now { color: var(--warn-700); }
.license.is-expired .activity-now { color: var(--err-700); }
.license.is-none .activity-now { color: var(--ink-3); font-weight: 500; }
.license-sub.chip { margin-top: 3px; }
.data-table tr.license-expired td:first-child { box-shadow: inset 3px 0 0 var(--err-500); }

/* Customer form: the license field shows its state while choosing */
.license-input { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.license-input input[type="date"] { flex: 1 1 170px; width: auto; max-width: 220px; font-variant-numeric: tabular-nums; }
.license-input input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.7; }
.license-state { min-height: 1.3em; font-weight: 500; }
.license-field.is-ok .license-state { color: var(--ok-700); }
.license-field.is-warn .license-state { color: var(--warn-700); }
.license-field.is-warn input[type="date"] { border-color: var(--warn-500); background: var(--warn-50); }
.license-field.is-expired .license-state { color: var(--err-700); }
.license-field.is-expired input[type="date"] { border-color: var(--err-500); background: var(--err-50); }

/* Dashboard: licenses that end or ended */
.license-alert {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 20px; padding: 14px 18px;
    border: 1px solid #f3dfb8; border-radius: var(--r-md); color: var(--warn-700); background: var(--warn-50);
}
.license-alert.is-expired { border-color: #f5c2bc; color: var(--err-700); background: var(--err-50); }
.license-alert-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.license-alert-text span { color: var(--ink); }
.license-alert-text span + strong { margin-top: 6px; }

/* Kundenzugang */
.access-panel.is-off .access-body { display: none; }
.access-panel.is-off .form-section-head { margin-bottom: 0; }
.login-name {
    display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
    margin-top: 6px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
    font-family: var(--mono); font-size: var(--fs-base); color: var(--ink); background: var(--surface-2); overflow-wrap: anywhere;
}
.login-name i { color: var(--petrol-600); }
.password-field input { letter-spacing: 0.02em; }

/* Settings: the active API key */
.key-current {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line);
}
.key-current-icon {
    width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px;
    color: var(--ok-700); background: var(--ok-50);
}
.key-current-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.key-current-value { font-family: var(--mono); font-size: var(--fs-lg); font-weight: 600; }
.key-current.is-missing { border-color: #f5c2bc; background: var(--err-50); }
.key-current.is-missing .key-current-icon { color: var(--err-700); background: #fad6d1; }
.key-current.is-missing .key-current-value { font-family: var(--font); color: var(--err-700); }

/* „Wann hierhin?“: a real text field with room for topics and examples */
.routing-field .routing-lead { margin: 2px 0 6px; }
.routing-field textarea { min-height: 84px; }
.routing-field .suggestions { margin-top: 8px; }

/* „Wissen aus Website“: the call to action above the field */
.knowledge-cta {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 14px 16px; border: 1px dashed var(--petrol-300); border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--petrol-50), var(--surface) 80%);
}
.knowledge-cta-icon {
    width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px;
    color: var(--petrol-700); background: var(--petrol-100);
}
.knowledge-cta-text { flex: 1 1 240px; display: grid; gap: 2px; min-width: 0; }
.knowledge-cta-title { font-size: var(--fs-base); }
.knowledge-cta-hint { font-size: var(--fs-sm); color: var(--ink-2); }
.knowledge-cta.is-compact { padding: 0; border: 0; background: none; justify-content: flex-end; }
.knowledge-cta.is-compact .knowledge-cta-icon, .knowledge-cta.is-compact .knowledge-cta-text { display: none; }

/* The assistant: form, live progress, result */
dialog.knowledge-dialog { max-height: calc(100dvh - 32px); overflow: auto; }
.kw-lead { margin-top: 2px; }
.kw-form { gap: 16px; }
.kw-perspectives { margin: 0; padding: 0; border: 0; min-width: 0; }
.kw-perspectives legend { margin-bottom: 8px; padding: 0; }
.kw-perspective-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kw-perspective {
    position: relative; display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer;
    background: var(--surface); transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.kw-perspective:hover { border-color: var(--petrol-300); }
.kw-perspective input { position: absolute; opacity: 0; pointer-events: none; }
.kw-perspective:has(input:focus-visible) { box-shadow: var(--ring); }
.kw-perspective:has(input:checked) { border-color: var(--petrol-600); background: var(--petrol-50); box-shadow: 0 0 0 1px var(--petrol-600); }
.kw-perspective-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; color: var(--petrol-700); background: var(--petrol-50); }
.kw-perspective:has(input:checked) .kw-perspective-icon { color: #fff; background: var(--petrol-600); }
.kw-perspective-text { display: grid; gap: 1px; min-width: 0; }
.kw-perspective-text strong { font-size: var(--fs-sm); }
.kw-perspective-text span { font-size: var(--fs-xs); color: var(--ink-2); }
.kw-content { display: grid; gap: 12px; margin-top: 14px; }
.kw-steps { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; flex-wrap: wrap; }
.kw-step {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px;
    border-radius: var(--r-full); font-size: var(--fs-sm); color: var(--ink-3); background: var(--surface-2);
}
.kw-step-mark { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; font-size: 10px; background: var(--line); color: var(--ink-3); }
.kw-step.is-active { color: var(--petrol-900); background: var(--petrol-50); font-weight: 600; }
/* the running step: its mark itself is the ring, so it turns around the mark's centre */
.kw-step.is-active .kw-step-mark { background: none; border: 2px solid var(--petrol-100); border-top-color: var(--petrol-600); animation: spin 0.8s linear infinite; }
.kw-step.is-done { color: var(--ok-700); }
.kw-step.is-done .kw-step-mark { color: #fff; background: var(--ok-500); }
.kw-bar { position: relative; height: 10px; border-radius: var(--r-full); overflow: hidden; background: var(--line); }
.kw-bar > span {
    position: absolute; inset: 0 auto 0 0; border-radius: inherit; transition: width 0.6s var(--ease);
    background: linear-gradient(90deg, var(--petrol-600), var(--petrol-400), var(--petrol-600));
    background-size: 200% 100%; animation: shimmer 2.2s linear infinite;
}
.kw-statusline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); }
.kw-status { color: var(--ink); font-weight: 500; }
.kw-clock { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.kw-pages-head { margin-top: 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); }
.kw-pages {
    display: grid; gap: 2px; max-height: 200px; overflow: auto; margin: 0; padding: 6px;
    list-style: none; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
}
.kw-pages:empty::before { content: "Noch keine Seite gelesen."; padding: 6px 8px; font-size: var(--fs-sm); color: var(--ink-3); }
.kw-page { display: grid; grid-template-columns: 16px minmax(0, 1fr) minmax(0, max-content); align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.kw-page i { color: var(--ok-500); font-size: 12px; }
.kw-page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-page-path { max-width: 22em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-3); }
.kw-page.is-new { animation: pop-in 0.25s var(--ease); }
.kw-preview {
    max-height: min(46vh, 420px); overflow: auto; padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere;
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
    font-size: var(--fs-sm); line-height: 1.55; color: var(--ink);
}
.kw-preview:focus-visible { box-shadow: var(--ring); outline: none; }
.dialog-icon.is-success { color: var(--ok-700); background: var(--ok-50); }
@media (max-width: 640px) {
    .status-cards { grid-template-columns: minmax(0, 1fr); }
    .kw-perspective-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .kw-page-path { display: none; }
    .kw-page { grid-template-columns: 16px minmax(0, 1fr); }
}
@media (max-width: 480px) {
    .kw-perspective-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 21. Motion --------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 22. Responsive ----------------------------------------------------------- */
@media (max-width: 1279px) {
    .data-table .col-targets { display: none; }
    .data-table th, .data-table td { padding-left: 12px; padding-right: 12px; }
}
@media (max-height: 760px) {
    .testrun-result, .testrun-result:has(.testrun-output:not([hidden])) { position: static; max-height: none; height: auto; }
    .testrun-preview { flex: none; height: 560px; }
}
@media (max-width: 1099px) {
    .testrun-grid { grid-template-columns: minmax(0, 1fr); }
    .testrun-result, .testrun-result:has(.testrun-output:not([hidden])) { position: static; max-height: none; height: auto; }
    .testrun-preview { flex: none; height: 560px; }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
    .main-content { padding: 28px 24px 56px; }
    .sticky-header { margin: -28px -24px 20px; padding: 14px 24px; }
    .target-form-grid { grid-template-columns: minmax(0, 1fr); }
    .explainer-steps { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.open { transform: none; box-shadow: var(--sh-float); }
    .mobile-menu-toggle { display: grid; place-items: center; }
    .mobile-overlay.active { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(11 42 47 / 0.4); }
    .main-content { margin-left: 0; padding: 72px 16px 48px; }
    .sticky-header { margin: -72px -16px 16px; padding: 12px 16px 12px 66px; min-height: 66px; }
    .sticky-header-title { font-size: var(--fs-lg); }
    .sticky-header-actions .btn { min-height: 34px; padding: 0 12px; font-size: var(--fs-sm); }
    .hide-mobile { display: none !important; }
    .form-section { padding: 18px 16px 20px; }
    .field-grid { grid-template-columns: minmax(0, 1fr); }
    .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
    .page-header h2 { font-size: var(--fs-xl); }
    .log-item { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 16px; }
    .log-item .log-message { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
    .dashboard-log-controls, .dashboard-log-controls select { max-width: 100%; min-width: 0; }
    .dashboard-log-controls input[type="search"] { width: 100%; }
    .target-header { flex-wrap: wrap; row-gap: 2px; }
    .target-header h4 { flex: 1 1 100%; }
    .target-header-controls { margin-left: 32px; }
    .testrun-preview { height: 520px; }
    /* Tables become cards */
    .data-table table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table thead { display: none; }
    .data-table tbody tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .data-table td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; text-align: right; }
    .data-table td::before { content: attr(data-label); flex: none; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); text-align: left; }
    /* a card row is one line: the averages and the quota rest stay in the tooltip */
    .data-table .activity-avg, .data-table .quota-sub { display: none; }
    .data-table .col-targets { display: flex; }
    .data-table .customer-chips { justify-content: flex-end; }
    /* the license: date and its state side by side on the right; an ended one marks the whole card */
    .data-table td.license { justify-content: flex-end; align-items: center; gap: 8px; }
    .data-table td.license::before { margin-right: auto; }
    .data-table td.license .license-sub.chip { margin-top: 0; }
    .data-table tr.license-expired { box-shadow: inset 3px 0 0 var(--err-500); }
    .data-table tr.license-expired td:first-child { box-shadow: none; }
    .row-actions { justify-content: flex-end; }
    .data-table-toolbar .search-input { max-width: none; }
    .data-table-toolbar select { flex: 1 1 auto; min-width: 0; }
}
