/* ==========================================================================
   EPC QR-Code Generator — Professional Design System (Full Edition)
   Marke: BTV (Blau #0A3F87 / Grün #00A850). Klassen-/ID-/Variablennamen sind
   bewusst stabil (app_full.js nutzt sie als Vertrag: display/classList/Variablen).
   ========================================================================== */

/* ---------------------------------------------------------------- Tokens -- */
:root {
    /* Marke — BTV (Namen stabil; vom JS/Inline referenziert) */
    --btv-blue: #0A3F87;
    --btv-green: #00A850;
    --primary-color: #0A3F87;   /* BTV-Blau */
    --primary-600: #0d4a99;
    --primary-700: #082f63;
    --primary-100: #d4e2f4;
    --primary-050: #eaf1fb;
    --secondary-color: #0e6fb0;

    /* Statusfarben (AA-tauglich auf Weiß / mit weißem Text) */
    --success-color: #047857;   --success-700: #036b4e;  --success-050: #ecfdf5;
    --danger-color:  #dc2626;   --danger-700:  #b91c1c;  --danger-050:  #fef2f2;
    --warning-color: #b45309;   --warning-700: #92400e;  --warning-050: #fffbeb;
    --info-color:    #1d4ed8;   --info-050:    #eff6ff;
    --accent:        #4f46e5;   --accent-050:  #eef2ff;   /* KI-Akzent */

    /* Oberflächen & Text (Slate) */
    --bg-app: #eef2f7;
    --bg-light: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;       /* AA: ~4.6:1 auf Weiß */
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Verläufe */
    --grad-brand: linear-gradient(135deg, #0d4a99 0%, #0A3F87 100%);
    --grad-logo: linear-gradient(135deg, #0d4a99 0%, #0A3F87 55%, #00A850 165%);
    --grad-app: radial-gradient(900px 480px at 100% -14%, rgba(13,74,153,.07), transparent 62%),
                linear-gradient(180deg, #f5f8fc 0%, var(--bg-app) 60%);

    /* Spacing-Skala */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 40px;

    /* Type-Skala */
    --text-xs: .75rem; --text-sm: .8125rem; --text-base: .9375rem;
    --text-md: 1rem; --text-lg: 1.125rem; --text-xl: 1.375rem; --text-2xl: 1.625rem;

    /* Radius & Schatten (präzise, nicht „soft template") */
    --radius-sm: 7px; --radius: 9px; --radius-lg: 12px; --radius-xl: 18px;
    --shadow-xs: 0 1px 1px rgba(15,23,42,.05);
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
    --shadow-md: 0 1px 2px rgba(15,23,42,.06), 0 4px 10px rgba(15,23,42,.06);
    --shadow-lg: 0 6px 18px rgba(15,23,42,.09), 0 2px 6px rgba(15,23,42,.05);
    --shadow-xl: 0 18px 44px rgba(15,23,42,.18), 0 6px 14px rgba(15,23,42,.08);
    --ring: 0 0 0 3px rgba(10,63,135,.22);

    --ease: cubic-bezier(.4, 0, .2, 1);
    /* Distinktive, selbst-gehostete Typografie (kein externer Runtime-Abruf) */
    --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Sora", "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    /* App-Shell-Maße (fixe Leisten oben/unten) */
    --topbar-h: 60px;
    --bottomnav-h: 66px;
}

/* ------------------------------------------------------- Self-hosted Fonts */
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/manrope-400.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/manrope-500.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/manrope-600.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 700; font-display: swap; src: url("/static/fonts/manrope-700.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/sora-600.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-style: normal; font-weight: 700; font-display: swap; src: url("/static/fonts/sora-700.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-style: normal; font-weight: 800; font-display: swap; src: url("/static/fonts/sora-800.woff2") format("woff2"); }

/* ------------------------------------------------------------------ Base -- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--grad-app);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 700; color: var(--text-primary); line-height: 1.22; }

a { color: var(--primary-600); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
::selection { background: rgba(10,63,135,.16); }

/* Icons (SVG-Sprite) */
.icon {
    width: 18px; height: 18px; flex: none;
    stroke: currentColor; stroke-width: 1.9;
    stroke-linecap: round; stroke-linejoin: round;
    fill: none; vertical-align: -.18em;
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }

/* --------------------------------------------------------------- Layout --- */
/* Inhalt zwischen den fixen Leisten (App-Shell) */
.container {
    max-width: 1200px; margin: 0 auto;
    padding: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--space-6)) var(--space-6)
             calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--space-6));
}

