/* Newsletter Studio – Neutrales, modernes UI (Mailchimp/Linear-inspiriert) */
:root {
    --accent: #2563EB;
    --accent-soft: color-mix(in srgb, var(--accent) 10%, #FFFFFF);
    --accent-hover: color-mix(in srgb, var(--accent) 88%, #000000);
    --bg: #F8F9FB;
    --surface: #FFFFFF;
    --surface-subtle: #F3F4F6;
    --border: #E5E7EB;
    --border-strong: #D1D5DB;
    --text: #111827;
    --text-muted: #6B7280;
    --text-faint: #9CA3AF;
    --success: #059669;
    --success-bg: #ECFDF5;
    --warning: #D97706;
    --warning-bg: #FFFBEB;
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
    --sidebar-w: 248px;
    --bottom-bar-h: 64px;
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-x: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

.boot-loader {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth / Setup Screen */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.brand-dot {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
    overflow: hidden;
}
.brand-dot.has-logo {
    background: #FFFFFF;
    border: 1px solid var(--border);
    padding: 3px;
}
.brand-dot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.auth-title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.auth-sub {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* Main App Layout */
.layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
}
.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.tenant-switcher {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}
.tenant-switcher:hover {
    border-color: var(--border-strong);
    background: var(--bg);
}
.tenant-switcher-info {
    min-width: 0;
    flex: 1;
}
.tenant-switcher-name {
    display: block;
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tenant-switcher-domain {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tenant-dropdown {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    padding: 4px;
    display: none;
}
.tenant-dropdown.open { display: block; }
.tenant-opt {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
}
.tenant-opt:hover { background: var(--surface-subtle); }
.tenant-opt.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tenant-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    padding: 12px 10px 6px;
}
.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 0;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, color 0.12s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }
.nav-item:hover { background: var(--surface-subtle); color: var(--text); }
.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.nav-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-subtle);
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
    flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--text-muted); }

/* Main Content */
.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.page-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mobile-menu-btn {
    display: none;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.content {
    padding: 28px;
    max-width: 1160px;
    width: 100%;
    margin: 0 auto;
}

/* Cards & Grid */
.grid-kpi {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    align-items: stretch;
}
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 20px; }
.grid-kpi > .card, .grid-2 > .card { margin-top: 0; }

.dash-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.dash-hero-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Kompakte iOS-PWA Installationsanimation */
.ios-anim-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin: 14px 0;
}
.ios-anim-bar {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 18px;
    box-shadow: var(--shadow-sm);
}
.ios-share-pulse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    animation: iosPulse 1.8s ease-in-out infinite;
}
@keyframes iosPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.14); }
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.card-sub {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; }
.kpi-meta { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* Checklist */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.checklist-item:hover { border-color: var(--border-strong); background: var(--bg); }
.check-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: transparent;
}
.checklist-item.done .check-circle {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.checklist-item.done .check-label { color: var(--text-muted); text-decoration: line-through; }

/* Forms & Buttons */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 500; color: var(--text); }
.field-hint { font-size: 12px; color: var(--text-muted); }
.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 92px; resize: vertical; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-picker { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; cursor: pointer; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 7px 10px; }
.btn-ghost:hover { background: var(--surface-subtle); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--surface-subtle);
    color: var(--text-muted);
}
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

/* Empty / Phase Notice */
.empty-box {
    text-align: center;
    padding: 40px 24px;
    color: var(--text-muted);
}
.empty-box svg { width: 36px; height: 36px; color: var(--text-faint); margin-bottom: 10px; }
.empty-box h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.empty-box p { margin: 0 auto; max-width: 440px; font-size: 13.5px; }

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 80;
}
.modal-backdrop.open { display: flex; }
.modal {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.modal-title { margin: 0; font-size: 16px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Toast */
.toast-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--text);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    box-shadow: var(--shadow-md);
}
.toast-error { background: var(--danger); }

/* Subtabs, Filter & Pager */
.subtabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    overflow-x: auto;
    padding-bottom: 2px;
}
.subtab {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.subtab:hover { border-color: var(--border-strong); color: var(--text); }
.subtab.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.filter-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
@media (max-width: 768px) {
    .filter-bar { grid-template-columns: 1fr 1fr; }
    .filter-bar > :first-child { grid-column: 1 / -1; }
}

/* Mobile Bottom Bar & Slide-In Drawer */
.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.4);
    z-index: 35;
}
.drawer-backdrop.open { display: block; }

.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 30;
}
.bottom-nav-inner {
    height: var(--bottom-bar-h);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}
.bottom-nav-btn {
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}
.bottom-nav-btn svg { width: 20px; height: 20px; }
.bottom-nav-btn.active { color: var(--accent); font-weight: 600; }

@media (max-width: 960px) {
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        width: 276px;
    }
    .sidebar.open { transform: translateX(0); }
    .main-wrap {
        margin-left: 0;
        padding-bottom: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px) + 12px);
    }
    .topbar { padding: 0 16px; }
    .mobile-menu-btn { display: inline-flex; }
    .content { padding: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .bottom-nav { display: block; }
    .toast-root { bottom: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px) + 12px); right: 12px; left: 12px; }
}
