/* Levinus Consulting CRM — Design System */

@import url('https://fonts.googleapis.com/css2?family=Lora:wght@500;600;700&family=Work+Sans:wght@400;500;600;700&display=swap');

:root {
    --navy: #202A3F;
    --navy-light: #2B3752;
    --cream: #F5F2EA;
    --gold: #C8A45D;
    --gold-dark: #B08D48;

    --status-neu: #5C7FA6;       --status-neu-bg: #E7EEF5;
    --status-kontakt: #C8A45D;   --status-kontakt-bg: #F6ECD9;
    --status-erstgespraech: #8B6BA8; --status-erstgespraech-bg: #EFE7F3;
    --status-angebot: #C97D4A;   --status-angebot-bg: #F5E2D3;
    --status-kunde: #4F8F63;     --status-kunde-bg: #E1EFE4;

    --success: #4F8F63;
    --success-dark: #356B45;
    --danger: #A2564F;
    --danger-dark: #8A3F38;

    --border: rgba(32, 42, 63, 0.1);
    --border-strong: rgba(32, 42, 63, 0.18);
    --text: #202A3F;
    --text-muted: #667089;

    --radius-card: 10px;
    --radius-input: 7px;
    --radius-pill: 999px;
    --shadow-modal: 0 8px 24px rgba(32, 42, 63, 0.15);

    --sidebar-width: 224px;
    --detail-width: 380px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--cream);
    color: var(--text);
    font-family: 'Work Sans', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: 'Lora', serif;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--navy);
}

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

button { font-family: inherit; cursor: pointer; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .logo-chip {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-family: 'Lora', serif;
    font-weight: 700;
    color: var(--navy);
    overflow: hidden;
}
.sidebar-brand .logo-chip img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-brand .brand-text {
    font-family: 'Lora', serif;
    font-size: 13px;
    line-height: 1.3;
    letter-spacing: 0.04em;
}
.sidebar-brand .brand-text strong { display: block; font-size: 14px; color: var(--gold); }

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 7px;
    color: rgba(255,255,255,0.75);
    font-weight: 500;
    font-size: 13.5px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.sidebar-nav a .nav-icon { width: 18px; text-align: center; }

.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-footer .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--gold); color: var(--navy);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12.5px; flex: none;
}
.sidebar-footer .who { line-height: 1.3; }
.sidebar-footer .who strong { display: block; font-size: 13px; }
.sidebar-footer .who span { font-size: 11.5px; color: rgba(255,255,255,0.55); }
.sidebar-footer form { margin-left: auto; }
.sidebar-footer .logout-btn {
    background: none; border: none; color: rgba(255,255,255,0.5); font-size: 16px;
}
.sidebar-footer .logout-btn:hover { color: #fff; }

/* ---------- Main ---------- */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--cream);
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.search-input {
    width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-input);
    background: #fff;
    font-size: 13px;
}
.bell {
    width: 34px; height: 34px; border-radius: 50%;
    background: #fff; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
}

.content {
    flex: 1;
    display: flex;
    gap: 22px;
    padding: 24px 28px;
    align-items: flex-start;
}
.content-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 18px;
}

.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kpi-card { display: flex; align-items: center; gap: 14px; }
.kpi-icon {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex: none;
}
.kpi-icon.hue-1 { background: var(--status-neu-bg); color: var(--status-neu); }
.kpi-icon.hue-2 { background: var(--status-angebot-bg); color: var(--status-angebot); }
.kpi-icon.hue-3 { background: var(--status-erstgespraech-bg); color: var(--status-erstgespraech); }
.kpi-value { font-family: 'Lora', serif; font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.kpi-delta { font-size: 11.5px; color: var(--success-dark); margin-top: 4px; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: rgba(200,164,93,0.06); }
.data-table tr.selected { background: rgba(200,164,93,0.12); }
.cell-name { font-weight: 600; color: var(--navy); }
.cell-sub { color: var(--text-muted); font-size: 12px; }

.pill {
    display: inline-block; padding: 4px 11px; border-radius: var(--radius-pill);
    font-size: 12px; font-weight: 600;
}

.pagination { display: flex; justify-content: flex-end; gap: 6px; padding: 12px; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; border-radius: 6px; font-size: 12.5px;
    border: 1px solid var(--border); color: var(--text);
}
.pagination a:hover { background: var(--cream); text-decoration: none; }
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 7px; border: 1px solid transparent;
    font-size: 13.5px; font-weight: 600;
}
.btn-primary { background: var(--gold); color: var(--navy); }
.btn-primary:hover { background: var(--gold-dark); text-decoration: none; }
.btn-secondary { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--cream); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); text-decoration: none; }
.btn-text { background: none; border: none; color: var(--gold-dark); font-weight: 600; padding: 4px 6px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=search],
textarea, select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-input);
    font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error { color: var(--danger-dark); font-size: 12px; margin-top: 4px; }
.field-hint { color: var(--text-muted); font-size: 11.5px; margin-top: 4px; }