/* Fixe Top-Bar (App-Shell) — Höhe inkl. Safe-Area (Notch) */
.app-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background: rgba(255,255,255,.9);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border-color);
}
.app-bar-inner {
    max-width: 1200px; margin: 0 auto; height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--space-4);
    padding: 0 max(var(--space-6), env(safe-area-inset-right)) 0 max(var(--space-6), env(safe-area-inset-left));
}
.app-brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; margin-right: auto; }
.app-logo {
    flex: none; width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--grad-logo);
    color: #fff;
    box-shadow: 0 6px 16px rgba(10,63,135,.32);
}
.app-logo .icon { width: 23px; height: 23px; }
.app-brand-text { min-width: 0; }
header h1 { font-size: var(--text-lg); }
.wordmark { font-weight: 800; }
.wm-a { color: var(--btv-blue); }
.wm-b { color: var(--success-color); }   /* AA-taugliches Grün statt #00A850 */
.subtitle {
    margin: 1px 0 0; font-size: var(--text-sm); color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.version {
    flex: none; align-self: center;
    padding: 4px 11px; font-size: var(--text-xs); font-weight: 600;
    color: var(--primary-700); background: var(--primary-050);
    border: 1px solid var(--primary-100); border-radius: 999px;
    white-space: nowrap;
}

.main-content { animation: fadeUp .4s var(--ease) both; }

footer {
    margin-top: var(--space-8); padding-top: var(--space-6);
    border-top: 1px solid var(--border-color);
    text-align: center; color: var(--text-muted); font-size: var(--text-sm);
}
footer p { margin: var(--space-1) 0; }

/* ---------------------------------------------------------- User-Menü ----- */
.user-menu { position: relative; flex: none; margin-left: var(--space-3); }
.user-menu-toggle {
    display: flex; align-items: center; gap: var(--space-2);
    padding: 6px 12px 6px 7px;
    background: #fff; border: 1px solid var(--border-color); border-radius: 999px;
    font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
    cursor: pointer;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.user-menu-toggle:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.user-menu-avatar {
    width: 28px; height: 28px; flex: none;
    display: grid; place-items: center; border-radius: 50%;
    background: var(--grad-brand); color: #fff;
}
.user-menu-avatar .icon { width: 15px; height: 15px; }
.user-menu-caret { color: var(--text-muted); display: inline-flex; }
.user-menu-caret .icon { width: 14px; height: 14px; }
.user-menu-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 252px; max-width: calc(100vw - var(--space-4));
    background: #fff; border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: var(--space-2); z-index: 60;
    animation: popIn .14s var(--ease) both;
}
.user-menu-info {
    padding: 10px 12px 12px; margin-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-color);
    font-size: var(--text-sm); color: var(--text-muted); line-height: 1.5; word-break: break-all;
}
.user-menu-info strong { color: var(--text-primary); font-weight: 600; }
.user-menu-role {
    display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 999px;
    font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--primary-700); background: var(--primary-050);
}
.user-menu-item {
    display: flex; align-items: center; gap: var(--space-2); width: 100%;
    padding: 10px 12px; background: none; border: none; border-radius: var(--radius-sm);
    font: inherit; font-size: var(--text-base); font-weight: 500; color: var(--text-secondary);
    text-align: left; cursor: pointer;
    transition: background .12s var(--ease), color .12s var(--ease);
}
.user-menu-item .icon { color: var(--text-muted); }
.user-menu-item:hover { background: var(--bg-subtle); color: var(--text-primary); }
.user-menu-item:hover .icon { color: var(--primary-600); }
.user-menu-logout { color: var(--danger-color); }
.user-menu-logout .icon { color: var(--danger-color); }
.user-menu-logout:hover { background: var(--danger-050); color: var(--danger-700); }

/* ----------------------------------------------- Fixe Bottom-Navigation -- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    display: flex; justify-content: center; gap: var(--space-1);
    padding: 6px max(12px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgba(255,255,255,.92);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -6px 22px rgba(15,23,42,.07);
}
.bottom-nav .tab-button {
    position: relative;
    flex: 1 1 0; max-width: 170px; min-height: 44px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 6px 8px; background: none; border: none; border-radius: var(--radius);
    font: inherit; font-family: var(--font-display); font-size: var(--text-xs); font-weight: 600;
    color: var(--text-muted); cursor: pointer;
    transition: color .15s var(--ease), background .15s var(--ease);
}
.bottom-nav .tab-button .tab-icon { width: 23px; height: 23px; color: currentColor; }
.bottom-nav .tab-button:hover { color: var(--text-secondary); background: var(--bg-subtle); }
.bottom-nav .tab-button.active { color: var(--primary-color); }
.bottom-nav .tab-button.active::before {
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 30px; height: 3px; border-radius: 0 0 3px 3px; background: var(--grad-brand);
}
.nav-label { line-height: 1; }
.tab-icon { line-height: 0; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp .32s var(--ease) both; }
.tab-content:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 4px; border-radius: var(--radius-sm); }
.tab-content > h2 { font-size: var(--text-2xl); margin-bottom: var(--space-5); }

/* ----------------------------------------------------------------- Cards -- */
.card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-6);
}

