/* Local fonts (DSGVO-compliant, no external requests) */
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/dm-sans-v17-latin-regular.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/dm-sans-v17-latin-500.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/dm-sans-v17-latin-600.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/dm-sans-v17-latin-700.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/dm-sans-v17-latin-800.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-v20-latin-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-v20-latin-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-v20-latin-700.woff2') format('woff2'); }

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #1f2b3d;
  --border: #2d3a4f;
  --border-focus: #3b82f6;
  --text: #e6edf3;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --success: #22c55e;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.25);
  --transition: 150ms ease;
  --sidebar-w: 240px;
  --font: 'DM Sans', 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---- Login ---- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
}
.login-card h1 {
  text-align: center;
  color: var(--accent);
  margin-bottom: 24px;
  font-size: 24px;
}

/* ---- Layout ---- */
#main-app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  border-right: 1px solid var(--border);
}
.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 20px; font-weight: 700; color: #fff; }
.logo-sub { font-size: 14px; font-weight: 400; color: var(--accent); margin-left: 4px; }

.nav-links {
  list-style: none;
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.nav-links li a {
  display: block;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.nav-links li a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-links li a.active {
  background: rgba(59,130,246,0.12);
  color: #fff;
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px 32px;
  min-height: 100vh;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--transition);
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.6; }
select option { background: var(--surface); color: var(--text); }
textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.btn:hover { background: var(--surface-hover); border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }
.btn-accent { background: var(--success); color: #fff; border-color: var(--success); }
.btn-accent:hover { opacity: 0.9; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 8px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h2 { font-size: 18px; font-weight: 600; }
.card-header h3 { font-size: 16px; font-weight: 600; }

/* ---- Data Grid ---- */
.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-grid th, .data-grid td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-grid th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  background: var(--surface);
}
.data-grid th.sortable { cursor: pointer; user-select: none; }
.data-grid th.sortable:hover { color: var(--accent); }
.data-grid tbody tr { transition: background var(--transition); }
.data-grid tbody tr:hover { background: var(--surface-hover); }
.data-grid tbody tr.clickable { cursor: pointer; }
.clickable-row { transition: background var(--transition); border-radius: var(--radius-sm); }
.clickable-row:hover { background: var(--surface-hover); }
.data-grid a { color: var(--accent); text-decoration: none; }
.data-grid a:hover { color: var(--accent-hover); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.pagination .btn { margin-left: 4px; }

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input { max-width: 280px; }

/* ---- Tags/Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(59,130,246,0.18);
  color: var(--accent);
}
.badge-accent { background: rgba(34,197,94,0.18); color: var(--success); }
.badge-warning { background: rgba(217,119,6,0.18); color: #fbbf24; }
.badge-danger { background: rgba(220,38,38,0.18); color: #f87171; }
.badge-neutral { background: rgba(139,156,179,0.15); color: var(--text-muted); }

.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---- Person Tag Badges (accessible: icon + label + tooltip) ---- */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tag-badge .tag-icon { font-size: 10px; opacity: 0.85; }

/* Category shapes via left-border */
.tag-cat--outreach      { border-left: 3px solid; border-radius: 2px 10px 10px 2px; }
.tag-cat--relationship  { border-radius: 3px; }
.tag-cat--lifecycle     { border-radius: 10px; }
.tag-cat--data_quality  { border-left: 3px dashed; border-radius: 2px 10px 10px 2px; }

/* Color variants */
.tag-color--gray   { background: rgba(139,156,179,0.15); color: var(--text-muted); border-color: rgba(139,156,179,0.3); }
.tag-color--blue   { background: rgba(59,130,246,0.15); color: #60a5fa; border-color: rgba(59,130,246,0.3); }
.tag-color--teal   { background: rgba(20,184,166,0.15); color: #2dd4bf; border-color: rgba(20,184,166,0.3); }
.tag-color--orange { background: rgba(249,115,22,0.15); color: #fb923c; border-color: rgba(249,115,22,0.3); }
.tag-color--yellow { background: rgba(234,179,8,0.15); color: #facc15; border-color: rgba(234,179,8,0.3); }
.tag-color--purple { background: rgba(168,85,247,0.15); color: #c084fc; border-color: rgba(168,85,247,0.3); }
.tag-color--red    { background: rgba(239,68,68,0.15); color: #f87171; border-color: rgba(239,68,68,0.3); }
.tag-color--green  { background: rgba(34,197,94,0.15); color: #4ade80; border-color: rgba(34,197,94,0.3); }
.tag-color--gold   { background: rgba(234,179,8,0.18); color: #fbbf24; border-color: rgba(234,179,8,0.35); }

/* Do-not-contact warning banner */
.dnc-banner {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tag picker */
.tag-picker { margin-top: 8px; }
.tag-picker-group { margin-bottom: 10px; }
.tag-picker-group-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.tag-picker-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  margin: 2px 4px 2px 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  transition: all var(--transition);
}
.tag-picker-item:hover { border-color: var(--accent); color: var(--text); }
.tag-picker-item.active { border-color: var(--accent); background: rgba(59,130,246,0.12); color: var(--accent); }
.tag-picker-item .tag-icon { font-size: 11px; }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  gap: 0;
}
.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Pipeline Board ---- */
.pipeline-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.pipeline-column {
  min-width: 240px;
  max-width: 280px;
  flex-shrink: 0;
  background: rgba(26,35,50,0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.pipeline-column-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pipeline-column-header .count {
  background: var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
}
.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.pipeline-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.pipeline-card-title { font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.pipeline-card-sub { font-size: 12px; color: var(--text-muted); }

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}
.timeline-item-header { font-size: 13px; font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.timeline-item-meta { font-size: 12px; color: var(--text-muted); }
.timeline-item-body { font-size: 13px; margin-top: 4px; color: var(--text-muted); }
.timeline-item.clickable { padding: 8px 10px; margin-left: -10px; border-radius: var(--radius-sm); transition: background var(--transition); }
.timeline-item.clickable:hover { background: var(--surface-hover); }

/* ---- Drop Zone ---- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.drop-zone.active {
  border-color: var(--accent);
  background: rgba(59,130,246,0.06);
  color: var(--accent);
}
.drop-zone.dragover {
  border-color: var(--success);
  background: rgba(34,197,94,0.06);
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 90%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  min-width: 280px;
  color: var(--text);
  animation: slideIn 200ms ease;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--accent); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Error ---- */
.error-msg { color: #f87171; font-size: 13px; margin-top: 8px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ---- Stats Row ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-card-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-card-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---- Detail Layout ---- */
.detail-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .detail-layout { grid-template-columns: 1fr; } }

/* ---- Search Results Dropdown ---- */
.search-results {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}
.search-results-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-results-item:last-child { border-bottom: none; }
.search-results-item:hover { background: var(--surface-hover); }
.search-results-item.selected { background: rgba(59,130,246,0.12); color: var(--accent); }

/* ---- Utility ---- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }

/* ---- Contact cards (email analysis modal) ---- */
.contact-card input { padding: 6px 8px; font-size: 12px; }
.contact-card .btn-sm { font-size: 11px; padding: 2px 8px; }
.contact-domain-group:last-child { margin-bottom: 0; }

/* ---- Notification Bell ---- */
.sidebar-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 6px;
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.btn-icon:hover { color: var(--text); background: var(--surface-hover); }
.notification-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.notification-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.notif-header .btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.notif-header .btn-link:hover { text-decoration: underline; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-hover); }
.notif-unread { background: rgba(59,130,246,0.06); }
.notif-unread .notif-title { font-weight: 600; }
.notif-title { font-size: 13px; color: var(--text); }
.notif-body { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-empty, .notif-loading {
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- GDPR / Consent Section ---- */
.consent-table { width: 100%; font-size: 13px; }
.consent-table th { text-align: left; font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--border); }
.consent-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.consent-active { color: var(--success, #22c55e); }
.consent-revoked { color: var(--danger, #ef4444); }
.data-source-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  background: rgba(59,130,246,0.1);
  color: var(--accent);
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 16px; }
}
