/* ============================================================
   Tekari Werkstatt-Frontend (CT 101) – Styles
   Dark default, Light toggle, blau-violetter Akzent
   Konsistent mit tekari.app, aber Sidebar-Layout statt Landing.
   ============================================================ */

:root {
    --bg:           #080d1a;
    --bg-2:         #0d1530;
    --bg-3:         #111d3c;
    --bg-sidebar:   #060a16;
    --border:       rgba(59, 130, 246, 0.15);
    --border-soft:  rgba(255, 255, 255, 0.06);
    --text:         #e2e8f0;
    --text-muted:   #64748b;
    --text-light:   #94a3b8;

    /* Primary kann pro Tenant überschrieben werden via tenant_settings */
    --primary:      #3b82f6;
    --primary-dark: #2563eb;
    --accent:       #6366f1;
    --primary-glow: rgba(59, 130, 246, 0.2);
    --grad:         linear-gradient(135deg, var(--primary), var(--accent));
    --on-primary:   #fff;   /* wird von header.php je nach Akzentfarbe überschrieben */
    --grad-subtle:  linear-gradient(135deg, rgba(59,130,246,0.08), rgba(99,102,241,0.08));

    --green:        #4ade80;
    --red:          #f87171;
    --orange:       #fb923c;
    --yellow:       #fbbf24;

    --radius:       10px;
    --radius-lg:    16px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);

    --sidebar-w:    240px;
    --header-h:     60px;
}

html.light {
    --bg:           #f8fafc;
    --bg-2:         #ffffff;
    --bg-3:         #f1f5f9;
    --bg-sidebar:   #ffffff;
    --border:       rgba(59, 130, 246, 0.2);
    --border-soft:  rgba(0, 0, 0, 0.06);
    --text:         #0f172a;
    --text-muted:   #64748b;
    --text-light:   #475569;
    --primary-glow: rgba(59, 130, 246, 0.1);
    --grad-subtle:  linear-gradient(135deg, rgba(59,130,246,0.05), rgba(99,102,241,0.05));
    --shadow:       0 4px 24px rgba(0,0,0,0.08);
    /* Hellmodus: kräftigeres Grün (das dunkle #4ade80 ist auf Weiß zu blass, z.B. der
       „✓ ausgezahlt"-Marker in der Provisions-Auszahlung). Dunkelmodus behält #4ade80. */
    --green:        #16a34a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
/* Desktop-App-Shell: Body scrollt NIE selbst – nur die inneren Panels (main/sidebar).
   Verhindert, dass ein Scroll in der Sidebar den ganzen Body verschiebt (Scroll-Chaining/
   Rubber-Banding). Mobile (≤720px) hebt das wieder auf → normaler Body-Scroll. */
@media (min-width: 721px) { html, body { overflow: hidden; } }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    /* 3 Rows: Header (fixed) / Main (grows) / Footer (auto-height).
       Vor v22 hatte der Footer `grid-area: main` mit `align-self:end` und
       overlappte deshalb den unteren Rand vom Content sobald die Seite lang
       genug war. Jetzt hat der Footer eine eigene Row. */
    grid-template-rows: var(--header-h) 1fr auto;
    grid-template-areas:
        "sidebar header"
        "sidebar main"
        "sidebar footer";
    /* Desktop: Viewport-hoch fixieren → Sidebar + Header bleiben stehen, nur der
       Inhalt (main) scrollt. Mobile setzt das unten wieder auf normalen Body-Scroll.
       ⚠️ 100dvh statt 100vh: auf iOS meint 100vh die GROSSE Viewport-Höhe (so als wären
       die Safari-Leisten ausgeblendet). Das Layout wurde dadurch höher als der sichtbare
       Bereich → unten blieb ein toter Balken (Andi, iPhone 16 Pro Max quer).
       100dvh folgt der tatsächlich sichtbaren Höhe. vh bleibt als Fallback davor. */
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-soft);
    padding: 24px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 24px;
    text-decoration: none;
}

.sidebar-brand img {
    /* B-1: KEINE starre max-height + kein object-fit hier – das überstimmte sonst
       die Inline-Breite (Logo blieb 36px hoch, die gewünschte Breite ergab nur
       leeren Raum = „verschiebt sich statt zu skalieren"). Die tatsächliche Größe
       steuert header.php inline (auto = 100% Breite, sonst px-Wert). */
    display: block;
    max-width: 100%;
    height: auto;
}

.sidebar-brand .brand-text {
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-section {
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.72;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 16px 12px 6px;
    margin-top: 8px;
    /* Feine Trennlinie oben → hebt die Kategorie klar von den Menüpunkten darüber ab,
       damit man sieht dass es ein Gruppen-Titel ist und kein anklickbarer Punkt. */
    border-top: 1px solid var(--border-soft, rgba(128,128,128,0.2));
}
/* Erste Kategorie braucht keine Trennlinie/Abstand oben. */
.nav-scroll > .sidebar-section:first-child {
    border-top: none;
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
    background: var(--bg-3);
    color: var(--text);
}
.nav-item.active {
    background: var(--grad-subtle);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--border);
}
.nav-item-icon { width: 18px; flex-shrink: 0; text-align: center; }

/* ── Header (Topbar) ─────────────────────────────────────── */
.header {
    grid-area: header;
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    /* ⚠️ KEIN overflow:hidden hier! (Regression 2026-07-22, von Andi gefunden)
       Sollte lange Auftragstitel bändigen, klippte aber das User-Dropdown, das
       per position:absolute UNTER der Leiste hängt (.user-menu-pop mit
       top: calc(100% + 8px)) → Abmelden war nicht mehr erreichbar. z-index hilft
       dagegen NICHT: Clipping durch einen Vorfahren sticht jede Stapelreihenfolge.
       Der Titelüberlauf ist ohnehin an der richtigen Stelle gelöst: .header-title
       klippt sich selbst (overflow + ellipsis + nowrap + min-width:0) und
       .header-actions steht auf flex:0 0 auto. Hier war es nur doppelt gemoppelt. */
    min-width: 0;
}

/* Titel darf die Kopfleiste nie sprengen: schrumpft dynamisch mit der Breite und
   wird notfalls mit … abgeschnitten, statt über die Icons zu laufen.
   min-width:0 ist Pflicht – sonst weigert sich das Flex-Item zu schrumpfen. */
.header-title {
    font-size: clamp(0.85rem, 2.6vw, 1rem);
    font-weight: 600;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    /* Buttons behalten IMMER ihren Platz – der Titel weicht, nicht sie. */
    flex: 0 0 auto;
    min-width: 0;
}

