/* =====================================================
   KER Frontend Dashboard – Mobile-First CSS
   Clean Finance App Design
   Alle Klassen unter #ker-fe-app / .ker-fe-* isoliert
   ===================================================== */

/* === CSS VARIABLES === */
#ker-fe-app {
    --ker-blue: #2196F3;
    --ker-blue-light: #e3f2fd;
    --ker-blue-medium: #bbdefb;
    --ker-navy: #1a2332;
    --ker-bg: #f0f4f8;
    --ker-card: #ffffff;
    --ker-card-blue: #e8f4fc;
    --ker-border: #dfe6ed;
    --ker-green: #27ae60;
    --ker-orange: #f39c12;
    --ker-red: #e74c3c;
    --ker-text: #1a2332;
    --ker-text-secondary: #556877;
    --ker-text-muted: #8a9bab;
    --ker-radius: 14px;
    --ker-radius-sm: 10px;
    --ker-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --ker-shadow-md: 0 4px 20px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
}

/* === RESET / ISOLATION === */
#ker-fe-app {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--ker-bg);
    min-height: 100vh;
    padding-bottom: 90px;
    position: relative;
    color: var(--ker-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}

#ker-fe-app *, #ker-fe-app *::before, #ker-fe-app *::after {
    box-sizing: border-box;
}

/* === HEADER === */
.ker-fe-header {
    background: var(--ker-navy);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.ker-fe-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    min-height: 60px;
}

.ker-fe-firma-name {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Top Nav: hidden on mobile */
.ker-fe-top-nav {
    display: none;
}

.ker-fe-top-nav button {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.45);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ker-fe-top-nav button:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.8);
}

.ker-fe-top-nav button.ker-fe-tab--active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Period selectors */
.ker-fe-header-period {
    display: flex;
    gap: 12px;
    padding: 0 24px 18px;
}

.ker-fe-header-period select {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    min-height: 44px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 12px 36px 12px 14px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.6)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.ker-fe-header-period select option {
    color: var(--ker-navy);
    background: #fff;
}

/* === PANELS === */
.ker-fe-panel {
    display: none;
    padding: 24px 20px 32px;
}

.ker-fe-panel--active {
    display: block;
}

/* === KPI CARDS === */
.ker-fe-kpi-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 28px;
}

.ker-fe-kpi-card {
    background: var(--ker-card);
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--ker-shadow);
}

.ker-fe-kpi-primary {
    background: var(--ker-card-blue);
    border-left: 4px solid var(--ker-blue);
}

.ker-fe-kpi-highlight {
    background: var(--ker-card-blue);
    border-left: 4px solid var(--ker-blue);
}

.ker-fe-kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ker-blue);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.ker-fe-kpi-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--ker-text);
    white-space: nowrap;
    letter-spacing: -0.02em;
}

.ker-fe-kpi-soll-ist {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 17px;
    font-weight: 700;
}

.ker-fe-soll {
    color: var(--ker-blue);
}

.ker-fe-vs {
    font-size: 11px;
    color: var(--ker-text-muted);
    font-weight: 400;
}

.ker-fe-ist {
    color: var(--ker-text);
}

.ker-fe-ist--ok   { color: var(--ker-green) !important; }
.ker-fe-ist--warn { color: var(--ker-orange) !important; }
.ker-fe-ist--bad  { color: var(--ker-red) !important; }

/* === SECONDARY KPIs (Reichweite, Gewinn%) === */
.ker-fe-kpi-secondary {
    display: flex;
    gap: 14px;
    margin-bottom: 28px;
}

.ker-fe-kpi-mini {
    flex: 1;
    background: var(--ker-card);
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius);
    padding: 22px 16px;
    text-align: center;
    box-shadow: var(--ker-shadow);
}

.ker-fe-kpi-mini-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ker-red);
    font-weight: 700;
    display: block;
    margin-bottom: 8px;
}

.ker-fe-kpi-mini-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--ker-blue);
    display: block;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.ker-fe-kpi-mini-unit {
    font-size: 12px;
    color: var(--ker-text-muted);
    margin-top: 4px;
    display: block;
}

.ker-fe-kpi-mini-label,
.ker-fe-kpi-mini-value {
    white-space: nowrap;
}

/* Beträge brechen nie um; die Schrift wird bei Bedarf per KER.fitText()
   (assets/ker-charts.js) auf die verfügbare Breite verkleinert. */
