:root{
  --bg:#F4F9FC; --bg-panel:#EAF5FB; --navy:#0A2E4D; --blue-deep:#0A6BAE;
  --blue:#1E9BDB; --blue-light:#CDEBFA; --green:#5FA63A; --green-dark:#48802B;
  --amber:#E0A93E; --teal:#2FA1A6; --muted:#8FA0AC; --red:#D9534F;
  --text:#12222E; --text-soft:#54697A; --white:#FFFFFF;
  --shadow:rgba(10,46,77,0.14); --radius-lg:20px; --radius-md:14px; --radius-sm:10px;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:'Inter',-apple-system,BlinkMacSystemFont,sans-serif;
  -webkit-font-smoothing:antialiased;
  display:flex; flex-direction:column; min-height:100%;
}
h1,h2,h3{font-family:'Poppins',sans-serif; color:var(--navy); margin:0; letter-spacing:-0.01em;}
button{font-family:inherit;}
::-webkit-scrollbar{height:8px; width:8px;}
::-webkit-scrollbar-thumb{background:rgba(30,155,219,.35); border-radius:99px;}

/* ---------- Login ---------- */
.login-body{
  align-items:center; justify-content:center;
  background:
    radial-gradient(circle at 14% 8%, rgba(143,214,247,.45), transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(116,177,67,.22), transparent 42%),
    var(--bg);
  padding:24px;
}
.login-card{
  width:100%; max-width:380px; background:var(--white); border-radius:24px;
  padding:36px 30px; box-shadow:0 26px 54px -20px var(--shadow); text-align:center;
}
.login-logo{width:84px; height:84px; border-radius:50%; object-fit:cover; margin-bottom:14px;}
.login-card h1{font-size:1.3rem; margin-bottom:2px;}
.login-sub{color:var(--text-soft); font-size:.9rem; margin:0 0 20px;}
.login-error{
  background:rgba(217,83,79,.1); color:var(--red); border-radius:10px;
  padding:10px 12px; font-size:.85rem; margin-bottom:16px; font-weight:600;
}
.login-form{text-align:left;}
.btn-block{width:100%; justify-content:center; margin-top:6px;}