.icon-btn {
    /* flex:0 0 auto → wird in der Kopfleiste NIE gestaucht (sonst wird aus dem Kreis
       eine Ellipse, sobald der Titel viel Platz braucht). */
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border-soft);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.95rem;
    text-decoration: none;
}
.icon-btn:hover { border-color: var(--primary); color: var(--text); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 5px;
    border-radius: 100px;
    border: 1px solid var(--border-soft);
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    transition: border-color 0.15s;
}
.user-chip:hover { border-color: var(--primary); }

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
}

/* ── Main Content ────────────────────────────────────────── */
main {
    grid-area: main;
    padding: 28px 32px;
    /* Desktop: main scrollt intern (Sidebar/Header bleiben fix). Mobile = normal. */
    overflow: auto;
    min-height: 0;
    /* ⚠️ KEIN overscroll-behavior:contain hier! (Andi-Fund 2026-07-22, Chrome DevTools)
       Es blockierte auf manchen Seiten (free_label.php) das Scrollen per Mausrad komplett –
       Scrollbalken war da, Rad wirkungslos. Es wird hier auch gar nicht gebraucht: das
       Scroll-Chaining zum Body ist bereits durch `html,body{overflow:hidden}` (≥721px, oben)
       unterbunden – dort gibt es schlicht keinen Body-Scrollport mehr, der sich verschieben
       könnte. Also ersatzlos raus statt doppelt abzusichern. */
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
    /* Einheitlicher vertikaler Abstand zwischen aufeinanderfolgenden Karten/Blöcken,
       damit sie nicht zusammenkleben. */
    margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ── Einstellungs-Seiten: breite Displays nutzen (2-Spalten-Masonry) ───────
   Problem: Karten mit fixem max-width standen auf großen Screens schmal links-
   bündig, rechts blieb viel Platz leer. Lösung: Seiten setzen $mainClass=
   'settings-wide' → ab 1200px fließen die Karten in 2 Spalten (CSS-Columns =
   echtes Masonry ohne Höhen-Lücken). Titel/Untertitel/Alerts/Banner spannen
   via column-span über beide Spalten. Handy/Tablet (<1200px) bleibt 1-spaltig
   genau wie bisher (die inline max-width der Karten greift dort weiter). */
@media (min-width: 1200px) {
    /* ⚠️ Die Spalten MÜSSEN auf dem inneren .sw-cols-Wrapper sitzen, NICHT auf <main>.
       Grund (Bug 2026-07-22): seit der fixen Navbar hat <main> eine DEFINITE Höhe
       (.app{height:100vh} + Grid-Row 1fr) und scrollt selbst (overflow:auto). Ein
       Multi-Column-Container mit definiter Höhe wächst aber NICHT nach unten, sondern
       erzeugt immer neue Spalten NACH RECHTS → Inhalt lief seitlich raus, vertikal gab
       es nichts zu scrollen (Scrollbalken sichtbar, Mausrad wirkungslos). Der Wrapper
       hat auto-Höhe → Spalten wachsen nach unten, main scrollt normal. */
    main.settings-wide > .sw-cols {
        column-count: 2;
        column-gap: 26px;
    }
    main.settings-wide > .sw-cols > .page-title,
    main.settings-wide > .sw-cols > .page-subtitle,
    main.settings-wide > .sw-cols > .alert,
    main.settings-wide > .sw-cols > .tk-platform-banner,
    main.settings-wide > .sw-cols > [data-fullwidth] {
        column-span: all;
        -webkit-column-span: all;
    }
    /* Karten füllen die Spaltenbreite (inline max-width übersteuern) und bleiben
       in einer Spalte zusammen (kein Umbruch mitten in einer Karte). */
    main.settings-wide > .sw-cols > .card,
    main.settings-wide > .sw-cols > form.card {
        max-width: none !important;
        width: 100%;
        margin: 0 0 26px;
        break-inside: avoid;
        -webkit-column-break-inside: avoid;
    }
}

/* ── Footer (Powered by Tekari – PFLICHT) ────────────────── */
.footer-bar {
    grid-area: footer;
    text-align: center;
    padding: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-soft);
}
.footer-bar a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
    /* <button> erbt color NICHT → sonst fallen Buttons ohne eigene color
       (z.B. .btn-secondary) auf System-Schwarz zurück = im Dark-Mode unlesbar. */
    color: var(--text);
}
.btn-primary {
    background: var(--grad);
    /* NICHT auf #fff festnageln: bei hellen Akzentfarben verschwindet der Text sonst.
       --on-primary wird serverseitig nach WCAG-Kontrast berechnet (header.php),
       Fallback #fff für Seiten ohne Branding-Injektion. */
    color: var(--on-primary, #fff);
}
.btn-primary:hover { opacity: 0.9; }

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--text); }

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-light);
}

