@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap");

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

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: #f9fafb;
  color: #1f2937;
  min-height: 100vh;
  padding: 24px;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 960px;
  margin: 0 auto;
}

/* ── Header ── */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 32px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e5e7eb;
}

.page-header h1 {
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 600;
  color: #111827;
  letter-spacing: -0.4px;
}

.page-header .badge {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 10px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Status bar ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 13px;
  color: #6b7280;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 1.8s ease-in-out infinite;
}

.status-dot.error {
  background: #ef4444;
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ── Table ── */
.table-wrap {
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  user-select: none;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: #f9fafb;
}

tbody td {
  padding: 12px 18px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

.col-id {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: #9ca3af;
  width: 150px;
}

.col-name {
  color: #111827;
  font-weight: 600;
}

/* ── Bitrix24 field ── */
.bx-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.user-field {
  display: none;
}

.bx-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px dashed #d1d5db;
  background: transparent;
  color: #6b7280;
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 130px;
}

.bx-trigger:hover {
  border-color: #3b82f6;
  color: #111827;
  background: rgba(59, 130, 246, 0.08);
}

.bx-trigger.linked {
  border-style: solid;
  border-color: #22c55e;
  color: #16a34a;
  background: rgba(34, 197, 94, 0.08);
}

.bx-trigger .icon {
  font-size: 15px;
  line-height: 1;
}

.btn-unlink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-unlink:hover {
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
}

/* ── Buttons ── */
.btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 52px 16px;
  color: #9ca3af;
  font-size: 14px;
}

.empty-state .icon {
  font-size: 34px;
  margin-bottom: 14px;
  opacity: 0.35;
}

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 52px;
  color: #9ca3af;
  font-size: 14px;
  gap: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  color: #111827;
  box-shadow: 0 5px 22px rgba(0, 0, 0, 0.08);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: #fca5a5;
  color: #b91c1c;
}

/* ── Row entrance animation ── */
tbody tr {
  animation: rowIn 0.25s ease both;
}

@keyframes rowIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