.ker-fe-kpi-mini {
    min-width: 0; /* Flex-Element darf nicht mit dem Inhalt mitwachsen */
}
.ker-fe-kpi-mini-value {
    overflow: hidden;
}
.ker-fe-kpi-hero .ker-fe-kpi-hero-value {
    white-space: nowrap;
    word-break: normal;
    overflow: hidden;
    max-width: 100%;
}

/* Kleine Handys: etwas weniger Innenabstand und Sperrung, damit Beschriftung
   und (i) in einer Zeile bleiben. Karten bleiben nebeneinander. */
@media (max-width: 479px) {
    .ker-fe-kpi-secondary {
        gap: 10px;
    }
    .ker-fe-kpi-mini {
        padding: 18px 10px;
    }
    .ker-fe-kpi-mini-label {
        letter-spacing: 0.3px;
    }
}

/* === FILTER TRIGGER (Mobile) === */
.ker-fe-filter-trigger-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.ker-fe-filter-btn {
    background: var(--ker-blue);
    color: #fff;
    border: none;
    padding: 11px 22px;
    min-height: 44px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(33,150,243,0.25);
    transition: box-shadow 0.2s;
}

.ker-fe-filter-btn:active {
    box-shadow: 0 1px 4px rgba(33,150,243,0.2);
}

.ker-fe-filter-chip {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

/* === DESKTOP FILTER (hidden on mobile) === */
.ker-fe-desktop-filter {
    display: none;
}

.ker-fe-desktop-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--ker-border);
    font-size: 13px;
    font-weight: 700;
    color: var(--ker-text);
}

.ker-fe-desktop-filter-actions {
    display: flex;
    gap: 8px;
}

.ker-fe-filter-btn-sm {
    background: var(--ker-bg);
    border: 1px solid var(--ker-border);
    color: var(--ker-text-secondary);
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.ker-fe-filter-btn-sm:hover {
    background: var(--ker-blue-light);
    color: var(--ker-blue);
    border-color: var(--ker-blue);
}

.ker-fe-desktop-filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 20px;
}

.ker-fe-desktop-filter-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--ker-border);
    background: #fff;
    transition: all 0.15s;
}

.ker-fe-desktop-filter-item:hover {
    border-color: var(--ker-blue);
    background: var(--ker-blue-light);
}

.ker-fe-desktop-filter-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--ker-blue);
    cursor: pointer;
}

.ker-fe-desktop-filter-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* === CHARTS === */
.ker-fe-charts {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ker-fe-chart-card {
    background: var(--ker-card);
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius);
    padding: 22px;
    box-shadow: var(--ker-shadow);
}

.ker-fe-chart-card h4 {
    margin: 0 0 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ker-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ker-fe-chart-wrap {
    position: relative;
    height: 240px;
}

.ker-fe-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Kosten-Kategorien: viele Balken je Monat – auf dem Handy etwas mehr Höhe */
.ker-fe-chart-overview .ker-fe-chart-wrap {
    height: 300px;
}

/* === BOTTOM SHEET (Filter – Mobile) === */
.ker-fe-sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.ker-fe-sheet-backdrop--open {
    display: block;
}

.ker-fe-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    z-index: 201;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 70vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}

.ker-fe-bottom-sheet--open {
    transform: translateY(0);
}

.ker-fe-sheet-handle {
    width: 36px;
    height: 4px;
    background: #dde1e6;
    border-radius: 2px;
    margin: 12px auto 0;
}

.ker-fe-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--ker-border);
}

.ker-fe-sheet-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ker-text);
}

.ker-fe-sheet-close {
    background: var(--ker-bg);
    border: none;
    font-size: 18px;
    color: var(--ker-text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ker-fe-filter-list {
    padding: 10px 0;
}

.ker-fe-filter-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    cursor: pointer;
    font-size: 16px;
    color: var(--ker-text);
    transition: background 0.1s;
}

.ker-fe-filter-item:active {
    background: var(--ker-bg);
}

.ker-fe-filter-item input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: var(--ker-blue);
    cursor: pointer;
    flex-shrink: 0;
}

.ker-fe-filter-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.ker-fe-sheet-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--ker-border);
}

.ker-fe-sheet-footer button {
    flex: 1;
    padding: 14px;
    border-radius: var(--ker-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--ker-border);
    background: var(--ker-bg);
    color: var(--ker-text);
    transition: all 0.15s;
}