input, select, textarea {
    background: var(--bg-3);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    /* Verhindert Overflow aus Cards bei schmaleren Browser-Breiten */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
/* Checkboxen + Radios sollen ihre natürliche Größe behalten */
input[type="checkbox"], input[type="radio"] {
    width: auto;
    max-width: none;
}

/* ── UI-3: Checkboxen systemweit als Apple-Style Toggle-Slider ──────────────
   Reine CSS-Lösung (appearance:none) – KEINE Markup-Änderung nötig. Radios
   bleiben Radios. !important, weil viele Checkboxen inline `width:auto` haben.
   Escape-Hatch: class="no-toggle" lässt eine Checkbox normal. */
input[type="checkbox"]:not(.no-toggle) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    position: relative;
    display: inline-block;
    width: 42px !important;
    min-width: 42px;
    height: 24px !important;
    margin: 0;
    padding: 0;
    border: none !important;
    border-radius: 999px;
    background: var(--border, #cbd5e1);
    box-shadow: none !important;
    cursor: pointer;
    vertical-align: middle;
    flex: 0 0 auto;
    transition: background 0.2s ease;
}
input[type="checkbox"]:not(.no-toggle)::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
    transition: transform 0.2s ease;
}
input[type="checkbox"]:not(.no-toggle):checked {
    background: var(--primary, #3b82f6);
}
input[type="checkbox"]:not(.no-toggle):checked::before {
    transform: translateX(18px);
}
input[type="checkbox"]:not(.no-toggle):focus-visible {
    outline: 2px solid var(--primary, #3b82f6);
    outline-offset: 2px;
}
input[type="checkbox"]:not(.no-toggle):disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
input.invalid, select.invalid { border-color: rgba(239,68,68,0.5); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 18px;
    border: 1px solid;
}
.alert-error   { background: rgba(239,68,68,0.08);   border-color: rgba(239,68,68,0.3);   color: var(--red); }
.alert-success { background: rgba(34,197,94,0.08);   border-color: rgba(34,197,94,0.3);   color: var(--green); }
.alert-info    { background: rgba(59,130,246,0.08);  border-color: rgba(59,130,246,0.3);  color: var(--primary); }

/* ── Login Page ──────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, rgba(59,130,246,0.10), transparent 70%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: 0 8px 60px rgba(0,0,0,0.4);
}

.auth-logo {
    font-size: 1.6rem;
    font-weight: 800;
    text-align: center;
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.auth-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 32px;
}

.auth-card .btn { width: 100%; justify-content: center; }

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Responsive ──────────────────────────────────────────── */

/* Mittlere Browser-Breite (≤960px): KPI-/Filter-Grids quetschen bereits.
   Wir reduzieren 4-Spalten auf 2 + asymmetrische Layouts auf 1.
   Sidebar bleibt sichtbar (das macht erst die 720er-Query). */
@media (max-width: 960px) {
    [style*="grid-template-columns:repeat(4,1fr)"],
    [style*="grid-template-columns:repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    [style*="grid-template-columns:repeat(4, 1fr) auto"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    [style*="grid-template-columns:1.5fr 1fr"],
    [style*="grid-template-columns: 1.5fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    main { padding: 22px 18px; }
}

/* Tablet + kleines Tablet (≤720px): Sidebar wird zu horizontalem Topbar-Strip */
@media (max-width: 720px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-h) auto 1fr auto;
        grid-template-areas:
            "header"
            "sidebar"
            "main"
            "footer";
        /* Mobile: wieder normaler Body-Scroll statt fixiertem Viewport-Layout. */
        height: auto;
        overflow: visible;
    }
    main { overflow: visible; }
    .sidebar {
        flex-direction: row;
        padding: 10px 12px;
        gap: 6px;
        overflow-x: auto;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid var(--border-soft);
        -webkit-overflow-scrolling: touch;
    }
    .sidebar-brand, .sidebar-section { display: none; }
    .nav-item {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 8px 12px !important;
    }
    /* WICHTIG (BUG-14): `overflow-x:auto` auf main macht overflow-y rechnerisch
       auch zu `auto` → main wird verschachtelter Scroll-Container → am Handy
       (Touch) kaputt + die Seite selbst scrollt nicht. Am Handy daher visible
       → die SEITE scrollt natürlich (Tabellen sind hier eh gestapelt).
       `min-width:0` ist KRITISCH: main ist Grid-Item (.app 1fr); ohne das wäre
       seine Grid-min-width = min-content. Eine no-stack-Tabelle mit min-width:480px
       bläht damit die 1fr-Spur auf 480px → GANZE Seite läuft seitlich über (auch der
       Fließtext), statt dass die Tabelle intern scrollt (Andi 2026-07-29, Reseller-
       Provision mobil). min-width:0 lässt die Spur schrumpfen → Tabelle scrollt selbst. */
    main { padding: 20px 16px; overflow: visible; min-width: 0; }

    .header {
        /* Etwas höher als Desktop: auf dem Handy ist der Titel oft zweizeilig lang,
           dadurch wirkt die Leiste sonst gequetscht. */
        --header-h: 66px;
        min-height: 66px;
        padding: 0 12px;
        gap: 10px;
    }
    .header-title {
        /* Dynamisch: schrumpft mit der Displaybreite, bricht NICHT um und läuft
           nicht über die Icons – bei Bedarf mit … abgeschnitten. */
        font-size: clamp(0.8rem, 3.4vw, 1.02rem);
        line-height: 1.25;
        min-width: 0;
        flex: 1 1 auto;
    }
}

/* Inline overflow:hidden auf Karten aufheben, sobald eine Tabelle drinsteckt –
   sonst werden die gestapelten Tabellen-Karten auf Mobil abgeschnitten und das
   Stacking wirkt „kaputt". (Parität mit dem Admin-Panel.) */
.card:has(table) { overflow: visible !important; }

/* no-stack-Tabellen (z.B. Provisions-Tarife) auf schmalen Screens horizontal scrollen lassen
   statt die Spalten zu zerquetschen. Diese Tabellen wählen das Karten-Stapeln bewusst ab
   (no-stack); ohne Ausweg kollabierte die Kategorie-Spalte auf Buchstabenbreite (Andi
   2026-07-28, Reseller-Provision mobil). Trick: die Tabelle selbst wird zum Scroll-Container
   (display:block + overflow-x), die inneren thead/tbody behalten Tabellen-Layout und eine
   Mindestbreite → sauberes seitliches Scrollen. Greift zentral für ALLE no-stack-Tabellen
   (Provision-Tarife/-Auszahlung, KV-Editor). Desktop (>760px) unberührt. */
@media (max-width: 760px) {
    main table.no-stack:not(.tariff-cards) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    main table.no-stack:not(.tariff-cards) > thead,
    main table.no-stack:not(.tariff-cards) > tbody {
        display: table;
        width: 100%;
        min-width: 480px;
    }
}

/* Tarif-Tabellen (Reseller-Provision): statt seitlich zu scrollen mobil VERTIKAL als Karten.
   Kategorie volle Breite oben, die Preisboxen als flex-wrap darunter (spart Breite, Andi
   2026-07-29). Tabellenkopf mobil weg → jede Preiszelle trägt ihr Label per data-label; die
   Notiz-/Leerzelle (data-note) steht klein unter den Boxen. */
@media (max-width: 760px) {
    main table.tariff-cards,
    main table.tariff-cards > tbody { display: block; width: 100%; }
    main table.tariff-cards > thead { display: none; }
    main table.tariff-cards > tbody > tr {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 6px 10px;
        padding: 12px 2px;
        border-bottom: 1px solid var(--border-soft);
    }
    main table.tariff-cards > tbody > tr > td {
        display: block;
        padding: 0 !important;
        border: 0;
    }
    /* Kategorie: volle Breite, als Kartenkopf */
    main table.tariff-cards > tbody > tr > td:first-child { flex: 1 1 100%; }
    /* Preisboxen: nebeneinander, wachsen, brechen bei Bedarf um */
    main table.tariff-cards > tbody > tr > td[data-label] { flex: 1 1 130px; min-width: 0; }
    main table.tariff-cards > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.66rem;
        color: var(--text-muted);
        margin-bottom: 3px;
        text-align: left;
        white-space: nowrap;
    }
    /* Eingaben füllen ihre Box statt fixer 120px */
    main table.tariff-cards > tbody > tr > td[data-label] input { width: 100% !important; box-sizing: border-box; }
    /* Notiz/Leer-Zelle: klein unter den Boxen (leer = kollabiert) */
    main table.tariff-cards > tbody > tr > td[data-note] { flex: 1 1 100%; }
    main table.tariff-cards > tbody > tr > td[data-note]:empty { display: none; }

    /* Fuß (Summe/MwSt): einfache Zeile Label ↔ Wert */
    main table.tariff-cards > tfoot { display: block; }
    main table.tariff-cards > tfoot > tr {
        display: flex; flex-wrap: wrap; justify-content: space-between;
        align-items: baseline; gap: 2px 10px; padding: 6px 2px;
    }
    main table.tariff-cards > tfoot > tr > td { display: block; padding: 0 !important; border: 0; }
    main table.tariff-cards > tfoot > tr > td:empty { display: none; }

    /* Checkbox-Variante (Auszahlung): 1. Spalte = Checkbox (klein), 2. = Auftrag (füllt die
       Kopfzeile daneben) statt die Checkbox als voller Kartenkopf. */
    main table.tariff-cards--check > tbody > tr > td:first-child { flex: 0 0 auto; }
    main table.tariff-cards--check > tbody > tr > td:nth-child(2) { flex: 1 1 auto; min-width: 0; }
}

/* Tabellen ≤1200px (schon bei halbem Display): KEIN Scrollen und KEIN gequetschter
   Text, sondern gestapelte Karten. Jede Zeile = Karte, jede Zelle eine Zeile
   (Label links via data-label, Wert rechts). Gleiche Logik wie im Admin-Panel. */
@media (max-width: 1200px) {
    /* Kleine Tabellen können mit class="no-stack" das Stapeln abwählen. */
    main table:has(thead):not(.no-stack) thead {
        position: absolute; width: 1px; height: 1px;
        overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
    }
    main table:has(thead):not(.no-stack),
    main table:has(thead):not(.no-stack) tbody,
    main table:has(thead):not(.no-stack) tbody tr,
    main table:has(thead):not(.no-stack) tbody td {
        display: block; width: 100%;
    }
    /* Wenig Text pro Zeile → nicht 6 lange Zeilen, sondern 2 Spalten (≈ 3×2).
       Label über dem Wert je Zelle, dadurch dichter & weniger leer. */
    main table:has(thead):not(.no-stack) tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        border: 1px solid var(--border-soft);
        border-radius: 12px;
        margin-bottom: 12px;
        background: var(--bg-3);
        overflow: hidden;
    }
    main table:has(thead):not(.no-stack) tbody td {
        display: flex;
        flex-direction: column;
        gap: 3px;
        align-items: flex-start;
        padding: 9px 14px;
        border: none;
        border-top: 1px solid var(--border-soft);
        text-align: left;
        white-space: normal;
        word-break: normal;
        overflow-wrap: anywhere;
        min-width: 0;
        font-size: 0.9rem;
    }
    /* Obere Reihe (erste zwei Zellen) ohne Trennlinie nach oben. */
    main table:has(thead):not(.no-stack) tbody tr td:nth-child(1),
    main table:has(thead):not(.no-stack) tbody tr td:nth-child(2) { border-top: none; }
    main table:has(thead):not(.no-stack) tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        color: var(--text-muted);
    }
    main table:has(thead):not(.no-stack) tbody td:not([data-label])::before { content: ""; display: none; }
    main table:has(thead):not(.no-stack) tbody td .btn { white-space: nowrap; }
}