/* Erfassen: kompakte, zentrierte Einspalter-Maske (max-width hält die Maske
   auch auf großen Screens fokussiert statt sie in die Breite zu ziehen). */
.capture { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.capture-head h2 { font-size: var(--text-xl); }
.capture-sub { color: var(--text-muted); font-size: var(--text-sm); margin-top: 4px; }
.capture-tools { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.capture-tools .btn { flex: 1 1 auto; }
/* Touch-Targets: die schlanken Toolbar-/URL-Buttons trotzdem auf 44px halten. */
.capture-tools .btn-small, .url-row .btn-small { min-height: 44px; }
.url-row { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.url-row[hidden] { display: none; }
.url-row input { flex: 1; min-width: 0; }
.url-row .btn { flex: none; }

/* Formular-Raster: kurze Felder (BIC/Betrag) teilen sich eine Zeile. */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-grid .form-group { margin-bottom: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }

.settings-section h3 {
    font-size: var(--text-md); margin-bottom: var(--space-4);
    display: flex; align-items: center; gap: var(--space-2);
}
.settings-section h3 .icon { color: var(--primary-color); }

/* ----------------------------------------------------------------- Forms -- */
.form-group { margin-bottom: var(--space-4); }
.form-group:last-child { margin-bottom: 0; }
.form-group label, .search-section label {
    display: block; margin-bottom: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="url"], textarea, select {
    width: 100%; padding: 11px 13px; font: inherit; font-size: var(--text-base);
    color: var(--text-primary); background: #fff;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
    appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary-color); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; cursor: pointer;
}
.field-hint { display: block; margin-top: 6px; font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; }

.form-group.checkbox { display: flex; align-items: center; gap: var(--space-2); }
.form-group.checkbox input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--primary-color); cursor: pointer; }
.form-group.checkbox label { margin: 0; font-weight: 500; color: var(--text-secondary); cursor: pointer; }

.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }

/* IBAN-Live-Status */
.iban-status { display: block; margin-top: 6px; font-size: var(--text-sm); font-weight: 600; }
.iban-status-ok { color: var(--success-color); }
.iban-status-bad { color: var(--danger-color); }
input#iban.iban-ok { border-color: var(--success-color); box-shadow: 0 0 0 3px rgba(4,120,87,.16); }
input#iban.iban-bad { border-color: var(--danger-color); box-shadow: 0 0 0 3px rgba(220,38,38,.15); }

/* --------------------------------------------------------------- Buttons -- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    padding: 10px 17px; min-height: 44px; font: inherit; font-size: var(--text-base); font-weight: 600; line-height: 1.1;
    color: #fff; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; white-space: nowrap;
    transition: transform .07s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease),
                border-color .15s var(--ease), color .15s var(--ease), filter .15s var(--ease);
}
.btn .icon { width: 17px; height: 17px; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Hierarchie: 1 lauter Primary, Success medium, Soft/Ghost/Secondary leise */
.btn-primary { background: var(--grad-brand); box-shadow: 0 5px 14px rgba(10,63,135,.26); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 20px rgba(10,63,135,.32); }

