:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --line: #2a323d;
  --text: #e8edf3;
  --muted: #8b97a6;
  --gold: #c9a24b;
  --gold-soft: rgba(201, 162, 75, 0.15);
  --green: #3fb950;
  --red: #f0546b;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  color: var(--gold);
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand span { color: var(--gold); font-weight: 600; }
.mainnav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; align-items: center; }
.mainnav > a { color: var(--muted); font-weight: 500; }
.mainnav > a:hover { color: var(--text); text-decoration: none; }

/* ---- Nav-Dropdowns (native <details>) ---- */
.navdrop { position: relative; }
.navdrop > summary { list-style: none; cursor: pointer; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.navdrop > summary::-webkit-details-marker { display: none; }
.navdrop > summary::after { content: "\25be"; font-size: 0.7em; opacity: 0.75; }
.navdrop > summary:hover { color: var(--text); }
.navdrop[open] > summary { color: var(--text); }
.navdrop-menu { position: absolute; top: calc(100% + 10px); left: 0; min-width: 210px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; z-index: 50; }
.navdrop-menu a { color: var(--muted); padding: 9px 12px; border-radius: 7px; font-weight: 500; white-space: nowrap; }
.navdrop-menu a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.logout { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.whoami { color: var(--muted); font-size: 0.85rem; }

/* ---- Layout ---- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
h1 { font-size: 1.6rem; margin: 8px 0 20px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.r { text-align: right; }
.dim { opacity: 0.5; }

/* ---- Cards ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.card-narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.kpi-num { font-size: 1.8rem; font-weight: 700; }
.kpi-label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.kpi-gold { border-color: var(--gold); background: linear-gradient(180deg, var(--gold-soft), transparent); }
.kpi-gold .kpi-num { color: var(--gold); }

/* ---- Forms ---- */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: block; font-size: 0.9rem; color: var(--muted); }
input, select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }

.btn {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
}
.btn:hover { border-color: var(--gold); text-decoration: none; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-danger { background: transparent; border-color: rgba(240,84,107,0.5); color: var(--red); }
.btn-danger:hover { background: rgba(240,84,107,0.12); border-color: var(--red); }

.preisform { margin: 0; }
.preisform input { margin-top: 0; padding: 6px 8px; font-size: 0.85rem; width: 120px; text-align: right; }

/* ---- Ref-Link ---- */
.reflink { display: flex; gap: 10px; }
.reflink input { font-family: ui-monospace, monospace; }

/* ---- Tables ---- */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.list th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
table.mini { width: 100%; border-collapse: collapse; }
table.mini td { padding: 8px 4px; border-bottom: 1px solid var(--line); }

/* ---- Funnel ---- */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 12px; }
.funnel-label { font-size: 0.85rem; color: var(--muted); }
.funnel-bar { background: var(--panel-2); border-radius: 6px; height: 16px; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--gold); border-radius: 6px; transition: width 0.3s; }
.funnel-val { text-align: right; font-weight: 600; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.badge-neu { background: rgba(139,151,166,0.2); color: #b7c2cf; }
.badge-kontaktiert, .badge-qualifiziert { background: rgba(88,166,255,0.15); color: #79b8ff; }
.badge-termin { background: var(--gold-soft); color: var(--gold); }
.badge-abschluss, .badge-ausgezahlt { background: rgba(63,185,80,0.18); color: var(--green); }
.badge-verloren { background: rgba(240,84,107,0.15); color: var(--red); }

/* ---- Filter chips ---- */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { padding: 6px 14px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.chip:hover { color: var(--text); text-decoration: none; }
.chip.active { background: var(--gold); border-color: var(--gold); color: #1a1408; }

.statusform select { margin-top: 0; padding: 6px 8px; font-size: 0.85rem; }

/* ---- Alerts ---- */
.alert { position: relative; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert.error { background: rgba(240,84,107,0.12); border: 1px solid var(--red); color: #ffb3bf; }
.alert.ok { background: rgba(63,185,80,0.12); border: 1px solid var(--green); color: #b8f0c0; }
.alert-dismissible { padding-right: 40px; }
.alert-x { position: absolute; top: 8px; right: 10px; background: transparent; border: none; color: inherit; font-size: 1.25rem; line-height: 1; cursor: pointer; opacity: 0.6; padding: 2px 6px; border-radius: 6px; }
.alert-x:hover { opacity: 1; background: rgba(255,255,255,0.08); }

/* ---- Button-Reihen ---- */
.btnrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btnrow form { margin: 0; }

/* ---- Kanban-Board ---- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.board-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 120px; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 0.9rem; }
.board-count { background: var(--panel-2); color: var(--muted); border-radius: 20px; padding: 1px 9px; font-size: 0.78rem; }
.board-drop { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; transition: background 0.15s; }
.board-drop.over { background: var(--gold-soft); }
.board-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; }
.board-card.dragging { opacity: 0.5; }
.board-card:hover { border-color: var(--gold); }
.bc-name { font-weight: 600; }
.bc-meta { margin-top: 2px; }
.bc-preis { color: var(--gold); font-weight: 600; margin-top: 4px; }
.bc-owner { margin-top: 4px; }
.bc-open { display: inline-block; margin-top: 6px; font-size: 0.8rem; }

/* ---- Timeline / Verlauf ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-dot { position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); border: 2px solid var(--panel); }
.tl-status_change { background: #79b8ff; }
.tl-notiz { background: var(--gold); }
.tl-anruf { background: var(--green); }
.tl-auszahlung { background: var(--green); }
.tl-owner { background: #b083f0; }
.tl-created { background: var(--muted); }
.tl-head { font-size: 0.9rem; }
.tl-text { margin-top: 2px; color: var(--text); font-size: 0.92rem; white-space: pre-wrap; }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 24px; border-top: 1px solid var(--line); }