/* Handy (≤600px): zusätzlich Grids auf 1 Spalte zwingen, Touch-Targets vergrößern */
@media (max-width: 600px) {

    /* Inline-Grid-Styles in PHP-Pages auf 1 Spalte zwingen.
       Match auf alle Elemente die ein style-Attribut mit "grid-template-columns" haben –
       deckt KPI-Karten, Form-Grids, Detail-Grids etc. überall im Code ab. */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Ausnahme: Button-Reihen mit display:flex sollen auf Mobile in einer Zeile
       bleiben (flex-wrap kümmert sich um Umbruch wenn nötig). */
    [style*="display:flex"][style*="gap"] {
        flex-wrap: wrap;
    }

    /* Gestapelte Tabellen-Karten: auf dem Handy 2 Spalten → wieder 1 Spalte,
       sonst wird's zu eng. Trennlinie der 2. Zelle wieder herstellen. */
    main table:has(thead):not(.no-stack) tbody tr { grid-template-columns: 1fr; }
    main table:has(thead):not(.no-stack) tbody tr td:nth-child(2) { border-top: 1px solid var(--border-soft); }
    main table:has(thead):not(.no-stack) tbody tr td:first-child { border-top: none; }

    /* Touch-Targets vergrößern (Apple HIG: min 44px).
       ⚠️ .icon-btn ist hier BEWUSST ausgenommen: er ist rund (34x34, border-radius 50%).
       Ein reines min-height machte daraus 34 breit x 42 hoch = Ellipse/Pille. Er bekommt
       stattdessen unten ein gleichmäßiges 42x42 – bleibt also rund UND gut treffbar. */
    .btn, button, .nav-item {
        min-height: 42px;
    }
    .icon-btn {
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
        flex: 0 0 auto;
        border-radius: 50%;
        padding: 0;
    }
    /* User-Chip ist eine Pille by design, darf aber nicht gestaucht werden. */
    .user-chip { flex: 0 0 auto; min-height: 42px; }
    .user-chip .user-avatar { width: 28px; height: 28px; flex: 0 0 auto; }
    .btn { padding: 10px 16px; }
    input[type="text"], input[type="email"], input[type="password"],
    input[type="number"], input[type="date"], input[type="url"], select, textarea {
        font-size: 16px; /* iOS verhindert Auto-Zoom bei >=16px */
        padding: 10px 12px;
    }

    /* Cards: weniger Padding auf Handy */
    .card {
        padding: 16px;
        margin-bottom: 14px;
    }

    /* Headings kleiner */
    .page-title { font-size: 1.35rem; }
    .page-subtitle { font-size: 0.88rem; }
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.2rem; }

    /* Login/Auth-Card breiter machen damit's nicht so eingequetscht aussieht */
    .auth-card { max-width: none; padding: 24px 18px; }

    /* Header: User-Chip kompakt */
    .user-chip { padding: 4px 8px; font-size: 0.8rem; }
    .user-chip span:not(.user-avatar) { display: none; }
    .user-chip .user-avatar { margin: 0; }

    /* KPI-Karten: kompakter */
    .kpi-card { padding: 14px; }
    .kpi-value { font-size: 1.5rem; }
    .kpi-label { font-size: 0.78rem; }

    /* Endkunden-Public-Pages (customer.php / faq.php standalone / imprint / privacy):
       weniger Padding, kleinere Headings. */
    main[style*="padding:32px 24px"],
    main[style*="padding:40px 24px"] {
        padding: 18px 14px !important;
    }
    nav[style*="padding:14px 24px"] {
        padding: 10px 14px !important;
    }

    /* DL-Listen (Label/Wert-Paare): durch globale Grid-Override sind sie schon
       1-spaltig, hier nur Spacing optimieren. */
    dl[style*="grid-template-columns"] dt {
        padding-top: 6px;
        font-size: 0.78rem;
        margin-bottom: -4px;
    }
    dl[style*="grid-template-columns"] dd {
        margin: 0 0 4px;
    }
}