.ker-fe-sheet-footer button:active {
    background: var(--ker-border);
}

/* === BOTTOM TAB NAV (Mobile) === */
.ker-fe-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: var(--ker-card);
    display: flex;
    z-index: 150;
    border-top: 1px solid var(--ker-border);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.ker-fe-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--ker-text-muted);
    cursor: pointer;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.ker-fe-tab--active {
    color: var(--ker-blue) !important;
}

.ker-fe-tab-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ker-fe-tab-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.ker-fe-tab-label {
    font-weight: 700;
    font-size: 11px;
}

/* === FORMS (Vorgaben + Profil) === */
.ker-fe-form-header {
    padding: 0 0 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.ker-fe-form-header select {
    font-size: 16px;
    font-weight: 700;
    color: var(--ker-blue);
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius-sm);
    padding: 14px 40px 14px 18px;
    background: var(--ker-card);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%232196F3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    box-shadow: var(--ker-shadow);
}

.ker-fe-field-group {
    background: var(--ker-card);
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius);
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: var(--ker-shadow);
}

.ker-fe-field-group h4 {
    font-size: 12px;
    font-weight: 700;
    color: var(--ker-blue);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ker-border);
}

.ker-fe-field {
    margin-bottom: 18px;
}

.ker-fe-field:last-child {
    margin-bottom: 0;
}

.ker-fe-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--ker-text-secondary);
    margin-bottom: 8px;
}

.ker-fe-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ker-fe-input-row input,
.ker-fe-field > input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px; /* 16px = verhindert iOS Zoom */
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius-sm);
    background: var(--ker-bg);
    color: var(--ker-text);
    font-weight: 500;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ker-fe-input-row input:focus,
.ker-fe-field > input:focus {
    border-color: var(--ker-blue);
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(33,150,243,0.12);
}

.ker-fe-input-unit {
    font-size: 15px;
    font-weight: 600;
    color: var(--ker-text-muted);
    min-width: 24px;
    text-align: center;
}

.ker-fe-hint {
    font-size: 14px;
    color: var(--ker-text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* === SAVE BUTTON === */
.ker-fe-save-btn {
    display: block;
    width: 100%;
    padding: 18px;
    background: var(--ker-blue);
    color: #fff;
    border: none;
    border-radius: var(--ker-radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 24px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(33,150,243,0.3);
    letter-spacing: 0.02em;
}

.ker-fe-save-btn:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(33,150,243,0.3);
}

/* === TOAST === */
.ker-fe-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--ker-navy);
    color: #fff;
    padding: 14px 28px;
    border-radius: 28px;
    font-size: 15px;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    max-width: calc(100vw - 40px);
    text-align: center;
    line-height: 1.35;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.ker-fe-toast--show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ker-fe-toast--success { background: var(--ker-green); }
.ker-fe-toast--error   { background: var(--ker-red); }

/* === LOADING === */
.ker-fe-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px;
    color: var(--ker-text-muted);
    font-size: 15px;
}

/* === LOGIN REQUIRED (Fallback für Nicht-Mandanten) === */
.ker-fe-login-required {
    padding: 80px 28px;
    text-align: center;
    color: var(--ker-text-secondary);
    font-size: 16px;
    line-height: 1.6;
}

.ker-fe-login-required a {
    color: var(--ker-blue);
    font-weight: 600;
    text-decoration: none;
}

/* === LOGIN SCREEN === */
.ker-fe-login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 24px;
}

.ker-fe-login-logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--ker-blue);
    letter-spacing: -0.02em;
    margin-bottom: 40px;
}

.ker-fe-login-screen form {
    width: 100%;
    max-width: 400px;
}

.ker-fe-login-notice {
    color: #1b7a43;
    background: #e8f7ee;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding: 12px 16px;
    margin-bottom: 18px;
    border-radius: var(--ker-radius-sm);
}

.ker-fe-login-error {
    display: none;
    color: var(--ker-red);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding: 12px 16px;
    margin-top: 16px;
    background: rgba(231, 76, 60, 0.08);
    border-radius: var(--ker-radius-sm);
}

.ker-fe-login-forgot {
    display: inline-block;
    margin-top: 24px;
    color: var(--ker-text-muted);
    font-size: 14px;
    text-decoration: none;
}

.ker-fe-login-forgot:hover {
    color: var(--ker-blue);
}

