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

:root {
  --color-dark: #2d2d2d;
  --color-darker: #1a1a1a;
  --color-light: #f5f5f5;
  --color-white: #ffffff;
  --color-primary: #7ed957;
  --color-primary-dark: #6bc244;
  --color-gray: #757575;
  --color-gray-light: #e0e0e0;
  --color-gray-dark: #424242;
  --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: all 0.3s ease;
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.4);
}

html { font-size: 16px; }

body {
  font-family: var(--font-family);
  background-color: var(--color-darker);
  color: var(--color-light);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(126, 217, 87, 0.15);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  height: 36px;
  width: 36px;
  object-fit: cover;
  border-radius: 8px;
  filter: drop-shadow(0 0 8px rgba(126, 217, 87, 0.3));
}
.brand-text { font-weight: 700; font-size: 1.05rem; color: var(--color-white); }
.brand-text span {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--color-gray);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.conn-status {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.9rem;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--color-gray-light);
}
.conn-status.ok {
  background: rgba(126, 217, 87, 0.15);
  border-color: rgba(126, 217, 87, 0.5);
  color: var(--color-primary);
}
.conn-status.warn {
  background: rgba(217, 166, 62, 0.15);
  border-color: rgba(217, 166, 62, 0.5);
  color: #e6b955;
}

.highlight { color: var(--color-primary); }

/* ===== QR Screen ===== */
.qr-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 30%, rgba(126, 217, 87, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(126, 217, 87, 0.08) 0%, transparent 50%),
    var(--color-darker);
}
.qr-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2.5rem;
  border-radius: 20px;
  text-align: center;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
}
.qr-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.75rem; }
.qr-card p { color: var(--color-gray-light); font-size: 0.92rem; line-height: 1.7; }
.qr-card strong { color: var(--color-white); }
.qr-frame {
  display: inline-block;
  padding: 1rem;
  margin: 1.25rem 0;
  background: var(--color-white);
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(126, 217, 87, 0.3), 0 0 30px rgba(126, 217, 87, 0.15);
}
.qr-card img { width: 240px; height: 240px; display: block; }
.qr-hint { color: var(--color-gray); font-size: 0.8rem; }

/* ===== Board ===== */
.board {
  flex: 1;
  overflow: auto;
  padding: 1.25rem;
}
.columns {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(300px, 1fr);
  gap: 1.25rem;
  height: 100%;
}
.column {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.column-header {
  padding: 1rem 1.1rem;
  font-weight: 600;
  color: var(--color-white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}
.column-header::after {
  content: '';
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), transparent);
}
.column-count {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-gray-light);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
}
.column-body {
  padding: 0.85rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border: 1px solid transparent;
  transition: var(--transition);
}
.column-body.drag-over {
  border-color: rgba(126, 217, 87, 0.9);
  background: rgba(126, 217, 87, 0.04);
}

/* ===== Lead card ===== */
.lead-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}
.lead-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg) scale(0.98);
}
.lead-card:hover {
  transform: translateY(-3px);
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
.lead-name { font-weight: 600; font-size: 0.92rem; color: var(--color-white); }
.lead-phone { font-size: 0.74rem; color: var(--color-gray); font-family: 'Courier New', monospace; }
.lead-preview {
  font-size: 0.82rem;
  color: var(--color-gray-light);
  margin-top: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.lead-time { font-size: 0.7rem; color: var(--color-gray); margin-top: 0.35rem; }

/* ===== Panel ===== */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 35;
}
.panel {
  position: fixed;
  top: 0; right: 0;
  width: min(440px, 100%);
  height: 100%;
  background: var(--color-darker);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  z-index: 36;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.panel-header h2 { margin: 0; font-size: 1.1rem; color: var(--color-white); font-weight: 600; }
.panel-phone { color: var(--color-gray); font-size: 0.82rem; font-family: 'Courier New', monospace; margin-top: 2px; }
.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--color-gray-light);
  transition: var(--transition);
}
.icon-btn:hover { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-darker); }

.panel-stage { padding: 0.9rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.panel-stage label {
  display: block;
  font-size: 0.72rem;
  color: var(--color-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}
.panel-stage select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  color: var(--color-light);
  font-family: var(--font-family);
  font-size: 0.9rem;
}
.panel-stage select:focus { outline: none; border-color: var(--color-primary); }

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background:
    radial-gradient(circle at 15% 20%, rgba(126, 217, 87, 0.05) 0%, transparent 40%),
    var(--color-dark);
}
.bubble {
  max-width: 82%;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.in {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--color-light);
}
.bubble.out {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.35), rgba(18, 140, 126, 0.35));
  border: 1px solid rgba(37, 211, 102, 0.4);
  color: var(--color-white);
}
.bubble time { display: block; font-size: 0.66rem; color: rgba(245, 245, 245, 0.55); margin-top: 0.3rem; text-align: right; }

/* ===== Reply box ===== */
.reply-box {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--color-darker);
}
.reply-box textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.6rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  color: var(--color-light);
  font-family: var(--font-family);
  font-size: 0.88rem;
  line-height: 1.4;
}
.reply-box textarea:focus { outline: none; border-color: var(--color-primary); }
.reply-box textarea:disabled { opacity: 0.5; }
.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: var(--color-white);
  font-size: 1.05rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.35);
}
.send-btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.panel-notes { padding: 0.9rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.panel-notes label {
  display: block;
  font-size: 0.72rem;
  color: var(--color-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}
.panel-notes textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  color: var(--color-light);
  font-family: var(--font-family);
  font-size: 0.88rem;
  resize: vertical;
  margin-bottom: 0.65rem;
}
.panel-notes textarea:focus { outline: none; border-color: var(--color-primary); }

/* ===== Buttons ===== */
.btn {
  padding: 0.65rem 1.4rem;
  border-radius: 50px;
  border: none;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-darker);
  box-shadow: 0 4px 15px rgba(126, 217, 87, 0.3);
}
.btn-primary:hover {
  background-color: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(126, 217, 87, 0.5);
}

.empty-hint {
  color: var(--color-gray);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(126, 217, 87, 0.4); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .brand-text { font-size: 0.95rem; }
  .qr-card { padding: 1.75rem; margin: 0 1rem; }
  .qr-card img { width: 200px; height: 200px; }
  .columns { grid-auto-columns: minmax(260px, 85vw); }
  .panel { width: 100%; }
}
