/* Placetel-Anrufliste – App-Styles (ergänzend zum DevExtreme-Light-Theme). */

:root {
    --brand: #1b5e9c;
    --brand-dark: #154b7d;
    --bg: #f1f4f8;
    --card: #ffffff;
    --text: #1f2733;
    --muted: #6b7785;
    --danger: #c0392b;
    --border: #dde3ea;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

/* ── Boot-Hinweis ─────────────────────────────────────────────────────────── */
.boot {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 15px;
}

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-view {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border-radius: 16px;
    padding: 28px 24px 24px;
    box-shadow: 0 10px 40px rgba(20, 40, 70, 0.12);
}

.login-logo { font-size: 40px; text-align: center; }
.login-card h1 { margin: 6px 0 2px; text-align: center; font-size: 22px; }
.login-sub { margin: 0 0 20px; text-align: center; color: var(--muted); font-size: 13px; }

.login-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 12px 0 4px;
    color: var(--muted);
}

.login-card input {
    width: 100%;
    padding: 11px 12px;
    font-size: 16px; /* >=16px verhindert iOS-Zoom beim Fokus */
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfe;
}
.login-card input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(27, 94, 156, 0.15);
}

/* Passwortfeld mit Anzeigen/Verbergen-Umschalter. */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 96px; }
.pass-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    padding: 0 12px;
    border: none;
    background: transparent;
    color: var(--brand);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.pass-toggle:hover { text-decoration: underline; }

.btn-primary {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--brand);
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.login-msg {
    margin-top: 14px;
    min-height: 18px;
    font-size: 13px;
    color: var(--danger);
    text-align: center;
}

/* Direkter APK-Download (nur Android, vor Installation sichtbar). */
.apk-link {
    display: block;
    margin-top: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
    text-decoration: none;
}
.apk-link:hover { text-decoration: underline; }

/* ── App-Layout ───────────────────────────────────────────────────────────── */
.app-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--brand);
    color: #fff;
}
.app-title { font-weight: 600; font-size: 17px; }
.app-spacer { flex: 1; }
.app-user { font-size: 13px; opacity: 0.9; }
.key-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.28); }
.btn-ghost.is-active { background: rgba(255, 255, 255, 0.34); }
.btn-icon { font-size: 15px; }

/* ── Menü (Dropdown im Header) ────────────────────────────────────────────── */
.menu-wrap { position: relative; display: inline-flex; }

/* Hamburger-Icon per CSS (keine Schrift-Abhängigkeit). */
.hamburger {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}
.hamburger::before,
.hamburger::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}
.hamburger::before { top: -6px; }
.hamburger::after  { top: 6px; }

.menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 210px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(20, 40, 70, 0.15);
}
.menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 13px 16px;
    background: transparent;
    border: none;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
}
.menu-item + .menu-item { border-top: 1px solid var(--border); }
.menu-item:hover { background: var(--bg); }
.menu-item.active { color: var(--brand); font-weight: 600; }

/* ── Seiten/Views ─────────────────────────────────────────────────────────── */
.view { flex: 1; min-height: 0; }
.page { overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px; }
.page-title { font-size: 18px; font-weight: 600; margin: 4px 0 16px; }
.page-empty { color: var(--muted); }

.opt-block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    max-width: 480px;
}
.opt-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.opt-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
#opt-apply { margin-top: 16px; }