/* === LOGOUT === */
.ker-fe-logout-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--ker-border);
}

.ker-fe-logout-btn {
    display: block;
    width: 100%;
    padding: 16px;
    background: transparent;
    color: var(--ker-red);
    border: 1px solid var(--ker-red);
    border-radius: var(--ker-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ker-fe-logout-btn:active {
    background: rgba(231, 76, 60, 0.08);
}


/* =====================================================
   DESKTOP (>= 768px)
   ===================================================== */

@media (min-width: 768px) {
    #ker-fe-app {
        padding-bottom: 0;
        max-width: 1200px;
        margin: 32px auto;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: var(--ker-shadow-md);
        min-height: auto;
        background: var(--ker-bg);
    }

    .ker-fe-header-top {
        padding: 18px 32px;
    }

    .ker-fe-top-nav {
        display: flex;
        gap: 4px;
        margin-left: 32px;
    }

    .ker-fe-header-period {
        padding: 0 32px 18px;
        justify-content: flex-end;
        gap: 14px;
    }

    .ker-fe-header-period select {
        flex: none;
        width: auto;
        min-width: 160px;
    }

    .ker-fe-bottom-nav {
        display: none;
    }

    .ker-fe-panel {
        padding: 32px;
    }

    /* KPI Cards: 4 Kostenquoten-Karten über volle Breite */
    .ker-fe-kpi-stack {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .ker-fe-kpi-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 24px 16px;
        gap: 10px;
    }

    .ker-fe-kpi-label {
        font-size: 11px;
    }

    .ker-fe-kpi-value {
        font-size: 26px;
    }

    .ker-fe-kpi-soll-ist {
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .ker-fe-vs {
        display: inline;
    }

    .ker-fe-kpi-primary,
    .ker-fe-kpi-highlight {
        border-left: 1px solid var(--ker-border);
        border-top: 3px solid var(--ker-blue);
    }

    /* Secondary KPIs */
    .ker-fe-kpi-secondary {
        gap: 16px;
    }

    /* Filter */
    .ker-fe-filter-trigger-row {
        display: none;
    }

    .ker-fe-desktop-filter {
        display: block;
        background: var(--ker-card);
        border: 1px solid var(--ker-border);
        border-radius: var(--ker-radius);
        margin-bottom: 24px;
        box-shadow: var(--ker-shadow);
    }

    /* Charts: Grid */
    .ker-fe-charts {
        display: grid;
        grid-template-columns: 1.5fr 1fr;
        gap: 20px;
    }

    /* Große Grafik links über beide Zeilen; ihr Chart füllt die volle Kartenhöhe.
       Die Zeilenhöhe bestimmen allein die beiden kleineren Grafiken rechts. */
    .ker-fe-chart-overview {
        grid-row: span 2;
        display: flex;
        flex-direction: column;
    }

    .ker-fe-chart-wrap {
        height: 220px;
    }

    .ker-fe-chart-overview .ker-fe-chart-wrap {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
    }

    /* Vorgaben: 2 columns */
    #ker-fe-panel-vorgaben form {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    #ker-fe-panel-vorgaben .ker-fe-save-btn {
        grid-column: span 2;
    }

    /* Profil: 2 columns */
    #ker-fe-panel-profil form {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    #ker-fe-panel-profil .ker-fe-save-btn {
        grid-column: span 2;
    }
}

/* ============================================
   Paket B: Status-Banner, Zustände, Hero, Ampel, Info
   ============================================ */

