:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
}

* { box-sizing: border-box; }

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

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--card);
  padding: 40px;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  width: 100%;
  max-width: 360px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .subtitle { margin: 0 0 20px; color: var(--text-muted); }
.login-card label { display: block; margin: 12px 0 6px; font-size: 14px; font-weight: 600; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px;
}
.login-card button {
  margin-top: 20px; width: 100%; padding: 11px; background: var(--primary);
  color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: var(--primary-dark); }
.alert-error {
  background: #fee2e2; color: var(--danger); padding: 10px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 10px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); padding: 14px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 700; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-pill { background: #eef2ff; color: var(--primary-dark); padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.logout-link { color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.logout-link:hover { color: var(--danger); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; padding: 12px 24px 0; background: var(--card);
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab-btn {
  padding: 10px 18px; border: none; background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-muted); border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--primary-dark); }

.content { padding: 24px; max-width: 1200px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Overview ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--card); border-radius: 12px; padding: 20px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.stat-num { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.mini-list { background: var(--card); border-radius: 12px; padding: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.mini-list-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.mini-list-item:last-child { border-bottom: none; }

/* ---------- Panel header / filters ---------- */
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.panel-header h2 { margin: 0; font-size: 20px; }
.filter-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-input, .status-filter {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.search-input { flex: 1; min-width: 200px; }

.btn-primary {
  background: var(--primary); color: #fff; border: none; padding: 9px 16px;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: #f3f4f6; color: var(--text); border: none; padding: 9px 16px;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger-link { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-edit-link { color: var(--primary); background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; margin-right: 10px; }

/* ---------- Table ---------- */
.table-wrap { background: var(--card); border-radius: 12px; overflow-x: auto; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.contact-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 700px; }
.contact-table th {
  text-align: left; padding: 12px 14px; background: #f9fafb; color: var(--text-muted);
  font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.contact-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.contact-table tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: var(--text-muted); padding: 30px !important; }

.status-badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-connection_sent { background: #e0e7ff; color: #3730a3; }
.status-connected { background: #dbeafe; color: #1e40af; }
.status-engaged { background: #fef3c7; color: #92400e; }
.status-outreached { background: #fce7f3; color: #9d174d; }
.status-followup_sent { background: #ffedd5; color: #9a3412; }
.status-booked_call { background: #dcfce7; color: #166534; }
.status-closed { background: #f3f4f6; color: #4b5563; }

.notes-cell { max-width: 220px; white-space: normal; word-break: break-word; color: var(--text-muted); }
.link-cell a { color: var(--primary); text-decoration: none; font-size: 13px; }
.link-cell a:hover { text-decoration: underline; }

/* ---------- Tasks ---------- */
.inline-form { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.inline-form input[type=date] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }
.inline-form input[type=text] { flex: 1; min-width: 200px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }
.task-list { background: var(--card); border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.task-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.task-item:last-child { border-bottom: none; }
.task-item.done .task-desc { text-decoration: line-through; color: var(--text-muted); }
.task-date { font-size: 12px; color: var(--text-muted); min-width: 90px; }
.task-desc { flex: 1; font-size: 14px; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; padding: 26px; width: 100%; max-width: 440px;
  max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { margin: 0 0 16px; }
.modal-box label { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 600; }
.modal-box input, .modal-box select, .modal-box textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 640px) {
  .content { padding: 14px; }
  .topbar { padding: 12px 14px; }
}
