/* POSTARIS – Stil angelehnt an mein-crm.cloud („Obere Navigation“). Kontraste nach WCAG 2.1 AA.
   Inline-Styles sind per CSP verboten; Breiten setzt archive.js über CSSOM bzw. CSS-Variablen. */
:root {
  --ci-bg: #08090B; --ci-surface: #14171B; --ci-surface-2: #1B1F24; --ci-line: #2A2F36;
  --ci-text: #F4F4F5; --ci-text-2: #B4B9C2; --ci-text-3: #8A9099;
  --ci-accent: #FF6600; --ci-ink: #0B0B0C;
  --ci-display: 'Oswald', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --bg: #f4f6f9; --card: #fff; --text: #1d2433; --muted: #667085; --border: #dfe3ea; --hover: #f2f4f8;
  --primary: #c2410c; --primary-hover: #9a3412; --primary-text: #B34700; --primary-soft: #FFF1E6;
  --info: #1f4e8c; --info-bg: #e8f0fb; --danger: #b3261e; --danger-bg: #fdecea; --warn: #8a6d00; --warn-bg: #fff4ce;
  --focus: #FF6600; --radius: 4px; --topbar: 62px;
  /* alte Namen für bestehende Regeln */
  --ma-primary: var(--primary-text); --ma-text: var(--text); --ma-muted: var(--muted); --ma-border: var(--border); --ma-surface: var(--hover);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 14px; }
.skip-link { position: absolute; left: -9999px; top: 0; padding: .5rem 1rem; background: var(--ci-accent); color: var(--ci-ink); z-index: 100; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--primary-text); }
a:hover { color: var(--primary-hover); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-family: var(--ci-display); text-transform: uppercase; letter-spacing: .02em; font-weight: 600; font-size: 26px; margin: .3rem 0 1rem; }
h2 { font-size: 18px; font-weight: 600; margin: 1.2rem 0 .5rem; }
h3 { font-size: 15px; font-weight: 600; }
code { font-size: 12px; word-break: break-all; }

/* ---------- Kopfzeile ---------- */
.ui-topbar { position: sticky; top: 0; z-index: 50; height: var(--topbar); display: flex; align-items: center; gap: 24px;
  padding: 0 24px; background: var(--ci-bg); color: var(--ci-text); }
.ui-brand { display: flex; align-items: center; gap: 12px; color: var(--ci-text); text-decoration: none; flex: none; }
.ui-brand:hover { color: var(--ci-text); }
.ui-brand-mark { font-family: var(--ci-display); font-size: 20px; font-weight: 600; padding-right: 12px; border-right: 3px solid var(--ci-accent); line-height: 1.1; }
.ui-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.ui-brand-title { font-family: var(--ci-display); text-transform: uppercase; letter-spacing: .08em; font-size: 14px; }
.ui-brand-name { font-size: 12px; color: var(--ci-text-3); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-areas { display: flex; align-items: stretch; gap: 4px; height: 100%; flex: 1; min-width: 0; }
.ui-area { display: flex; align-items: center; gap: 4px; height: 100%; padding: 0 12px; font-family: var(--ci-display); text-transform: uppercase;
  letter-spacing: .08em; font-size: 14px; color: var(--ci-text-2); text-decoration: none; border-bottom: 3px solid transparent; cursor: pointer;
  list-style: none; white-space: nowrap; }
.ui-area::-webkit-details-marker { display: none; }
.ui-area:hover, .ui-menu[open] > .ui-area { color: var(--ci-text); }
.ui-area.active { color: var(--ci-text); border-bottom-color: var(--ci-accent); }
.ui-caret { font-size: 10px; color: var(--ci-text-3); }
.ui-menu { position: relative; display: flex; height: 100%; }
.ui-menu > summary { list-style: none; }
.ui-menu > summary::-webkit-details-marker { display: none; }
.ui-mega { position: absolute; top: 100%; left: 0; min-width: 220px; background: #fff; color: var(--text); border-top: 3px solid var(--ci-accent);
  box-shadow: 0 12px 32px rgba(8, 9, 11, .18); border-radius: 0 0 6px 6px; padding: 8px 0; display: flex; flex-direction: column; z-index: 60; }
.ui-mega a, .ui-mega button.link { display: block; padding: 8px 16px; color: var(--text); text-decoration: none; text-align: left; width: 100%; font-size: 14px; }
.ui-mega a:hover, .ui-mega button.link:hover { background: var(--hover); color: var(--primary-text); }
.ui-mega a.active { color: var(--primary-text); font-weight: 600; background: var(--primary-soft); }
.ui-mega-right { left: auto; right: 0; }
.ui-mega-head { padding: 6px 16px 8px; font-weight: 600; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ui-account { margin-left: auto; align-items: center; }
.ui-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ci-surface-2); color: var(--ci-text); display: flex; align-items: center;
  justify-content: center; font-weight: 600; font-size: 13px; cursor: pointer; border: 1px solid var(--ci-line); list-style: none; }