/* Status auf einen Blick */
.ker-fe-status-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--ker-radius);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}
.ker-fe-status-dot {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
}
.ker-fe-banner--ok   { background: #e8f7ee; color: #1b7a43; }
.ker-fe-banner--warn { background: #fff5e0; color: #9a6a00; }
.ker-fe-banner--bad  { background: #fdecea; color: #b3261e; }

/* Korrektur-Hinweis (neu eingespielter Monat, 30 Tage sichtbar) */
.ker-fe-korrektur {
    background: var(--ker-card);
    border-left: 4px solid var(--ker-orange);
    border-radius: var(--ker-radius);
    box-shadow: var(--ker-shadow);
    padding: 16px 18px;
    margin-bottom: 20px;
    font-size: 14px;
}
.ker-fe-korrektur-titel { font-weight: 700; }
.ker-fe-korrektur-datum { font-weight: 400; color: var(--ker-text-muted); margin-left: 6px; }
.ker-fe-korrektur-text { margin: 6px 0 10px; color: var(--ker-text-secondary); font-size: 13px; }
.ker-fe-korrektur-tabelle { width: 100%; border-collapse: collapse; font-size: 13px; }
.ker-fe-korrektur-tabelle th,
.ker-fe-korrektur-tabelle td { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--ker-border); }
.ker-fe-korrektur-tabelle th:first-child,
.ker-fe-korrektur-tabelle td:first-child { text-align: left; }
.ker-fe-korrektur-tabelle thead th { font-weight: 600; color: var(--ker-text-muted); }
.ker-fe-korrektur-tabelle td { font-variant-numeric: tabular-nums; }
.ker-fe-korrektur-tabelle td:first-child { overflow-wrap: anywhere; }
.ker-fe-korrektur-tabelle td:not(:first-child) { white-space: nowrap; }
.ker-fe-korrektur-monat th { text-align: left !important; padding-top: 10px; font-weight: 700; color: var(--ker-text); }
.ker-fe-korrektur-konten { margin-top: 10px; }
.ker-fe-korrektur-konten summary { cursor: pointer; color: var(--ker-blue); font-weight: 600; padding: 4px 0; }

/* Lade-/Fehler-/Leerzustände */
.ker-fe-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--ker-text-muted);
    font-size: 15px;
}
.ker-fe-state .ker-fe-hint { margin-top: 6px; font-size: 13px; }
.ker-fe-state--error { color: var(--ker-red); }
.ker-fe-state .ker-fe-filter-btn { margin-top: 14px; }
.ker-fe-spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto 16px;
    border: 4px solid var(--ker-border);
    border-top-color: var(--ker-blue);
    border-radius: 50%;
    animation: ker-fe-spin 0.8s linear infinite;
}
@keyframes ker-fe-spin { to { transform: rotate(360deg); } }

/* Hero-Karte: Gewinn als wichtigste Zahl */
.ker-fe-kpi-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    background: var(--ker-card-blue);
    border-left: 4px solid var(--ker-blue);
    margin-bottom: 20px;
}
.ker-fe-kpi-hero-value {
    font-size: 38px;
    line-height: 1.05;
    white-space: normal;
    word-break: break-word;
}

.ker-fe-kpi-value-sm {
    font-size: 20px;
    font-weight: 800;
    color: var(--ker-text);
}

/* Ampelfarben für beliebige Werte */
.ker-fe-level--ok   { color: var(--ker-green) !important; }
.ker-fe-level--warn { color: var(--ker-orange) !important; }
.ker-fe-level--bad  { color: var(--ker-red) !important; }

/* Info-Button + Hint */
.ker-fe-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--ker-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}
/* Gegen Theme-Button-Stile absichern (Themes setzen oft Rahmen, Padding,
   Mindestbreite und Akzentfarbe auf alle <button>). Gezielt per ID-Präfix,
   kein generischer #ker-fe-app-button-Reset – der würde alle Plugin-Buttons
   überschreiben. */
#ker-fe-app .ker-fe-info,
#ker-fe-app .ker-fe-info:hover,
#ker-fe-app .ker-fe-info:focus,
#ker-fe-app .ker-fe-info:active {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    min-width: 0;
    height: 18px;
    min-height: 0;
    margin: 0 0 0 6px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--ker-blue);
    color: #fff;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
    letter-spacing: 0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 12px;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    vertical-align: middle;
    cursor: pointer;
}
#ker-fe-app .ker-fe-info:focus-visible {
    outline: 2px solid var(--ker-blue);
    outline-offset: 2px;
}
/* 44px Tippfläche ohne sichtbare Vergrößerung */
#ker-fe-app .ker-fe-info {
    position: relative;
}
#ker-fe-app .ker-fe-info::after {
    content: '';
    position: absolute;
    inset: -13px;
}

#ker-fe-app .ker-fe-kontostand-btn,
#ker-fe-app .ker-fe-kontostand-btn:hover,
#ker-fe-app .ker-fe-kontostand-btn:focus {
    border: 1px solid var(--ker-blue);
    background: #fff;
    color: var(--ker-blue);
    border-radius: var(--ker-radius-sm);
    padding: 8px 14px;
    min-width: 0;
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}
#ker-fe-app .ker-fe-kontostand-btn--primary,
#ker-fe-app .ker-fe-kontostand-btn--primary:hover,
#ker-fe-app .ker-fe-kontostand-btn--primary:focus {
    background: var(--ker-blue);
    color: #fff;
}