/* ---------- Status filter pills ---------- */
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-pill {
    padding: 7px 14px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
    background: #fff; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
.filter-pill.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter-pill .count { opacity: 0.7; margin-left: 4px; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-input); overflow: hidden; }
.segmented a { padding: 7px 16px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); background: #fff; }
.segmented a.active { background: var(--navy); color: #fff; }
.segmented a:hover { text-decoration: none; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.kanban-col { background: rgba(32,42,63,0.03); border-radius: var(--radius-card); padding: 12px; min-height: 120px; }
.kanban-col-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kanban-col.drag-over { background: rgba(200,164,93,0.12); outline: 2px dashed var(--gold); }
.kanban-card {
    background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
    cursor: grab; font-size: 13px;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .cell-name { display: block; }
.kanban-card .cell-sub { display: block; margin-top: 2px; }

/* ---------- Detail Panel ---------- */
.detail-panel {
    width: var(--detail-width); flex: none; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius-card); position: sticky; top: 88px; max-height: calc(100vh - 110px);
    overflow-y: auto;
}
.detail-panel.empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); min-height: 200px; text-align: center; padding: 30px; }
.detail-header { display: flex; align-items: center; gap: 12px; padding: 18px; border-bottom: 1px solid var(--border); }
.detail-header .avatar {
    width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: var(--gold);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: none;
}
.detail-header .who { flex: 1; min-width: 0; }
.detail-header .who strong { display: block; font-size: 15px; color: var(--navy); }
.detail-header .who span { font-size: 12px; color: var(--text-muted); }
.icon-btn { background: none; border: none; font-size: 16px; color: var(--text-muted); padding: 4px; }
.icon-btn:hover { color: var(--danger); }
.icon-btn.close-btn:hover { color: var(--navy); }

.detail-section { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }
.detail-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.detail-section-header h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-family: 'Work Sans', sans-serif; font-weight: 700; }
.kv-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13px; }
.kv-row .k { color: var(--text-muted); flex: none; padding-top: 4px; }
.kv-row .v { text-align: right; font-weight: 500; flex: 1; }
.detail-section .kv-edit { display: none; }
.detail-section.editing .kv-view { display: none; }
.detail-section.editing .kv-edit { display: inline-block; width: 100%; text-align: left; }
.addr-edit-fields { display: flex; flex-direction: column; gap: 4px; }
.detail-section.editing .kv-edit.addr-edit-fields { display: flex; }

.note-signature { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

.doc-item { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.doc-item:last-child { border-bottom: none; }
.doc-item .doc-meta { color: var(--text-muted); font-size: 11.5px; }
.upload-drop {
    margin-top: 10px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-input);
    padding: 16px; text-align: center; font-size: 12.5px; color: var(--text-muted); position: relative;
}
.upload-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.verlauf-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.verlauf-item:last-child { border-bottom: none; }
.verlauf-icon { flex: none; }
.verlauf-item .meta { color: var(--text-muted); font-size: 11.5px; }

.detail-footer { padding: 14px 18px; font-size: 11.5px; color: var(--text-muted); }

/* ---------- Wiedervorlagen due labels ---------- */
.due-overdue { color: var(--danger-dark); font-weight: 600; }
.due-today { color: var(--gold-dark); font-weight: 600; }
.due-future { color: var(--text-muted); font-weight: 500; }

/* ---------- Verlauf feed ---------- */
.feed-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--cream); display: flex; align-items: center; justify-content: center; flex: none; font-size: 15px; }
.feed-title { font-weight: 600; color: var(--navy); }
.feed-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.feed-note { margin-top: 4px; font-size: 13px; }

/* ---------- Connection status cards ---------- */
.status-card { display: flex; align-items: center; gap: 12px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); flex: none; }
.status-dot.off { background: var(--text-muted); }
.status-card .info strong { display: block; font-size: 13.5px; color: var(--navy); }
.status-card .info span { font-size: 12px; color: var(--text-muted); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(32,42,63,0.45); display: none;
    align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-modal);
    width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.mapping-table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.mapping-table td { padding: 8px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.mapping-table td.arrow { color: var(--text-muted); text-align: center; width: 30px; }
.mapping-table td.lex-field { color: var(--gold-dark); font-weight: 600; text-align: right; }
.export-spinner { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 30px 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.export-success { text-align: center; padding: 10px 0; }
.export-success .check { width: 52px; height: 52px; border-radius: 50%; background: var(--status-kunde-bg); color: var(--success-dark); display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 14px; }
.confirm-line { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 13px; margin-top: 6px; color: var(--text); }

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 340px; background: #fff; border-radius: var(--radius-card); padding: 30px 26px; box-shadow: var(--shadow-modal); }
.login-logo { display: block; max-width: 100%; margin: 0 auto 22px; }
.login-card .field { margin-bottom: 16px; }
.login-links { text-align: center; margin-top: 16px; font-size: 12.5px; }
.login-error { background: var(--status-angebot-bg); color: var(--danger-dark); border-radius: var(--radius-input); padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }
.login-info { background: var(--status-kunde-bg); color: var(--success-dark); border-radius: var(--radius-input); padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }

/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.flex-gap { display: flex; gap: 8px; align-items: center; }
.hidden { display: none !important; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

@media (max-width: 1100px) {
    .detail-panel { display: none; }
    .kpi-row { grid-template-columns: 1fr; }
    .kanban { grid-template-columns: 1fr 1fr; }
}
