:root {
  --purple-100: #f4e9fb;
  --purple-200: #e0bdf5;
  --purple-300: #cd8ff0;
  --purple-400: #b158e6;
  --purple-500: #9200c4;
  --purple-600: #7a05a4;
  --purple-700: #5c0980;
  --purple-800: #400a5c;
  --purple-900: #260938;
  --purple-950: #160521;

  --ink: #130317;
  --ink-soft: #4a3d52;
  --gray-500: #79707f;
  --gray-300: #d9d0e0;
  --gray-100: #f6f2fa;
  --gray-50: #fbf9fd;
  --white: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #b45309;

  --grad-hero: linear-gradient(160deg, var(--purple-400) 0%, var(--purple-600) 55%, var(--purple-800) 100%);
  --grad-dark: linear-gradient(165deg, var(--purple-900) 0%, var(--ink) 100%);

  --font-display: 'Sora', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --ease: cubic-bezier(.16,.84,.44,1);

  --shadow-soft: 0 16px 36px -18px rgba(38, 9, 56, .3);
  --shadow-lift: 0 30px 70px -25px rgba(20, 0, 30, .5);
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Garante que [hidden] sempre vence, mesmo em elementos com display:flex
   definido — sem isso a sidebar aparecia por cima da tela de login. */
[hidden] { display: none !important; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), opacity .2s, background .2s;
}
.btn--primary { background: var(--purple-500); color: #fff; box-shadow: 0 12px 26px -12px rgba(146,0,196,.6); }
.btn--primary:hover { background: var(--purple-600); transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(146,0,196,.7); }
.btn--primary:active { transform: translateY(0); }
.btn--primary:disabled { opacity: .6; cursor: default; transform: none; }

.btn--light { background: #fff; color: var(--purple-600); box-shadow: 0 16px 34px -14px rgba(0,0,0,.4); }
.btn--light:hover { transform: translateY(-1px); box-shadow: 0 20px 40px -14px rgba(0,0,0,.45); }
.btn--light:active { transform: translateY(0); }
.btn--light:disabled { opacity: .6; cursor: default; transform: none; }

/* ============ LOGIN ============ */
.login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-hero);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login__grid {
  position: absolute; top: -20%; right: -15%; width: 70%;
  opacity: .18; mix-blend-mode: overlay; pointer-events: none;
  animation: spin 70s linear infinite;
}
.login__grid--b {
  top: auto; bottom: -25%; left: -20%; right: auto; width: 55%;
  opacity: .12; animation-duration: 90s; animation-direction: reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login__card {
  width: 100%; max-width: 380px;
  background: rgba(38, 9, 56, .55);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius-lg);
  padding: 38px 32px 32px;
  box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column;
  position: relative; z-index: 1;
  overflow: hidden;
}
.login__logo { height: 26px; width: auto; align-self: flex-start; margin-bottom: 26px; }
.login h1 { font-size: 21px; margin-bottom: 6px; color: #fff; }
.login p { color: rgba(255,255,255,.65); font-size: 13.5px; margin-bottom: 24px; line-height: 1.5; }
.login .field { margin-bottom: 14px; }
.login .field span { color: rgba(255,255,255,.6); }
.login .field input {
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff;
}
.login .field input::placeholder { color: rgba(255,255,255,.35); }
.login .field input:focus {
  background: rgba(255,255,255,.13); border-color: var(--purple-300);
  box-shadow: 0 0 0 4px rgba(205,143,240,.18);
}
.login__error { color: #ff8a8a; font-size: 13px; min-height: 16px; margin-bottom: 6px; }
.login .btn { margin-top: 8px; padding-block: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em;
}
.field input, .field textarea {
  border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 14.5px; color: var(--ink);
  background: var(--gray-50);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--purple-400); background: #fff;
  box-shadow: 0 0 0 4px rgba(146,0,196,.1);
}

/* ============ APP LAYOUT ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--grad-dark);
  display: flex; flex-direction: column;
  padding: 22px 16px;
  position: fixed; inset: 0 auto 0 0; height: 100vh;
  transition: transform .35s var(--ease);
  z-index: 50;
  overflow: hidden;
}
.sidebar__grid {
  position: absolute; bottom: -25%; left: -30%; width: 90%;
  opacity: .07; mix-blend-mode: screen; pointer-events: none;
}
.sidebar__brand {
  padding: 8px 10px 26px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 18px;
  position: relative; z-index: 1;
}
.sidebar__brand img { height: 20px; width: auto; }
.sidebar__nav { display: flex; flex-direction: column; gap: 3px; flex: 1; position: relative; z-index: 1; }
.sidebar__link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.62); font-size: 14.5px; font-weight: 500;
  transition: background .2s, color .2s;
  position: relative;
}
.sidebar__link svg { flex-shrink: 0; }
.sidebar__link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar__link.is-active {
  background: linear-gradient(90deg, rgba(146,0,196,.35), rgba(146,0,196,.08));
  color: #fff;
}
.sidebar__link.is-active::before {
  content: '';
  position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: var(--purple-300);
}
.sidebar__badge {
  margin-left: auto; background: var(--purple-500); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px;
  padding: 1px 7px;
}
.sidebar__logout {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.5); font-size: 14px;
  position: relative; z-index: 1;
}
.sidebar__logout:hover { color: #fff; background: rgba(255,255,255,.06); }

.main { flex: 1; margin-left: 240px; padding: 30px 34px 60px; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 30px;
}
.topbar h2 { font-size: 25px; flex: 1; }
.topbar__user { font-size: 13px; color: var(--gray-500); }
.topbar__menu { display: none; }

/* ============ DASHBOARD ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: #fff; border-radius: var(--radius-md); padding: 20px;
  border: 1px solid var(--gray-300);
  box-shadow: var(--shadow-soft);
  display: flex; align-items: flex-start; gap: 14px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.stat-card__icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--purple-400), var(--purple-700));
  color: #fff;
}
.stat-card__body { display: flex; flex-direction: column; gap: 4px; }
.stat-card__label { font-size: 12.5px; color: var(--gray-500); font-weight: 500; }
.stat-card__value { font-size: 27px; color: var(--ink); font-family: var(--font-display); font-weight: 800; }

.panel {
  background: #fff; border-radius: var(--radius-md);
  border: 1px solid var(--gray-300);
  box-shadow: var(--shadow-soft);
  padding: 22px;
}
.panel + .panel { margin-top: 20px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel__head h3 { font-size: 16px; }
.panel__link { font-size: 13px; color: var(--purple-600); font-weight: 600; }
.panel__link:hover { text-decoration: underline; }

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-family: var(--font-display); font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500);
  padding: 10px 14px; border-bottom: 1.5px solid var(--gray-300); white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; white-space: nowrap; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--gray-50); }
.table-empty { padding: 40px 20px; text-align: center; color: var(--gray-500); font-size: 14px; }

.lead-name { display: flex; align-items: center; gap: 10px; }
.lead-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--purple-300), var(--purple-600));
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 12.5px;
}

.status-select {
  border: 1.5px solid var(--gray-300); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 700;
  font-family: var(--font-display); cursor: pointer;
}
.status-badge { display: inline-flex; padding: 5px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700; font-family: var(--font-display); }
.status-novo { background: #ede9fe; color: var(--purple-600); }
.status-em_contato { background: #fef3c7; color: var(--amber); }
.status-convertido { background: #dcfce7; color: var(--green); }
.status-perdido { background: #fee2e2; color: var(--red); }

.lead-link { color: var(--purple-600); font-weight: 600; text-decoration: none; }
.lead-link:hover { text-decoration: underline; }
.icon-btn {
  color: var(--gray-500); padding: 6px; border-radius: var(--radius-sm);
  display: inline-flex; transition: background .2s, color .2s;
}
.icon-btn:hover { color: var(--purple-600); background: var(--purple-100); }

/* ============ VIEW TOOLBAR ============ */
.view__toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.view__toolbar input, .view__toolbar select {
  border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.view__toolbar input:focus, .view__toolbar select:focus {
  outline: none; border-color: var(--purple-400); box-shadow: 0 0 0 4px rgba(146,0,196,.1);
}
.view__toolbar input { flex: 1; min-width: 200px; }

/* ============ AGENDA ============ */
.agenda { display: grid; gap: 22px; grid-template-columns: 1fr; }
.agenda__form h3, .agenda__list h3 { margin-bottom: 16px; font-size: 16px; }
.agenda__form .field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.event-item {
  display: flex; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.event-item:last-child { border-bottom: none; }
.event-item__date {
  flex-shrink: 0; width: 56px; text-align: center;
  background: var(--purple-100); border-radius: var(--radius-sm); padding: 6px 0;
}
.event-item__date .day { display: block; font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--purple-600); }
.event-item__date .month { display: block; font-size: 10.5px; text-transform: uppercase; color: var(--purple-500); font-weight: 600; }
.event-item__body { flex: 1; min-width: 0; }
.event-item__body h4 { font-size: 14.5px; margin-bottom: 3px; }
.event-item__meta { font-size: 12.5px; color: var(--gray-500); margin-bottom: 4px; }
.event-item__notes { font-size: 13px; color: var(--ink-soft); }
.event-item__del { flex-shrink: 0; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lift); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; padding: 20px 18px 60px; }
  .topbar__menu { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--radius-sm); color: var(--ink); }
  .topbar__user { display: none; }
}

