/* conturam Design-Tokens, Quelle: Vertrieb/Branding/Claude-Design-Test/conturam-design-tokens.json
   Fürs Arbeitswerkzeug angepasst: warmer Seitenhintergrund, weiße Karten, spürbare Interaktion.
   Grundsatz von Damian: Text ist schwarz. Hierarchie entsteht über Größe und Gewicht, nicht über Grau. */
:root {
    --akzent: #ed2c1e;
    --ink: #111111;
    --text: #1d1d1d;
    --linie: #e8e8e8;
    --flaeche-hell: #faf7f7;
    --seite: #f6f3f1;
    --karte: #ffffff;
    --schatten: 0 1px 2px rgba(17, 17, 17, 0.05), 0 4px 14px rgba(17, 17, 17, 0.05);
    --schatten-hover: 0 2px 4px rgba(17, 17, 17, 0.07), 0 8px 22px rgba(17, 17, 17, 0.08);
    --radius: 10px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    font-family: Inter, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--seite);
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

a { color: var(--ink); text-decoration-color: var(--linie); }
a:hover { text-decoration-color: var(--akzent); }
a.ext { text-decoration: underline; text-decoration-color: var(--ink); text-underline-offset: 2px; }
a.ext:hover { color: var(--akzent); text-decoration-color: var(--akzent); }

/* ---------- Kopfzeile ---------- */
.topbar {
    background: var(--karte);
    border-bottom: 1px solid var(--linie);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding: 0.85rem 1.5rem;
}
.wordmark {
    font-weight: 700;
    font-size: 1.45rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
}
.wordmark-by { font-weight: 400; font-size: 1.05rem; }
.wordmark-brand { color: var(--akzent); }

.topsearch { flex: 1; display: flex; justify-content: center; min-width: 200px; position: relative; }
#suggest {
    position: absolute;
    top: calc(100% + 6px);
    width: 100%;
    max-width: 380px;
    background: var(--karte);
    border: 1px solid var(--linie);
    border-radius: 10px;
    box-shadow: var(--schatten-hover);
    overflow: hidden;
    z-index: 30;
}
#suggest a {
    display: block;
    padding: 0.55rem 0.9rem;
    text-decoration: none;
    color: var(--ink);
    border-bottom: 1px solid var(--linie);
    transition: background 0.12s ease;
}
#suggest a:last-child { border-bottom: none; }
#suggest a:hover, #suggest a.active { background: var(--flaeche-hell); }
.suggest-name { display: block; font-weight: 600; }
.suggest-sub { display: block; font-size: 0.83rem; }
.topsearch input {
    width: 100%;
    max-width: 380px;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: var(--flaeche-hell);
}
.topsearch input:focus-visible { background: var(--karte); }

.topbar nav { display: flex; align-items: center; gap: 1.1rem; }
.topbar nav a {
    color: var(--ink);
    text-decoration: none;
    padding: 0.25rem 0.1rem;
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s ease;
}
.topbar nav a.active { font-weight: 600; border-bottom-color: var(--akzent); }
.topbar nav a.btn-primary {
    color: #ffffff;
    border-bottom: 1px solid var(--ink);
    padding: 0.45rem 0.95rem;
}
.topbar nav a.btn-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0 !important;
    border-bottom: none !important;
    font-size: 1.35rem;
    font-weight: 600;
}

/* ---------- Überschriften und Akzent ---------- */
h1 {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0 0 0.4rem;
}
h2 {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
}
h3 { font-size: 0.95rem; font-weight: 600; color: var(--ink); margin: 1.4rem 0 0.5rem; }
.accent-stroke {
    width: 44px;
    height: 3px;
    background: var(--akzent);
    margin-bottom: 1.6rem;
    border-radius: 2px;
}
.subline { margin: 0 0 1rem; }
.detail-company { margin: 0 0 0.2rem; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.detail-head .accent-stroke { margin-bottom: 0.9rem; }
.count { font-size: 0.88rem; margin: 0 0 0.6rem; }

/* ---------- Panels (weiße Karten auf warmem Grund) ---------- */
.panel {
    background: var(--karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 1.1rem 1.25rem 1.25rem;
    margin-bottom: 1.4rem;
}
.panel-primary { position: relative; overflow: hidden; }
.panel-primary::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--akzent);
}
.panel-success { position: relative; overflow: hidden; }
.panel-success::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #4c7a4e;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

