/* ═══════════════════════════════════════════════════════════════════════════
   nullaufwand CRM – Dark Design System
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #0d0d0f;
  --surface:     #16161a;
  --surface-2:   #1e1e24;
  --surface-3:   #26262e;
  --border:      #2a2a35;
  --border-2:    #38384a;

  --text:        #e8e8f0;
  --text-muted:  #7a7a96;
  --text-faint:  #4a4a62;

  --accent:      #ff6d5a;
  --accent-h:    #ff8a7a;
  --accent-soft: rgba(255, 109, 90, 0.15);

  --green:       #10b981;
  --green-soft:  rgba(16, 185, 129, 0.15);
  --yellow:      #f59e0b;
  --yellow-soft: rgba(245, 158, 11, 0.15);
  --red:         #ef4444;
  --red-soft:    rgba(239, 68, 68, 0.15);
  --blue:        #3b82f6;
  --blue-soft:   rgba(59, 130, 246, 0.15);

  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   16px;

  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --transition:  0.18s ease;

  --sidebar-w:   240px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}
.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.brand-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-h);
  border: 1px solid rgba(124,58,237,0.25);
}
.nav-item svg { width: 16px; height: 16px; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
  display: none;
}
.nav-badge.show { display: inline-block; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.webhook-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

/* ─── Content ────────────────────────────────────────────────────────────── */
.content {
  padding: 32px;
  flex: 1;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  transition: var(--transition);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn svg { width: 14px; height: 14px; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-sm { padding: 14px 16px; }

/* ─── Dashboard ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
}
.stat-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

.recent-section { }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.search-bar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-bar svg { color: var(--text-muted); }
.search-input {
  background: none;
  border: none;
  outline: none;
  width: 100%;
  font-size: 13.5px;
  color: var(--text);
}
.search-input::placeholder { color: var(--text-faint); }
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-lead    { background: var(--yellow-soft); color: var(--yellow); }
.badge-active  { background: var(--green-soft);  color: var(--green); }
.badge-inactive{ background: var(--surface-3);   color: var(--text-muted); }
.badge-planning{ background: var(--blue-soft);   color: var(--blue); }
.badge-done    { background: var(--green-soft);  color: var(--green); }
.badge-paused  { background: var(--surface-3);   color: var(--text-muted); }
.badge-todo    { background: var(--surface-3);   color: var(--text-muted); }
.badge-in-progress { background: var(--accent-soft); color: var(--accent-h); }

/* ─── Kanban / Projects ──────────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  align-items: start;
}
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kanban-col-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}
.kanban-col-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kanban-count {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface-3);
  border-radius: 10px;
  padding: 1px 7px;
}
.kanban-cards {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}
.project-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.project-card:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}
.project-card-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.project-card-client {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.project-card-date {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 10px;
}

/* ─── Tasks ──────────────────────────────────────────────────────────────── */
.tasks-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.task-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.task-card:hover { border-color: var(--border-2); background: var(--surface-3); }
.task-card-title { font-size: 13.5px; font-weight: 500; margin-bottom: 8px; }
.task-card-project {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
}
.task-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.task-status-btn {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.task-status-btn:hover { background: var(--accent-soft); color: var(--accent-h); border-color: var(--accent); }
.task-status-btn.active { background: var(--accent-soft); color: var(--accent-h); border-color: var(--accent); }

/* ─── Drag & Drop ────────────────────────────────────────────────────────── */
.project-card, .task-card { cursor: grab; }
.project-card.dragging, .task-card.dragging {
  opacity: 0.45;
  transform: scale(0.97);
  cursor: grabbing;
}
.kanban-col.drag-over .kanban-cards {
  background: rgba(255, 109, 90, 0.06);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  border-radius: 8px;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7a96' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-select option { background: var(--surface-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
}
.modal-backdrop.show { display: block; }
.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 201;
}
.modal.show { display: block; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted);
  padding: 4px; border-radius: 6px;
  transition: var(--transition);
  display: flex;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 20px 24px 24px; }

/* ─── Detail Panel ───────────────────────────────────────────────────────── */
.detail-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}
.detail-backdrop.show { display: block; }
.detail-panel {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 460px;
  background: var(--surface);
  border-left: 1px solid var(--border-2);
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
  z-index: 151;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.detail-panel.show {
  display: block;
  transform: translateX(0);
}
.detail-header {
  padding: 20px 20px 0;
  display: flex;
  justify-content: flex-end;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.detail-body { padding: 8px 24px 32px; }
.detail-section { margin-bottom: 24px; }
.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}
.detail-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.detail-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.detail-field-label {
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 500;
}
.detail-field-value {
  font-size: 13.5px;
  color: var(--text);
}
.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.qa-list { display: flex; flex-direction: column; gap: 12px; }
.qa-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.qa-question {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.qa-answer { font-size: 13.5px; }

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-faint);
  text-align: center;
}
.empty-state svg {
  width: 40px; height: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state p { font-size: 13.5px; margin-bottom: 16px; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 300px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Misc ───────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.link {
  color: var(--accent-h);
  text-decoration: none;
}
.link:hover { text-decoration: underline; }
.row-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: var(--transition);
}
tr:hover .row-actions { opacity: 1; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ─── Login Screen ───────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.login-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.login-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.login-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s;
}
.login-input:focus { border-color: var(--accent); }
.login-error {
  font-size: 13px;
  color: var(--danger, #f87171);
  text-align: center;
  margin-top: 4px;
}
.login-success {
  font-size: 13px;
  color: #4ade80;
  text-align: center;
  margin-top: 4px;
}
.login-forgot {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  padding: 4px 0;
  margin-top: 4px;
  transition: color .15s;
}
.login-forgot:hover { color: var(--text); }
.login-btn {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 14px;
  margin-bottom: 12px;
}
.logout-btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .sidebar { width: 60px; }
  .sidebar .brand-name, .sidebar .brand-tag, .sidebar .nav-item span,
  .sidebar .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .main { margin-left: 60px; }
  .kanban, .tasks-board { grid-template-columns: 1fr; }
}