/* ---------- Header ---------- */
header{
  position:sticky; top:0; z-index:40;
  background:rgba(244,249,252,.92); backdrop-filter:blur(10px);
  border-bottom:1px solid rgba(30,155,219,.16);
  padding:12px 20px;
}
.header-row{
  max-width:1400px; margin:0 auto;
  display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap;
}
.brand{display:flex; align-items:center; gap:10px;}
.brand img{height:34px; width:34px; object-fit:cover; border-radius:8px;}
.brand-text{display:flex; flex-direction:column; line-height:1.15;}
.brand-text strong{font-family:'Poppins',sans-serif; font-size:.98rem; color:var(--navy);}
.brand-text span{font-size:.76rem; color:var(--text-soft); font-weight:500;}
.header-actions{display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
.user-pill{font-size:.82rem; color:var(--text-soft); font-weight:600;}
.search-box{
  display:flex; align-items:center; gap:8px;
  background:var(--white); border-radius:999px; padding:9px 14px;
  box-shadow:0 6px 16px -10px var(--shadow); min-width:200px;
}
.search-box svg{width:16px; height:16px; color:var(--text-soft); flex:none;}
.search-box input{border:none; outline:none; background:transparent; font-size:.9rem; width:100%; color:var(--text);}
.btn{
  display:inline-flex; align-items:center; gap:8px; border:none; cursor:pointer;
  padding:11px 18px; border-radius:999px; font-weight:600; font-size:.9rem;
  transition:transform .15s ease, box-shadow .15s ease; text-decoration:none;
}
.btn:hover{transform:translateY(-1px);}
.btn-primary{background:var(--green); color:#fff; box-shadow:0 10px 22px -10px rgba(95,166,58,.5);}
.btn-primary:hover{background:var(--green-dark);}
.btn-ghost{background:var(--white); color:var(--navy); box-shadow:0 6px 16px -10px var(--shadow);}
.btn-danger{background:var(--red); color:#fff;}
.btn:disabled{opacity:.5; cursor:not-allowed; transform:none;}

.status-banner{
  max-width:1400px; margin:10px auto 0; padding:10px 16px; border-radius:12px;
  background:var(--blue-light); color:var(--blue-deep); font-size:.85rem; font-weight:500;
  display:none; align-items:center; gap:8px;
}
.status-banner.show{display:flex;}
.status-banner.error{background:rgba(217,83,79,.14); color:var(--red);}

/* ---------- Board ---------- */
main{flex:1; padding:18px 20px 40px;}
.board-wrap{max-width:1400px; margin:0 auto;}
.stage-summary{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:18px;}
.stage-chip{
  display:flex; align-items:center; gap:8px; background:var(--white);
  padding:8px 14px; border-radius:999px; box-shadow:0 6px 16px -12px var(--shadow);
  font-size:.82rem; font-weight:600; color:var(--text-soft);
}
.stage-dot{width:8px; height:8px; border-radius:50%;}

.board{display:flex; gap:16px; overflow-x:auto; padding-bottom:12px; scroll-snap-type:x proximity;}
.column{
  flex:0 0 280px; scroll-snap-align:start;
  background:var(--bg-panel); border-radius:var(--radius-lg);
  display:flex; flex-direction:column; max-height:calc(100vh - 220px); min-height:220px;
}
.column-head{padding:14px 16px 10px; display:flex; align-items:center; justify-content:space-between;}
.column-head .title{display:flex; align-items:center; gap:8px; font-weight:700; color:var(--navy); font-size:.92rem;}
.column-head .dot{width:10px; height:10px; border-radius:50%;}
.column-head .count{background:var(--white); color:var(--text-soft); font-size:.76rem; font-weight:700; padding:2px 9px; border-radius:999px;}
.column-body{flex:1; overflow-y:auto; padding:2px 12px 14px; display:flex; flex-direction:column; gap:10px;}
.empty-col{color:var(--text-soft); font-size:.8rem; text-align:center; padding:24px 8px; opacity:.7;}

.lead-card{
  background:var(--white); border-radius:var(--radius-md); padding:14px 14px 12px;
  box-shadow:0 10px 22px -16px var(--shadow); cursor:pointer;
  border-left:4px solid var(--blue);
  transition:transform .15s ease, box-shadow .15s ease;
}
.lead-card:hover{transform:translateY(-2px); box-shadow:0 16px 30px -16px var(--shadow);}
.lead-card .name{font-weight:700; font-size:.94rem; color:var(--navy); margin-bottom:3px;}
.lead-card .meta{font-size:.78rem; color:var(--text-soft); display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px;}
.tag{display:inline-block; padding:2px 8px; border-radius:999px; font-size:.72rem; font-weight:600; background:var(--bg-panel); color:var(--blue-deep);}
.lead-card .note-preview{font-size:.78rem; color:var(--text-soft); margin-bottom:10px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;}
.lead-card .row-actions{display:flex; align-items:center; gap:6px;}
.stage-select{flex:1; font-size:.76rem; font-weight:600; color:var(--navy); border:1px solid rgba(30,155,219,.25); border-radius:8px; padding:6px 8px; background:var(--white);}
.wa-link{flex:none; width:30px; height:30px; border-radius:8px; background:var(--green); display:flex; align-items:center; justify-content:center; color:#fff;}
.wa-link svg{width:15px; height:15px;}

/* ---------- Modal ---------- */
.overlay{position:fixed; inset:0; background:rgba(6,20,32,.5); backdrop-filter:blur(2px); display:none; align-items:flex-end; justify-content:center; z-index:100;}
.overlay.show{display:flex;}
@media (min-width:640px){ .overlay{align-items:center; padding:24px;} }
.modal{background:var(--bg); width:100%; max-width:520px; max-height:92vh; overflow-y:auto; border-radius:22px 22px 0 0; padding:22px;}
@media (min-width:640px){ .modal{border-radius:22px;} }
.modal-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:16px;}
.modal-head h2{font-size:1.2rem;}
.close-btn{width:32px; height:32px; border-radius:50%; border:none; background:var(--bg-panel); color:var(--navy); font-size:1.1rem; cursor:pointer; display:flex; align-items:center; justify-content:center;}
.field{margin-bottom:14px;}
.field label{display:block; font-size:.82rem; font-weight:600; color:var(--text-soft); margin-bottom:6px;}
.field input, .field select, .field textarea{
  width:100%; padding:11px 13px; border-radius:11px; border:1.5px solid rgba(30,155,219,.18);
  background:var(--white); font-size:.92rem; color:var(--text); font-family:inherit;
}
.field input:focus, .field select:focus, .field textarea:focus{outline:2px solid var(--blue-light); border-color:var(--blue);}
.field textarea{resize:vertical; min-height:70px;}
.field-row{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.modal-actions{display:flex; gap:10px; margin-top:20px;}
.modal-actions .btn{flex:1; justify-content:center;}
.modal-sub{font-size:.78rem; color:var(--text-soft); margin-top:2px;}
.empty-state{max-width:1400px; margin:60px auto; text-align:center; color:var(--text-soft);}

@media (max-width:640px){
  .field-row{grid-template-columns:1fr;}
  .search-box{min-width:140px;}
  main{padding:14px 12px 32px;}
}