.ui-avatar:hover, .ui-account[open] .ui-avatar { border-color: var(--ci-accent); }
.ui-account .ui-mega { top: calc(100% + 13px); }
.logout { margin: 0; }
.ui-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.ui-eyebrow::before { content: ''; width: 18px; height: 2px; background: var(--ci-accent); }

main { max-width: 76rem; margin: 0 auto; padding: 20px 24px; }
main:has(.ma-archive) { max-width: none; padding: 12px 16px 0; }

/* ---------- Bausteine ---------- */
button, .button, .btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; padding: 7px 14px; border: 1px solid var(--primary);
  border-radius: var(--radius); background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.3; }
button:hover, .button:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn { background: #fff; color: var(--text); border-color: var(--border); }
.btn:hover { background: var(--hover); color: var(--text); border-color: #c9ced8; }
.btn.primary { background: var(--ci-accent); border-color: var(--ci-accent); color: var(--ci-ink); font-weight: 600; }
.btn.primary:hover { background: #e65c00; border-color: #e65c00; color: var(--ci-ink); }
.btn.small, button.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; }
button.secondary, .button.secondary { background: #fff; color: var(--text); border: 1px solid #8a8f96; }
button.secondary:hover, .button.secondary:hover { background: var(--hover); color: var(--text); }
button.link, button.linkish, .linkish { background: none; border: 0; color: var(--primary-text); text-decoration: underline; padding: 0; cursor: pointer; font: inherit; }
button.linkish:hover { background: none; color: var(--primary-hover); }
.ui-mega button.link { text-decoration: none; color: var(--text); border-radius: 0; }
button:disabled { opacity: .6; cursor: progress; }
.form { display: grid; gap: .4rem; max-width: 28rem; margin: .5rem 0 1.25rem; }
.form button { justify-self: start; margin-top: .4rem; }
.form-inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
input, select, textarea { font: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid #b8bec9; border-radius: var(--radius); background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--ci-accent); outline: 2px solid rgba(255, 102, 0, .25); outline-offset: 0; }
input.narrow { width: 6rem; }
label { font-weight: 600; }
label.check { font-weight: 400; display: block; }
.alert { background: var(--danger-bg); border-left: 4px solid var(--danger); padding: .6rem .8rem; border-radius: var(--radius); }
.info { background: var(--info-bg); border-left: 4px solid var(--info); padding: .6rem .8rem; border-radius: var(--radius); }
.support-banner { background: var(--warn-bg); border-bottom: 2px solid var(--warn); margin: 0; padding: .5rem 24px; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 14px 18px; margin: 12px 0; }
.tenant-list, .methods { list-style: none; padding: 0; }
.methods li { margin: .4rem 0; }
.qr svg { width: 200px; height: 200px; background: #fff; }
.secret { font-size: 1.1rem; letter-spacing: .05em; }
table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--card); }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; min-width: 0; }
.search-main { display: flex; gap: .5rem; max-width: 40rem; }
.search-main input { flex: 1; }
.search-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .5rem 1rem; margin: .5rem 0; }
.search-filters label { display: grid; gap: .2rem; font-weight: 600; font-size: 13px; }
.search-filters label.check { display: flex; align-items: center; gap: 6px; align-self: end; }
.pager { display: flex; gap: 1rem; margin: 10px 0; align-items: center; }
.mailframe { width: 100%; min-height: 30rem; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; display: block; }
.mailtext { white-space: pre-wrap; word-break: break-word; background: var(--hover); padding: .8rem; border-radius: var(--radius); font-family: inherit; margin: 0; }
.status-error, .status-auth_failed { color: var(--danger); font-weight: 600; }
.status-warning { color: var(--warn); }
details > summary { cursor: pointer; }

/* ---------- Archiv: drei Bereiche ---------- */
.ma-archive { --ma-tree-w: 260px; --ma-list-w: 760px; display: grid; grid-template-columns: var(--ma-tree-w) 6px var(--ma-list-w) 6px minmax(320px, 1fr);
  height: calc(100vh - var(--topbar) - 12px); background: var(--card); border: 1px solid var(--border); border-bottom: 0; border-radius: 6px 6px 0 0; overflow: hidden; }
.ma-archive.resizing { user-select: none; cursor: col-resize; }
.ma-pane { min-width: 0; min-height: 0; overflow: auto; }
.ma-splitter { background: var(--border); cursor: col-resize; position: relative; }
.ma-splitter:hover, .ma-splitter:focus-visible, .resizing .ma-splitter:active { background: var(--ci-accent); outline: none; }
.ma-pane-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 6px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.ma-tree-tools { display: flex; gap: 8px; }
.ma-tree-tools .linkish { text-decoration: none; color: var(--muted); font-size: 15px; }
.ma-tree-tools .linkish:hover { color: var(--primary-text); }

/* Ordnerbaum wie im DMS von mein-crm */
.dm-tree-list { padding: 0 8px 12px; }
.dm-tree-row { display: flex; align-items: center; }
.dm-tree-row[hidden] { display: none; }
.dm-tree-row[data-depth="1"] { margin-left: 14px; } .dm-tree-row[data-depth="2"] { margin-left: 28px; }
.dm-tree-row[data-depth="3"] { margin-left: 42px; } .dm-tree-row[data-depth="4"] { margin-left: 56px; }
.dm-tree-row[data-depth="5"] { margin-left: 70px; } .dm-tree-row[data-depth="6"] { margin-left: 84px; }
.dm-tree-row[data-depth="7"] { margin-left: 98px; } .dm-tree-row[data-depth="8"] { margin-left: 112px; }
.dm-twisty, .dm-twisty-space { flex: none; width: 18px; height: 22px; }
.dm-twisty { padding: 0; background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; justify-content: center; line-height: 1; }
.dm-twisty:hover { background: none; color: var(--primary-text); }
.dm-node { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 6px;
  color: var(--text); text-decoration: none; }
.dm-node:hover { background: var(--hover); color: var(--text); }
.dm-node.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.dm-node-box { font-weight: 600; }
.dm-node-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-count { flex: none; font-size: 11px; color: var(--muted); font-weight: 400; }
.dm-tree-list > .dm-node { margin-bottom: 4px; }

/* Liste */
.ma-list { display: flex; flex-direction: column; overflow: hidden; }
.ma-search { padding: 10px 12px 6px; border-bottom: 1px solid var(--border); }
.ma-search-main { display: flex; gap: 6px; }
.ma-search-main input { flex: 1; min-width: 0; }
.ma-filters { margin-top: 6px; font-size: 13px; }
.ma-filters > summary { color: var(--muted); }
.ma-list-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; flex-wrap: wrap; }
.ma-list-tools { display: flex; gap: 6px; align-items: center; }
.dm-colmenu { position: relative; }
.dm-colmenu > summary { list-style: none; }
.dm-colmenu > summary::-webkit-details-marker { display: none; }
.dm-colmenu-box { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--border); border-top: 3px solid var(--ci-accent);
  border-radius: 0 0 6px 6px; box-shadow: 0 10px 24px rgba(8, 9, 11, .14); padding: 10px 12px; width: 240px; display: grid; gap: 6px; }