.btn-success { background: linear-gradient(135deg, #047857, #036b4e); box-shadow: 0 5px 14px rgba(4,120,87,.24); }
.btn-success:hover { filter: brightness(1.08); box-shadow: 0 8px 20px rgba(4,120,87,.3); }

.btn-danger { background: linear-gradient(135deg, #dc2626, #b91c1c); box-shadow: 0 5px 14px rgba(220,38,38,.22); }
.btn-danger:hover { filter: brightness(1.07); box-shadow: 0 8px 20px rgba(220,38,38,.28); }

.btn-secondary { background: #fff; color: var(--text-secondary); border-color: var(--border-color); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--bg-subtle); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary .icon { color: var(--text-muted); }

/* Soft = KI-Akzent, dezent */
.btn-soft { background: var(--accent-050); color: var(--accent); border-color: #e0e3ff; }
.btn-soft:hover { background: #e4e8ff; border-color: #c9cffb; }
.btn-soft .icon { color: var(--accent); }

/* Ghost = ruhig (tertiär) */
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }
.btn-ghost .icon { color: var(--text-muted); }
.btn-ghost-danger { background: transparent; color: var(--danger-color); border-color: transparent; }
.btn-ghost-danger:hover { background: var(--danger-050); color: var(--danger-700); }

.btn-small { padding: 7px 13px; min-height: 40px; font-size: var(--text-sm); }
.btn-small .icon { width: 15px; height: 15px; }

/* Aktions-Buttons: Primary über volle Breite (btn-block), Rest 2-spaltig.
   Flex statt Grid, damit ein ausgeblendeter Button (z.B. „QR anzeigen")
   sauber kollabiert und die Nachbarn nachrücken. */
.action-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.action-buttons .btn { flex: 1 1 calc(50% - var(--space-2)); }
.action-buttons .btn-block { flex-basis: 100%; }

/* ---------------------------------------------------------------- QR-Code -- */
/* QR-Anzeige lebt jetzt im Ergebnis-Modal (#qr-result-modal). */
.qr-display {
    display: grid; place-items: center; min-height: 240px; text-align: center;
    background:
        linear-gradient(var(--bg-card), var(--bg-card)) padding-box,
        repeating-linear-gradient(45deg, #eef2f7 0 11px, #fff 11px 22px) border-box;
    border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.qr-display img { max-width: 100%; height: auto; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.placeholder-text { color: var(--text-muted); font-size: var(--text-base); }

.qr-actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); }
.qr-actions .btn { width: 100%; }

/* Schlanke einzeilige Statuszeile (ersetzt die große Status-Karte). */
.status-line { padding: 0 2px; }
.status-messages {
    display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap;
    font-size: var(--text-sm); color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.status-messages .status-time { font-weight: 700; }

/* ------------------------------------------------------- Records / Table -- */
.search-section { margin-bottom: var(--space-5); display: flex; flex-direction: column; gap: 6px; }
.table-container { padding: 0; overflow: hidden; }
.table-info {
    margin: 0; padding: var(--space-3) var(--space-5); font-size: var(--text-sm); color: var(--text-muted);
    border-bottom: 1px solid var(--border-color); background: var(--bg-subtle);
}
.table-scroll { overflow-x: auto; }
#payments-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: var(--text-sm); }
#payments-table thead th {
    position: sticky; top: 0; padding: 12px 16px; text-align: left;
    font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); background: var(--bg-card); border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
#payments-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); vertical-align: middle; }
#payments-table tbody tr { transition: background .12s var(--ease); }
#payments-table tbody tr:hover { background: var(--primary-050); }
#payments-table tbody tr:last-child td { border-bottom: none; }
#payments-table tbody td:nth-child(3) { font-family: var(--mono); font-size: var(--text-xs); color: var(--text-primary); }
.loading { padding: var(--space-7) !important; text-align: center; color: var(--text-muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* -------------------------------------------------------------- Settings -- */
/* Einstellungen: Sub-Navigation oben gruppiert die Bereiche (zeigt einen pro Klick). */
.settings-nav {
    display: flex; gap: var(--space-2); max-width: 720px; margin: 0 auto var(--space-5);
    overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch;
}
.settings-nav-btn {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; min-height: 44px;
    background: #fff; border: 1px solid var(--border-color); border-radius: 999px;
    font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
    cursor: pointer; white-space: nowrap;
    transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.settings-nav-btn .icon { width: 15px; height: 15px; color: var(--text-muted); }
.settings-nav-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.settings-nav-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.settings-nav-btn.active { background: var(--grad-brand); border-color: transparent; color: #fff; box-shadow: var(--shadow-sm); }
.settings-nav-btn.active .icon { color: #fff; }

.settings-grid { max-width: 720px; margin: 0 auto; }
#tab-settings .settings-section { display: none; }
#tab-settings .settings-section.set-active { display: block; }
.section-description { margin: 0 0 var(--space-4); font-size: var(--text-base); color: var(--text-muted); line-height: 1.55; }

/* ------------------------------------------------------------- Contacts --- */
.contacts-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.contact-item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: 12px 14px; background: var(--bg-subtle); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.contact-info { min-width: 0; }
.contact-name { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-primary); font-size: var(--text-base); }
.contact-fav { width: 15px; height: 15px; fill: #f59e0b; stroke: none; }
.contact-details { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--text-sm); color: var(--text-muted); margin-top: 3px; word-break: break-word; }
.contact-meta { display: inline-flex; align-items: center; gap: 5px; }
.contact-meta .icon { width: 14px; height: 14px; color: var(--text-muted); }
.contact-actions { flex: none; display: flex; gap: var(--space-1); }

/* Admin: Ereignis-Protokoll */
.events-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.events-list { display: flex; flex-direction: column; gap: var(--space-2); max-height: 420px; overflow-y: auto; }
.event-row {
    padding: 10px 12px; background: var(--bg-subtle);
    border: 1px solid var(--border-color); border-left: 3px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
.event-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin-bottom: 4px; }
.event-badge {
    flex: none; padding: 1px 8px; border-radius: 999px;
    font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.event-badge-error   { color: var(--danger-700);  background: var(--danger-050); }
.event-badge-warning { color: var(--warning-700); background: var(--warning-050); }
.event-badge-info    { color: var(--primary-700); background: var(--primary-050); }
.event-row:has(.event-badge-error)   { border-left-color: var(--danger-color); }
.event-row:has(.event-badge-warning) { border-left-color: var(--warning-color); }
.event-cat { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); font-family: ui-monospace, monospace; }
.event-time { margin-left: auto; font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.event-msg { font-size: var(--text-sm); color: var(--text-primary); line-height: 1.45; overflow-wrap: anywhere; }
.event-detail { margin-top: 4px; font-size: var(--text-xs); color: var(--text-muted); overflow-wrap: anywhere; }
.event-who { margin-top: 4px; font-size: var(--text-xs); color: var(--text-muted); }

.status-time { margin-bottom: 5px; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- Banners -- */
.banner { padding: 13px 15px; border-radius: var(--radius-sm); font-size: var(--text-base); line-height: 1.5; border: 1px solid transparent; }
.banner strong { font-weight: 700; }
.info-banner { background: var(--info-050); border-color: #dbeafe; color: #1e3a8a; }
.warning-banner { background: var(--warning-050); border-color: #fde68a; color: var(--warning-700); }
.auth-notice-text { margin: 6px 0 0; font-size: var(--text-sm); }

/* AI-Key-Modal */
.ai-status-box { margin-bottom: var(--space-4); }
.ai-admin-shared { display: none; margin-top: var(--space-5); border-top: 1px solid var(--border-color); padding-top: var(--space-4); }
.ai-admin-shared h3 { font-size: var(--text-md); display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.ai-admin-shared h3 .icon { color: var(--primary-color); }

/* ---------------------------------------------------------------- Modals -- */
.modal {
    display: none;            /* per JS via inline display:block geöffnet */
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,42,.55); backdrop-filter: blur(5px);
    overflow-y: auto;
    padding: max(var(--space-7), env(safe-area-inset-top)) max(var(--space-4), env(safe-area-inset-right)) max(var(--space-7), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
    animation: backdropIn .2s var(--ease) both;
}
.modal-content {
    background: var(--bg-card); max-width: 520px; margin: 5vh auto;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); overflow: hidden;
    animation: modalIn .22s var(--ease) both;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-color); }
.modal-header h2 { font-size: var(--text-lg); display: flex; align-items: center; gap: var(--space-2); }
.modal-header h2 .icon { color: var(--primary-color); }
.close {
    flex: none; width: 44px; height: 44px; display: grid; place-items: center;
    background: none; border: none; border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer;
    transition: background .12s var(--ease), color .12s var(--ease);
}
.close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.close:focus-visible { outline: none; box-shadow: var(--ring); }
.modal-body { padding: var(--space-5); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-color); background: var(--bg-light); }

/* Kamera-Aufnahme */
.camera-stage { background: #0b1220; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ----------------------------------------------------------- Auth-Overlay - */
.auth-overlay {
    display: none;           /* per JS via inline display:flex geöffnet */
    position: fixed; inset: 0; z-index: 1500;
    align-items: center; justify-content: center; overflow-y: auto;
    padding: max(var(--space-6), env(safe-area-inset-top)) max(var(--space-6), env(safe-area-inset-right)) max(var(--space-6), env(safe-area-inset-bottom)) max(var(--space-6), env(safe-area-inset-left));
    background: var(--grad-logo);
}
.auth-overlay::before { content: ""; position: absolute; inset: 0; background: radial-gradient(820px 460px at 82% -12%, rgba(255,255,255,.22), transparent 60%); pointer-events: none; }
.auth-card { position: relative; width: 100%; max-width: 420px; margin: auto; padding: var(--space-7); border: none; box-shadow: var(--shadow-xl); animation: modalIn .25s var(--ease) both; }
.auth-brand { text-align: center; margin-bottom: var(--space-6); }
.auth-logo { width: 58px; height: 58px; margin: 0 auto var(--space-3); display: grid; place-items: center; border-radius: 16px; background: var(--grad-logo); color: #fff; box-shadow: 0 10px 24px rgba(10,63,135,.4); }
.auth-logo .icon { width: 30px; height: 30px; }
.auth-brand h2 { font-size: var(--text-xl); margin-bottom: 6px; }
.auth-subtitle { color: var(--text-muted); font-size: var(--text-base); }
.auth-btn-block { width: 100%; margin-top: var(--space-1); padding: 12px; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.auth-links a { font-size: var(--text-sm); }
.auth-message { margin-top: var(--space-4); padding: 12px 14px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: 500; border: 1px solid transparent; }
.auth-message.error { background: var(--danger-050); border-color: #fecaca; color: var(--danger-700); }
.auth-message.success { background: var(--success-050); border-color: #a7f3d0; color: var(--success-700); }
.auth-message.info { background: var(--info-050); border-color: #dbeafe; color: #1e3a8a; }

/* ---------------------------------------------------------------- Toasts -- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: var(--space-2); max-width: min(360px, calc(100vw - 40px)); }
.toast {
    display: flex; align-items: flex-start; gap: var(--space-2); padding: 12px 15px;
    background: #fff; border: 1px solid var(--border-color); border-left: 4px solid var(--info-color);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: var(--text-base); font-weight: 500; color: var(--text-primary);
    animation: slideInRight .3s var(--ease) both;
}
.toast .icon { flex: none; margin-top: 1px; }
.toast span { flex: 1; min-width: 0; line-height: 1.4; overflow-wrap: anywhere; }
.toast-close {
    flex: none; margin: -2px -4px 0 0; padding: 3px; line-height: 0;
    background: none; border: none; border-radius: var(--radius-sm);
    color: var(--text-muted); cursor: pointer;
    transition: background .12s var(--ease), color .12s var(--ease);
}
.toast-close:hover { background: rgba(15,23,42,.08); color: var(--text-primary); }
.toast-close:focus-visible { outline: none; box-shadow: var(--ring); }
.toast-close .icon { width: 14px; height: 14px; margin: 0; }
.toast.success { border-left-color: var(--success-color); background: var(--success-050); }
.toast.error   { border-left-color: var(--danger-color);  background: var(--danger-050); }
.toast.warning { border-left-color: var(--warning-color); background: var(--warning-050); }
.toast.info    { border-left-color: var(--info-color);    background: var(--info-050); }

/* ------------------------------------------------------------- Utilities -- */
.text-center { text-align: center; }
.mt-20 { margin-top: var(--space-5); }

/* ---------------------------------------------------------------- Motion -- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------- Responsiveness - */
@media (max-width: 900px) {
    .container { padding: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--space-5)) var(--space-4) calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--space-5)); }
    .app-bar-inner { padding: 0 max(var(--space-4), env(safe-area-inset-right)) 0 max(var(--space-4), env(safe-area-inset-left)); }
}
@media (max-width: 560px) {
    :root { --topbar-h: 56px; }
    body { font-size: var(--text-sm); }
    .subtitle, .version { display: none; }
    header h1 { font-size: var(--text-md); }
    .form-grid { grid-template-columns: 1fr; }
    .action-buttons .btn { flex-basis: 100%; }
    .btn { white-space: normal; }
    .url-row { flex-direction: column; }
    .url-row .btn { width: 100%; }
    .modal { padding: max(var(--space-4), env(safe-area-inset-top)) max(var(--space-3), env(safe-area-inset-right)) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-3), env(safe-area-inset-left)); }
    .modal-content { margin: 0 auto; }
    #user-menu-email { display: none; }
    .bottom-nav .tab-button { max-width: none; }
}
/* Sehr kleine Höhe (Tastatur offen o.ä.): Bottom-Nav kompakter, Safe-Area + 44px-Tabs bleiben */
@media (max-height: 480px) {
    .bottom-nav { height: calc(58px + env(safe-area-inset-bottom)); padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
    .nav-label { font-size: 10px; }
}

/* --------------------------------------------------- A11y / reduced motion - */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.btn:focus-visible, .close:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
