* { box-sizing: border-box; }

:root {
  --crm-bg: #08080d;
  --crm-surface: rgba(15, 15, 23, 0.74);
  --crm-surface-2: rgba(255, 255, 255, 0.055);
  --crm-line: rgba(255, 255, 255, 0.1);
  --crm-text: #f8f7ff;
  --crm-muted: #a7adbd;
  --crm-purple: #6557ff;
  --crm-violet: #8b5cf6;
  --crm-red: #ef4444;
}

html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--crm-text);
  background:
    radial-gradient(circle at 18% 8%, rgba(101, 87, 255, 0.22), transparent 30rem),
    radial-gradient(circle at 84% 16%, rgba(139, 92, 246, 0.14), transparent 32rem),
    var(--crm-bg);
  font-family: Inter, system-ui, sans-serif;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at 48% 36%, black, transparent 74%);
}

.crm-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.crm-sidebar {
  min-height: 100vh;
  padding: 1.25rem;
  border-right: 1px solid var(--crm-line);
  background: rgba(8, 8, 13, 0.66);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #fff;
  text-decoration: none;
  padding: 0.8rem;
  border-radius: 1rem;
}

.crm-brand img { width: 42px; height: 42px; object-fit: contain; filter: drop-shadow(0 0 18px rgba(101,87,255,0.45)); }
.crm-brand strong { display: block; font-size: 1.1rem; }
.crm-brand span { display: block; color: var(--crm-muted); font-size: 0.78rem; margin-top: 0.15rem; }

.crm-nav { display: grid; gap: 0.5rem; margin-top: 2rem; }
.crm-nav a, .crm-logout {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 0.95rem;
  border-radius: 0.9rem;
  color: var(--crm-muted);
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.crm-nav a:hover, .crm-nav a.active { color: #fff; border-color: rgba(101,87,255,0.28); background: rgba(101,87,255,0.12); }
.crm-logout { margin-top: auto; color: rgba(255,255,255,0.72); }
.crm-logout:hover { color: #fff; background: rgba(255,255,255,0.055); }

.crm-main { padding: clamp(1.25rem, 3vw, 2.5rem); }
.crm-topbar { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.5rem; }
.crm-eyebrow { color: #c4b5fd; font-size: 0.78rem; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 0.65rem; }
.crm-topbar h1 { margin: 0; font: 800 clamp(2.4rem, 5vw, 4.8rem)/0.95 Sora, Inter, sans-serif; letter-spacing: -0.07em; }
.crm-topbar p { margin: 0.8rem 0 0; color: var(--crm-muted); font-size: 1rem; }

.crm-refresh, .crm-card-action, .crm-delete {
  min-height: 42px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--crm-purple), var(--crm-violet));
  color: #fff;
  padding: 0 1rem;
  font: 800 0.9rem Inter, sans-serif;
  cursor: pointer;
}

.crm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.crm-stats article, .crm-panel, .crm-card {
  border: 1px solid var(--crm-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.035));
  box-shadow: 0 24px 70px rgba(0,0,0,0.26);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.crm-stats article { border-radius: 1.2rem; padding: 1.1rem; }
.crm-stats span { color: var(--crm-muted); font-size: 0.82rem; }
.crm-stats strong { display: block; margin-top: 0.35rem; font-size: 2rem; letter-spacing: -0.05em; }

.crm-panel { border-radius: 1.4rem; padding: 1rem; }
.crm-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 1rem; margin-bottom: 1rem; }
.crm-toolbar label { display: grid; gap: 0.45rem; color: rgba(255,255,255,0.82); font-size: 0.82rem; font-weight: 800; }
.crm-toolbar input, .crm-toolbar select, .crm-card select, .crm-card textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--crm-line);
  border-radius: 0.95rem;
  background: rgba(5,5,10,0.58);
  color: #fff;
  padding: 0 0.9rem;
  font: inherit;
  outline: none;
}

