:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #3b5bfd;
  --primary-hover: #2c47d6;
  --danger: #e0483f;
  --danger-bg: #fdecea;
  --warn: #f2a93b;
  --warn-bg: #fef3e0;
  --ok-bg: #eef1f8;
  --radius: 8px;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.screen { min-height: 100vh; }
.screen[hidden] { display: none; }

/* --- Login --- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0 0 8px; font-size: 1.4rem; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
input, select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
}
input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

button {
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--ok-bg); color: var(--text); }
.btn-secondary:hover { background: #dfe3f0; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f9d8d5; }
.btn-icon {
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 6px 10px;
}
.btn-icon:hover { background: var(--ok-bg); }

.error-text { color: var(--danger); font-size: 0.85rem; margin: 0; }

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.2rem; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* --- Kanban board --- */
main { padding: 20px; overflow-x: auto; }
.board {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-height: 60vh;
}
.column {
  background: #eceef2;
  border-radius: var(--radius);
  width: 250px;
  flex: 0 0 250px;
  padding: 10px;
  min-height: 200px;
}
.column.drag-over { background: #dde1ec; }
.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 10px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.column-count {
  background: #d9dce4;
  color: var(--text);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.75rem;
}

.card {
  background: var(--surface);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  cursor: grab;
  border-left: 3px solid transparent;
}
.card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.card.dragging { opacity: 0.4; }
.card.follow-overdue { border-left-color: var(--danger); }
.card.follow-due_soon { border-left-color: var(--warn); }

.card-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 2px; }
.card-sub { font-size: 0.8rem; color: var(--text-muted); }
.card-followup {
  margin-top: 6px;
  font-size: 0.75rem;
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
}
.card-followup.follow-overdue { background: var(--danger-bg); color: var(--danger); }
.card-followup.follow-due_soon { background: var(--warn-bg); color: #8a5a12; }
.card-followup.follow-ok { background: var(--ok-bg); color: var(--text-muted); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 30, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 520px;
  max-width: 100%;
  padding: 28px;
  position: relative;
}
.modal h2 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 4px 8px;
}
.modal-close:hover { background: var(--ok-bg); border-radius: 4px; }

.contact-form, .settings-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }
.form-actions { display: flex; justify-content: space-between; margin-top: 6px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
fieldset label { flex-direction: row; align-items: center; justify-content: space-between; }
fieldset input { width: 140px; }

#interactions-section { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
#interactions-section h3 { margin-top: 0; font-size: 1rem; }
.interaction-form { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.interaction-form input { flex: 1; min-width: 120px; }

.interaction-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.interaction-item {
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.85rem;
}
.interaction-meta { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 3px; display: flex; justify-content: space-between; }
.reaction-tag { padding: 1px 6px; border-radius: 8px; font-size: 0.7rem; }
.reaction-positive { background: #e4f6ea; color: #1c7a3c; }
.reaction-neutral { background: var(--ok-bg); color: var(--text-muted); }
.reaction-negative { background: var(--danger-bg); color: var(--danger); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  z-index: 200;
}
.toast[hidden] { display: none; }
.toast.toast-error { background: var(--danger); }