.ma-table-wrap { flex: 1; overflow: auto; min-height: 0; border-top: 1px solid var(--border); }
.dm-table.dm-fixed { table-layout: fixed; }
.ma-mails col[hidden] { display: none; }
.ma-mails thead th { position: sticky; top: 0; z-index: 2; user-select: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ma-mails thead th a { color: var(--muted); text-decoration: none; }
.ma-mails thead th a:hover { color: var(--primary-text); }
.ma-mails thead th[aria-sort] a { color: var(--primary-text); }
.ma-mails th[draggable="true"] { cursor: grab; }
.ma-mails th.dragging { opacity: .5; }
.ma-mails th.drop-target { box-shadow: inset 3px 0 0 var(--ci-accent); }
.dm-col-resize { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; }
.dm-col-resize:hover { background: rgba(255, 102, 0, .35); }
.ma-mails thead th { position: sticky; }
.ma-mails td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 10px; }
.ma-mails td[data-col="att"], .ma-mails th[data-col="att"] { text-align: center; padding-left: 4px; padding-right: 4px; }
.ma-mails td[data-col="size"], .ma-mails td[data-col="date"] { color: var(--muted); font-variant-numeric: tabular-nums; }
.ma-mails td[data-col="size"] { text-align: right; }
.ma-mails tbody tr { cursor: pointer; }
.ma-mails tbody tr:hover { background: var(--hover); }
.ma-mails tbody tr.selected { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--ci-accent); }
.ma-mails td[data-col="subject"] a { color: var(--text); text-decoration: none; }
.ma-mails tr.selected td[data-col="subject"] a { color: var(--primary-text); font-weight: 600; }
.ma-list .pager { padding: 6px 12px; margin: 0; border-top: 1px solid var(--border); }