/* ---------- Kennzahl-Kacheln (klickbar, dezent gefärbt) ---------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.4rem;
}
a.kpi {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
a.kpi:hover { box-shadow: var(--schatten-hover); transform: translateY(-1px); }
.kpi, .card {
    background: var(--karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 0.85rem 1.1rem;
}
.tile-neutral { border-left: 3px solid #4a4a4a; background: rgba(17, 17, 17, 0.02); }
.tile-sand { border-left: 3px solid #b9862e; background: rgba(185, 134, 46, 0.06); }
.tile-red { border-left: 3px solid var(--akzent); background: rgba(237, 44, 30, 0.04); }
.tile-green { border-left: 3px solid #5f8460; background: rgba(95, 132, 96, 0.07); }
.kpi-value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.kpi-label, .card-label { font-size: 0.83rem; font-weight: 600; color: var(--ink); }
.card-note { font-size: 0.85rem; }

/* ---------- Karten auf der Detailseite ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem;
    margin: 1rem 0 1.4rem;
}
.card-line { font-weight: 600; color: var(--ink); margin: 0.25rem 0; }
/* Score-Skala: je höher, desto grüner */
.score-low { border-left: 3px solid #4a4a4a; background: rgba(17, 17, 17, 0.02); }
.score-mid { border-left: 3px solid #b9862e; background: rgba(185, 134, 46, 0.06); }
.score-high { border-left: 3px solid #8fa876; background: rgba(143, 168, 118, 0.10); }
.score-top { border-left: 3px solid #4c7a4e; background: rgba(76, 122, 78, 0.10); }
.status-form { margin: 0.3rem 0; }
.postpone-form { display: flex; gap: 0.4rem; margin-top: 0.6rem; }

/* ---------- Tabellen ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink);
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--linie);
    white-space: nowrap;
}
td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tr[data-href] { cursor: pointer; transition: background 0.12s ease; }
tr[data-href]:hover { background: var(--flaeche-hell); }
.lead-name { display: block; font-weight: 600; color: var(--ink); }
.lead-company { display: block; font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.score { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
td a { color: var(--ink); font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
.th-actions { text-align: left; }
td.actions { text-align: left; }
td.actions form { display: inline-flex; gap: 0.35rem; }
.table-note { font-size: 0.85rem; margin: 0.6rem 0 0; }

/* Dashboard: beide Tabellen im selben festen Spaltenraster */
.aligned { table-layout: fixed; min-width: 760px; }
.aligned .col-score { width: 7%; }
.aligned .col-lead { width: 26%; }
.aligned .col-status { width: 14%; }
.aligned .col-step { width: 25%; }
.aligned .col-due { width: 12%; }
.aligned .col-actions { width: 16%; }

/* ---------- Überfällig-Markierung ---------- */
.overdue-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--akzent);
    margin-right: 0.25rem;
}
.empty { padding: 0.6rem 0; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--linie);
    border-radius: 7px;
    background: var(--karte);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:hover { border-color: var(--ink); box-shadow: var(--schatten); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.btn-primary:hover { background: #000000; border-color: #000000; }
.btn-danger:hover { border-color: var(--akzent); color: var(--akzent); }
.btn-small { padding: 0.2rem 0.55rem; font-size: 0.8rem; font-weight: 500; }

/* ---------- Filterleiste ---------- */
.filterbar {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filterbar input[type="search"] { flex: 1; min-width: 220px; }
.filter-reset { color: var(--akzent); text-decoration: none; font-size: 0.88rem; }
.filter-reset:hover { text-decoration: underline; }
.filter-export { margin-left: auto; color: var(--ink); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.filter-export:hover { text-decoration: underline; }
.filter-export-second { margin-left: 0; }

/* ---------- Login, Account und Rollen ---------- */
.account-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--flaeche-hell);
    border: 1px solid var(--linie);
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}
.topbar nav a.account-badge:hover { background: #f0eae8; }
.auth-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.auth-panel { width: 100%; max-width: 420px; }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 0.5rem; }
.auth-form label { display: block; font-size: 0.85rem; font-weight: 600; }
.auth-form input, .auth-form select { display: block; width: 100%; margin-top: 0.3rem; }
.auth-form button { align-self: flex-start; }
.form-error-box, .form-notice-box {
    border-radius: 8px;
    padding: 0.7rem 1rem;
    margin: 0 0 1rem;
    font-weight: 600;
    border: 1px solid var(--linie);
}
.form-error-box { border-left: 4px solid var(--akzent); background: #fdf0ef; }
.form-notice-box { border-left: 4px solid #4c7a4e; background: #eef3ee; }
.role-badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--linie);
    background: var(--flaeche-hell);
}
.role-admin { border-color: var(--akzent); }
.role-inactive { background: #eee; }
.user-list { list-style: none; margin: 0; padding: 0; }
.user-list li { padding: 0.7rem 0; border-bottom: 1px solid var(--linie); }
.user-list li:last-child { border-bottom: none; }
.user-line { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.user-name { font-weight: 600; }
.user-sub { font-size: 0.85rem; margin: 0.15rem 0 0.4rem; }
.user-actions { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; }
.pw-reset summary { list-style: none; cursor: pointer; }
.pw-reset summary::-webkit-details-marker { display: none; }
.pw-reset-form { display: flex; gap: 0.4rem; margin-top: 0.45rem; }
.pw-reset-form input { padding: 0.3rem 0.6rem; }

/* CSV-Import */
.import-form input[type="file"] { display: block; margin: 0.8rem 0 1rem; }
.import-summary { font-size: 1rem; }
.import-list { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.import-list li { margin: 0.25rem 0; }
.import-list a { color: var(--akzent); font-weight: 600; }

/* Blättern unter der Leads-Tabelle */
.pager {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 0.2rem 0 1.4rem;
}
.pager-info { font-size: 0.88rem; }

/* Duplikat-Warnung beim Anlegen */
.dup-warning h2 { margin: 0.2rem 0 0.4rem; font-size: 1.05rem; }
.dup-warning p { margin: 0.35rem 0; }
.dup-warning ul { margin: 0.5rem 0; padding-left: 1.2rem; }
.dup-warning li { margin: 0.25rem 0; }
.dup-warning a { color: var(--akzent); font-weight: 600; }

/* ---------- Formulare ---------- */
input, select, textarea {
    font: inherit;
    color: var(--text);
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--linie);
    border-radius: 7px;
    background: var(--karte);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
}
select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23111111' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 2.1rem;
}
.lead-form select, .lead-form input, .log-row select, .log-row input { width: 100%; }
.form-hint { font-size: 0.85rem; margin: 0.9rem 0 0; }
.form-error { color: var(--akzent); font-weight: 600; align-self: center; }

.lead-form .grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem 1.2rem;
}
@media (max-width: 900px) { .lead-form .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .lead-form .grid { grid-template-columns: 1fr; } }
.lead-form label, .log-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
}
.lead-form .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.6rem; }

details.more summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
    padding: 0.1rem 0;
}
details.more[open] summary { margin-bottom: 0.9rem; }

/* Scoring als klickbare Skala */
.scoring {
    margin-top: 1.3rem;
    display: flex;
    gap: 3rem;
    flex-wrap: wrap;
}
.seg-group { display: flex; flex-direction: column; gap: 0.35rem; }
.seg-label { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.seg-hint { font-weight: 400; }
.seg { display: inline-flex; border: 1px solid var(--linie); border-radius: 7px; overflow: hidden; width: fit-content; }
.seg-item { position: relative; }
.seg-item input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.seg-item span {
    display: inline-block;
    padding: 0.4rem 0.95rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    border-right: 1px solid var(--linie);
    transition: background 0.12s ease, color 0.12s ease;
    user-select: none;
}
.seg-item:last-child span { border-right: none; }
.seg-item span:hover { background: var(--flaeche-hell); }
.seg-item input:checked + span { background: var(--ink); color: #ffffff; }
.seg-item input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--akzent); }

/* Update erfassen */
.log-form { display: flex; flex-direction: column; gap: 0.8rem; }
.log-form > input[name="note"] { width: 100%; }
.log-row { display: flex; gap: 0.8rem; align-items: flex-start; flex-wrap: wrap; }
.log-row label { flex: 1; min-width: 150px; }
.log-row .btn { white-space: nowrap; }
.log-row .btn-primary { align-self: flex-end; }

/* ---------- Detailseite ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 0.6rem; }
.detail-columns {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.4rem;
    align-items: start;
}
.facts {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0.4rem 1rem;
    margin: 0;
}
.facts dt { font-weight: 600; color: var(--ink); font-size: 0.85rem; padding-top: 0.1rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-line; background: var(--flaeche-hell); border-radius: 8px; padding: 0.9rem 1.1rem; margin: 0; }

/* Weitere Ansprechpartner bei diesem Unternehmen */
.colleagues { list-style: none; margin: 0; padding: 0; }
.colleagues li { padding: 0.45rem 0; border-bottom: 1px solid var(--linie); }
.colleagues li:last-child { border-bottom: none; }
.colleagues a { color: var(--ink); font-weight: 600; text-decoration: none; }
.colleagues a:hover { text-decoration: underline; }
.colleague-status { display: block; font-size: 0.85rem; }
.colleagues-more { margin: 0.7rem 0 0; font-size: 0.88rem; }
.colleagues-more a { color: var(--akzent); font-weight: 600; text-decoration: none; }
.colleagues-more a:hover { text-decoration: underline; }

/* Fälligkeit als Monat+Jahr-Auswahl und Feld-Hinweise */
.month-year { display: flex; gap: 0.5rem; }
.month-year select:first-child { flex: 1.6; min-width: 0; }
.month-year select:last-child { flex: 1; min-width: 0; }
.field-hint { display: block; font-size: 0.8rem; font-weight: 400; margin-top: 0.4rem; }

/* Fit/Potenzial direkt in der Score-Kachel ändern */
.score-form { display: flex; gap: 0.6rem; margin-top: 0.5rem; }
.score-form label { flex: 1; font-size: 0.8rem; font-weight: 600; }
.score-form select { width: 100%; margin-top: 0.2rem; padding: 0.25rem 1.6rem 0.25rem 0.5rem; font-size: 0.9rem; }

/* ---------- Kontakthistorie ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    display: flex;
    gap: 1rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--linie);
}
.timeline li:last-child { border-bottom: none; }
.timeline-date { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.timeline-note { flex: 1; }
.timeline-delete {
    border: none;
    background: none;
    color: var(--ink);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.3rem;
    opacity: 0.35;
    transition: opacity 0.12s ease, color 0.12s ease;
}
.timeline li:hover .timeline-delete { opacity: 1; }
.timeline-delete:hover { color: var(--akzent); }

/* ---------- Toast ---------- */
#toast {
    position: fixed;
    bottom: 1.6rem;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--ink);
    color: #ffffff;
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 50;
    box-shadow: var(--schatten-hover);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Schmale Fenster ---------- */
@media (max-width: 800px) {
    .detail-columns { grid-template-columns: 1fr; }
    .topsearch { order: 3; flex-basis: 100%; }
}
