/* ============================================================
   HIGHLIGHT LEAD-MANAGEMENT  -  STYLES
   Weiss / Schwarz / Magenta (#fe25c7), Mobile-First
   ============================================================ */

:root {
    --magenta: #fe25c7;
    --magenta-dark: #d4159f;
    --bg: #ffffff;
    --sidebar-bg: #ffffff;
    --text: #111111;
    --muted: #6b6b6b;
    --border: #e6e6e6;
    --hover: #f5f5f5;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;

    --status-offen: #fe25c7;
    --status-handlungsbedarf: #ff7a00;
    --status-bearbeitung: #2b7cff;
    --status-abgeschlossen: #2bbf6a;
    --status-kein: #9a9a9a;

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

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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--magenta); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--magenta); color: #fff; border: none;
    padding: 12px 20px; border-radius: 10px; font-weight: 600; font-size: 15px;
    transition: background .15s ease;
}
.btn:hover { background: var(--magenta-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-outline {
    background: #fff; color: var(--text); border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--hover); }
.btn-danger { background: #e23b3b; }
.btn-danger:hover { background: #c42f2f; }
.btn-sm { padding: 8px 14px; font-size: 14px; border-radius: 8px; }

/* ---------- FORMS ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 16px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--magenta);
    box-shadow: 0 0 0 3px rgba(254,37,199,0.12);
}
.field textarea { min-height: 90px; resize: vertical; }

/* ---------- ALERTS ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fde8e8; color: #a51e1e; }
.alert-success { background: #e6f7ee; color: #1a7a44; }
.alert-info { background: #eef3ff; color: #2b5bbf; }

/* ============================================================
   LOGIN / SETUP (zentrierte Karte)
   ============================================================ */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background: #fafafa;
}
.auth-card {
    width: 100%; max-width: 420px; background: #fff;
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 28px;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo img { max-height: 48px; width: auto; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.totp-code-input {
    letter-spacing: 8px; text-align: center; font-size: 24px !important; font-weight: 700;
}
.app-open-row { display: flex; gap: 10px; margin: 14px 0; }
.app-open-row .btn { flex: 1; }

.secret-box {
    display: flex; align-items: center; gap: 8px; background: var(--hover);
    border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; margin: 12px 0;
}
.secret-box code { font-size: 15px; font-weight: 700; letter-spacing: 1px; word-break: break-all; flex: 1; }
.qr-holder { text-align: center; margin: 18px 0; }
.qr-holder canvas, .qr-holder img { border: 1px solid var(--border); border-radius: 10px; padding: 8px; background:#fff; }

/* ============================================================
   APP-LAYOUT (Sidebar + Content)
   ============================================================ */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
    background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; z-index: 40;
}
.app-header .logo img { max-height: 34px; width: auto; display: block; }
.hamburger {
    background: none; border: none; width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.hamburger:hover { background: var(--hover); }
.hamburger span {
    display: block; position: relative; width: 22px; height: 2px; background: var(--text);
}
.hamburger span::before, .hamburger span::after {
    content: ""; position: absolute; left: 0; width: 22px; height: 2px; background: var(--text);
}
.hamburger span::before { top: -7px; }
.hamburger span::after { top: 7px; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: var(--sidebar-bg); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
}
.sidebar.open { transform: translateX(0); }
.sidebar-head {
    height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
    padding: 0 18px; border-bottom: 1px solid var(--border);
}
.sidebar-head img { max-height: 34px; }
.sidebar-close { background: none; border: none; font-size: 26px; line-height: 1; color: var(--muted); }

/* ---------- Standort-Picker (iOS-Stil) ---------- */
.loc-switch { padding: 14px 14px; border-bottom: 1px solid var(--border); }
.loc-switch .loc-label { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .04em; margin: 0 4px 8px; display: block; }
.loc-trigger {
    width: 100%; display: flex; align-items: center; gap: 10px;
    background: #f2f2f7; border: none; border-radius: 12px;
    padding: 12px 14px; text-align: left; color: var(--text);
    font-size: 15px; font-weight: 600; transition: background .15s ease;
}
.loc-trigger:active { background: #e9e9ef; }
.loc-trigger .pin { width: 18px; height: 18px; flex: none; color: var(--magenta); }
.loc-trigger .loc-current { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-trigger .chev-d { width: 18px; height: 18px; flex: none; color: #b8b8bf; }

/* Overlay + Sheet */
.loc-sheet-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 95; opacity: 0; visibility: hidden; transition: opacity .2s ease;
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.loc-sheet-overlay.show { opacity: 1; visibility: visible; }

.loc-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 96;
    background: #f7f7f8; border-radius: 20px 20px 0 0;
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
    transform: translateY(110%); transition: transform .28s cubic-bezier(.32,.72,0,1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
    pointer-events: none;
}
.loc-sheet.open { transform: translateY(0); pointer-events: auto; }
.loc-sheet-handle {
    width: 38px; height: 5px; border-radius: 3px; background: #d2d2d7;
    margin: 8px auto 12px;
}
.loc-sheet-title {
    text-align: center; font-size: 13px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px;
}
.loc-options { background: #fff; border-radius: 14px; overflow: hidden; }
.loc-option {
    width: 100%; display: flex; align-items: center; gap: 10px;
    background: #fff; border: none; padding: 15px 16px; text-align: left;
    font-size: 17px; color: var(--text); border-bottom: 1px solid #ececee;
}
.loc-option:last-child { border-bottom: none; }
.loc-option:active { background: #f2f2f7; }
.loc-option .check { width: 20px; height: 20px; flex: none; margin-left: auto; color: var(--magenta); opacity: 0; }
.loc-option.selected { font-weight: 700; }
.loc-option.selected .check { opacity: 1; }
.loc-sheet-cancel {
    width: 100%; background: #fff; border: none; border-radius: 14px;
    padding: 15px; margin-top: 10px; font-size: 17px; font-weight: 700;
    color: var(--magenta);
}
.loc-sheet-cancel:active { background: #f2f2f7; }

.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav a {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    color: var(--text); border-radius: 10px; font-weight: 600; font-size: 15px; margin-bottom: 2px;
}
.nav a:hover { background: var(--hover); }
.nav a.active { background: rgba(254,37,199,0.10); color: var(--magenta); }
.ico { width: 22px; height: 22px; flex: none; }
.nav a .ico { width: 22px; height: 22px; flex: none; }
.nav a .badge {
    margin-left: auto; background: var(--magenta); color: #fff; font-size: 12px;
    font-weight: 700; border-radius: 999px; padding: 2px 8px; min-width: 22px; text-align: center;
}

.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 10px; }
.sidebar-foot .user-line { padding: 8px 14px; font-size: 14px; color: var(--muted); }
.sidebar-foot .user-line strong { color: var(--text); display: block; font-size: 15px; }
.sidebar-foot a { display: flex; align-items: center; gap: 9px; padding: 9px 14px; color: var(--text); border-radius: 10px; font-weight: 500; font-size: 14px; }
.sidebar-foot a:hover { background: var(--hover); }
.sidebar-foot a.logout { color: var(--muted); }
.sidebar-foot a.logout:hover { color: #e23b3b; }
.sidebar-foot a.logout .ico { width: 15px; height: 15px; }

.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 50;
    opacity: 0; visibility: hidden; transition: opacity .2s ease;
}
.overlay.show { opacity: 1; visibility: visible; }

.content {
    padding: calc(var(--header-h) + 18px) 16px 40px;
    max-width: 1100px; margin: 0 auto;
}
.page-title { font-size: 22px; font-weight: 800; margin-bottom: 18px; }

/* ---------- CARDS / DASHBOARD ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow); text-decoration: none; color: var(--text); display: block;
}
.stat-card .num { font-size: 30px; font-weight: 800; }
.stat-card .lbl { color: var(--muted); font-size: 14px; margin-top: 4px; }
.stat-card.accent .num { color: var(--magenta); }

/* ---------- KAMPAGNEN-TOGGLE ---------- */
.campaign {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.campaign-head {
    display: flex; align-items: center; gap: 12px; padding: 16px 18px;
    cursor: pointer; user-select: none;
}
.campaign-head .chev { transition: transform .2s ease; color: var(--muted); }
.campaign.open .campaign-head .chev { transform: rotate(90deg); }
.campaign-head .c-name { font-weight: 700; font-size: 16px; flex: 1; }
.campaign-head .c-badge {
    background: var(--magenta); color: #fff; font-weight: 700; font-size: 13px;
    border-radius: 999px; padding: 3px 10px; min-width: 24px; text-align: center;
}
.campaign-head .c-badge.zero { background: #e6e6e6; color: var(--muted); }
.campaign-body { display: none; border-top: 1px solid var(--border); }
.campaign.open .campaign-body { display: block; }

/* ---------- LEAD-ZEILE ---------- */
.lead-row {
    display: flex; align-items: center; gap: 12px; padding: 14px 18px;
    border-bottom: 1px solid var(--border); cursor: pointer;
}
.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: var(--hover); }
.lead-name { font-weight: 600; flex: 1; }
.lead-name small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }

.status-pill {
    font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
    color: #fff; white-space: nowrap;
}
.status-offen { background: var(--status-offen); }
.status-handlungsbedarf { background: var(--status-handlungsbedarf); }
.status-in_bearbeitung { background: var(--status-bearbeitung); }
.status-abgeschlossen { background: var(--status-abgeschlossen); }
.status-kein_interesse { background: var(--status-kein); }

/* ---------- SLIDEOVER (Lead-Detail) ---------- */
.slideover {
    position: fixed; top: 0; right: 0; bottom: 0; width: 100%; max-width: 460px;
    background: #fff; z-index: 80; box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    transform: translateX(100%); transition: transform .25s ease;
    display: flex; flex-direction: column;
}
.slideover.open { transform: translateX(0); }
.slideover-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px; border-bottom: 1px solid var(--border);
}
.slideover-head h3 { font-size: 18px; }
.slideover-close { background: none; border: none; font-size: 28px; color: var(--muted); line-height: 1; }
.slideover-body { padding: 18px; overflow-y: auto; flex: 1; }
.detail-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-row .k { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.detail-row .v { font-size: 16px; margin-top: 3px; word-break: break-word; }
.detail-row .v a { font-weight: 600; }

/* ---------- TABELLE (Mitarbeiter) ---------- */
.table-card { background:#fff; border:1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow:hidden; }
.emp-row { display:flex; align-items:center; gap:12px; padding:14px 18px; border-bottom:1px solid var(--border); }
.emp-row:last-child { border-bottom:none; }
.emp-info { flex:1; }
.emp-info strong { display:block; }
.emp-info small { color: var(--muted); }
.emp-actions { display:flex; gap:8px; }
.role-tag { font-size:12px; font-weight:700; padding:3px 9px; border-radius:999px; background: var(--hover); color: var(--muted); }
.device-tag { font-size:12px; color: var(--muted); }
.device-tag.linked { color: var(--status-abgeschlossen); font-weight:600; }

/* ---------- MODAL ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 90;
    display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
    background:#fff; border-radius: var(--radius); width: 100%; max-width: 460px;
    padding: 24px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 18px; }
.modal-actions { display:flex; gap:10px; margin-top: 8px; }
.modal-actions .btn { flex:1; }

.empty { text-align:center; color: var(--muted); padding: 40px 20px; }

.leads-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.leads-top .btn { white-space: nowrap; }

/* ============================================================
   DESKTOP
   ============================================================ */
@media (min-width: 900px) {
    .app-header { display: none; }
    .hamburger, .sidebar-close { display: none; }
    .sidebar { transform: translateX(0); }
    .overlay { display: none !important; }
    .content { margin-left: var(--sidebar-w); padding-top: 30px; max-width: none; }
    .content-inner { max-width: 1100px; margin: 0 auto; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }

    /* Standort-Picker auf Desktop als Popover statt Bottom-Sheet */
    .loc-sheet-overlay { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
    .loc-sheet {
        position: absolute; left: 14px; right: auto; top: 92px; bottom: auto;
        width: calc(var(--sidebar-w) - 28px);
        border-radius: 14px; padding: 8px;
        transform: translateY(-8px) scale(.98); transform-origin: top center;
        opacity: 0; transition: opacity .15s ease, transform .15s ease;
        box-shadow: 0 12px 40px rgba(0,0,0,0.18); border: 1px solid var(--border);
    }
    .loc-sheet.open { transform: translateY(0) scale(1); opacity: 1; }
    .loc-sheet-handle { display: none; }
    .loc-sheet-title { display: none; }
    .loc-option { font-size: 15px; padding: 11px 12px; }
    .loc-sheet-cancel { display: none; }
}