/* ── Status-Pills / Badges (global – vorher fehlten die Klassen komplett) ── */
.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.55;
    letter-spacing: 0.01em;
    white-space: nowrap;
    vertical-align: middle;
}
.pill-info    { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.pill-success { background: rgba(74, 222, 128, 0.16); color: var(--green); }
.pill-warn    { background: rgba(251, 146, 60, 0.16); color: var(--orange); }
.pill-error   { background: rgba(248, 113, 113, 0.16); color: var(--red); }
.pill-muted   { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* ── UI-4: Lange User-Texte global umbrechen ────────────────────────────────
   Lange ununterbrochene Eingaben (Beschreibung/Seriennr. ohne Leerzeichen)
   sprengten das Layout nach rechts → horizontaler Scroll. Jetzt wrappt der Text
   überall (Werkstatt/Endkunde/Admin), kein Seitwärts-Scrollen mehr. */
body { overflow-wrap: break-word; }
dd, td, th, p, li, blockquote, dl, .lead { overflow-wrap: anywhere; }

/* Hover-Rahmen (ersetzt inline onmouseover/onmouseout fuer nonce-CSP) */
.hover-primary:hover { border-color: var(--primary) !important; }

/* ── Snappy Button-Micro-Interactions (P7a, Teil 1) – nur Feel, kein Layout ── */
.btn { transition: transform .12s ease, filter .15s ease, opacity .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease; will-change: transform; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn-primary:hover { opacity: 1; filter: brightness(1.06); }


/* ═══════════════════════════════════════════════════════════
   Nav-Redesign: Glas-Optik + Handy-Wheel-Scroller (2026-06)
   Überschreibt bewusst die Basis-Regeln weiter oben (Cascade).
   ═══════════════════════════════════════════════════════════ */
.nav-scroll { display: flex; flex-direction: column; gap: 4px; min-height: 0; }

.nav-item {
    position: relative;
    transition: background .18s ease, color .18s ease,
                transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease;
}
.nav-item:hover {
    background: rgba(255,255,255,0.05);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    color: var(--text);
}
.nav-item.active {
    background:
        linear-gradient(135deg, rgba(59,130,246,0.16), rgba(99,102,241,0.16)),
        rgba(255,255,255,0.04);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 6px 18px rgba(59,130,246,0.16);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.nav-item.active .nav-item-icon { filter: drop-shadow(0 0 5px var(--primary-glow)); }

/* Glas-Sidebar (Desktop) – leichtes Frosted-Panel mit Tiefe. */
.sidebar {
    background: linear-gradient(180deg, rgba(13,21,48,0.55), rgba(6,10,22,0.70));
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    backdrop-filter: blur(14px) saturate(120%);
}

/* ── Handy: horizontaler Wheel-Strip ───────────────────────────
   Die Skalierung (Mitte groß → Ränder klein) macht overlay.js live
   per scroll – hier nur Bühne (Snap, kein Scrollbar, Seiten-Padding
   damit Rand-Items in die Mitte scrollen können). */
@media (max-width: 720px) {
    .sidebar {
        flex-direction: row; align-items: center;
        padding: 6px 0; overflow: hidden;
        background: linear-gradient(180deg, rgba(13,21,48,0.72), rgba(6,10,22,0.82));
    }
    .nav-scroll {
        flex: 1; min-width: 0;
        flex-direction: row; gap: 8px;
        overflow-x: auto; overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding: 4px max(40px, calc(50% - 72px));
        scrollbar-width: none;
    }
    .nav-scroll::-webkit-scrollbar { display: none; }
    .nav-scroll .sidebar-section { display: none; }
    .nav-item {
        flex-shrink: 0; white-space: nowrap;
        scroll-snap-align: center;
        transform-origin: center center; will-change: transform;
    }
    .nav-item.active {
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 8px 22px rgba(59,130,246,0.28);
    }
}


/* ═══════════════════════════════════════════════════════════
   Magic-Slider (Desktop) + In-Page-Tabs als Glas (.tk-tabs)
   ═══════════════════════════════════════════════════════════ */
.nav-scroll, .subtab-bar, .tk-tabs { position: relative; }

/* Gleitende Glas-Markierung – overlay.js initMagicSliders() positioniert sie. */
.tk-mag {
    position: absolute; top: 0; left: 0; z-index: 0;
    border-radius: var(--radius); pointer-events: none; opacity: 0;
    background:
        linear-gradient(135deg, rgba(59,130,246,0.18), rgba(99,102,241,0.18)),
        rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 6px 18px rgba(59,130,246,0.18);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    transition: transform .30s cubic-bezier(.4,.6,.2,1),
                width .30s cubic-bezier(.4,.6,.2,1),
                height .30s cubic-bezier(.4,.6,.2,1),
                opacity .2s ease;
}
.nav-item, .subtab, .tk-tab { position: relative; z-index: 1; }

/* Desktop: statische Pille/Hover-bg weg – die gleitende Markierung IST das
   Highlight. Text + Icon-Glow des aktiven Items bleiben. */
@media (min-width: 721px) {
    .nav-item.active, .subtab.active, .tk-tab.active {
        background: transparent; border-color: transparent; box-shadow: none;
        -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .nav-item:hover, .subtab:hover, .tk-tab:hover {
        background: transparent;
        -webkit-backdrop-filter: none; backdrop-filter: none;
    }
}

/* In-Page-Tab-Leiste: glasige Pillen statt Unterstrich; am Handy Scroller. */
.tk-tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.tk-tab {
    padding: 9px 16px; text-decoration: none; border-radius: 999px;
    color: var(--text-muted); font-weight: 500; font-size: 0.92rem;
    border: 1px solid transparent; white-space: nowrap;
    transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.tk-tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tk-tab.active {
    color: var(--text); font-weight: 600;
    background: linear-gradient(135deg, rgba(59,130,246,0.18), rgba(99,102,241,0.18)), rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 4px 14px rgba(59,130,246,0.18);
}
.tk-tab-spacer { margin-left: auto; }

@media (max-width: 720px) {
    .tk-mag { display: none; }
    .tk-tabs {
        flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
        -webkit-overflow-scrolling: touch; gap: 6px;
    }
    .tk-tabs::-webkit-scrollbar { display: none; }
    .tk-tab { flex-shrink: 0; }
    .tk-tab-spacer { display: none; }
}


/* ── Fix: Desktop-Neutralisierung NACH allen .active/.tk-tab-Definitionen,
   sonst überschreibt die statische Pille die gleitende Markierung (Doppel-Pille). */
@media (min-width: 721px) {
    .nav-item.active, .subtab.active, .tk-tab.active {
        background: transparent; border-color: transparent; box-shadow: none;
        -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .nav-item:hover, .subtab:hover, .tk-tab:hover {
        background: transparent;
        -webkit-backdrop-filter: none; backdrop-filter: none;
    }
}


/* ═══════════════════════════════════════════════════════════
   Inline-Style-Utilities – aus häufig wiederholten inline styles
   extrahiert (kürzere Zeilen, kleineres HTML, CSS einmal gecached).
   ═══════════════════════════════════════════════════════════ */
.muted   { color: var(--text-muted); }
.m-0     { margin: 0; }
.mb-20   { margin-bottom: 20px; }
.mt-20   { margin-top: 20px; }
.mt-14   { margin-top: 14px; }
.tar     { text-align: right; }
.w-auto  { width: auto; }
.fs-70   { font-size: 0.7rem; }
.fs-78   { font-size: 0.78rem; }
.fs-85   { font-size: 0.85rem; }
.hint-72 { font-size: 0.72rem; color: var(--text-muted); }
.hint-75 { font-size: 0.75rem; color: var(--text-muted); }

/* Fußnote „Details im FAQ" (faq_hint()). Bewusst unaufdringlich: der Hinweis soll
   den kurzen Satz daneben nicht optisch überholen. */
.faq-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    white-space: nowrap;
}
.faq-hint:hover { color: var(--primary); }
.hint-78 { font-size: 0.78rem; color: var(--text-muted); }
.hint-85 { font-size: 0.85rem; color: var(--text-muted); }

/* ── Chat-Verlauf (job_view) – BUG-14 (Andi-Fix) ──
   KEIN display:flex/flex-direction:column! Ein Flex-Column-Container mit overflow
   scrollt auf iOS-Safari NICHT (bekannter Bug) → „nur am Handy nicht scrollbar".
   Normaler BLOCK-Flow → Blasen stapeln nach unten + scrollt überall. Abstand via
   margin (gap gibt's im Block nicht). Desktop: kompakter Scroll; Handy: fließt
   in die Seite (Seite scrollt).    hab noch  max-height: none; overflow: visible; rausgenommen . */
.tk-chat-thread {
    max-height: 480px;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-right: 8px;
}
.tk-chat-msg { margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--grad-subtle); border-left: 3px solid var(--primary); }
.tk-chat-msg:last-child { margin-bottom: 0; }
.tk-chat-msg--system { background: var(--bg-3); border-left-color: var(--border); }
.tk-chat-meta { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 4px; }
.tk-chat-name { color: var(--text-light); font-weight: 700; }
.tk-chat-body { font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
@media (max-width: 720px) {
    .tk-chat-thread { padding-right: 0; }
}

/* ═══════════════════════════════════════════════════════════
   BUG-03: Light-Mode-Varianten für die Glas-Nav-Regeln.
   Die dunklen Glas-Regeln oben (.sidebar-Gradient, weiße Pillen-Highlights)
   überschrieben im Hellen das weiße --bg-sidebar → Text unlesbar. Hier hell.
   ═══════════════════════════════════════════════════════════ */
html.light .sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(241,245,249,0.92));
}
@media (max-width: 720px) {
    html.light .sidebar {
        background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(241,245,249,0.96));
    }
}
html.light .nav-item:hover { background: rgba(15,23,42,0.05); color: var(--text); }
html.light .nav-item.active {
    background:
        linear-gradient(135deg, rgba(59,130,246,0.13), rgba(99,102,241,0.13)),
        rgba(255,255,255,0.65);
    color: var(--primary-dark);
    border: 1px solid rgba(59,130,246,0.25);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 4px 14px rgba(59,130,246,0.13);
}
html.light .nav-item.active .nav-item-icon { filter: none; }
html.light .tk-mag {
    background:
        linear-gradient(135deg, rgba(59,130,246,0.13), rgba(99,102,241,0.13)),
        rgba(255,255,255,0.55);
    border: 1px solid rgba(59,130,246,0.22);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 4px 14px rgba(59,130,246,0.13);
}
html.light .tk-tab:hover { background: rgba(15,23,42,0.05); }
html.light .tk-tab.active, html.light .subtab.active {
    background:
        linear-gradient(135deg, rgba(59,130,246,0.13), rgba(99,102,241,0.13)),
        rgba(255,255,255,0.65);
    border-color: rgba(59,130,246,0.25);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 4px 14px rgba(59,130,246,0.13);
}


/* ═══════════════════════════════════════════════════════════
   Seiten-Übergänge – Cross-Document View Transitions (Stufe 1).
   Progressive Enhancement: Browser ohne Support (z.B. Firefox) navigieren
   normal → kein Verlust. Chrome/Edge/Safari zeigen ein sanftes Fade mit
   leichtem Hochgleiten des neuen Inhalts. Greift bei JEDEM Seitenwechsel
   (inkl. Login → Dashboard, alles same-origin).
   ═══════════════════════════════════════════════════════════ */
@view-transition { navigation: auto; }
@keyframes tk-vt-out { to   { opacity: 0; } }
@keyframes tk-vt-in  { from { opacity: 0; transform: translateY(10px); } }
::view-transition-old(root) { animation: tk-vt-out .16s ease both; }
::view-transition-new(root) { animation: tk-vt-in  .28s cubic-bezier(.2,.7,.2,1) both; }
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}


/* ═══════════════════════════════════════════════════════════
   Seiten-Übergänge STUFE 2: Sidebar + Header bleiben beim Wechsel STEHEN
   (eigener view-transition-name → eigene Gruppe, keine Animation), nur der
   Inhaltsbereich <main> gleitet/faded rein. Wirkt wie eine App statt Full-
   Page-Reload. Reuse der tk-vt-* Keyframes aus Stufe 1.
   ═══════════════════════════════════════════════════════════ */
.sidebar { view-transition-name: tk-sidebar; }
.header  { view-transition-name: tk-header; }
/* ⚠️ main bekommt BEWUSST KEINEN eigenen view-transition-name (2026-07-28 Chrome-Fix):
   <main> ist der Scroll-Container (overflow-y:auto). Als eigene VT-Gruppe morphte Chrome
   bei Fragment-Redirects (#chat/#fotos/#versand …) die Box-Geometrie des Scrollers vom
   gescrollten in den ungescrollten Zustand → Inhalt „rutschte hoch" und der Scroll blieb
   hängen (Safari macht keine Cross-Document-VT → dort nie sichtbar). Ohne eigenen Namen
   gehört der Inhalt zu `root` und cross-fadet über die root-Keyframes (Header/Sidebar
   bleiben durch ihre eigene Gruppe stehen) – gleiche Optik, kein Box-Morph des Scrollers. */
::view-transition-old(tk-sidebar), ::view-transition-new(tk-sidebar),
::view-transition-old(tk-header),  ::view-transition-new(tk-header) { animation: none; }

/* ═══════════════════════════════════════════════════════════
   Liquid Glass (iOS-26/27-Anlehnung) – 2026-07-13
   Nur Optik, kein Layout. Baut auf bestehenden Tokens auf.
   Alle Theme-Vars mit Fallback (falls ein CT die Var nicht kennt).
   ═══════════════════════════════════════════════════════════ */
:root {
    --glass-stroke:      rgba(255,255,255,0.14);
    --glass-hi:          rgba(255,255,255,0.22);
    --glass-fill:        rgba(255,255,255,0.07);
    --glass-fill-hover:  rgba(255,255,255,0.12);
}
html.light {
    --glass-stroke:      rgba(15,23,42,0.10);
    --glass-hi:          rgba(255,255,255,0.85);
    --glass-fill:        rgba(255,255,255,0.55);
    --glass-fill-hover:  rgba(255,255,255,0.72);
}

/* Sekundär- / Ghost- / Icon-Buttons + User-Chip → frosted Glas */
.btn-secondary, .btn-ghost, .icon-btn, .user-chip {
    background: var(--glass-fill);
    -webkit-backdrop-filter: blur(14px) saturate(1.5);
    backdrop-filter: blur(14px) saturate(1.5);
    border: 1px solid var(--glass-stroke);
    box-shadow: 0 1px 0 0 var(--glass-hi) inset, 0 4px 16px -10px rgba(0,0,0,0.6);
}
.btn-secondary:hover, .btn-ghost:hover, .icon-btn:hover, .user-chip:hover {
    background: var(--glass-fill-hover);
    border-color: var(--primary, #3b82f6);
    box-shadow: 0 1px 0 0 var(--glass-hi) inset,
                0 6px 20px -10px rgba(0,0,0,0.65),
                0 0 0 3px var(--primary-glow, rgba(59,130,246,0.22));
}

/* Primär-Button → getöntes Liquid Glass mit oberem Highlight + Sheen-Wisch */
.btn-primary {
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 0 0 rgba(255,255,255,0.40) inset,
                0 8px 24px -10px var(--primary-glow, rgba(59,130,246,0.35)),
                0 2px 6px -2px rgba(0,0,0,0.40);
}
.btn-primary::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255,255,255,0.30), rgba(255,255,255,0) 48%);
}
.btn-primary::after {
    content: "";
    position: absolute;
    top: 0;
    left: -70%;
    width: 45%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,0.38), transparent);
    transform: skewX(-18deg);
    transition: left 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-primary:hover::after { left: 130%; }
