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

:root {
  --bg: #eef2f7;
  --card: #fff;
  --text: #1e3a5f;
  --text-muted: #6b829e;
  --border: #d8e2ed;
  --primary: #1a7bbf;
  --primary-hover: #15608f;
  --success: #27ae60;
  --warning: #e9a820;
  --danger: #e04545;
  --sidebar-bg: #dce9f5;
  --sidebar-text: #1e3a5f;
  --sidebar-active: #c4daf0;
  --sidebar-active-text: #1e3a5f;
  --topbar-bg: #1e3a5f;
  --col-nowy: #1a7bbf;
  --col-kontakt: #7c5cbf;
  --col-weryfikacja: #e9a820;
  --col-spotkanie: #2ea8a1;
  --col-procesowanie: #4f5ec0;
  --col-sfinalizowany: #27ae60;
  --col-archiwum: #95a5b8;
  --shadow: 0 1px 3px rgba(30,58,95,.06);
  --shadow-lg: 0 4px 12px rgba(30,58,95,.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* LOGIN */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #dce9f5 0%, #eef2f7 100%);
}
.login-box {
  background: var(--card); border-radius: 16px; padding: 48px;
  width: 400px; max-width: 90vw; box-shadow: var(--shadow-lg);
}
.login-box h1 { font-size: 24px; margin-bottom: 8px; }
.login-box p { color: var(--text-muted); margin-bottom: 32px; }
.login-box input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; margin-bottom: 16px; outline: none;
}
.login-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.login-box button {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: .2s;
}
.login-box button:hover { background: var(--primary-hover); }
.login-error { color: var(--danger); font-size: 14px; margin-bottom: 12px; display: none; }

/* LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  border-right: 1px solid var(--border);
}
.sidebar-logo {
  padding: 20px 16px; font-size: 18px; font-weight: 700;
  border-bottom: 1px solid rgba(30,58,95,.12); color: var(--text);
}
.sidebar-logo span { color: var(--primary); }
.sidebar-nav { flex: 1; padding: 10px 6px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px; color: var(--sidebar-text);
  text-decoration: none; font-size: 13px; transition: .15s; cursor: pointer;
}
.sidebar-nav a:hover { background: var(--sidebar-active); }
.sidebar-nav a.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-nav a svg { width: 17px; height: 17px; opacity: .6; }
.sidebar-nav .divider { height: 1px; background: rgba(30,58,95,.1); margin: 10px 8px; }
.sidebar-user {
  padding: 14px 16px; border-top: 1px solid rgba(30,58,95,.12);
  font-size: 12px; display: flex; justify-content: space-between; align-items: center;
}
.sidebar-user button {
  background: none; border: none; color: var(--sidebar-text);
  cursor: pointer; opacity: .6; font-size: 12px;
}
.sidebar-user button:hover { opacity: 1; }

.main { margin-left: 200px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* HEADER */
.header {
  padding: 16px 24px; background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.header h2 { font-size: 20px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border); background: var(--card);
  transition: .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--success); color: #fff; border-color: var(--success); }