@media (min-width: 760px) {
  .agenda { grid-template-columns: 1fr 1.3fr; align-items: start; }
}

/* ============ STAT CARD VARIANTS ============ */
.stat-card--money .stat-card__icon { background: linear-gradient(135deg, #34d399, #059669); }
.stat-card--money .stat-card__value { color: var(--green); }
.stat-card--warn .stat-card__icon { background: linear-gradient(135deg, #fbbf24, #b45309); }
.stat-card--warn .stat-card__value { color: var(--amber); }

.btn--danger { background: #fee2e2; color: var(--red); }
.btn--danger:hover { background: #fecaca; }

/* ============ KANBAN ============ */
.kanban {
  display: grid; grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 16px; overflow-x: auto; padding-bottom: 8px; align-items: start;
}
.kanban-col {
  background: var(--gray-100); border-radius: var(--radius-md);
  border: 1px solid var(--gray-300);
  padding: 12px; min-height: 120px;
}
.kanban-col.is-dragover { background: var(--purple-100); border-color: var(--purple-300); }
.kanban-col__head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: 13.5px;
  color: var(--ink); padding: 4px 6px 12px;
}
.kanban-count {
  margin-left: auto; background: #fff; border: 1px solid var(--gray-300);
  color: var(--gray-500); font-size: 11.5px; font-weight: 700;
  border-radius: 999px; padding: 1px 8px;
}
.kanban-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-dot--novo { background: var(--purple-500); }
.kanban-dot--em_contato { background: var(--amber); }
.kanban-dot--convertido { background: var(--green); }
.kanban-dot--perdido { background: var(--red); }
.kanban-col__body { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }

.kanban-card {
  background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--gray-300);
  padding: 13px 14px; box-shadow: var(--shadow-soft);
  cursor: grab; transition: transform .15s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kanban-card.is-dragging { opacity: .4; }
.kanban-card__top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.kanban-card__top strong { font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card__empresa { font-size: 12.5px; color: var(--gray-500); margin-bottom: 8px; }
.kanban-card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.kanban-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--gray-100); }
.kanban-card__value { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--green); }
.kanban-card__date { font-size: 11.5px; color: var(--gray-500); }
.kanban-card__date.is-late { color: var(--red); font-weight: 700; }

.origem-tag {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 999px;
}
.origem-site { background: var(--purple-100); color: var(--purple-600); }
.origem-prospeccao { background: #dbeafe; color: #1d4ed8; }
.origem-indicacao { background: #dcfce7; color: var(--green); }
.origem-anuncio { background: #fef3c7; color: var(--amber); }

.resp-tag { font-size: 11px; color: var(--gray-500); display: inline-flex; align-items: center; gap: 4px; }

@media (max-width: 900px) {
  .kanban { grid-template-columns: repeat(4, minmax(240px, 1fr)); }
}

/* ============ MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(19,3,23,.55); backdrop-filter: blur(4px); }
.modal__panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column;
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--gray-100);
}
.modal__head h3 { font-size: 17px; }
.modal__body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal__body .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal__footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--gray-100);
}
.modal .field select {
  border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 14.5px; color: var(--ink); background: #fff;
}

@media (max-width: 560px) {
  .modal__body .field-row { grid-template-columns: 1fr; }
}

/* ============ CRIATIVOS (kanban de 3 colunas) ============ */
.kanban--3 { grid-template-columns: repeat(3, minmax(260px, 1fr)); }
@media (max-width: 900px) {
  .kanban--3 { grid-template-columns: repeat(3, minmax(240px, 1fr)); }
}
.kanban-dot--solicitado { background: var(--gray-500); }
.kanban-dot--andamento { background: var(--amber); }
.kanban-dot--concluido { background: var(--green); }

.tipo-tag {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 999px;
  background: var(--purple-100); color: var(--purple-600);
}
.kanban-card__link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--purple-600);
}
.kanban-card__link:hover { text-decoration: underline; }