/* Inhalt (Text/Icon) über den Pseudo-Layern halten */
.btn-primary > * { position: relative; z-index: 1; }

/* Danger-Button → leichte Glas-Tönung */
.btn-danger {
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    backdrop-filter: blur(12px) saturate(1.4);
    box-shadow: 0 1px 0 0 rgba(255,255,255,0.14) inset, 0 4px 16px -10px rgba(0,0,0,0.6);
}

/* Pills → Mini-Glas */
.pill {
    -webkit-backdrop-filter: blur(8px) saturate(1.3);
    backdrop-filter: blur(8px) saturate(1.3);
    border: 1px solid var(--glass-stroke);
    box-shadow: 0 1px 0 0 var(--glass-hi) inset;
}

/* Cards → dezentes Glas-Kantenlicht (Hintergrund bewusst erhalten für Lesbarkeit) */
.card {
    border: 1px solid var(--glass-stroke);
    box-shadow: 0 1px 0 0 var(--glass-hi) inset, 0 10px 30px -18px rgba(0,0,0,0.55);
}

/* Reduced-Motion respektieren: kein Sheen-Wisch */
@media (prefers-reduced-motion: reduce) {
    .btn-primary::after { transition: none; }
}

/* ── Selbst-gehostete Schrift (Inter Variable) – DSGVO-sauber, kein Google-Abruf ── */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/InterVariable.woff2") format("woff2");
}