/* Lesebereich */
.ma-read { padding: 14px 18px; }
.ma-read[aria-busy="true"], [data-read-body][aria-busy="true"] { opacity: .55; }
.ma-back { display: none; margin-bottom: 8px; }
.ma-empty { margin-top: 30vh; text-align: center; }
.ma-mail-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ma-mail-subject { font-size: 19px; margin: 0 0 8px; word-break: break-word; }
.ma-mail-head { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 10px; font-size: 13px; }
.ma-mail-head dt { color: var(--muted); font-weight: 600; }
.ma-mail-head dd { margin: 0; word-break: break-word; }
.ma-attachments { list-style: none; padding: 8px 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.ma-attachments li { background: var(--hover); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px 8px; font-size: 13px; }
.ma-attachments a { text-decoration: none; }
.ma-mail-body .mailframe { min-height: 55vh; }
.ma-mail-info { margin-top: 12px; font-size: 13px; }
.ma-single { max-width: 60rem; }

/* Fenster „E-Mail-Header“ */
.ma-dialog { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 0; border-top: 3px solid var(--ci-accent);
  border-radius: 6px; box-shadow: 0 24px 60px rgba(8, 9, 11, .35); color: var(--text); }
.ma-dialog[open] { display: flex; flex-direction: column; }
.ma-dialog::backdrop { background: rgba(8, 9, 11, .55); }
.ma-dialog-head, .ma-dialog-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.ma-dialog-head { justify-content: space-between; border-bottom: 1px solid var(--border); }
.ma-dialog-head h2 { margin: 0; font-size: 16px; }
.ma-dialog-foot { justify-content: flex-end; border-top: 1px solid var(--border); }
.ma-dialog-foot [data-copy-state] { margin-right: auto; }
.ma-header-text { flex: 1; overflow: auto; margin: 0; padding: 12px 16px; background: #fafbfc; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre; tab-size: 4; }

/* ---------- Mobiles Seitenmenü (nur ≤ 820 px) ---------- */
.ui-burger, .ui-drawer-wrap, .ma-folders-btn, .ma-folders-close { display: none; }
.ui-burger { width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 6px; color: var(--ci-text); text-decoration: none;
  font-size: 24px; flex: none; margin-left: -6px; }
.ui-burger:hover { background: var(--ci-surface-2); color: var(--ci-text); }

/* ---------- Breiten: Desktop = Dreiteilung; Tablet = Ordner + Liste/Lesebereich; Mobil = eine Spalte ---------- */
.ma-archive { grid-template-columns: var(--ma-tree-w) 6px minmax(280px, var(--ma-list-w)) 6px minmax(320px, 1fr); }
@media (max-width: 1100px) {
  .ma-archive, .ma-archive.has-mail { grid-template-columns: var(--ma-tree-w) 6px minmax(0, 1fr); }
  .ma-archive > .ma-splitter[data-split="list"] { display: none; }
  .ma-read { display: none; }
  .ma-archive.has-mail .ma-list, .ma-archive.has-mail > .ma-splitter[data-split="list"] { display: none; }
  .ma-archive.has-mail .ma-read { display: block; grid-column: 3; }
  .ma-back { display: inline-flex; }
}
@media (max-width: 820px) {
  :root { --topbar: 56px; }
  body { font-size: 15px; }
  body:has(.ui-drawer:target), body.ma-sheet-open { overflow: hidden; }
  .ui-topbar { gap: 8px; padding: 0 12px; height: var(--topbar); flex-wrap: nowrap; }
  .ui-burger { display: flex; }
  .ui-areas { display: none; }
  .ui-brand { min-width: 0; }
  .ui-brand-name { display: none; }
  .ui-brand-mark { font-size: 18px; padding-right: 10px; }
  .ui-account { margin-left: auto; }
  .ui-avatar { width: 40px; height: 40px; }
  main { padding: 14px 12px; }
  .support-banner { padding: .5rem 12px; }

  /* Seitenmenü über die volle Bildschirmhöhe; Untermenüs als neue Ebene mit Zurück-Pfeil (ohne eigene Scrollleiste) */
  .ui-drawer-wrap { display: block; }
  .ui-drawer-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(8, 9, 11, .55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .ui-drawer-wrap:has(.ui-drawer:target) .ui-drawer-backdrop { opacity: 1; pointer-events: auto; }
  .ui-drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(88vw, 360px); height: 100vh; height: 100dvh; z-index: 90; display: flex; flex-direction: column;
    background: var(--ci-bg); color: var(--ci-text); transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s;
    box-shadow: 8px 0 32px rgba(8, 9, 11, .35); overflow: hidden; }
  .ui-subdrawer { z-index: 91; }
  .ui-drawer:target { transform: none; visibility: visible; transition: transform .2s ease; }
  .ui-drawer-head { display: flex; align-items: center; gap: 8px; height: var(--topbar); padding: 0 8px 0 16px; border-bottom: 1px solid var(--ci-line); flex: none; }
  .ui-drawer-title { flex: 1; font-family: var(--ci-display); text-transform: uppercase; letter-spacing: .08em; font-size: 15px; }
  .ui-drawer-back, .ui-drawer-close { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--ci-text); text-decoration: none;
    font-size: 22px; border-radius: 6px; margin-left: -8px; flex: none; }
  .ui-drawer-close { margin-left: 0; font-size: 18px; }
  .ui-drawer-back:hover, .ui-drawer-close:hover { background: var(--ci-surface-2); color: var(--ci-text); }
  .ui-drawer-list { list-style: none; margin: 0; padding: 8px 0; }
  .ui-drawer > .ui-drawer-list:first-of-type { flex: 1; min-height: 0; overflow-y: auto; }
  .ui-subdrawer .ui-drawer-list { overflow: hidden; }
  .ui-drawer-foot { flex: none; border-top: 1px solid var(--ci-line); }
  .ui-drawer-user { padding: 8px 20px 4px; font-size: 12px; color: var(--ci-text-3); }
  .ui-drawer-item { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; padding: 0 20px; color: var(--ci-text-2);
    text-decoration: none; font-family: var(--ci-display); text-transform: uppercase; letter-spacing: .08em; font-size: 15px; border-left: 3px solid transparent;
    background: none; border-top: 0; border-right: 0; border-bottom: 0; border-radius: 0; text-align: left; cursor: pointer; }
  .ui-drawer-item:hover, .ui-drawer-item:focus-visible { background: var(--ci-surface-2); color: var(--ci-text); }
  .ui-drawer-item.active { color: var(--ci-text); border-left-color: var(--ci-accent); }
  .ui-drawer-next span { color: var(--ci-text-3); font-size: 22px; }
  .ui-drawer-logout { font-weight: 400; }
  .logout { margin: 0; }

  /* Formulare und Tabellen auf dem Telefon */
  input, select, textarea, button, .btn, .button { font-size: 16px; min-height: 40px; }
  .form { max-width: 100%; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: .4rem; }
  main table:not(.ma-mails) { display: block; overflow-x: auto; }
  h1 { font-size: 22px; }

  /* Archiv: nur die Mail-Liste; Antippen öffnet die Mail in voller Breite (Zurück-Knopf), Ordner als Blatt, Suche oben angeheftet */
  main:has(.ma-archive) { padding: 0; }
  .ma-archive, .ma-archive.has-mail { display: block; height: auto; min-height: calc(100vh - var(--topbar)); border: 0; border-radius: 0; overflow: visible; }
  .ma-archive > .ma-splitter { display: none !important; }
  .ma-pane { overflow: visible; }
  .ma-tree { display: none; }
  .ma-tree:target, .ma-archive.show-tree .ma-tree { display: block; position: fixed; inset: 0; z-index: 95; background: var(--card); overflow-y: auto; padding-bottom: 24px; }
  .ma-tree .ma-pane-head { padding: 12px 16px; }
  .ma-folders-btn { display: inline-flex; min-width: 44px; justify-content: center; }
  .ma-folders-close { display: inline-flex; margin-left: auto; margin-right: 12px; }
  .dm-node { min-height: 40px; }
  .ma-list { display: block; }
  .ma-archive.has-mail .ma-list { display: none; }
  .ma-search { position: sticky; top: var(--topbar); z-index: 20; background: var(--card); padding: 8px 12px; box-shadow: 0 1px 0 var(--border); }
  .ma-search-main input { min-height: 44px; }
  .ma-search-main .btn.primary { padding: 0 14px; }
  .ma-filters { margin-top: 4px; }
  .search-filters { grid-template-columns: 1fr 1fr; }
  .ma-list-bar { padding: 6px 12px; }
  .ma-list-tools .dm-colmenu, .ma-list-tools form { display: none; } /* Spalten/Export gibt es nur in der breiten Ansicht */
  .ma-table-wrap { overflow: visible; border-top: 0; }

  /* Liste als Karten: Absender + Datum, Betreff, Treffer */
  .ma-mails, .ma-mails tbody { display: block; width: 100% !important; min-width: 0 !important; } /* JS setzt Spaltenbreiten inline (Desktop) */
  .ma-mails colgroup, .ma-mails thead { display: none; }
  .ma-mails tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .ma-mails td { display: block; padding: 0; border: 0; min-width: 0; }
  .ma-mails td[hidden] { display: none; }
  .ma-mails td[data-col="from"], .ma-mails td[data-col="date"], .ma-mails td[data-col="subject"] { display: block; }
  .ma-mails td[data-col="from"] { grid-column: 1; grid-row: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ma-mails td[data-col="date"] { grid-column: 2; grid-row: 1; font-size: 12px; }
  .ma-mails td[data-col="subject"] { grid-column: 1 / -1; grid-row: 2; }
  .ma-mails td[data-col="att"] { grid-column: 2; grid-row: 2; text-align: right; }
  .ma-mails td[data-col="att"]:empty { display: none; }
  .ma-mails td[data-col="size"] { display: none; }
  .ma-mails tbody tr.selected { box-shadow: inset 3px 0 0 var(--ci-accent); }
  .ma-mails td[data-col="subject"] > a { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ma-mails tbody tr:has(td[colspan]) { display: block; }
  .ma-mails td[colspan] { padding: 14px; }
  .ma-list .pager { padding: 12px; justify-content: space-between; }

  /* Lesebereich in voller Breite */
  .ma-read { display: none; padding: 0 14px 20px; }
  .ma-archive.has-mail .ma-read { display: block; }
  .ma-back { display: flex; position: sticky; top: var(--topbar); z-index: 20; width: calc(100% + 28px); min-height: 48px; margin: 0 -14px 10px; padding: 0 14px; border-radius: 0;
    background: var(--card); border: 0; border-bottom: 1px solid var(--border); color: var(--primary-text); justify-content: flex-start; font-weight: 600; }
  .ma-back:hover { background: var(--hover); color: var(--primary-text); }
  .ma-mail-head { grid-template-columns: 1fr; gap: 0; }
  .ma-mail-head dt { margin-top: 6px; }
  .ma-mail-body .mailframe { min-height: 60vh; }
  .ma-only-wide { display: none; }
  .ma-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  table { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
fieldset.checklist { border: 0; padding: 0; margin: 0 0 .4rem; display: grid; gap: 6px; }
fieldset.checklist label.check { display: flex; align-items: center; gap: 8px; }
h2[id] { scroll-margin-top: calc(var(--topbar) + 12px); }
/* Suchtreffer */
mark { background: #ffe08a; color: inherit; padding: 0 1px; border-radius: 2px; }
.ma-mails td[data-col="subject"] { white-space: normal; }
.ma-mails td[data-col="subject"] > a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ma-hit { font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.ma-hit-where { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--primary-text); }
.ma-hit-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ma-index-note { margin: 6px 12px 0; }
.ma-att-hit { border-color: var(--ci-accent) !important; background: var(--primary-soft) !important; }
.ma-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--hover); color: var(--text); }
.ma-badge-hit { background: var(--ci-accent); color: var(--ci-ink); }
.ma-badge-needs_ocr, .ma-badge-empty { background: var(--info-bg); color: var(--info); }
.ma-badge-encrypted, .ma-badge-unsupported { background: var(--warn-bg); color: var(--warn); }
.ma-badge-error { background: var(--danger-bg); color: var(--danger); }
.ma-index-card progress { width: 100%; height: 10px; accent-color: var(--ci-accent); margin: 8px 0 10px; }
.ma-index-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ma-card-title { margin-top: 0; font-size: 16px; }
/* Fortschritt (Import) */
.ma-progress { display: grid; gap: 4px; margin: 10px 0 14px; max-width: 34rem; }
.ma-progress progress { width: 100%; height: 10px; accent-color: var(--ci-accent); }
td .ma-progress { margin: 0; min-width: 12rem; }
/* Ordner verschieben */
.dm-tree-row.picked > .dm-node { background: var(--primary-soft); outline: 1px dashed var(--ci-accent); }
.dm-tree-row.dragging { opacity: .5; }
.dm-tree-row.drop-target > .dm-node { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--ci-accent); }
.dm-tree-row[draggable="true"] > .dm-node { cursor: grab; }
.dm-moved { color: var(--muted); font-size: 11px; }
.ma-tree-hint { cursor: help; }
.ma-arrange-reset { padding: 8px 12px 14px; border-top: 1px solid var(--border); }
.ma-arrange-reset form { display: inline-block; margin: 4px 4px 0 0; }
.ma-move-body { padding: 12px 16px; overflow: auto; }
.ma-move-actions { margin: 0 0 10px; padding-left: 18px; }
.ma-move-actions li { margin: 3px 0; }
.ma-move-merge { color: var(--primary-text); }

/* ---------- E-Rechnung (docs/19) ---------- */
.ma-einv { margin-left: 4px; white-space: nowrap; }
.ma-einv-ok { background: #e3f4e8; color: #17653a; }
.ma-einv-warn { background: var(--warn-bg); color: var(--warn); }
.ma-einv-bad { background: var(--danger-bg); color: var(--danger); }
.ma-einv-new { background: var(--info-bg); color: var(--info); }
.ma-einvoice-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: var(--radius); background: var(--info-bg); }
.ma-einv-box-valid { border-left-color: #17653a; background: #f0faf3; }
.ma-einv-box-warnings { border-left-color: var(--warn); background: var(--warn-bg); }
.ma-einv-box-invalid, .ma-einv-box-error { border-left-color: var(--danger); background: var(--danger-bg); }
.ma-ei-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border: 1px solid var(--border); border-left: 6px solid var(--info);
  border-radius: var(--radius); background: var(--info-bg); margin: 0 0 12px; }
.ma-ei-badge { font-size: 14px; padding: 3px 12px; }
.ma-ei-messages ul { margin: 0; padding-left: 18px; }
.ma-ei-msg { margin: 6px 0; }
.ma-ei-msg-error strong { color: var(--danger); }
.ma-ei-msg-warning strong { color: var(--warn); }
.ma-ei-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 0 16px; }
.ma-ei-table { overflow-x: auto; }
.ma-ei-table td, .ma-ei-table th, .ma-ei-grid th, .ma-ei-grid td { vertical-align: top; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ma-ei-total th, .ma-ei-total td { font-weight: 700; border-top: 2px solid var(--border); }
.ma-ei-sum th { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); background: none; font-weight: 400; }
.ma-ei-pdf { min-height: 75vh; }
.ma-ei-status.ma-einv-box-valid { border-left-color: #17653a; background: #f0faf3; }
.ma-ei-status.ma-einv-box-warnings { border-left-color: var(--warn); background: var(--warn-bg); }
.ma-ei-status.ma-einv-box-invalid, .ma-ei-status.ma-einv-box-error { border-left-color: var(--danger); background: var(--danger-bg); }

/* ---------- Speicherplatz (Systemverwaltung, docs/20) ---------- */
.ma-vol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: 0 16px; }
.ma-vol { border-left: 6px solid #17653a; }
.ma-vol-warning { border-left-color: var(--warn); }
.ma-vol-critical { border-left-color: var(--danger); }
.ma-vol-pct { font-size: 24px; font-weight: 700; margin: 4px 0; }
.ma-vol progress { width: 100%; height: 12px; accent-color: #17653a; margin-bottom: 8px; }
.ma-vol-warning progress { accent-color: #b8860b; }
.ma-vol-critical progress { accent-color: var(--danger); }
.ma-vol-badge-normal { background: #e3f4e8; color: #17653a; }
.ma-vol-badge-warning { background: var(--warn-bg); color: var(--warn); }
.ma-vol-badge-critical { background: var(--danger-bg); color: var(--danger); }
.ma-spark { width: 100%; height: 60px; margin-top: 8px; background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius); }
.ma-spark-line { stroke: var(--primary-text); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.ma-spark-warn { stroke: #b8860b; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.ma-spark-crit { stroke: var(--danger); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }

/* Versionsanzeige (Fußzeile und Benutzermenü) */
.site-footer { max-width: 76rem; margin: 0 auto; padding: 8px 24px 20px; font-size: 12px; color: var(--muted); }
body:has(.ma-archive) .site-footer { display: none; } /* im Archiv füllt die Dreiteilung die Seite; die Version steht im Benutzermenü */
.ui-mega-foot { display: block; padding: 6px 16px 2px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
@media (max-width: 820px) { .site-footer { padding: 8px 12px 20px; } }