.ker-fe-kpi-hint {
    display: none;
    width: 100%;
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(0,0,0,0.04);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
    color: var(--ker-text);
}

/* Ziel/Ist-Blöcke (klarer als "vs.") */
.ker-fe-kpi-soll-ist {
    flex-wrap: wrap;
    gap: 16px;
}
.ker-fe-soll-block,
.ker-fe-ist-block {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: var(--ker-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ker-fe-soll-block strong,
.ker-fe-ist-block strong {
    font-size: 18px;
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ker-text);
}
.ker-fe-soll-block strong { color: var(--ker-blue); }

/* Karten mit Hint dürfen umbrechen (Hero/Soll-Ist) */
.ker-fe-kpi-card[data-hint] { flex-wrap: wrap; }

/* "Angemeldet bleiben" + Hinweis-Texte */
.ker-fe-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 16px;
    font-size: 14px;
    color: var(--ker-text);
    cursor: pointer;
    min-height: 44px;
}
.ker-fe-remember input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    flex: 0 0 auto;
}
.ker-fe-hint-inline {
    font-weight: 400;
    font-size: 12px;
    color: var(--ker-text-muted);
    text-transform: none;
    letter-spacing: 0;
}

/* Kontostand: Anzeige + selbst aktualisieren */
.ker-fe-kontostand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--ker-card);
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--ker-shadow);
}

.ker-fe-kontostand-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ker-fe-kontostand-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ker-text-muted);
}

.ker-fe-kontostand-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--ker-text);
}

.ker-fe-kontostand-meta {
    font-size: 12px;
    color: var(--ker-text-secondary);
}

.ker-fe-kontostand-btn {
    border: 1px solid var(--ker-blue);
    background: #fff;
    color: var(--ker-blue);
    border-radius: var(--ker-radius-sm);
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
}

.ker-fe-kontostand-btn--primary {
    background: var(--ker-blue);
    color: #fff;
}

.ker-fe-kontostand-form {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.ker-fe-kontostand-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--ker-text-secondary);
}

.ker-fe-kontostand-form input {
    padding: 8px 10px;
    border: 1px solid var(--ker-border);
    border-radius: var(--ker-radius-sm);
    font-size: 16px; /* verhindert Zoom auf iOS */
    min-width: 140px;
}

.ker-fe-kontostand-actions {
    display: flex;
    gap: 8px;
}

.ker-fe-kontostand-error {
    flex-basis: 100%;
    color: var(--ker-red);
    font-size: 13px;
}

/* =====================================================
   DESKTOP-GERÄTE: Backend-Ansicht im Frontend
   (templates/dashboard.php + assets/style.css, siehe
   KER_Dashboard::frontend_desktop())
   ===================================================== */
#ker-fe-app.ker-fe-desktop-view #ker-fe-panel-dashboard {
    padding: 0;
}
/* Admin-spezifische Ränder/Höhen aus style.css neutralisieren */
#ker-fe-app .ker-dashboard-wrapper {
    margin: 0;
    min-height: 0;
}
#ker-fe-app .ker-dashboard-layout {
    min-height: 0;
}

/* Spalten dürfen schmaler werden als ihr Inhalt (Theme-Inhaltsbreite ist
   kleiner als der Admin-Bereich). Gleiche Stufen wie style.css, nur mit
   minmax(0, …). */
#ker-fe-app .ker-dashboard-layout { grid-template-columns: 200px minmax(0, 1fr); }
#ker-fe-app .ker-kpi-row          { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#ker-fe-app .ker-charts-grid      { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
@media (max-width: 1200px) {
    #ker-fe-app .ker-dashboard-layout { grid-template-columns: 180px minmax(0, 1fr); }
    #ker-fe-app .ker-kpi-row          { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    #ker-fe-app .ker-charts-grid      { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    #ker-fe-app .ker-dashboard-layout { grid-template-columns: minmax(0, 1fr); }
    #ker-fe-app .ker-kpi-row          { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    #ker-fe-app .ker-kpi-row          { grid-template-columns: minmax(0, 1fr); }
}

/* KPI-Werte einzeilig; Hauptwerte verkleinert ker-dashboard.js per
   KER.fitText, Ziel/Ist skaliert mit der Kartenbreite */