/* ── Kamera-Aufnahme (tenant_044, camera.js) ──────────────────────────────
   Overlay für die Einzelbild-Aufnahme in der Foto-Doku. Bewusst KEIN
   position:fixed-Element im normalen Fluss: das Overlay existiert nur solange
   der Dialog offen ist (camera.js baut es auf und entfernt es wieder) – so kann
   es niemals unsichtbar über der Seite liegen und Klicks/Scroll schlucken. */
.tk-cam {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(4, 8, 18, 0.72);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tk-cam-box {
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
    width: min(640px, 100%);
    max-height: 100%;
    overflow: auto;
    /* Ein Abstands-Rhythmus für ALLE direkten Kinder statt überall eigene margins –
       dadurch klebt nichts mehr aneinander und es bleibt trotzdem ruhig. */
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.tk-cam-head {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
/* ⚠️ FESTE Rahmenhöhe für Live-Bild UND Standbild (2026-07-23, Andi: „sieht einfach
   nicht toll aus"). Vorher richtete sich die Höhe nach dem jeweiligen Seitenverhältnis –
   beim Auslösen sprang der ganze Dialog in der Größe, weil das Standbild anders
   proportioniert ist als der Kamera-Stream. Ein fixer Rahmen mit object-fit:contain
   hält das Fenster ruhig; die schwarze Fläche rahmt das Bild sauber ein. */
/* ⚠️ MUSS vor .tk-cam-view stehen und gewinnen: das hidden-Attribut ist im
   Browser-Stylesheet nur `display:none` mit minimaler Spezifität. Eine Klassen-Regel
   mit `display:block` schlägt es – dadurch blieb das Live-Video beim Auslösen SICHTBAR
   und stand direkt über dem Standbild (Andi: „das eine groß auf die Aufnahme-Vorschau
   und komplett rangeklebt"). Genau dieser Fall, deshalb explizit und mit !important. */
.tk-cam [hidden] { display: none !important; }

.tk-cam-view {
    display: block;
    width: 100%;
    height: min(48vh, 360px);
    background: #05070d;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    object-fit: contain;
}
.tk-cam-msg {
    padding: 28px 12px; text-align: center;
    color: var(--text-light); font-size: 0.88rem;
    background: var(--bg-3);
    border-radius: 12px;
}
.tk-cam-select { width: 100%; }
.tk-cam-bar {
    display: flex; gap: 10px; flex-wrap: wrap;
    justify-content: flex-end;
    /* Feine Trennlinie: die Aktionen sind eine eigene Zone, nicht Teil der Vorschau. */
    border-top: 1px solid var(--border-soft);
    padding-top: 14px;
}

/* Übernommene Aufnahmen. Ohne sichtbare Rückmeldung wirkte „Übernehmen" wie ein Klick
   ins Leere (Andi-Fund 2026-07-23): bei Mehrfach-Feldern springt der Dialog absichtlich
   zurück ins Live-Bild, statt sich zu schließen. */
.tk-cam-strip {
    display: flex; gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 6px;
    scrollbar-width: thin;
}
.tk-cam-thumb {
    width: 58px; height: 58px; flex: 0 0 auto;
    object-fit: cover; border-radius: 10px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
    animation: tkCamPop 0.26s ease-out;
}
@keyframes tkCamPop {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .tk-cam-thumb { animation: none; }
}
.tk-cam-stat {
    font-size: 0.8rem;
    color: var(--green, #4ade80);
    font-weight: 600;
    /* dezent statt laut – die Miniaturen sind schon der Beweis, der Text nur die Zahl */
    opacity: 0.92;
    margin-top: -4px;
}

/* Schmale Displays: Rahmen etwas flacher, Knöpfe volle Breite = besser treffbar. */
@media (max-width: 520px) {
    .tk-cam-box { padding: 16px; gap: 12px; }
    .tk-cam-view { height: min(40vh, 280px); }
    .tk-cam-bar { justify-content: stretch; }
    .tk-cam-bar .btn { flex: 1 1 auto; }
}

/* ── Foto-Lightbox (Blur-Overlay, app.js) ─────────────────────────────────
   Fotos aus der Auftrags-Doku öffnen im Overlay statt in einem neuen Tab.
   Gleiche Optik wie der Kamera-Dialog (.tk-cam) – ein durchgängiges System.
   Wird von app.js komplett dynamisch erzeugt und beim Schließen wieder aus dem
   DOM entfernt → es kann nie unsichtbar über der Seite liegen. */
.tk-lightbox {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px; padding: 20px;
    background: rgba(4, 8, 18, 0.78);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
            backdrop-filter: blur(10px) saturate(1.2);
    animation: tk-lb-in .16s ease-out;
}
@keyframes tk-lb-in { from { opacity: 0; } to { opacity: 1; } }
.tk-lightbox img {
    max-width: min(1100px, 100%);
    max-height: calc(100vh - 130px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: #000;
    object-fit: contain;
}
.tk-lightbox-cap {
    color: var(--text-light);
    font-size: 0.85rem;
    text-align: center;
    max-width: min(1100px, 100%);
}
.tk-lightbox-close {
    position: absolute; top: 14px; right: 16px;
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(128,128,128,0.18); color: var(--text);
    border: 1px solid var(--border-soft); cursor: pointer;
    font-size: 1.1rem; line-height: 1;
}
.tk-lightbox-close:hover { border-color: var(--primary); }
.tk-lightbox-open {
    position: absolute; bottom: 16px;
    font-size: 0.8rem; color: var(--text-muted); text-decoration: none;
}
.tk-lightbox-open:hover { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .tk-lightbox { animation: none; } }

/* ── iOS: Safe-Area + versteckte Inputs ──────────────────────────────────
   Unterer Rand respektiert den Home-Indicator (nur wirksam mit viewport-fit=cover
   im Meta-Viewport, siehe header.php). */
.footer-bar { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
@media (max-height: 520px) { main { padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); } }

/* Ein Input mit `hidden`/display:none öffnet auf iOS Safari KEINEN Datei-/Kamera-Dialog.
   Deshalb wird das capture-Feld optisch versteckt, bleibt technisch aber gerendert. */
.tk-visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip: rect(0 0 0 0); clip-path: inset(50%);
    overflow: hidden; white-space: nowrap;
    opacity: 0; pointer-events: none;
}

/* ── Handy im QUERFORMAT ───────────────────────────────────────────────────
   Muss GANZ AM ENDE stehen: sonst gewinnt die weiter oben stehende
   `.app { height:100vh; overflow:hidden }` (gleiche Spezifität → die spätere Regel
   zählt) und der Override liefe ins Leere. Genau das war im ersten Anlauf der Fall.
   Ein Handy quer ist breiter als 720px, aber sehr flach → die fixierte Viewport-Shell
   ist dort falsch (Sidebar+Header fressen die halbe Höhe, und auf iOS entstand unten
   ein toter Balken, weil 100vh größer ist als die sichtbare Höhe). Also normaler Fluss. */
@media (max-height: 520px) {
    html, body { overflow: visible; }
    .app { height: auto; overflow: visible; }
    main { overflow: visible; min-height: 0; padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
    .sidebar { overflow-y: visible; }
}
