/* EVEX-Tools: gemeinsames Stylesheet (Basis aus Transaktionsmails, identisch halten).
   Eine Akzentfarbe (Blau) für die eine Hauptaktion je Seite, Grün/Rot nur für Status. Videoportal-Ergänzungen am Ende. */

:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --soft: #f1f4f9;
    --text: #17202c;
    --muted: #596577;
    --faint: #6a7586;            /* Platzhalter, 4,7:1 auf Weiß */
    --border: #e2e7ef;           /* Trennlinien (dekorativ) */
    --border-strong: #8592a4;    /* Feldrahmen, 3,2:1 auf Weiß */

    --accent: #1f5fd6;
    --accent-hover: #194fb4;
    --accent-soft: #e9f0fd;
    --accent-text: #ffffff;

    --error: #b3261e;
    --error-soft: #fdeceb;
    --error-wash: #fffafa;
    --ok: #16743a;
    --ok-soft: #e7f5ec;
    --warn: #7a4d00;
    --warn-soft: #fff4dc;

    /* Schriftrollen: fünf Größen, jede mit einer Aufgabe */
    --fs-title: 1.625rem;    /* 26 px Seitenüberschrift */
    --fs-heading: 1.125rem;  /* 18 px Abschnitt, Dialogtitel */
    --fs-body: 1rem;         /* 16 px Fließtext, Felder, Adressen */
    --fs-ui: .875rem;        /* 14 px Beschriftungen, Tabellen, Hinweise, Buttons */
    --fs-meta: .8rem;        /* 12,8 px Datum, Herkunft, Spaltenköpfe, Badges */

    --radius: 10px;
    --radius-card: 14px;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --ease-out-expo: cubic-bezier(.16, 1, .3, 1);

    color-scheme: light;
    accent-color: var(--accent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    overflow-y: scroll;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: var(--fs-body)/1.55 system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    caret-color: var(--accent);
}
::selection { background: #cfdcf7; color: var(--text); }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
code { background: var(--soft); padding: .1rem .35rem; border-radius: 5px; font-size: .88em; }
h1 { font-size: var(--fs-title); line-height: 1.3; font-weight: 650; letter-spacing: -.02em; margin: 0 0 1rem; text-wrap: balance; }
h2 { font-size: var(--fs-heading); line-height: 1.35; font-weight: 650; letter-spacing: -.01em; margin: 0 0 .75rem; }
p { margin: 0 0 1rem; }
/* Erklärtexte in Karten: lesbare Zeilenlänge, deutsche Silbentrennung */
main.wide section > p, .hint, .notice, .empty, .sd-hint { max-width: 70ch; hyphens: auto; -webkit-hyphens: auto; }
ul { padding-left: 1.2rem; }
/* Textklasse; Buttons nutzen .small nur als Größe (siehe button.small) */
.small:not(button):not(.btn) { font-size: var(--fs-ui); color: var(--muted); }
p.small { margin: 1.25rem 0 0; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--error); font-weight: 600; }
.icon { display: inline-block; flex: none; width: 1em; height: 1em; vertical-align: -.14em; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* Scrollbalken passend zur Fläche */
* { scrollbar-color: #c3cbd8 transparent; scrollbar-width: thin; }

/* ---- Kopfzeile ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
    max-width: 1180px; margin: 0 auto; padding: .25rem 1.25rem; min-height: 4rem;
    display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 2rem;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.brand:hover { color: var(--text); }
.brand { gap: .15rem; }
/* Die Datei enthält den Schutzraum: Höhe 3,5rem ergibt etwa 18 px Schriftzug */
.brand .logo { display: block; height: 3.5rem; width: auto; margin-left: -1.05rem; }
.brand-name { padding-left: .9rem; border-left: 1px solid var(--border-strong); font-weight: 600; font-size: var(--fs-body); letter-spacing: -.005em; color: var(--muted); line-height: 1.6rem; }
.brand:hover .brand-name { color: var(--text); }
.topbar nav { display: flex; gap: .25rem; margin-right: auto; }
.topbar nav a {
    padding: .4rem .75rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: var(--fs-ui); text-decoration: none;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.topbar nav a:hover { background: var(--soft); color: var(--text); }
.topbar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.topbar .who { color: var(--muted); font-size: var(--fs-ui); margin-left: auto; }
.topbar nav + .who { margin-left: 0; }
.topbar .who a { color: var(--muted); }

/* ---- Seitenrahmen ---- */
.card {
    width: calc(100% - 2rem); max-width: 26rem; margin: 2.5rem auto 1.5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 2rem;
}
.card form { margin-top: .25rem; }
.card form button[type=submit] { width: 100%; }
.card .btn { margin-top: 0; }

main.wide { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
main.wide section {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
    padding: 1.4rem 1.6rem; margin-bottom: 1.25rem;
}
main.wide section form.grid, main.wide > form.grid { max-width: 46rem; }
main.wide section input:not([type=checkbox]):not([type=radio]):not([type=search]), main.wide section textarea, main.wide section select { max-width: 40rem; }
main.wide section input.short { max-width: 14rem; }
.back { margin: 0 0 .5rem; font-size: var(--fs-ui); }
.back a { display: inline-block; padding: .2rem 0; text-decoration: none; color: var(--muted); }
.back a:hover { color: var(--accent); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head > button { margin: 0; }
.page-head button .icon, .page-head .btn .icon { width: 1.1rem; height: 1.1rem; }
.page-meta { display: flex; align-items: center; gap: .4rem; margin: .3rem 0 0; font-size: var(--fs-ui); color: var(--muted); }
.page-meta .icon { color: var(--faint); }

/* Projektübersicht: Kacheln */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 1rem; }
.tile {
    position: relative; display: flex; flex-direction: column; gap: 1.1rem; min-height: 8.5rem; padding: 1.15rem 1.2rem 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.tile:hover { border-color: var(--accent); box-shadow: 0 6px 18px -10px rgba(16, 28, 48, .3); }
.tile:has(.tile-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-name { margin: 0; padding-right: 2.5rem; font-size: var(--fs-heading); line-height: 1.3; overflow-wrap: anywhere; }
.tile-link { color: var(--text); text-decoration: none; }
.tile-link:hover { color: var(--text); }
.tile-link:focus-visible { outline: none; }
/* Ganze Kachel klickbar */
.tile-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.tile .badge { position: absolute; top: 3.1rem; left: 1.2rem; }
.tile.is-inactive { background: var(--soft); }
.tile.is-inactive .tile-name { color: var(--muted); }
.tile.is-inactive .tile-name { margin-bottom: 1.6rem; }
.tile-facts { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: var(--fs-ui); color: var(--muted); }
.tile-facts li { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: .35rem; }
.tile-facts strong { color: var(--text); font-weight: 600; }
.tile-facts .icon { color: var(--faint); }
.tile-facts .unit { margin-left: -.1rem; }
.tile .tile-edit { position: absolute; top: .7rem; right: .7rem; z-index: 1; }
.tile-new { align-items: center; justify-content: center; border-style: dashed; border-color: var(--border-strong); background: transparent; }
.tile-new .tile-link { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--muted); }
.tile-new .tile-link .icon { width: 1.25rem; height: 1.25rem; }
.tile-new:hover .tile-link { color: var(--accent); }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.section-head h2 { margin: 0; }
.narrow { max-width: 26rem; }
.static { margin: 0; }
.hint { margin: .35rem 0 0; font-size: var(--fs-ui); color: var(--muted); max-width: 40rem; }
.count {
    display: inline-block; margin-left: .35rem; padding: .05rem .5rem; border-radius: 999px;
    background: var(--soft); color: var(--muted); font-size: var(--fs-meta); font-weight: 600; vertical-align: .1em;
}

/* ---- Formulare ---- */
label { display: block; font-weight: 600; font-size: var(--fs-ui); margin: 1.1rem 0 .35rem; }
input, select, textarea {
    display: block; width: 100%; min-height: 2.75rem; padding: .6rem .8rem; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
/* Auswahlfelder wie Textfelder: gleiche Breite und Höhe, eigener Pfeil statt Systemoptik */
select {
    -webkit-appearance: none; appearance: none; padding-right: 2.4rem; text-overflow: ellipsis; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23596577' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.5L8 10l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .75rem center; background-size: 1rem;
}
textarea { min-height: 0; resize: vertical; }
textarea.mono { font: var(--fs-ui)/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea.code { max-width: none !important; min-height: 16rem; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: #6f7c8f; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px rgba(31, 95, 214, .18);
}
input:disabled, select:disabled { background: var(--soft); color: var(--muted); cursor: not-allowed; }
input.short { max-width: 14rem; }
input[type=checkbox], input[type=radio] { display: inline-block; width: 1.05rem; min-height: 0; height: 1.05rem; margin: 0 .5rem 0 0; vertical-align: -.15rem; }
input[type=file] { padding: .4rem; }
input[type=file]::file-selector-button {
    margin-right: .75rem; padding: .4rem .8rem; font: inherit; font-weight: 600; color: var(--text);
    background: var(--soft); border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer;
}
label.check { display: flex; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: .3rem; flex: none; }
fieldset { border: 0; padding: 0; margin: 1.4rem 0 0; }
fieldset > legend + label, fieldset > legend + .checklist { margin-top: .35rem; }
/* Erstes Feld direkt unter der Kartenüberschrift bzw. am Kartenanfang ohne Extra-Abstand */
main.wide section > form:first-child > input[type=hidden] + label,
main.wide section > h2 + form > input[type=hidden] + label { margin-top: 0; }
legend { font-weight: 600; font-size: var(--fs-ui); margin-bottom: .35rem; padding: 0; }
/* Auswahlliste mit Checkboxen: eine Zeile je Eintrag */
.picklist { margin: 1.1rem 0 0; padding: 0; max-width: 40rem; }
.picklist legend { margin-bottom: .4rem; }
.pick {
    display: flex; align-items: center; gap: .65rem; margin: 0; padding: .6rem .8rem;
    font-weight: 400; font-size: var(--fs-body); cursor: pointer;
    border: 1px solid var(--border-strong); border-top-width: 0; background: var(--surface);
    transition: background-color .12s var(--ease);
}
.picklist legend + .pick, .picklist > .pick:first-of-type { border-top-width: 1px; border-radius: var(--radius) var(--radius) 0 0; }
.picklist > .pick:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
.picklist > .pick:only-of-type { border-radius: var(--radius); }
.pick:hover { background: var(--soft); }
.pick:has(input:checked) { background: var(--accent-soft); }
.pick input[type=checkbox] { margin: 0; flex: none; width: 1.1rem; height: 1.1rem; }
.pick-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
label.check.spaced { margin-top: 1.25rem; }

.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .1rem 1rem; }
.checklist label.check { margin: .35rem 0; }
.row3 { display: grid; grid-template-columns: 1.6fr .8fr 1.7fr; gap: 0 .75rem; max-width: 40rem; }
form.inline { display: inline; margin: 0; }

/* ---- Buttons ---- */
button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    margin-top: 1rem; min-height: 2.75rem; padding: .6rem 1.15rem; font: inherit; font-weight: 600; line-height: 1.3;
    text-decoration: none; color: var(--accent-text); background: var(--accent); border: 1px solid var(--accent);
    border-radius: var(--radius); cursor: pointer; white-space: nowrap;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button:disabled { opacity: .55; cursor: progress; transform: none; }
button.secondary, .btn.secondary { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
button.secondary:hover, .btn.secondary:hover { background: var(--soft); border-color: #6f7c8f; color: var(--text); }
button.danger { color: var(--error); background: var(--surface); border-color: #d99a95; }
button.danger:hover { background: var(--error-soft); border-color: var(--error); color: var(--error); }
button.small, .btn.small { margin: 0; min-height: 2.25rem; padding: .35rem .75rem; font-size: var(--fs-ui); }
.btn.small { color: var(--accent); background: var(--surface); border-color: var(--border-strong); }
.btn.small:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
button.link {
    margin: 0; min-height: 0; padding: 0; border: 0; background: none; color: var(--accent);
    font: inherit; font-weight: 400; text-decoration: underline; text-underline-offset: .18em; cursor: pointer;
}
button.link:hover { background: none; color: var(--accent-hover); }
.rowactions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.rowactions form { margin: 0; }
.rowactions.spaced { margin-top: .9rem; }

/* ---- Reiter ---- */
.tabs { display: flex; gap: .25rem; margin: 0 0 1.25rem; border-bottom: 1px solid var(--border-strong); }
.tabs a {
    position: relative; padding: .6rem 1rem; margin-bottom: -1px; color: var(--muted); font-weight: 600; font-size: var(--fs-ui);
    text-decoration: none; border-bottom: 2px solid transparent; transition: color .12s var(--ease), border-color .12s var(--ease);
}
.tabs a:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Meldungen ---- */
.notice { margin: 0 0 1rem; padding: .7rem .95rem; border-radius: var(--radius); background: var(--soft); border: 1px solid var(--border); }
.notice.ok { background: var(--ok-soft); border-color: #bfe3cc; color: #0f5a2c; }
.notice.error { background: var(--error-soft); border-color: #f1c4c0; color: var(--error); }

/* ---- Tabellen ---- */
.tablewrap { overflow-x: auto; margin: 0 -.25rem; padding: 0 .25rem; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-ui); }
th, td { text-align: left; padding: .65rem .55rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: var(--fs-meta); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover { background: #f8fafd; }
tbody tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }
.num { text-align: right; }

.badge {
    display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: var(--fs-meta); font-weight: 600; white-space: nowrap;
    background: var(--soft); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--error-soft); color: var(--error); }
.badge.sent { background: var(--accent-soft); color: var(--accent); }

/* ==== Projektseite ======================================================= */

/* Kopf der Projektseite: "Neuer Kontakt" ist die Hauptaktion */
.head-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.head-actions .btn, .head-actions button { margin: 0; }
.btn-new { padding-left: 1rem; padding-right: 1.25rem; font-size: var(--fs-body); }
.btn-new .icon { width: 1.25rem; height: 1.25rem; }
.notice.warn { background: var(--warn-soft); border-color: #f0d9a8; color: var(--warn); font-weight: 600; }

/* Dialog "Neuer Kontakt": mehrere Formulare in einem Dialog */
.modal-body { padding: 1.5rem 1.6rem 1.35rem; }
.modal-body form { padding: 0; }
.modal-wide { width: min(38rem, calc(100vw - 2rem)); }
/* Reiter im Dialog: Einzelkontakt / Mehrere Kontakte */
.tabs-inline { margin: 0 0 1.1rem; }
.tabs-inline button {
    margin: 0 0 -1px; min-height: 0; padding: .55rem .9rem; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
    background: none; color: var(--muted); font-size: var(--fs-ui); font-weight: 600;
}
.tabs-inline button:hover { background: none; color: var(--text); border-bottom-color: var(--border-strong); }
.tabs-inline button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.modal [role=tabpanel] label:first-of-type { margin-top: 0; }
#batch-emails { font-size: var(--fs-ui); }

.batch-review h2 { margin-bottom: .75rem; }
.sd-facts.compact { padding: .6rem 0; margin-bottom: .75rem; font-size: var(--fs-ui); }
.batch-groups { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; gap: .35rem; font-size: var(--fs-ui); }
.batch-list { color: var(--muted); overflow-wrap: anywhere; }
.batch-warn strong { color: var(--warn); }
.batch-bad strong { color: var(--error); }
.batch-confirm label.check { margin: 0 0 .5rem; font-size: var(--fs-ui); }
.batch-confirm .sd-hint { margin-top: .6rem; }

/* Suche: filtert die Liste beim Tippen */
form.search { margin: 0; }
.search-field { position: relative; display: block; }
.search-field .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
main.wide section .search-field input { width: 17rem; max-width: 100%; min-height: 2.5rem; padding-left: 2.2rem; }
.empty { margin: .5rem 0 .25rem; color: var(--muted); }

/* Icon-Buttons: große Symbole, Bedeutung im Tooltip und für Screenreader */
.icon-btn {
    position: relative; margin: 0; width: 2.5rem; height: 2.5rem; min-height: 0; padding: 0; flex: none;
    color: var(--muted); background: var(--surface); border: 1px solid #cfd6e0; border-radius: 9px;
}
.icon-btn .icon { width: 1.3rem; height: 1.3rem; }
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); border-color: #a9bde6; }
.icon-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); border-color: #a9bde6; }
.icon-btn.primary { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.icon-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.icon-btn.danger { color: var(--muted); background: var(--surface); border-color: #cfd6e0; }
.icon-btn.danger:hover { color: var(--error); background: var(--error-soft); border-color: #e3a9a4; }
.icon-btn[aria-busy="true"] { opacity: .5; }
a.icon-btn { display: inline-flex; align-items: center; justify-content: center; }

/* Tooltips (data-tip) bei Hover und Tastaturfokus */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip); position: absolute; z-index: 30; bottom: calc(100% + 8px); left: 50%;
    width: max-content; max-width: min(24rem, 80vw); padding: .4rem .6rem; border-radius: 7px;
    background: #1b2433; color: #fff; font-size: var(--fs-meta); font-weight: 500; line-height: 1.45; letter-spacing: 0;
    text-align: left; white-space: pre-line; text-transform: none;
    opacity: 0; visibility: hidden; transform: translate(-50%, 3px); pointer-events: none;
    transition: opacity .12s var(--ease), transform .12s var(--ease), visibility 0s .12s;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
    opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: .2s, .2s, 0s;
}
.tip-start[data-tip]::after { left: 0; transform: translate(0, 3px); }
.tip-start[data-tip]:hover::after, .tip-start[data-tip]:focus-visible::after { transform: none; }
.tip-end[data-tip]::after { left: auto; right: 0; transform: translate(0, 3px); }
.tip-end[data-tip]:hover::after, .tip-end[data-tip]:focus-visible::after { transform: none; }
/* Ausgeklappt sitzt der Tooltip unter dem Button, damit er die Zeile darüber nicht verdeckt */
.rcp-panel [data-tip]::after { bottom: auto; top: calc(100% + 8px); }

/* Filter nach Versandstand */
.status-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.25rem 0 .9rem; }
.chip {
    margin: 0; min-height: 2.25rem; padding: .3rem .8rem; gap: .4rem; font-size: var(--fs-ui); font-weight: 600;
    color: var(--muted); background: var(--surface); border: 1px solid #cfd6e0; border-radius: 999px;
}
.chip:hover { color: var(--text); background: var(--soft); border-color: var(--border-strong); }
.chip .icon { width: 1rem; height: 1rem; }
.chip-n { min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: var(--fs-meta); text-align: center; }
.chip-open .icon { color: #b07a12; }
.chip-ok .icon { color: var(--ok); }
.chip-fail .icon { color: var(--error); }
.chip[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.chip[aria-pressed="true"] .chip-n { background: var(--surface); color: var(--accent); }

/* Kontaktliste: eine Zeile je Kontakt, Details beim Ausklappen */
.rcp-list { list-style: none; margin: 0 -.6rem; padding: 0; }
.rcp { border-radius: 10px; transition: background-color .12s var(--ease); }
.rcp + .rcp { border-top: 1px solid var(--border); }
.rcp:hover { background: #f8fafd; }
.rcp.is-open { background: #f8fafd; border-top-color: transparent; }
.rcp.is-open + .rcp { border-top-color: transparent; }
.rcp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "body status actions"; align-items: center; gap: .5rem 1rem; padding: .6rem .6rem .6rem .9rem; }
.rcp-body { grid-area: body; }
.rcp-row > .status { grid-area: status; }
.rcp-actions { grid-area: actions; }
.rcp-body { min-width: 0; }
.addr { display: block; font-weight: 600; overflow-wrap: anywhere; line-height: 1.35; }
.rcp-meta { display: flex; flex-wrap: wrap; gap: .1rem 1rem; margin-top: .1rem; font-size: var(--fs-meta); color: var(--muted); }
.rcp-meta > span { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.rcp-meta .icon { width: .95rem; height: .95rem; color: var(--faint); }
.rcp-actions { display: flex; }
.rcp-actions form { margin: 0; }
/* Senden: die Hauptaktion der Zeile. Noch nicht gesendet = gefüllt, danach "Erneut senden" = farbiger Rahmen */
.rcp-actions .icon-btn.send { color: var(--accent-text); background: var(--accent); border: 1.5px solid var(--accent); }
.rcp-actions .icon-btn.send:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.rcp-actions .icon-btn.send.is-again { color: var(--accent); background: var(--surface); }
.rcp-actions .icon-btn.send.is-again:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-hover); }
.rcp-actions { gap: .4rem; }

/* Versandstand: farbiger Streifen links und Etikett mit Text, Details im Tooltip */
.rcp { box-shadow: inset 3px 0 0 transparent; }
.rcp.st-open { box-shadow: inset 3px 0 0 #e3b341; }
.rcp.st-ok { box-shadow: inset 3px 0 0 #5bb37f; }
.rcp.st-fail { box-shadow: inset 3px 0 0 var(--error); }
.status {
    display: inline-flex; align-items: center; gap: .4rem; min-width: 11.5rem; padding: .3rem .7rem .3rem .5rem; border-radius: 999px;
    font-size: var(--fs-ui); font-weight: 600; line-height: 1.3; white-space: nowrap; cursor: default;
}
.status .icon { width: 1.1rem; height: 1.1rem; }
.status-sub { font-weight: 500; opacity: .85; }
.status-open { background: var(--warn-soft); color: var(--warn); }
.status-open .icon { color: #b07a12; }
.status-ok { background: var(--ok-soft); color: #0f5a2c; }
.status-ok .icon { color: var(--ok); }
.status-fail { background: var(--error-soft); color: var(--error); }
.status:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Ausgeklappter Eintrag */
.rcp-panel {
    display: grid; grid-template-columns: minmax(14rem, 22rem) minmax(0, 1fr) auto; gap: 1rem 2rem; align-items: start;
    margin: 0 .6rem 0 .9rem; padding: .9rem 0 1rem; border-top: 1px solid var(--border);
    animation: panel-in .18s var(--ease-out-expo);
}
@keyframes panel-in { from { opacity: 0; transform: translateY(-3px); } }
.rcp-panel form { margin: 0; }
.rcp-panel label { margin: 0 0 .3rem; font-size: var(--fs-meta); color: var(--muted); }
.inline-row { display: flex; gap: .4rem; align-items: center; }
main.wide section .inline-row select { flex: 1; min-width: 0; max-width: none; min-height: 2.5rem; padding-top: .4rem; padding-bottom: .4rem; font-size: var(--fs-ui); }
.panel-history h3 { margin: 0 0 .4rem; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.history-empty { margin: 0; font-size: var(--fs-ui); color: var(--muted); }
ol.history { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; font-size: var(--fs-ui); }
ol.history li { display: flex; gap: .45rem; align-items: flex-start; line-height: 1.45; }
ol.history li > .icon { margin-top: .2em; }
.h-ok > .icon { color: var(--ok); }
.h-fail > .icon, .h-fail strong { color: var(--error); }
.h-what { min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.h-what strong { color: var(--text); font-weight: 600; }
.h-att, .h-why { display: flex; gap: .3rem; align-items: center; font-size: var(--fs-meta); }
.h-why { color: var(--error); }
.panel-remove { align-self: end; }

/* Rückmeldung direkt am Eintrag */
.row-note {
    display: flex; gap: .45rem; align-items: flex-start; margin: .45rem 0 .1rem; padding: .35rem .6rem; border-radius: 8px;
    font-size: var(--fs-ui); line-height: 1.4; width: fit-content;
}
.row-note .icon { flex: none; margin-top: .15em; }
.row-note.ok { background: var(--ok-soft); color: #0f5a2c; }
.row-note.error { background: var(--error-soft); color: var(--error); }

/* Bestätigung vor dem Versand: die Mail so, wie der Kontakt sie bekommt */
.send-dialog, .modal {
    width: min(34rem, calc(100vw - 2rem)); padding: 0; border: 0; border-radius: var(--radius-card);
    color: var(--text); background: var(--surface);
    box-shadow: 0 24px 60px -12px rgba(16, 28, 48, .35), 0 4px 14px rgba(16, 28, 48, .12);
}
.send-dialog::backdrop, .modal::backdrop { background: rgba(16, 24, 38, .42); }
.send-dialog[open], .modal[open] { animation: dialog-in .32s var(--ease-out-expo); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.send-dialog > form, .modal > form { padding: 1.5rem 1.6rem 1.35rem; }
.modal { width: min(30rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; }
.modal label:first-of-type { margin-top: 0; }
.modal .notice { margin-bottom: .5rem; }
.modal .sd-actions { margin-top: 1.4rem; }
.send-dialog h2, .modal h2 { margin: 0 0 1rem; }
.sd-warn { margin: 0 0 1rem; padding: .6rem .8rem; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: var(--fs-ui); }
.sd-facts { display: grid; grid-template-columns: 5.5rem 1fr; gap: .55rem 1rem; margin: 0; padding: 1rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: var(--fs-body); }
.sd-facts dt { font-size: var(--fs-ui); padding-top: .1rem; }
.sd-facts dt { color: var(--muted); }
.sd-facts dd { margin: 0; overflow-wrap: anywhere; }
.sd-to { font-weight: 650; }
.sd-subject { font-weight: 600; }
.sd-hint { margin: .85rem 0 0; font-size: var(--fs-meta); color: var(--muted); }
.sd-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.sd-actions button, .sd-actions .btn { margin: 0; }

/* Eintragszustände */
.rcp.has-error { background: var(--error-wash); }
.rcp.is-recent, .rcp:target { animation: row-recent 2.6s var(--ease-out-expo) both; }
@keyframes row-recent {
    0%, 35% { background: var(--accent-soft); }
    100%    { background: transparent; }
}
.rcp.has-error.is-recent, .rcp.has-error:target { animation-name: row-recent-error; }
@keyframes row-recent-error {
    0%, 35% { background: var(--accent-soft); }
    100%    { background: var(--error-wash); }
}

/* ---- Sonstige Seiten ---- */
.preview-frame { border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: #fff; }
.preview-frame iframe { display: block; width: 100%; height: 70vh; min-height: 30rem; border: 0; }
/* Projektansicht: Vorschau der Vorlagen im Dialog */
.modal-preview { width: min(48rem, calc(100vw - 2rem)); }
.modal-preview .sd-facts { margin-top: .9rem; }
.modal-preview .preview-frame iframe { height: min(60vh, 42rem); min-height: 18rem; }
section.danger-zone { border-color: #f1c4c0; }

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: .01ms !important; }
    .rcp.is-recent, .rcp:target { animation: none; background: var(--accent-soft); }
    .send-dialog[open], .modal[open], .rcp-panel { animation: none; }
    [data-tip]::after { transition: none; }
}

/* ---- Schmale Bildschirme ---- */
@media (max-width: 60rem) {
    .rcp-panel { grid-template-columns: minmax(0, 1fr) auto; }
    .panel-template { grid-column: 1; }
    .panel-history { grid-column: 1; }
    .panel-remove { grid-column: 2; grid-row: 1; align-self: start; }
}
@media (max-width: 40rem) {
    .card { width: calc(100% - 1.5rem); margin-top: 1rem; padding: 1.25rem; }
    .topbar-inner { padding: .2rem 1rem .5rem; gap: .1rem 1rem; }
    .brand .logo { height: 3rem; margin-left: -.9rem; }
    .brand-name { font-size: var(--fs-ui); padding-left: .75rem; }
    .topbar nav { order: 3; width: 100%; margin: 0 -.25rem; overflow-x: auto; }
    .topbar .who { margin-left: auto; }
    main.wide { padding: 1.25rem .75rem 3rem; }
    main.wide section { padding: 1.1rem 1rem; }
    .row3 { grid-template-columns: 1fr; }

    /* Verwaltungstabellen (Projekte, Nutzer, Vorlagen) als gestapelte Einträge */
    table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: auto; }
    table.stack thead { display: none; }
    table.stack tr { padding: .8rem 0; border-bottom: 1px solid var(--border); }
    table.stack tbody tr:last-child { border-bottom: 0; }
    table.stack td { border: 0; padding: .15rem 0; text-align: left; }
    table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: var(--fs-ui); }
    table.stack td.c-main { font-size: var(--fs-body); padding-bottom: .3rem; }
    table.stack td.c-go { padding-top: .5rem; }
    table.stack td br { display: none; }
    table.stack td .muted.small:not(button) { margin-left: .35rem; }

    form.search, .section-head .search-field { width: 100%; }
    main.wide section .search-field input { width: 100%; }
    .rcp-list { margin: 0 -.5rem; }
    .rcp-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "body actions" "status actions"; gap: .45rem .6rem; padding: .6rem .5rem .6rem .8rem; }
    .rcp-row > .status { justify-self: start; min-width: 0; }
    .head-actions { width: 100%; }
    .head-actions .btn-new { flex: 1; }
    .rcp-panel { grid-template-columns: 1fr; margin: 0 .5rem 0 .8rem; gap: 1rem; }
    .panel-remove { grid-column: 1; grid-row: auto; justify-self: end; }
    .sd-facts { grid-template-columns: 1fr; gap: .1rem; }
    .sd-facts dd { margin-bottom: .45rem; }
    .sd-actions button, .sd-actions .btn { flex: 1 1 100%; }
}

/* ---- Felder je Kontakt (Version 2) ---- */
/* Angaben unter der Adresse */
.rcp-values { display: flex; flex-wrap: wrap; gap: .15rem 1rem; margin-top: .2rem; font-size: var(--fs-meta); }
.rv { display: inline-flex; align-items: baseline; gap: .35rem; min-width: 0; overflow-wrap: anywhere; }
.rv-label { color: var(--muted); }
.rv code { font-size: .95em; padding: 0 .3rem; border-radius: 4px; background: var(--soft); }
.rv-missing { align-items: center; color: var(--warn); font-weight: 600; }
.rv-missing .icon { width: .95rem; height: .95rem; }

/* Eingaben im Dialog und im ausgeklappten Eintrag */
.field-auto { display: flex; flex-wrap: wrap; gap: .2rem .5rem; align-items: baseline; margin: 1rem 0 0; font-size: var(--fs-ui); }
.field-auto-label { font-weight: 600; }
.field-auto code { padding: .05rem .35rem; border-radius: 4px; background: var(--soft); }
.panel-values { padding-bottom: 1rem; margin-bottom: 1rem !important; border-bottom: 1px solid var(--border); }
.panel-values h3 { margin: 0 0 .5rem; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.panel-values label { margin-top: .6rem !important; }
.panel-values h3 + label { margin-top: 0 !important; }
.panel-values input, .panel-values select { width: 100%; min-height: 2.5rem; padding-top: .4rem; padding-bottom: .4rem; font-size: var(--fs-ui); }
.panel-values .field-auto { margin-top: .6rem; }
.panel-values button { margin-top: .75rem; }

/* Import: Spalten zuordnen */
.map-grid { display: grid; grid-template-columns: minmax(8rem, auto) minmax(0, 1fr); gap: .6rem 1rem; align-items: center; margin: .5rem 0 0; }
.map-grid label, .map-grid .map-auto-label { margin: 0; font-weight: 600; font-size: var(--fs-ui); }
.map-grid select { width: 100%; margin: 0; }
.map-grid .muted { font-size: var(--fs-ui); }

/* Projekt bearbeiten: Felder, Listen */
.tabs .count { margin-left: .25rem; }
.fields-table .inline-row input { min-width: 10rem; margin: 0; }
.fields-table .inline-row button, .fields-table form.inline button { margin: 0; }
fieldset.choice label.check { margin: .35rem 0; }

/* Liste: Filter und Suche */
.list-toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; margin: 0 0 .9rem; }
.list-toolbar .status-filter { margin: 0; }
a.chip { display: inline-flex; align-items: center; text-decoration: none; }
a.chip[aria-current="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
a.chip[aria-current="true"] .chip-n { background: var(--surface); color: var(--accent); }
.items-table code { overflow-wrap: anywhere; }

@media (max-width: 40rem) {
    .map-grid { grid-template-columns: 1fr; gap: .25rem; }
    .map-grid select { margin-bottom: .5rem; }
}

/* ======================================================================
   Videoportal: Kundenseiten, Player, Backend-Ergänzungen
   ====================================================================== */
.card.card-wide { max-width: 60rem; }
.page-head > .btn { margin: 0; }
.actions { margin: 0; }
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0 0; font-size: var(--fs-ui); }

/* Suche und Testmail: Feld und Button in einer Zeile */
form.search { display: flex; gap: .5rem; max-width: 30rem; margin: 0 0 1rem; }
main.wide section form.search input { max-width: none; flex: 1; min-width: 0; }
form.search button { margin: 0; flex: none; }

/* Player mit Wasserzeichen und eigenem Vollbild-Knopf */
.player { position: relative; aspect-ratio: 16 / 9; width: 100%; background: #0b0f16; border-radius: 12px; overflow: hidden; }
.player iframe, .player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0b0f16; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.remaining { margin: .9rem 0 0; }
.watermark {
    position: absolute; z-index: 2; pointer-events: none; user-select: none;
    max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: #fff; opacity: .4; font: 600 .85rem/1 system-ui, sans-serif; text-shadow: 0 0 3px #000, 0 0 6px #000;
    animation: wm-move 48s linear infinite;
}
@keyframes wm-move {
    0%   { top: 5%;  left: 4%; }
    25%  { top: 5%;  left: 52%; }
    50%  { top: 86%; left: 52%; }
    75%  { top: 86%; left: 4%; }
    100% { top: 5%;  left: 4%; }
}
.player .fs {
    position: absolute; z-index: 3; right: .6rem; top: .6rem; margin: 0; min-height: 0; padding: .3rem .65rem; font-size: var(--fs-meta);
    background: rgba(0, 0, 0, .55); border-color: rgba(255, 255, 255, .35); color: #fff; opacity: 0; transition: opacity .15s;
}
.player:hover .fs, .player .fs:focus-visible { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .watermark { animation: none; top: 5%; left: 4%; }
}
@media (max-width: 40rem) {
    form.search { max-width: none; }
}

/* Vorschau im Backend: Dialog mit Player, Player-Seite im Rahmen, Icon-Buttons in der Videotabelle */
.modal.modal-video { width: min(56rem, calc(100vw - 2rem)); }
.modal-video .section-head { margin-bottom: .75rem; }
.modal-video .player { border-radius: var(--radius); }
.modal-video .hint { margin-top: .6rem; }
body.player-frame { margin: 0; min-height: 0; display: block; background: #0b0f16; overflow: hidden; }
body.player-frame video, body.player-frame iframe { display: block; width: 100%; height: 100vh; border: 0; background: #0b0f16; }
.player-message { margin: 0; padding: 2rem 1.5rem; color: #fff; font-size: var(--fs-ui); }
.row-icons { justify-content: flex-end; flex-wrap: nowrap; }
.row-icons .icon-btn { margin: 0; }
.page-head > button { margin: 0; }
@media (max-width: 40rem) {
    .row-icons { justify-content: flex-start; }
}
.row-icons form { margin: 0; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled:hover { color: var(--muted); background: var(--surface); border-color: #cfd6e0; }

/* Videotabelle: Titel in einer Zeile, darunter die Angaben zum Video */
.video-table td.c-main { width: 100%; max-width: 0; }
.v-title {
    display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    font-size: var(--fs-body); font-weight: 650; line-height: 1.35; color: var(--text); text-decoration: none;
}
.v-title:hover { color: var(--accent); text-decoration: underline; }
.v-meta { display: flex; flex-wrap: wrap; gap: .1rem 1rem; margin-top: .2rem; font-size: var(--fs-meta); color: var(--muted); }
.v-meta > span { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.v-meta .icon { width: .95rem; height: .95rem; color: var(--faint); }
@media (max-width: 40rem) {
    .video-table td.c-main { max-width: none; }
    .v-title { white-space: normal; }
}

/* Footer auf allen Seiten: Gegenstück zur Kopfzeile */
.sitefooter { margin-top: auto; background: var(--surface); border-top: 1px solid var(--border); font-size: var(--fs-meta); color: var(--muted); }
.sitefooter-inner {
    max-width: 1180px; margin: 0 auto; padding: 1rem 1.25rem;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1.5rem;
}
.sitefooter nav { display: flex; flex-wrap: wrap; gap: .25rem .6rem; }
.sitefooter a { color: var(--muted); }
.sitefooter a:hover { color: var(--text); }
@media (max-width: 40rem) {
    .sitefooter-inner { padding: .9rem 1rem; }
}


/* ---- Sprachen ---------------------------------------------------------- */
/* Sprachumschalter im Footer der Kundenseiten: aktuelle Sprache hervorgehoben */
.sitefooter nav.langs a[aria-current] { color: var(--text); font-weight: 600; text-decoration: none; }
/* Auswahl der verfügbaren Sprachen in den Einstellungen */
fieldset.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0 1rem; }
fieldset.checks > legend { grid-column: 1 / -1; font-weight: 600; margin-bottom: .2rem; }
fieldset.checks label.check { margin: .25rem 0; }
/* Sprachblöcke im Videoformular */
fieldset.lang-block { border-top: 1px solid var(--border); padding-top: .9rem; margin-top: 1.2rem; }
fieldset.lang-block > legend { font-weight: 600; padding: 0 .4rem 0 0; }
/* Sprachwahl in der Adresstabelle */
select.lang-pick { width: auto; min-width: 0; padding-top: .2rem; padding-bottom: .2rem; font-size: var(--fs-meta); }
/* Adresstabelle: Adresse fett, darunter die Angaben; rechts Sprache und Aktionen */
.addr-table span.v-title:hover { color: var(--text); text-decoration: none; }
.addr-table .v-meta .badge { font-size: var(--fs-meta); padding: .05rem .55rem; }
.addr-table .v-meta .warn { color: var(--error); }
.addr-table td.c-go { vertical-align: middle; }
.row-icons select.lang-pick { height: 2.5rem; margin: 0; padding: 0 1.9rem 0 .7rem; font-size: var(--fs-ui); }
/* Filterleiste der Adressliste: Suche, darunter Sprache, Status, Sortierung */
.list-filter { margin: 0 0 1rem; }
.list-filter .lf-search { display: flex; gap: .5rem; }
.list-filter .lf-search input { flex: 1; min-width: 0; max-width: 32rem; margin: 0; }
.list-filter .lf-search button { margin: 0; }
.list-filter .lf-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1rem; margin-top: .7rem; }
.list-filter .lf-row label { display: flex; flex-direction: column; gap: .25rem; margin: 0; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
main.wide section .list-filter .lf-row select { width: auto; min-width: 9rem; max-width: 17rem; margin: 0; min-height: 2.5rem; padding-top: .35rem; padding-bottom: .35rem; font-size: var(--fs-ui); font-weight: 400; }
.list-filter .lf-reset { font-size: var(--fs-ui); padding-bottom: .55rem; }