.crm-kanban { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.65rem; overflow: visible; padding-bottom: 0.35rem; }
.crm-column { min-width: 0; min-height: 420px; display: flex; flex-direction: column; gap: 0.65rem; border: 1px solid rgba(255,255,255,0.08); border-radius: 1rem; padding: 0.6rem; background: rgba(255,255,255,0.03); transition: border-color .2s ease, background .2s ease; }
.crm-column.drag-over { border-color: rgba(101,87,255,0.56); background: rgba(101,87,255,0.08); }
.crm-column-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.35rem 0.25rem 0.55rem; }
.crm-column-head strong { color: #fff; font-size: 0.9rem; }
.crm-column-head span { min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; background: rgba(101,87,255,0.16); color: #d8d2ff; font-size: 0.75rem; font-weight: 900; }
.crm-column-body { min-height: 340px; display: grid; gap: 0.65rem; align-content: start; }
.crm-card { border-radius: 0.95rem; padding: 0.8rem; display: block; cursor: grab; transition: transform .2s ease, border-color .2s ease, background .2s ease, opacity .2s ease; }
.crm-card:active { cursor: grabbing; }
.crm-card.dragging { opacity: 0.45; transform: scale(0.98); }
.crm-card:hover { transform: translateY(-3px); border-color: rgba(101,87,255,0.36); background: linear-gradient(180deg, rgba(255,255,255,0.095), rgba(255,255,255,0.04)); }
.crm-card h3 { margin: 0; font-size: 0.98rem; line-height: 1.2; overflow-wrap: anywhere; }
.crm-card-meta { display: grid; gap: 0.28rem; margin: 0.55rem 0; color: var(--crm-muted); font-size: 0.78rem; overflow-wrap: anywhere; }
.crm-interest { color: #d8d2ff; line-height: 1.45; font-size: 0.82rem; }
.crm-date { color: rgba(255,255,255,0.52); font-size: 0.78rem; margin-top: 0.75rem; }
.crm-card-controls { display: grid; gap: 0.7rem; align-content: start; }
.crm-card textarea { min-height: 92px; padding: 0.8rem; resize: vertical; }
.crm-card-actions { display: flex; gap: 0.5rem; }
.crm-delete { background: rgba(239, 68, 68, 0.14); color: #fecaca; border-color: rgba(239, 68, 68, 0.24); }
.crm-empty { text-align: center; padding: 4rem 1rem; color: var(--crm-muted); }
.crm-empty strong { display: block; color: #fff; font-size: 1.2rem; margin-bottom: 0.35rem; }
.crm-mini-actions { display: grid; grid-template-columns: 1fr; gap: 0.45rem; margin-top: 0.75rem; }
.crm-mini-actions button, .crm-mini-actions a { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; border: 1px solid rgba(255,255,255,0.1); padding: 0 0.55rem; color: #fff; background: rgba(255,255,255,0.055); text-decoration: none; font-size: 0.75rem; font-weight: 800; cursor: pointer; }
.crm-mini-actions a { background: rgba(101,87,255,0.16); }

.crm-modal { position: fixed; inset: 0; z-index: 2000; display: none; place-items: center; padding: 1.25rem; background: rgba(5,4,10,0.72); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.crm-modal.active { display: grid; }
.crm-modal-card { width: min(880px, 100%); max-height: min(820px, 92vh); overflow: auto; position: relative; border: 1px solid var(--crm-line); border-radius: 1.5rem; background: linear-gradient(180deg, rgba(20,18,32,0.97), rgba(10,9,18,0.97)); box-shadow: 0 34px 100px rgba(0,0,0,0.52), 0 0 44px rgba(101,87,255,0.14); padding: clamp(1.25rem, 3vw, 2rem); }
.crm-modal-close { position: absolute; top: 1rem; right: 1rem; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.055); color: #fff; font-size: 1.4rem; cursor: pointer; }
.crm-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-right: 3rem; margin-bottom: 1.4rem; }
.crm-modal-head h2 { margin: 0; font: 800 clamp(2rem, 4vw, 3.4rem)/0.95 Sora, Inter, sans-serif; letter-spacing: -0.06em; }
.crm-modal-head p { margin: 0.7rem 0 0; color: var(--crm-muted); }
.crm-whatsapp { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; padding: 0 1rem; border-radius: 999px; color: #fff; text-decoration: none; font-weight: 900; background: linear-gradient(135deg, var(--crm-purple), var(--crm-violet)); }
.crm-detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.crm-detail-item { border: 1px solid rgba(255,255,255,0.08); border-radius: 1rem; padding: 0.9rem; background: rgba(255,255,255,0.04); }
.crm-detail-item span { display: block; color: var(--crm-muted); font-size: 0.78rem; margin-bottom: 0.25rem; }
.crm-detail-item strong { color: #fff; word-break: break-word; }
.crm-detail-controls { display: grid; gap: 0.8rem; }
.crm-detail-controls label { display: grid; gap: 0.45rem; color: rgba(255,255,255,0.82); font-size: 0.82rem; font-weight: 800; }
.crm-detail-controls select, .crm-detail-controls textarea { width: 100%; border: 1px solid var(--crm-line); border-radius: 0.95rem; background: rgba(5,5,10,0.58); color: #fff; padding: 0.85rem; font: inherit; outline: none; }
.crm-detail-controls textarea { min-height: 130px; resize: vertical; }
.crm-modal-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; margin-top: 1rem; }
.crm-toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2500; max-width: 360px; padding: 1rem 1.1rem; border: 1px solid rgba(255,255,255,0.14); border-radius: 1rem; color: #fff; background: linear-gradient(180deg, rgba(20,18,32,0.96), rgba(10,9,18,0.96)); box-shadow: 0 24px 70px rgba(0,0,0,0.42), 0 0 36px rgba(101,87,255,0.2); transform: translateY(1rem); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.crm-toast.active { opacity: 1; transform: translateY(0); }
.crm-toast strong { display: block; margin-bottom: 0.25rem; }
.crm-toast span { display: block; color: var(--crm-muted); font-size: 0.88rem; line-height: 1.45; }

@media (max-width: 980px) {
  .crm-shell { grid-template-columns: 1fr; }
  .crm-sidebar { min-height: auto; border-right: 0; border-bottom: 1px solid var(--crm-line); }
  .crm-nav { grid-template-columns: repeat(3, 1fr); margin-top: 1rem; }
  .crm-logout { margin-top: 1rem; }
  .crm-stats { grid-template-columns: repeat(2, 1fr); }
  .crm-toolbar { grid-template-columns: 1fr; }
  .crm-kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-modal-head { flex-direction: column; padding-right: 3rem; }
  .crm-detail-grid { grid-template-columns: 1fr; }
  .crm-detail-grid { display: grid; }
}

@media (max-width: 560px) {
  .crm-main { padding: 1rem; }
  .crm-topbar, .crm-card-actions { flex-direction: column; }
  .crm-stats { grid-template-columns: 1fr; }
  .crm-kanban { grid-template-columns: 1fr; }
  .crm-toast { left: 1rem; right: 1rem; bottom: 1rem; max-width: none; }
}