#ker-fe-app .ker-kpi-card {
    min-width: 0;
    container-type: inline-size;
}
#ker-fe-app .ker-kpi-main-value {
    white-space: nowrap;
    overflow: hidden;
}
#ker-fe-app .ker-kpi-dual {
    gap: 10px;
}
#ker-fe-app .ker-kpi-dual .ker-soll,
#ker-fe-app .ker-kpi-dual .ker-ist {
    white-space: nowrap;
    font-size: min(20px, 11.5cqi);
}
#ker-fe-app.ker-fe-desktop-view .ker-fe-korrektur {
    margin: 20px;
}
/* Firmenname steht bereits in der Navigationsleiste – nicht doppelt zeigen */
#ker-fe-app .ker-header-firma {
    display: none;
}
#ker-fe-app .ker-header-period {
    margin-left: auto;
}
/* Gegen Theme-Button-Stile absichern (Werte wie in style.css) */
#ker-fe-app .ker-sidebar-actions button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.5);
    color: #fff;
    padding: 2px 6px;
    min-width: 0;
    border-radius: 3px;
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0;
    line-height: normal;
    font-size: 12px;
    cursor: pointer;
}
#ker-fe-app .ker-sidebar-actions button:hover {
    background: rgba(255,255,255,0.2);
}

/* Navigation gegen Theme-Button-Stile absichern (Werte wie oben bei
   .ker-fe-top-nav button und .ker-fe-tab) */
#ker-fe-app .ker-fe-top-nav button {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.45);
    padding: 10px 18px;
    min-width: 0;
    border-radius: 8px;
    box-shadow: none;
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    line-height: normal;
}
#ker-fe-app .ker-fe-top-nav button:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.8);
}
#ker-fe-app .ker-fe-top-nav button.ker-fe-tab--active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
#ker-fe-app .ker-fe-tab {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    min-width: 0;
    padding: 1px 6px;
    color: var(--ker-text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: normal;
}
#ker-fe-app .ker-fe-tab.ker-fe-tab--active {
    color: var(--ker-blue);
}

/* ==========================================
   KER-Tabelle (Erfolgsrechnung im Detail) – gemeinsam für Dashboard und Frontend
   ========================================== */
.ker-fe-tabelle-card { margin-top: 20px; }
.ker-tabelle-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#ker-fe-app .ker-tabelle { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
#ker-fe-app .ker-tabelle th, #ker-fe-app .ker-tabelle td { padding: 5px 8px; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; }
#ker-fe-app .ker-tabelle th { font-weight: 600; color: #555; border-bottom: 2px solid #ddd; }
#ker-fe-app .ker-tabelle .ker-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#ker-fe-app .ker-tabelle .ker-pct { text-align: right; white-space: nowrap; color: #777; width: 56px; font-variant-numeric: tabular-nums; }
#ker-fe-app .ker-tabelle td:nth-child(2), #ker-fe-app .ker-tabelle td:nth-child(4) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#ker-fe-app .ker-tabelle td:nth-child(3), #ker-fe-app .ker-tabelle td:nth-child(5) { text-align: right; color: #777; }
#ker-fe-app .ker-tabelle .ker-t-titel td { font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; color: #888; padding-top: 14px; border-bottom: none; }
#ker-fe-app .ker-tabelle .ker-t-summe td { font-weight: 600; border-top: 1px solid #ccc; }
#ker-fe-app .ker-tabelle .ker-t-ergebnis td { font-weight: 700; background: #f3f6fa; border-top: 2px solid #ccd; }
#ker-fe-app .ker-tabelle .ker-t-konto td { font-size: 12px; color: #666; background: #fafafa; }
#ker-fe-app .ker-tabelle .ker-t-konto td:first-child { padding-left: 28px; }
#ker-fe-app .ker-tabelle .ker-t-toggle { all: unset; cursor: pointer; display: inline-block; }
#ker-fe-app .ker-tabelle .ker-t-toggle:focus-visible { outline: 2px solid #1E90FF; outline-offset: 2px; }
#ker-fe-app .ker-tabelle .ker-t-pfeil { display: inline-block; width: 12px; color: #999; }
#ker-fe-app .ker-tabelle .ker-t-anzahl { color: #aaa; font-size: 11px; }
#ker-fe-app .ker-tabelle-hinweis { font-size: 12px; color: #888; margin: 8px 0 0; }
#ker-fe-app .ker-tabelle-leer { color: #888; }
