:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #172b4d;
  --muted: #6b778c;
  --border: #dfe1e6;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #1a1a2e;
  color: white;
}

.topbar h1 { font-size: 18px; margin: 0; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.status { font-size: 12px; opacity: 0.8; }

#refresh-btn {
  background: #3ecd5a;
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#refresh-btn:hover { opacity: 0.9; }

.add-btn {
  background: #0052cc;
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.add-btn:hover { opacity: 0.9; }

.board {
  display: flex;
  gap: 14px;
  padding: 16px;
  overflow-x: auto;
  align-items: flex-start;
  height: calc(100vh - 56px);
}

.column {
  background: #ebecf0;
  border-radius: 10px;
  min-width: 280px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.column-header {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 4px solid var(--accent, #999);
  border-radius: 10px 10px 0 0;
}

.column-count {
  background: rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  margin-left: auto;
}

.column-cards {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
}

.column-cards.drag-over {
  background: rgba(62, 205, 90, 0.15);
  outline: 2px dashed #3ecd5a;
  outline-offset: -4px;
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  cursor: grab;
  border: 1px solid var(--border);
}

.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.4; }

.card-name {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.channel-icon { font-size: 12px; }

.card-phone {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.card-message {
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}

.card-link {
  color: #0052cc;
  text-decoration: none;
}
.card-link:hover { text-decoration: underline; }

.empty-hint {
  font-size: 12px;
  color: var(--muted);
  padding: 10px;
  text-align: center;
}

.card-note {
  font-size: 12px;
  background: #fff8e1;
  border-left: 3px solid #f9a825;
  padding: 5px 7px;
  margin-bottom: 6px;
  border-radius: 3px;
  color: #5c4400;
  white-space: pre-wrap;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.card-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--muted);
}
.card-action-btn:hover { background: #f4f5f7; }
.card-action-btn.danger:hover { background: #ffebe6; color: #bf2600; border-color: #ffbdad; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 30, 66, 0.54);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 1000;
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: white;
  border-radius: 10px;
  width: 480px;
  max-width: 90vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header h2 { margin: 0; font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.search-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  margin-bottom: 10px;
}

.search-results {
  overflow-y: auto;
  flex: 1;
}

.search-result-item {
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.search-result-item:hover { background: #f4f5f7; border-color: var(--border); }
.search-result-name { font-weight: 600; font-size: 13.5px; }
.search-result-phone { font-size: 12px; color: var(--muted); }
.search-result-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.note-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  box-sizing: border-box;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.save-btn {
  background: #3ecd5a;
  border: none;
  color: white;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}
.save-btn:hover { opacity: 0.9; }