.btn-primary:hover { background: #219a52; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }

/* SERVICE TABS */
.service-tabs {
  display: flex; gap: 0; padding: 0 24px;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.service-tab {
  padding: 12px 24px; font-size: 14px; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--text-muted); transition: .2s;
}
.service-tab:hover { color: var(--text); }
.service-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* KANBAN */
.kanban-wrap { padding: 20px 24px; overflow-x: auto; flex: 1; }
.kanban {
  display: flex; gap: 16px; min-height: calc(100vh - 160px);
  align-items: flex-start;
}
.kanban-col {
  min-width: 260px; width: 260px; flex-shrink: 0;
  background: var(--card); border-radius: 8px; display: flex; flex-direction: column;
  max-height: calc(100vh - 180px); box-shadow: var(--shadow);
}
.kanban-col-header {
  padding: 10px 14px; font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; display: flex; justify-content: space-between; align-items: center;
  border-radius: 8px 8px 0 0; color: var(--text); position: sticky; top: 0;
  background: var(--card); border-bottom: 3px solid #ccc;
}
.kanban-col-header .count {
  background: var(--bg); padding: 2px 8px; border-radius: 10px; font-size: 11px; color: var(--text-muted);
}
.kanban-col[data-status="nowy"] .kanban-col-header { border-bottom-color: var(--col-nowy); }
.kanban-col[data-status="ponowny_kontakt"] .kanban-col-header { border-bottom-color: var(--col-kontakt); }
.kanban-col[data-status="weryfikacja"] .kanban-col-header { border-bottom-color: var(--col-weryfikacja); }
.kanban-col[data-status="umowione_spotkanie"] .kanban-col-header { border-bottom-color: var(--col-spotkanie); }
.kanban-col[data-status="procesowanie"] .kanban-col-header { border-bottom-color: var(--col-procesowanie); }
.kanban-col[data-status="sfinalizowany"] .kanban-col-header { border-bottom-color: var(--col-sfinalizowany); }
.kanban-col[data-status="archiwum"] .kanban-col-header { border-bottom-color: var(--col-archiwum); }
.kanban-cards { padding: 8px; overflow-y: auto; flex: 1; }

/* CARDS */
.lead-card {
  background: var(--bg); border-radius: 6px; padding: 12px;
  margin-bottom: 6px; cursor: pointer;
  transition: .15s; border-left: 3px solid transparent;
}
.lead-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.lead-card.priority-high { border-left-color: var(--danger); }
.lead-card.priority-medium { border-left-color: var(--warning); }
.lead-card.priority-low { border-left-color: transparent; }
.lead-card .card-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.lead-card .card-info { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.lead-card .card-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: 11px;
}
.lead-card .card-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.lead-card .card-amount { font-weight: 600; color: var(--success); }
.lead-card .card-attempts {
  font-size: 11px; color: var(--warning); font-weight: 500;
}
.lead-card.source-manual {
  background: #f3e8ff;
}
.lead-card .card-source {
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px;
}
.lead-card .card-source.src-manual { background: #ede9fe; color: #7c3aed; }
.lead-card .card-source.src-fb { background: #dbeafe; color: #1d4ed8; }
.lead-card .card-pixel {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 600; background: #dbeafe; color: #1d4ed8;
}
.lead-card .card-termin {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .3px; flex-shrink: 0;
}
.termin-today { background: #fee2e2; color: #dc2626; }
.termin-tomorrow { background: #fef3c7; color: #d97706; }
.termin-overdue { background: #fecaca; color: #b91c1c; }
.termin-future { background: #e0f2fe; color: #0369a1; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: 16px; width: 720px;
  max-width: 95vw; box-shadow: var(--shadow-lg); animation: modalIn .2s;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-10px); } }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: none; cursor: pointer; font-size: 20px; color: var(--text-muted);
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; }
.modal-body .form-row { display: flex; gap: 12px; margin-bottom: 16px; }
.modal-body .form-group { flex: 1; }
.modal-body label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 4px;
}
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; font-family: inherit;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.modal-body textarea { resize: vertical; min-height: 80px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* NOTES */
.notes-section { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.notes-section h4 { font-size: 15px; margin-bottom: 12px; }
.note-item {
  padding: 10px 12px; background: var(--bg); border-radius: 8px;
  margin-bottom: 8px; font-size: 13px;
}
.note-item .note-meta { color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.note-input {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.note-input textarea { flex: 1; min-height: 44px; }

/* STATS BAR */
.stats-bar {
  display: flex; gap: 16px; padding: 16px 24px; overflow-x: auto;
}
.stat-card {
  background: var(--card); border-radius: 12px; padding: 16px 20px;
  min-width: 160px; box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; }
.stat-card .stat-sub { font-size: 12px; color: var(--success); margin-top: 2px; }

/* STATUS BADGE */
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}

/* ARCHIVE VIEW */
.archive-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px; padding: 0;
}
.archive-card {
  background: var(--card); border-radius: 8px; padding: 16px;
  box-shadow: var(--shadow); border-left: 3px solid var(--col-archiwum);
}
.archive-card .archive-name { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.archive-card .archive-info { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.archive-card .archive-actions { margin-top: 12px; display: flex; gap: 8px; }
.btn-restore {
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--primary); background: var(--primary);
  color: #fff; transition: .15s;
}
.btn-restore:hover { background: var(--primary-hover); }

/* DRAG */
.lead-card.dragging { opacity: .4; }
.kanban-col.drag-over .kanban-cards { background: rgba(37,99,235,.05); border-radius: 0 0 12px 12px; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { width: 52px; }
  .sidebar-logo span, .sidebar-nav a span, .sidebar-user span { display: none; }
  .sidebar-nav a { justify-content: center; padding: 10px; }
  .main { margin-left: 52px; }
  .kanban-col { min-width: 240px; }
}
