/* Datavise CRM — CI-konformes Design */
:root {
    --navy: #1a3a5c;
    --blue: #2563eb;
    --green: #059669;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --muted: #64748b;
    --border: #e2e8f0;
    --red: #dc2626;
    --yellow: #d97706;
    --radius: 8px;
}

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

body {
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* --- Navigation --- */
.nav {
    background: var(--navy);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    color: #fff;
    font-weight: bold;
    font-size: 1.1rem;
    text-decoration: none;
    margin-right: 2rem;
}
.nav-brand span { color: var(--green); }
.nav a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}
.nav a:hover, .nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* --- Layout --- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.kpi-card .value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--navy);
}
.kpi-card .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--navy);
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}
td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}
tr:hover { background: #f1f5f9; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Status Badges --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-neu { background: #dbeafe; color: #1d4ed8; }
.badge-profilert { background: #e0e7ff; color: #4338ca; }
.badge-brief_vorbereitet { background: #fef3c7; color: #92400e; }
.badge-brief_versendet { background: #fed7aa; color: #9a3412; }
.badge-lp_besucht { background: #d1fae5; color: #065f46; }
.badge-opt_in { background: #a7f3d0; color: #047857; }
.badge-gespraech_vereinbart { background: #bbf7d0; color: #166534; }
.badge-angebot { background: #fde68a; color: #92400e; }
.badge-gewonnen { background: #059669; color: #fff; }
.badge-verloren { background: #fca5a5; color: #991b1b; }
.badge-pause { background: #e2e8f0; color: #475569; }
.badge-prospect { background: #e0e7ff; color: #4338ca; }
.badge-kontaktiert { background: #ddd6fe; color: #6d28d9; }
.badge-angebot_gesendet { background: #fde68a; color: #92400e; }
.badge-lead_erstellt { background: #dbeafe; color: #1d4ed8; }
.badge-ausstehend { background: #fef3c7; color: #92400e; }
.badge-freigegeben { background: #d1fae5; color: #065f46; }
.badge-abgelehnt { background: #fca5a5; color: #991b1b; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* --- Forms & Filters --- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: center;
}
select, input[type="text"], input[type="search"], textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
}
select:focus, input:focus, textarea:focus {
    outline: 2px solid var(--blue);
    outline-offset: -1px;
}
textarea { width: 100%; min-height: 80px; resize: vertical; }

/* --- Score Bars --- */
.score-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.score-bar .label { width: 100px; font-size: 0.85rem; color: var(--text-muted); }
.score-bar .bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.score-bar .bar-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 4px;
    transition: width 0.3s;
}
.score-bar .value { font-size: 0.85rem; font-weight: 600; width: 30px; text-align: right; }

/* --- Timeline --- */
.timeline { list-style: none; }
.timeline-item {
    padding: 0.75rem 0 0.75rem 1.5rem;
    border-left: 2px solid var(--border);
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 1rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--blue);
}
.timeline-item .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.timeline-item .content { font-size: 0.9rem; }

/* --- Pipeline Chart --- */
.pipeline-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.pipeline-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.pipeline-bar .label {
    width: 160px;
    font-size: 0.85rem;
    text-align: right;
}
.pipeline-bar .bar {
    flex: 1;
    height: 32px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}
.pipeline-bar .bar-fill {
    height: 100%;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    padding-left: 0.75rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 24px;
    transition: width 0.5s;
}
.pipeline-bar .count {
    font-size: 0.9rem;
    font-weight: 600;
    width: 40px;
}

/* --- Funnel --- */
.funnel { text-align: center; margin: 1.5rem 0; }
.funnel-step {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    margin: 0.25rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

/* --- Freigabe Queue --- */
.queue-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}
.queue-item .badge {
    flex-shrink: 0;
    margin-top: 0.15rem;
}
.queue-item:last-child { border-bottom: none; }

/* --- Detail Grid --- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
.detail-group h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}
.detail-row {
    display: flex;
    padding: 0.4rem 0;
    font-size: 0.9rem;
}
.detail-row .dt {
    width: 160px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.detail-row .dd { flex: 1; }

/* --- Freigabe Section --- */
.freigabe-section {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}
.freigabe-section h3 {
    color: var(--yellow);
    margin-bottom: 1rem;
}
.freigabe-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .nav { flex-wrap: wrap; height: auto; padding: 0.5rem 1rem; }
    .nav-brand { margin-right: auto; }
    .container { padding: 1rem; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .filters { flex-direction: column; }
    table { font-size: 0.8rem; }
    th, td { padding: 0.5rem; }
    .pipeline-bar .label { width: 100px; font-size: 0.75rem; }
}

/* --- Loading & Empty --- */
.loading { text-align: center; padding: 2rem; color: var(--text-muted); }
.empty { text-align: center; padding: 2rem; color: var(--text-muted); font-style: italic; }

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
}
.modal h3 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ===== GLOBAL MOBILE RESPONSIVE (added for mobile support) ===== */
@media (max-width: 768px) {
  /* Nav: horizontal scrollable */
  .nav {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    height: auto !important;
    padding: 0.5rem 0.75rem !important;
    white-space: nowrap !important;
  }
  .nav a {
    font-size: 0.8rem !important;
    padding: 0.4rem 0.6rem !important;
    flex-shrink: 0 !important;
  }
  .nav-brand {
    flex-shrink: 0 !important;
    margin-right: 0.5rem !important;
  }

  /* Modal volle Breite */
  .modal {
    width: 95% !important;
    max-width: 95% !important;
    padding: 1rem !important;
  }

  /* Viewport meta sicherstellen */
  body {
    overflow-x: hidden !important;
  }
}