/* ── Voicemail-Liste ──────────────────────────────────────────────────────── */
.vm-range { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.vm-list { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.vm-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
.vm-item.vm-unread { border-left: 4px solid var(--brand); }
.vm-head { display: flex; align-items: baseline; gap: 10px; }
.vm-from { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; min-width: 0;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vm-time { font-size: 13px; color: var(--muted); flex: none; }
.vm-sub  { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.vm-audio { width: 100%; height: 36px; }
.vm-badge { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600;
            color: var(--brand); }

/* iOS-Installationshilfe (dxPopup-Inhalt). */
.ios-help { font-size: 14px; line-height: 1.5; }
.ios-help ol { margin: 8px 0; padding-left: 20px; }
.ios-help li { margin: 4px 0; }
.ios-help-note { color: var(--muted); font-size: 13px; }

.toolbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
}
.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-actions { align-self: flex-end; }

.numbers-block { margin-top: 14px; }
.numbers-head {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}
.numbers-head a { color: var(--brand); text-decoration: none; }
.numbers-head a:hover { text-decoration: underline; }

.numbers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px 14px;
}

.grid-wrap {
    flex: 1;
    min-height: 0;
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
}
.status {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
    min-height: 18px;
}
.status.error { color: var(--danger); }
#grid {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;            /* rundet auch die Tabelleninhalte mit ab */
    background: #fff;
}

/* ── Anrufprotokoll-Liste (nur Handy, statt der Tabelle) ───────────────────── */
.calllist {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.cl-group {
    font-size: 12px;
    color: var(--muted);
    padding: 12px 14px 6px;
    background: var(--bg);
}
.cl-row {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    cursor: pointer;
}
.cl-group + .cl-row { border-top: none; }
.cl-row:active { background: #eef2f7; }
.cl-row-top { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.cl-audio { width: 100%; height: 34px; margin-top: 8px; }
.cl-call {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #e8f5e9;
    color: #1b8a3a;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.cl-call:active { background: #cdeccf; }
.cl-pick-ov {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.cl-pick {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.cl-pick-h {
    font-weight: 600;
    font-size: 15px;
    margin: 4px 4px 12px;
}
.cl-pick-opt {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f7f9fc;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
}
.cl-pick-opt:active { background: #eef2f7; }
.cl-pick-lbl { font-weight: 600; }
.cl-pick-num { font-size: 13px; color: var(--muted, #667); }
.cl-pick-cancel {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--muted, #667);
    padding: 10px;
    font-size: 15px;
    cursor: pointer;
}

/* ── Fehler-/Hinweis-Einblendung (Toast) ──────────────────────────────────── */
.app-toast {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 2000;
    background: #1f2937;
    color: #fff;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 40vh;
    overflow: auto;
    cursor: pointer;
}
.app-toast.error { background: #b3261e; }

/* ── Kundenverwaltung ─────────────────────────────────────────────────────── */
.cust-list { display: flex; flex-direction: column; gap: 10px; }
.cust-empty { color: var(--muted, #667); padding: 16px 4px; }
.cust-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.cust-card.open { border-color: #b9c6d6; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); }
.cust-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
}
.cust-head:active { background: #eef2f7; }
.cust-main { flex: 1 1 auto; min-width: 0; }
.cust-nm { font-weight: 600; font-size: 15px; }
.cust-sub {
    margin-top: 3px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 13px;
    color: var(--muted, #667);
}
.cust-lic::before { content: "🔑 "; }
.cust-srv::before { content: "✉ "; }
.cust-meta { flex: 0 0 auto; text-align: right; }
.cust-bis { font-size: 12px; color: var(--muted, #667); white-space: nowrap; }
.cust-caret { font-size: 13px; color: #9aa7b5; transition: transform 0.15s; }
.cust-card.open .cust-caret { transform: rotate(180deg); }
.cust-contacts { border-top: 1px solid var(--border); background: #fafbfd; }
.cust-ct-load, .cust-ct-empty { padding: 12px 14px; color: var(--muted, #667); font-size: 14px; }
.ct-item { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ct-item:last-child { border-bottom: none; }
.ct-nm { font-weight: 600; }
.ct-fn { font-size: 13px; color: var(--muted, #667); margin-top: 1px; }
.ct-rows { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.ct-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #14589c;
    text-decoration: none;
    font-size: 14px;
    word-break: break-all;
}
.ct-ico { flex: 0 0 auto; width: 18px; text-align: center; color: #6b7a89; }
button.ct-line {
    background: none;
    border: none;
    margin: 0;
    padding: 0;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    width: 100%;
}
button.ct-line:active { opacity: 0.6; }
.cl-av {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-size: 20px;
    line-height: 1;
}
.cl-av.ok   { background: #e1f5ee; color: #0f6e56; }
.cl-av.miss { background: #fcebeb; color: #a32d2d; }
.cl-av.canc { background: #faeeda; color: #854f0b; }
.cl-av.unk  { background: #eef1f5; color: var(--muted); }
.cl-arrow   { color: var(--muted); font-weight: 400; }
.cl-main { flex: 1; min-width: 0; }
.cl-nm {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
}
.cl-sub {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.cl-partner { font-size: 12px; opacity: 0.85; }
.cl-meta { text-align: right; flex: none; padding-left: 4px; }
.cl-tm { font-size: 13px; color: var(--muted); }
.cl-dur { font-size: 12px; color: var(--muted); opacity: 0.85; margin-top: 1px; }
.cl-empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── Mobil ────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .app-title { font-size: 16px; }
    .app-user { display: none; }

    /* Header schlank halten: Key-Status ausblenden, Buttons nur als Symbol. */
    .key-badge { display: none; }
    .app-header { gap: 6px; }
    .btn-ghost { padding: 8px; gap: 0; }
    .btn-ghost .btn-label { display: none; }
    .btn-icon { font-size: 18px; }

    /* Datumsboxen/Toolbar in der Handyansicht ausblenden (Standard: heute). */
    .toolbar { display: none; }

    .grid-wrap { padding: 8px 8px 12px; }

    /* DataGrid kompakter, damit alle 4 Spalten ohne H-Scroll passen */
    #grid .dx-datagrid .dx-row > td,
    #grid .dx-datagrid .dx-header-row > td {
        padding-left: 6px;
        padding-right: 6px;
        font-size: 13px;
    }
    #grid .dx-datagrid-headers {
        font-size: 12px;
    }
}

/* ── Passkey-Anmeldung ──────────────────────────────────────────────────────── */
.login-or {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin: 14px 0 12px;
}
.login-or::before,
.login-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}
.login-or span { padding: 0 10px; }

.btn-passkey {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--brand);
    border-radius: 8px;
    background: var(--card);
    color: var(--brand);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn-passkey:hover { background: var(--bg); }
.btn-passkey:disabled { opacity: 0.6; cursor: default; }

.opt-hint { margin: 4px 0 12px; color: var(--muted); font-size: 13px; }

.passkey-list { margin: 8px 0 12px; }
.passkey-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.passkey-name { font-size: 14px; color: var(--text); }

.passkey-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.passkey-label { font-size: 14px; font-weight: 600; color: var(--text); }
.passkey-meta { font-size: 12px; color: var(--muted); }

.passkey-row .btn-ghost,
.passkey-row .btn-ghost.passkey-del { flex: none; color: var(--danger); }
